Skip to content

Commit a6fd6fc

Browse files
authored
Merge pull request #5 from precice/tutorial-addition
Add tutorial for CHT coupling with OpenFOAM and Code-Aster: flow-over-plate
2 parents 15a498c + 81e236f commit a6fd6fc

31 files changed

+1231
-16
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# preCICE-adapter for the CSM code Code_Aster
22

3-
This adapter was implemented as part of the [master thesis of Lucia Cheung](https://www5.in.tum.de/pub/Cheung2016_Thesis.pdf) in cooperation with [SimScale](https://www.simscale.com/). Currently only conjugate heat transfer is supported.
3+
This adapter was implemented as part of the [master thesis of Lucia Cheung](https://www5.in.tum.de/pub/Cheung2016_Thesis.pdf) in cooperation with [SimScale](https://www.simscale.com/). Currently only conjugate heat transfer is supported.
44

5-
A documentation is available in the `cht` subfolder.
5+
The adapter currently supports preCICE v1.4.1 and Code_Aster v14.4. The following tutorials are available.
6+
7+
* Flow over plate OpenFoam-Code_Aster ([wiki](https://github.com/precice/code_aster-adapter/wiki/Flow-over-plate-Code_Aster-Tutorial))
8+
9+
A documentation is available in the `cht` subfolder, and in the [wiki](wiki).

cht/adapter.comm

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ isSteadyState = ("steady-state" in settings["simulation"]) and (settings["simula
3333
# Include case definition.comm.
3434
# Defines: MESH, MODEL, BC[], MAT[], MATS
3535
INCLUDE(UNITE=91)
36-
36+
3737
# ==========================================================================================
3838
# Create and initialize the adapter
3939
# ==========================================================================================
@@ -62,13 +62,13 @@ while adapter.isCouplingOngoing():
6262

6363
adapter.writeCheckpoint()
6464
adapter.readCouplingData()
65-
65+
6666
# ======================================================================================
6767
# Solve
6868
# ======================================================================================
69-
69+
7070
if isSteadyState:
71-
71+
7272
if participant["non-linear"]:
7373
TEMP = THER_NON_LINE(
7474
MODELE=MODEL,
@@ -92,12 +92,12 @@ while adapter.isCouplingOngoing():
9292
)
9393

9494
else:
95-
95+
9696
STEP = DEFI_LIST_REEL(
9797
DEBUT=time,
9898
INTERVALLE=(_F(JUSQU_A=time+dt, NOMBRE=1))
9999
)
100-
100+
101101
if participant["non-linear"]:
102102
TEMP = THER_NON_LINE(
103103
MODELE=MODEL,
@@ -134,11 +134,11 @@ while adapter.isCouplingOngoing():
134134
# Output if necessary
135135
k += 1
136136
if k % settings["simulation"]["output-frequency"] == 0:
137-
filename = "output-" + str(k) + ".rmed"
138-
DEFI_FICHIER(FICHIER=filename, UNITE=80)
139-
IMPR_RESU(FORMAT='MED', RESU=_F(RESULTAT=TEMP))
140-
call(["mv", filename, settings["base-path"] + "/" + participant["directory"]])
141-
DEFI_FICHIER(ACTION='LIBERER', UNITE=80)
137+
filename = "REPE_OUT/output-" + str(k) + ".rmed"
138+
DEFI_FICHIER(FICHIER=filename, UNITE=80+k, TYPE='BINARY')
139+
IMPR_RESU(FORMAT='MED', UNITE=80+k, RESU=_F(RESULTAT=TEMP))
140+
#call(["mv", filename, settings["base-path"] + "/" + participant["directory"]])
141+
DEFI_FICHIER(ACTION='LIBERER', UNITE=80+k)
142142

143143
# Use current solution as initial condition for the next time step
144144
if time > 0:
@@ -153,7 +153,7 @@ while adapter.isCouplingOngoing():
153153

154154
DETRUIRE(CONCEPT=_F(NOM=TEMP))
155155
DETRUIRE(CONCEPT=_F(NOM=T))
156-
156+
157157
if not isSteadyState:
158158
DETRUIRE(CONCEPT=_F(NOM=STEP))
159159

cht/adapter.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def configure(self, config):
2929
L = [None] * self.numInterfaces # Loads
3030
SM = [None] * self.numInterfaces # Shifted meshes
3131
for i in range(self.numInterfaces):
32+
# Shifted mesh (interface nodes displaced by a distance delta in the direction of the surface normal
3233
SM[i] = CREA_MAILLAGE(MAILLAGE=self.MESH, RESTREINT={"GROUP_MA": config[i]["patch"], "GROUP_NO": config[i]["patch"]})
3334
# Create interface
3435
interface = Interface(self.precice, self.participantName, config[i], self.MESH, SM[i], self.MODEL, self.MAT[config[i]["material-id"]], self.isNonLinear)
@@ -148,7 +149,6 @@ def configure(self, names):
148149
self.computeNormals()
149150

150151
self.nodeCoordinates = np.array([p for p in self.SHMESH.sdj.COORDO.VALE.get()])
151-
# Casted len(...)/3 to int
152152
self.nodeCoordinates = np.resize(self.nodeCoordinates, (int(len(self.nodeCoordinates)/3), 3))
153153
self.shiftMesh()
154154

@@ -182,7 +182,6 @@ def computeNormals(self):
182182
OPERATION='NORMALE'
183183
)
184184
self.normals = N.EXTR_COMP().valeurs
185-
# Casted len(...)/3 to int
186185
self.normals = np.resize(np.array(self.normals), (int(len(self.normals)/3), 3))
187186
DETRUIRE(CONCEPT=({"NOM": N}, {"NOM": DUMMY}))
188187

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
rm -f precice-Fluid-convergence.log
3+
rm -f precice-Fluid-events.json
4+
rm -f precice-Fluid-iterations.log
5+
rm -f solid/solid.mess
6+
rm -f solid/solid.resu
7+
8+
# Add file deletion for solid.rmed
9+
10+
# pyFoamClearCase.py
11+
12+
rm -r fluid/constant/polyMesh
13+
rm -r fluid/10
14+
rm -r fluid/20
15+
rm -r fluid/30
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Tutorial for an CHT simulation of a flow over a heated plate using OpenFOAM and Code_Aster
2+
3+
This tutorial is described in the [preCICE wiki](https://github.com/precice/code_aster-adapter/wiki/Flow-over-plate-Code_Aster-Tutorial).
4+
5+
## Disclaimer
6+
7+
This offering is not approved or endorsed by OpenCFD Limited, producer and distributor of the OpenFOAM software via www.openfoam.com, and owner of the OPENFOAM® and OpenCFD® trademarks.
8+
This offering is not approved or endorsed by Électricité de France (EDF), producer and distributor of the Code_Aster software via www.code-aster.org, and owner of the Code_Aster trademark.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
settings = \
2+
{'base-path': '/home/michel/Git/code_aster-adapter/tutorials/buoyantSimpleFoam-aster',
3+
'couplings': [['Solid-Interface', 'Fluid-Interface']],
4+
'participants': {'Fluid': {'directory': 'fluid',
5+
'domain-decomposed': False,
6+
'interfaces': [{'mesh': 'Fluid-Interface',
7+
'name': 'Fluid-Interface',
8+
'patches': ['interface'],
9+
'read-data': ['Sink-Temperature-Solid',
10+
'Heat-Transfer-Coefficient-Solid'],
11+
'write-data': ['Sink-Temperature-Fluid',
12+
'Heat-Transfer-Coefficient-Fluid']}],
13+
'solver': 'OpenFOAM'},
14+
'Solid': {'directory': 'solid',
15+
'domain-decomposed': False,
16+
'interfaces': [{'material-id': 0,
17+
'name': 'Solid-Interface',
18+
'patch': 'interface',
19+
'read-data': ['Sink-Temperature-Fluid',
20+
'Heat-Transfer-Coefficient-Fluid'],
21+
'read-mesh': 'Solid-Interface-Faces',
22+
'write-data': ['Sink-Temperature-Solid',
23+
'Heat-Transfer-Coefficient-Solid'],
24+
'write-mesh': 'Solid-Interface-Nodes'}],
25+
'non-linear': False,
26+
'solver': 'Code_Aster'}},
27+
'precice-config-file': 'precice-config.xml',
28+
'simulation': {'force-explicit': False,
29+
'force-parallel': False,
30+
'max-coupling-iterations': 100,
31+
'max-time': 100,
32+
'output-frequency': 10,
33+
'steady-state': True,
34+
'time-step': 10}}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
participants:
2+
Solid:
3+
directory: solid
4+
domain-decomposed: false
5+
interfaces:
6+
- material-id: 0
7+
name: Solid-Interface
8+
patch: interface
9+
read-data: [Sink-Temperature-Fluid, Heat-Transfer-Coefficient-Fluid]
10+
read-mesh: Solid-Interface-Faces
11+
write-data: [Sink-Temperature-Solid, Heat-Transfer-Coefficient-Solid]
12+
write-mesh: Solid-Interface-Nodes
13+
non-linear: false
14+
solver: Code_Aster
15+
precice-config-file: precice-config.xml
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
FoamFile
2+
{
3+
version 2.0;
4+
format ascii;
5+
class volScalarField;
6+
object T;
7+
}
8+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
9+
10+
dimensions [0 0 0 1 0 0 0];
11+
12+
internalField uniform 300;
13+
14+
boundaryField
15+
{
16+
17+
inlet
18+
{
19+
type fixedValue;
20+
value uniform 300;
21+
}
22+
23+
outlet
24+
{
25+
type zeroGradient;
26+
value uniform 300;
27+
}
28+
29+
interface
30+
{
31+
type mixed;
32+
refGradient uniform 0;
33+
refValue uniform 310;
34+
valueFraction uniform 0.5;
35+
}
36+
37+
top
38+
{
39+
type zeroGradient;
40+
value uniform 300;
41+
}
42+
43+
bottom
44+
{
45+
type zeroGradient;
46+
value uniform 300;
47+
}
48+
49+
slip-bottom
50+
{
51+
type zeroGradient;
52+
value uniform 300;
53+
}
54+
55+
outerWall
56+
{
57+
type zeroGradient;
58+
value uniform 300;
59+
}
60+
61+
defaultFaces
62+
{
63+
type empty;
64+
}
65+
66+
}
67+
68+
// ************************************************************************* //
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
FoamFile
2+
{
3+
version 2.0;
4+
format ascii;
5+
class volVectorField;
6+
object U;
7+
}
8+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
9+
10+
dimensions [0 1 -1 0 0 0 0];
11+
12+
internalField uniform (.1 0 0);
13+
14+
boundaryField
15+
{
16+
inlet
17+
{
18+
type fixedValue;
19+
value uniform (.1 0 0);
20+
}
21+
22+
outlet
23+
{
24+
type zeroGradient;
25+
}
26+
27+
top
28+
{
29+
type slip;
30+
value uniform (.1 0 0);
31+
}
32+
33+
bottom
34+
{
35+
type fixedValue;
36+
value uniform (0 0 0);
37+
}
38+
39+
slip-bottom
40+
{
41+
type slip;
42+
}
43+
44+
interface
45+
{
46+
type fixedValue;
47+
value uniform (0 0 0);
48+
}
49+
50+
defaultFaces
51+
{
52+
type empty;
53+
}
54+
55+
}
56+
57+
// ************************************************************************* //
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
FoamFile
2+
{
3+
version 2.0;
4+
format ascii;
5+
class volScalarField;
6+
location "0";
7+
object alphat;
8+
}
9+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
10+
11+
dimensions [1 -1 -1 0 0 0 0];
12+
13+
internalField uniform 0;
14+
15+
boundaryField
16+
{
17+
inlet
18+
{
19+
type fixedValue;
20+
value uniform 0;
21+
}
22+
outlet
23+
{
24+
type fixedValue;
25+
value uniform 0;
26+
}
27+
top
28+
{
29+
type fixedValue;
30+
value uniform 0;
31+
}
32+
bottom
33+
{
34+
type fixedValue;
35+
value uniform 0;
36+
}
37+
slip-bottom
38+
{
39+
type fixedValue;
40+
value uniform 0;
41+
}
42+
interface
43+
{
44+
type fixedValue;
45+
value uniform 0;
46+
}
47+
defaultFaces
48+
{
49+
type empty;
50+
}
51+
52+
}
53+
54+
55+
// ************************************************************************* //

0 commit comments

Comments
 (0)