### ===================================================================================================================
### Function to get the area of the foundation from dat-file
### ===================================================================================================================
# Copyright ©VIIA 2024
### ===================================================================================================================
### 1. Import modules
### ===================================================================================================================
# General imports
from __future__ import annotations
from typing import TYPE_CHECKING, Tuple, Optional
# References for functions and classes in the rhdhv_fem package
from rhdhv_fem.fem_math import fem_is_close
# References for functions and classes in the viiaPackage
if TYPE_CHECKING:
from viiapackage.viiaStatus import ViiaProject
### ===================================================================================================================
### 2. Function viia_foundation_area
### ===================================================================================================================
[docs]def viia_foundation_area(project: ViiaProject) -> Tuple[Optional[float], Optional[int]]:
"""
Function calculates the foundation area of the foundation strips from the generated dat-file.
Input:
- project (obj): Project object containing collections and of fem objects and project variables.
Output:
- Returns the two values as tuple. First value is the area of shallow foundation in the model (supported
surfaces), in [m2] and the second value is the number of piles. If one is not present it will return None
instead.
"""
total_found_area = 0
for shape in project.viia_supported_surfaces:
total_found_area += shape.mesh.get_area()
# Notification and logging
if not fem_is_close(total_found_area, 0):
project.write_log(f"The total foundation area of shallow foundations is {round(total_found_area, 1)} m2.")
else:
total_found_area = None
support_set = project.viia_get(collection='supportsets', name='PileSupport')
piles = None
if support_set:
piles = len(support_set.supports)
if piles:
# Notification and logging
project.write_log(f"There are {piles} piles in the foundation.")
return total_found_area, piles
### ===================================================================================================================
### 3. End of script
### ===================================================================================================================