Source code for viiapackage.pictures.result_pictures.result_pictures_eigenvalue

### ===================================================================================================================
###   Result pictures for eigenvalue analysis
### ===================================================================================================================
# Copyright ©VIIA 2024

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

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

# References for functions and classes in the rhdhv_fem package
from rhdhv_fem.analyses import Analysis
from rhdhv_fem.pictures import ResultPicture, View

# References for functions and classes in the viiaPackage
if TYPE_CHECKING:
    from viiapackage.viiaStatus import ViiaProject
from viiapackage.pictures.result_pictures.helper_functions import viia_load_result_picture_yaml, \
    viia_get_resultcase_info, viia_get_output_item, viia_get_scope_shape_sets, viia_set_model_and_analysis_diana


### ===================================================================================================================
###   2. Function to handle result pictures for eigenvalue analysis
### ===================================================================================================================

[docs]def viia_create_result_pictures_eigenvalue( project: ViiaProject, analysis: Analysis, view: Optional[View] = None) -> List[ResultPicture]: """ Function to create the eigenvalue analysis result pictures. Input: - project (obj): VIIA project object containing collections of fem objects and project variables. - analysis (obj): Object reference of analysis, to retrieve the result case, result items, result file and relevant information. - view (obj): View that should be used for the pictures. When None the default view will be used. Default is None. Output: - Returns the result pictures created for eigenvalue analysis. """ # Get the result picture dictionary picture_data = viia_load_result_picture_yaml(project=project) # Find the result scope result_scopes = picture_data['result_scope'][analysis.name] output_block_pic = analysis.calculation_blocks[-1].output_blocks[0] analysis_nr = analysis.name.split(' - ')[0] # Set up the path of the result file result_file = project.current_analysis_folder / (output_block_pic.output_filename + '.dnb') # Create render and view # The model is created if not project.rhdhvDIANA.model_created: if not project.diana_settings.latest_dat_file: project.diana_settings.latest_dat_file = project.viia_get_file(path=project.current_analysis_folder, suffix='.dat') if project.rhdhvDIANA.run_diana: viia_set_model_and_analysis_diana(project=project, analysis=analysis) if view is None: if project.rhdhvDIANA.model_created and project.rhdhvDIANA.run_diana: project.rhdhvDIANA.showAll('SHAPE') project.rhdhvDIANA.setViewPoint('ISO1') diana_view_point = list(project.rhdhvDIANA.currentViewPoint()).copy() view = project.create_view_from_diana_view_point(name='User_defined', diana_view_point=diana_view_point) else: view = project.create_view(name='ISO1') render = project.create_render(name='Render1') # Loop through result scope and picture type pictures = [] for pic_type_key, scopes in result_scopes.items(): picture_type = picture_data['picture_type'][pic_type_key] # Set units for the result picture unit_setting = None if picture_type.get('unit_type'): unit_setting = {} for unit_type, units in zip(picture_type.get('unit_type'), picture_type.get('units')): unit_setting[unit_type] = units # Create a legend with the given unit_settings contour_legend = project.create_contour_legend(unit_settings=unit_setting) # Loop through scopes, defining the shapes visible for scope in scopes: # Get the step and execute block step, execute = viia_get_resultcase_info( analysis=analysis, analysis_block=analysis.calculation_blocks[-1], case=scope, eigenfrequencies=project.results[analysis_nr]['eigenfrequencies']) # Get the shape sets for the picture shape_sets = viia_get_scope_shape_sets(project=project, scope=scope, pic_type=pic_type_key) # Defining the components, defining for example the directions for component in picture_type['components']: # Collect the output-item required for the result picture output_item = viia_get_output_item( project=project, picture_type=picture_type, output_item_lst=output_block_pic.output_items, component=component) if not output_item: continue # Create pictures for layer, shapes in shape_sets.items(): pictures.append(project.create_result_picture( name=f'{pic_type_key}_{scope}_{component}', analysis=analysis, render=render, shapes=shapes, view=view, output_block=output_block_pic, legend=contour_legend, execute_block=execute, output_item=output_item, result_layer=picture_type.get('result_layer'), mode=step, plot_type=picture_type.get('plot_type'), result_file=result_file.as_posix())) # Create the result pictures when running in DIANA if project.rhdhvDIANA.run_diana: # Getting result picture from existing result files current_dnb_file = None for picture in pictures: picture.to_diana(current_dnb_file=current_dnb_file) current_dnb_file = picture.result_file project.write_log(f"{len(pictures)} result pictures for {analysis_nr} are created.") return pictures
### =================================================================================================================== ### 3. End of script ### ===================================================================================================================