Source code for viiapackage.results.overburden_load.probe_curve

### ===================================================================================================================
###   CLASS: ProbeCurve
### ===================================================================================================================
# Copyright ©VIIA 2024

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

# General imports
from __future__ import annotations
from typing import TYPE_CHECKING, List

# References for functions and classes in the rhdhv_fem package
from rhdhv_fem.fem_DIANAutils import fem_conversion_set_result_plot

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


### ===================================================================================================================
###   2. Class ProbeCurve
### ===================================================================================================================

[docs]class ProbeCurve: """ This is the class for probe curves, specifying a line to collect the results on.""" # Class variable, corresponding to the current default index of the probe curve in DIANA, will compose the name # of the curve count = 1 def __init__( self, project: ViiaProject, start_point: List[float], end_point: List[float], result_case: List[str], view: List[str], steps: int = 10): """ Input: - project (obj): VIIA project object containing collections of fem objects and project variables. - start_point (list of 3 floats): The start point coordinate for the probe curve. - end_point (list of 3 floats): The end point coordinate for the probe curve. - result_case (list of 3 str): Consists of the executed analysis name, output file name and the corresponding load-case name. - view (list of 2 str): First item is the name of the result contour, second item is its component. - steps (int): Number of segments for the probe curve. Default value is 10. Create 10 sample points. """ self.project = project self.sta_point = start_point self.end_point = end_point # e.g. result_case = [ "A1 - Lineair statische analyse met fixed base", "OUTPUT_STATIC", "NLPO_equi_acc_+X" ] self.result_case = result_case # e.g. view = ["Distributed Forces/node", "Qxz"] self.view = view self.steps = steps # Set views fem_conversion_set_result_plot( project=project, plot_type='contours', result=self.view[0], component=self.view[1]) project.rhdhvDIANA.setResultCase(result_case)
[docs] def get_values(self, average: bool = False): """ Method of ProbeCurve class to evaluate the result value between the start point and end point.""" # Set curves index based on the existing ones default_idx = f'RESULT/PROBE/CURVES({ProbeCurve.count})/COORDS' coord = self.sta_point + self.end_point # Create curves self.project.rhdhvDIANA.setViewSettingValue(self.project.rhdhvDIANA.activeViewSetting(), default_idx, coord) # Set the stepsize self.project.rhdhvDIANA.setViewSettingValue( self.project.rhdhvDIANA.activeViewSetting(), f'RESULT/PROBE/CURVES({ProbeCurve.count})/NUMINT', self.steps) # Get the curve value # Default name of probe curve is 'probe-curve' if ProbeCurve.count == 1: result = self.project.rhdhvDIANA.probeCurveSampleValues('probe-curve') if average: # Mean # Duplicate values due to openings are removed result = sum(set(list(result))) / len(set(list(result))) else: result = self.project.rhdhvDIANA.probeCurveSampleValues(f'probe-curve {ProbeCurve.count}') if average: # Mean - Duplicate values due to openings are removed result = sum(set(list(result))) / len(set(list(result))) # Increment for the index ProbeCurve.count += 1 return result
[docs] def remove_all_curves(self): """ Method of ProbeCurve class to remove all the existing probe curves.""" for curve_idx in range(1, ProbeCurve.count + 1): self.project.rhdhvDIANA.clearViewSettingValue( self.project.rhdhvDIANA.activeViewSetting(), f'RESULT/PROBE/CURVES({curve_idx})')
### =================================================================================================================== ### 4. End of script ### ===================================================================================================================