Source code for viiapackage.analyses.viia_create_analysis_files

### ===================================================================================================================
###  FUNCTION: Create the files required for the analysis in the VIIA workflow
### ===================================================================================================================
# Copyright ©VIIA 2024

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

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

# References for functions and classes in the rhdhv_fem package
from rhdhv_fem.analyses import Analysis
from rhdhv_fem.fem_tools import fem_copy_file

# References for functions and classes in the viiaPackage
if TYPE_CHECKING:
    from viiapackage.viiaStatus import ViiaProject
from viiapackage.analyses.helper_functions import viia_create_analysis_files_abaqus, viia_create_analysis_files_diana


### ===================================================================================================================
###   2. Function viia_create_analysis_files
### ===================================================================================================================

[docs]def viia_create_analysis_files( project: ViiaProject, analysis: Analysis, combox_location: Optional[str] = None, signal: Optional[str] = None, abaqus_inp_location: Union[Path, str] = None) -> List[Path]: """ Function to create and save analysis files for the analysis in the analysis sub-folder, following the standard workflow in VIIA. For all software the log-file and json-file of the model are stored in the analysis folder. In DIANA the dat-file, dcf-file and dpf-file are added. When performing in ABAQUS the cae-file, jnl-file, inp-file, postprocessing, subroutines, abaqus_v6 env-file, envelope_results json-file, materials include-file and postprocessing batch files. In case of ABAQUS for analyses with signals, all the seven signals are prepared. .. note:: When this function is used for ABAQUS, user needs to call this function at the end of the mainscript separately (i.e., after the project.viia_create_model()) Input: - project (obj): VIIA project object containing collections of fem objects and project variables. - analysis (obj): Object reference of the analysis for which the files are created / collected. - combox_location (str): Optional input to prepare the dcf-file for running analysis. For example the location of the user supplied subroutines, if any. Default value is None, dcf-file is not updated. This input is only used for DIANA, input is ignored when software ABAQUS is selected. - signal (str): The signal for which the analysis files need to be created. Example format is 'S1'. This is used for A4, A12 and A15 analysis. Default value is None. - abaqus_inp_location (Path or str): Location of the ABAQUS inp-file. By default, the inp-file is retrieved from the workfolder, based on VIIA naming convention. This input is only used for ABAQUS, input is ignored when software DIANA is selected. Output: - Returns list of all created files in the 'current analysis folder', which files is software specific. """ # Create dump of current model if signal and signal in ['S1', 'S2', 'S3', 'S4', 'S5', 'S6', 'S7', 'S8', 'S9', 'S10', 'S11']: file_name = f'{project.name}_{signal}_v{project.version}.json' elif signal: raise ValueError( f"ERROR: Input for the signal {signal} is not recognised. Please select from S1, S2, S3, S4, S5, S6, S7, " f"S8, S9, S10 or S11.") else: file_name = f'{project.name}_v{project.version}.json' json_file, _, summary = project.viia_write_dump(filename=file_name, folder=project.current_analysis_folder) # Copy the log file into the analysis folder log_file = fem_copy_file( file_to_copy=project.logfile, destination_folder=project.current_analysis_folder) if project.rhdhvDIANA.model_created and project.rhdhvDIANA.run_diana: return [json_file, log_file] + viia_create_analysis_files_diana( project=project, analysis=analysis, combox_location=combox_location) if project.software.lower() == 'abaqus': return [json_file, log_file] + viia_create_analysis_files_abaqus( project=project, analysis=analysis, abaqus_inp_location=abaqus_inp_location) if not project.rhdhvDIANA.run_diana: project.write_log("WARNING: Script is not running in DIANA environment. Analysis files are not created.") return [] raise ValueError( f"ERROR: The software selected {project.software} is not available for VIIA workflow. Please select DIANA or " f"ABAQUS.")
### =================================================================================================================== ### 3. End of script ### ===================================================================================================================