OpenPisco.ExternalTools.Aster.AsterCommonWriter module#
AsterCommonWriter
Following OpenPisco business logic for external tools such as Code_Aster, we provide utilities suitable for the coupling with it. They are used across various physical analysis to produce input files given to Code_Aster.
The aim is to be able to build new analysis by: - relying on a higher level of abstraction module - translating high-level concepts in Code_Aster’s own DSL - avoiding repetitions across analysis.
First and foremost, we describe briefly the business logic and responsability of the current module. There are 3 type of files: - .export files: keeps the structure of the differents files used by Code_Aster to launch a calculation. Each analysis is supposed to be associated to one - .comm files: command files in python relying on Code_Aster’s own DSL to build the analysis from the beginning to the end (reading the mesh, defining the analysis/boundary condition, postprocessing) - .py files: typically dedicated writer files, supposed to write on disk information related to the specific usecase at end (material parameter, boundary condition values etc…) There is also the AsterInterface.py used to build the command line to use Code_Aster. We refer to the actual file for more details.
This is an example of a simplified AsterDummyAnalysis.export file
P actions make_etude P memjob 1000000 P memory_limit 1000.0 P mode interactif P nomjob AsterDummyAnalysis P version stable A memjeveux 2048.0 A args -max_base 300000 A tpmax 9000.0 F comm AsterDummyAnalysisparam.in D 1 F comm AsterDummyAnalysis.comm D 1 F mess AsterDummyAnalysis.log R 6 F mmed AsterDummyAnalysisinput.med D 20 F rmed AsterDummyAnalysisoutput.rmed R 80
For more detail about the content and inner working of the .export file, we refer to Code_Aster documentation.
In this module, we are interested in AsterDummyAnalysisparam.in. Typically, this file is dynamically created at run time by OpenPisco in a readble format and it is also the first one read by Code_Aster. As such, it allows to write code in the .comm file in a much more generic fashion. For instance, the specific boundary conditions or tags associated to the usecase at hand can be specified in this input file easily. By doing so, the variables defined in that file can be used in the .comm file as this very file is also within the visibility scope.
- OpenPisco.ExternalTools.Aster.AsterCommonWriter.CloseAsterParamFile(writeFile: TextIO)[source]#
Close Aster dedicated parameter file
- Parameters
writeFile (TextIO) – currently opened parameter file
- OpenPisco.ExternalTools.Aster.AsterCommonWriter.OpenAsterParamFile(fileName: str) TextIO[source]#
Open Aster dedicated parameter file
- Parameters
fileName (str) – filename
- Returns
opened parameter file
- Return type
TextIO
- OpenPisco.ExternalTools.Aster.AsterCommonWriter.WriteBodyForcesParametersInput(writeFile: TextIO, bodyforce: Dict, dimensionality: int, problems: Iterable)[source]#
Write body forces value in file
Example: writeFile = OpenAsterParamFile(“myFile.param”) bodyforce = {“idx1”: [[‘AllZones’,(0.,0.,-1.)]] } WriteBodyForcesParametersInput(writeFile,bodyforce=bodyforce,dimensionality=3,problems=[“idx1”]) CloseAsterParamFile(writeFile)
- Parameters
writeFile (TextIO) – currently opened parameter file
bodyforce (Dict) – body force description, number of components should match dimensionality (2 in 2D, 3 in 3D)
dimensionality (int) – problem dimensionality, correspond to dimension of the mesh (either 2 or 3)
problems (Iterable) – loading cases
- OpenPisco.ExternalTools.Aster.AsterCommonWriter.WriteDirichletParametersInput(writeFile: TextIO, dirichlet: Iterable[Tuple[str, Iterable]], dimensionality: int, method: str = 'BY_MULTIPLIER', group: str = 'OnElements')[source]#
Write Dirichlet value in file
Example writeFile = OpenAsterParamFile(“myFile.param”) dirichlet = [[‘X0’,(0.,0.,0.)]] WriteDirichletParametersInput(writeFile,dirichlet=dirichlet,dimensionality=3,problems=[“idx1”]) CloseAsterParamFile(writeFile)
- Parameters
writeFile (TextIO) – currently opened parameter file
dirichlet (Iterable[List[str,Iterable]]) – dirichlet boundary condition description on suitable boundary tags
dimensionality (int) – problem dimensionality, correspond to dimension of the mesh (either 2 or 3)
method (str, optional) – enforcement of dirichlet condition either with Lagrange multipliers (“BY_MULTIPLIER”) or by elimination (“BY_ELIMINATION”) or , by default “BY_MULTIPLIER”
group (str, optional) – where to apply dirichlet boundary condition, either on elements (OnElements) or on nodes (OnNodes), by default “OnElements”
- Raises
Exception – The dirichlet condition can only be enforce with Lagrange multipliers or by elimination
Exception – The dirichlet condition can only be enforce on nodes or on elements, any other choice will raise an exception
- OpenPisco.ExternalTools.Aster.AsterCommonWriter.WriteNeumannParametersInput(writeFile: TextIO, neumann: Dict, dimensionality: int, problems: Iterable[str])[source]#
Write neumann forces value in file
Example: writeFile = OpenAsterParamFile(“myFile.param”) neumann = {“idx1”: [[‘X1’,(0.,0.,-1.)]] } WriteNeumannParametersInput(writeFile,neumann=neumann,dimensionality=3,problems=[“idx1”]) CloseAsterParamFile(writeFile)
- Parameters
writeFile (TextIO) – currently opened parameter file
neumann (Dict) – neumann description by load cases, number of components should match dimensionality (2 in 2D, 3 in 3D)
dimensionality (int) – problem dimensionality, correspond to dimension of the mesh (either 2 or 3)
problems (Iterable[str]) – loading cases names, names should match the neumann boundary condition load cases
- OpenPisco.ExternalTools.Aster.AsterCommonWriter.WriteNodalForcesParametersInput(writeFile: TextIO, forcenodale: Dict, dimensionality: int, problems: Iterable)[source]#
Write nodal forces value in file
Example: writeFile = OpenAsterParamFile(“myFile.param”) forcenodale = {“idx1”: [[‘X1’,(0.,0.,-1.)]] } WriteNodalForcesParametersInput(writeFile,forcenodale=forcenodale,dimensionality=3,problems=[“idx1”]) CloseAsterParamFile(writeFile)
- Parameters
writeFile (TextIO) – currently opened parameter file
neumann (Dict) – neumann description by load cases, number of components should match dimensionality (2 in 2D, 3 in 3D)
dimensionality (int) – problem dimensionality, correspond to dimension of the mesh (either 2 or 3)
problems (Iterable) – loading cases, names should match the neumann boundary condition load cases
- OpenPisco.ExternalTools.Aster.AsterCommonWriter.WritePressureParametersInput(writeFile: TextIO, neumann: Dict, problems: Iterable)[source]#
Write pressure value in file
Example: writeFile = OpenAsterParamFile(“myFile.param”) neumann = {“idx1”: [[‘X1’,1]] } WritePressureParametersInput(writeFile,neumann=neumann,dimensionality=3,problems=[“idx1”]) CloseAsterParamFile(writeFile)
- Parameters
writeFile (TextIO) – currently opened parameter file
neumann (Dict) – pressure description by load cases
problems (Iterable) – loading cases, names should match the neumann boundary condition load cases
- OpenPisco.ExternalTools.Aster.AsterCommonWriter.WriteVariable(writeFile: TextIO, variableName: str, variableValue: any)[source]#
Write variable in file
Example: writeFile = OpenAsterParamFile(“myFile.param”) WriteVariable(writeFile=writeFile,variableName=”resi_rela”,variableValue=0.01) CloseAsterParamFile(writeFile)
- Parameters
writeFile (TextIO) – currently opened parameter file
variableName (str) – variable name
variableValue (any) – variable value