Source code for viiapackage.viiaChecking

### =============================================================================================================== ###
###                                                                                                                 ###
###                                                viiaChecking.py                                                  ###
###                                                                                                                 ###
### =============================================================================================================== ###
# The module ``viiaChecking`` contains the functions to check the meshed model.

# Module is based on:
# VIIA_QE_R376 Basis of Design Retrofit Advice NLTH, v11.0, d.d. 29 August 2024
# VIIA_QE_R376 Basis of Design Step-by-Step MRS, v1.0, d.d. 21 January 2022
# VIIA_QE_R1674 Uitgangspuntenrapport engineering NLPO, v1.0, d.d. 1 August 2019

# This script was based upon the Constitution For Python At VIIA
# For use by VIIA
# Copyright RHDHV

### ===================================================================================================================
###    Contents script 
### ===================================================================================================================

#   1. Import modules

#   2. Mesh checks

#   3. Connection checks

#   4. End of script

### ===================================================================================================================
###    1. Import modules 
### ===================================================================================================================

# General imports
from __future__ import annotations
from datetime import datetime
from pathlib import Path
from typing import TYPE_CHECKING, Optional

# References for functions and classes in the rhdhv_fem package
from rhdhv_fem.fem_tools import fem_create_folder, fem_copy_file
from rhdhv_fem.mesh import fem_check_mesh_data, fem_create_mesh_check_report

# References for functions and classes in the viiaPackage
if TYPE_CHECKING:
    from viiapackage.viiaStatus import ViiaProject
from viiapackage.viiaSettings import ViiaSettings


### ===================================================================================================================
###    2. Mesh check
### ===================================================================================================================

[docs]def viia_check_mesh( project: ViiaProject, min_angle: float = ViiaSettings.MIN_ANGLE, max_angle: float = ViiaSettings.MAX_ANGLE, max_skewness: float = ViiaSettings.MAX_SKEWNESS, max_aspect_ratio: float = ViiaSettings.MAX_ASPECT_RATIO, output_folder: Optional[Path] = None) -> Optional[Path]: """ This function checks the mesh of the model. The default requirements for VIIA are included in the ViiaSettings module. The function currently checks for the following items: - Check if the angles of the mesh-element are larger than the minimum angle requirement (VIIA default 15 degrees). - Check if the angles of the mesh-element are smaller than the maximum angle requirement (VIIA default 165 degrees). - Check if the skewness of the mesh-element is smaller than the maximum skewness requirement (VIIA default 45 degrees). - Check if the aspect-ratio of the mesh-element is smaller than the maximum aspect-ratio requirement (VIIA default is 5). .. note:: The model must be meshed. Input: - project (obj): Project object containing collections and of fem objects and project variables. - min_angle (float): Checking bound for smallest allowable mesh-element angle, in [deg]. Default value set in the ViiaSettings module. - max_angle (float): Checking bound for largest allowable mesh-element angle, in [deg]. Default value set in the ViiaSettings module. - max_skewness (float): Checking bound for the maximum allowed skewness of the mesh-element angle, in [deg]. Default value set in the ViiaSettings module. - max_aspect_ratio (float): Checking bound for the maximum allowed aspect-ratio of the mesh-element angle, in [-]. Default value set in the ViiaSettings module. - output_folder (Path): Optional input for location where to create the report. Default value is None, indicating the default location is used. In normal production objects do not change this! Output: - Returns the path of the folder with the mesh check output files. These include the mesh check report in pdf, json-file of the model and the model summary in pdf. - In case there is no mesh the function is not executed and a warning is provided. Script continues. - The report offers insights into the mesh setup. It displays the count of mesh nodes and elements and a list of the element-types used. Alongside general information, the report includes graphs depicting distributions. - All mesh-elements are checked for compliance to the provided boundaries. - In case of not compliance a warning is raised indicating the model is not complying to the VIIA requirements. The user can proceed, but should review the locations of the exceedances. In most cases the mesh can be improved by applying a mesh-seeding or simplify geometry. Discuss with your Lead Engineer. """ # Check if the model is meshed if not project.is_meshed: project.write_log( "WARNING: No mesh present (or not loaded in python memory), the mesh check is not performed and no report " "generated.") return None # Execute the mesh check data = fem_check_mesh_data( project=project, min_angle=min_angle, max_angle=max_angle, max_skewness=max_skewness, max_aspect_ratio=max_aspect_ratio, print_in_diana=True) # Create or check the location where the report is generated if output_folder is None: # Create default sub-folder fem_create_folder(ViiaSettings.DEFAULT_MESH_CHECK_FOLDER, ref_folder=project.workfolder_location) time_reference = datetime.now().strftime('%Y%m%d%H%M%S') folder = f'{time_reference}-v{str(project.version).zfill(3)}' fem_create_folder(folder, ref_folder=project.workfolder_location / ViiaSettings.DEFAULT_MESH_CHECK_FOLDER) report_location = project.workfolder_location / 'Mesh Check' / folder else: if isinstance(output_folder, str): output_folder = Path(output_folder) report_location = output_folder # Create mesh check report mesh_check_report = fem_create_mesh_check_report(project=project, data=data, output_folder=report_location) # Add the json dump of the model in the mesh check json_file, _, summary_file = project.viia_write_dump(folder=report_location) if not all([mesh_check_report.exists(), json_file.exists(), summary_file.exists()]): raise RuntimeError( "ERROR: Something went wrong in the mesh check procedure. Please contact the automation team of VIIA.") # Notification project.write_log(f"Mesh check has been performed, see output-files in {report_location.as_posix()}.") # Copy the log file to the mesh check report location fem_copy_file(project.logfile, report_location) # Return the folder with the mesh check return report_location
### =================================================================================================================== ### 3. End of script ### ===================================================================================================================