-
-
Notifications
You must be signed in to change notification settings - Fork 3
Flow over plate Code_Aster Tutorial
Now that you have Code_Aster, preCICE, the preCICE Python bindings, and the Code_Aster adapter up and running, it is time to run our first coupling tutorial. In this tutorial we will simulate flow over a heated plate with a fluid and a solid solver. We will use Code_Aster for solving the heat transfer in the solid domain, and OpenFOAM for solving the heat transfer in the fluid domain. Therefore, please also install OpenFOAM and the openfoam-adapter before continuing with this tutorial.
This tutorial is meant to also give some insight in the workflows of Code_Aster and preCICE. For those who wish to get a quick coupling working, please jump to Quick Tutorial.
The setup for this tutorial is similar to the flow over a heated plate using OpenFOAM. In this tutorial OpenFOAM is used as the solver for the fluid domain, and Code-Aster is the solver for the solid domain. A difference here is that we are using a steady-state OpenFOAM solver (buoyantSimpleFoam, instead of the transient buoyantPimpleFoam), for demonstration purposes, therefore the results between the two tutorials are not comparable.
You can find the tutorial files in the tutorial repository.
The Solid
directory contains, among others, the following files:
-
solid.astk
: In a Code_Aster case, there is always an export file that links all the separate case files, specifying their functionality and their location. The export file also sets additional, system-dependent variables. The export file is to be generated from thesolid.astk
file, which can be done in ASTK as described below. -
example.export
: This is an exemplary export file to run this tutorial. Apart from being a reference example for thesolid.export
file that is to be generated, it can be used to run this tutorial without using ASTK for generatingsolid.export
. See Alternative: Skipping ASTK configuration below for more information. -
solid.mmed
: This is the file that contains the mesh of the solid domain for Code_Aster. It can be opened and adapted with Salome Meca.
Code_Aster works with command files, which are the basis of every simulation case. The command files define the problem, the boundary conditions, the mesh that is used, and more parameters. When we couple Code_Aster with preCICE, we mainly use three command files:
-
adapter.comm
: This is the main command file of a Code_Aster coupling. Code_Aster starts at this command file, which wraps the solver call in a loop and triggers the coupling operations. Through the INCLUDE command, invoked at the beginning, the other command files are included. This file is part of the Code_Aster adapter. -
def.comm
: The test-case is defined in this command file. It is in charge of setting the mesh, model, materials, initial and boundary conditions. This file is case specific and is found in the tutorial repository. -
config.comm
: This file is used to configure the coupling. This file is part of the Code_Aster adapter
Additionally, the following files are created when the coupling is run:
-
solid.mess
: An output (message) file, which contains the Code_Aster log of a run. -
solid.rmed
: This file is the 'result mesh' file, and has the same format as the mesh filesolid.mmed
. It contains the result of the solid domain after a run, and can be opened with Salome Meca. In this tutorial, multiple rmed files will be generated and saved in theREPE_OUT
folder. -
solid.resu
: This file is also a 'result mesh' file, but it saves the results in ASCII format. It is not relevant for this tutorial.
The solid.export
file that is included in the tutorial needs to be configured for your local system. You can generate this file using ASTK. Alternatively, you can skip the generation of solid.export
, and use the exemplary export file provided. Please keep in mind that generating solid.export
through ASTK, will tune Code_Aster to your local system and run more efficiently:
- Start
astk
from your terminal. - Click "File > Open..." and select the file
solid/solid.astk
. - In the Base path field, set the path to your
solid/
directory. If you then put your cursor in one of the fields below, and then click on the Base path-field, astk will auto-fill the selected field with the base path (although this seems to not always work - please let us know if you find a better way). - Select under
D
(input) the filesadapter.comm
,solid.mmed
,config.comm
,def.comm
. Select underR
(output) the filessolid.mess
,solid.rmed
,solid.resu
. - For the
.comm
files, make sure thatadapter.comm
is assigned toUNIT=1
,def.comm
is assigned toUNIT=91
, andconfig.comm
hasUNIT=90
. Theadapter.comm
is the command file that comes with the Code_Aster adapter. For the rest of the files, ASTK will give the default UNIT values. Make sure that these correspond to the values in the image below. Lastly, make sure that in ASTK, thenodebug
mode is selected. - Lastly, add a new field of type
repe
, by pressing theAdd Entry
button on the right. In this field, pointREPE_OUT
to be located in the solid directory, as shown in the image below. Make sure to also create this directory on your system. ThisREPE_OUT
folder will hold thermed
output files of Code_Aster. - Now that you have updated the
solid.astk
file, save and export it. - Click "Run" to generate the rest of the files. You can then quit ASTK.
This alternative is provided to do a quick test-run of this tutorial. Please open Solid/example.export
, set /home/tester/
in the beginning of the file to the Code_Aster root directory on your system, and change /home/tester/
in the last few lines, such that the export file points to correct locations on your system for the files required to run the tutorial. After you have set the preCICE exchange directory, you can run the tutorial using the following line:
as_run --run Solid/example.export
For bigger problems that require efficient solving, please use ASTK to generate solid.export
.
We currently need to manually set the exchange-directory
in the m2n:sockets
node:
<m2n:sockets from="Fluid" to="Solid" exchange-directory="/home/tester/tutorials/CHT/flow-over-plate/buoyantSimpleFoam-aster"/>
See the respective issue for more details on why this is needed.
Everything is now set for your first OpenFOAM-Code_Aster coupling. Run Allrun
in a terminal, or run runFluid
and runSolid
in two separate terminals to start the coupled simulation.
runFluid
prepares and runs the OpenFOAM case, as described in the respective OpenFOAM-OpenFOAM tutorial. The runSolid
scripts starts Code_Aster:
as_run --run Solid/solid.export
There are two methods to visualize the results for Code_Aster:
- Salome-Meca is a intergated graphical interface, which also offers a post-processing unit called ParaViS (based on ParaView). The nice thing about ParaViS, is that it can open both the results of OpenFOAM and Code-Aster at the same time. Please make sure to have salome-meca 2018 or newer, as the med files are not compatible with older versions. Before installing Salome-Meca, please make sure that the environment on your system uses Python 2.7 (see the respective Salome-Meca issue).
-
GMSH is a stand-alone visualization tool that can open files of
med
format. Please make sure to get a version that is compatible with med 4.0 (GMSH 4.5 is known to work).
Firstly, enable the ParaViS view in Salome-Meca by selecting the icon in the top of the screen.
For visualizing the results of the fluid solver, go to File -> Open ParaView File
and select Fluid.OpenFOAM
. If you're asked to choose a reader, please select OpenFOAMReader
and press click Apply
to visualize the result.
For visualizing the result of the solid solver, press again Open ParaView File
and select the output-..rmed
group. Again, click Apply
to visualize the result. After setting the temperature scale for both domains to 300-310 K, the following result is given for timestep 200:
Clone this repository and generate a solid.export
file by exporting the solid.astk
file as an export file in ASTK. Open a terminal and run Allrun
.
More information on precice.org. Subscribe to the preCICE mailing list.
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. Please use "precice.org" for the attribution.
We moved these pages to the preCICE website: https://www.precice.org/adapter-code_aster.html