1
#-------------------------------------------------------------------------------
2
# This file is part of the Code_Saturne CFD tool.
4
# Copyright (C) 2011 EDF S.A.
6
# The Code_Saturne CFD tool is free software; you can redistribute it
7
# and/or modify it under the terms of the GNU General Public License
8
# as published by the Free Software Foundation; either version 2 of
9
# the License, or (at your option) any later version.
11
# The Code_Saturne CFD tool is distributed in the hope that it will be
12
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
13
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public Licence
17
# along with the Code_Saturne Preprocessor; if not, write to the
18
# Free Software Foundation, Inc.,
19
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#-------------------------------------------------------------------------------
24
from module_generator import Generator, Module, Service
25
from module_generator import ASTERComponent, CPPComponent
30
asterdir = os.path.expanduser("~/Code_Aster/NEW11.0")
32
milieuinc = "-I$(top_srcdir)/salome/libmilieu"
33
milieulib = "$(top_builddir)/salome/libmilieu/libmilieu.la"
35
# SALOME environment be must loaded beforehand
37
KERNEL_ROOT_DIR = os.getenv("KERNEL_ROOT_DIR")
38
if KERNEL_ROOT_DIR is None:
39
print("KERNEL_ROOT_DIR must be defined.\nPlease load SALOME environment.\n")
42
context = {'update':1,
43
"prerequisites":os.path.join(os.path.dirname(KERNEL_ROOT_DIR),
44
'prerequis-V6.3.0.sh'),
45
"kernel":KERNEL_ROOT_DIR}
47
# Definition of all the in/out streams
48
# ------------------------------------
50
astDisplacement = ("DEPAST","CALCIUM_double","I")
51
astVelocity = ("VITAST","CALCIUM_double","I")
52
astForces = ("FORAST","CALCIUM_double","I")
54
satDisplacement = ("DEPSAT","CALCIUM_double","I")
55
satForces = ("FORSAT","CALCIUM_double","I")
57
geometricData = ("DONGEO","CALCIUM_integer","I")
58
satLengthScale = ("ALMAXI","CALCIUM_double","I")
60
nbFor = ("NB_FOR","CALCIUM_integer","I")
61
nbDyn = ("NB_DYN","CALCIUM_integer","I")
63
nodesXYZ = ("COONOD","CALCIUM_double","I")
64
facesXYZ = ("COOFAC","CALCIUM_double","I")
66
nodesColor = ("COLNOD","CALCIUM_integer","I")
67
facesColor = ("COLFAC","CALCIUM_integer","I")
69
nbIter = ("NBPDTM","CALCIUM_integer","I")
70
nbSubIter = ("NBSSIT","CALCIUM_integer","I")
72
indSync =("ISYNCP","CALCIUM_integer","I")
73
frequency = ("NTCHRO","CALCIUM_integer","I")
75
epsilon = ("EPSILO","CALCIUM_double","I")
76
astConvergence = ("ICVAST","CALCIUM_integer","I")
77
satConvergence = ("ICV", "CALCIUM_integer","I")
78
extConvergence = ("ICVEXT","CALCIUM_integer","I")
80
prevTime = ("TTINIT","CALCIUM_double","I")
81
timeStep = ("PDTREF","CALCIUM_double","I")
83
astTimeStep = ("DTAST", "CALCIUM_double","I")
84
satTimeStep = ("DTSAT", "CALCIUM_double","I")
85
newTimeStep = ("DTCALC","CALCIUM_double","I")
89
aster_outstream = [astDisplacement, astVelocity, astTimeStep]
91
aster_instream = [nbFor, nbDyn,
93
nodesColor, facesColor,
96
epsilon, astConvergence,
98
prevTime, timeStep, newTimeStep]
100
# Code_Saturne streams
102
saturne_instream = [satDisplacement,
110
saturne_outstream = [satTimeStep,
114
nodesColor, facesColor,
120
milieu_outstream = [newTimeStep,
123
satDisplacement, astForces,
126
extConvergence, astConvergence,
129
milieu_instream = [satLengthScale,
130
satTimeStep, astTimeStep,
131
astDisplacement, astVelocity,
136
# Creation of the different components
137
# ------------------------------------
139
# Code_Aster component
141
aster_service = Service("op0117",
142
instream = aster_instream,
143
outstream = aster_outstream)
145
c1 = ASTERComponent("FSI_ASTER",
146
services = [aster_service],
147
aster_dir = asterdir,
149
exe_path = "./aster_by_yacs.sh")
151
# Code_Saturne component
153
saturne_defs = """extern "C" {
154
void cs_calcium_set_component(int comp_id, void *comp);
155
void cs_calcium_set_verbosity(int n_echo);
159
saturne_body = """cs_calcium_set_component(0, component);
160
cs_calcium_set_verbosity(verbosity);
163
saturne_service = Service("run",
164
inport = [("app_name", "string"),
165
("verbosity", "long")],
166
outport = [("retval", "long")],
167
instream = saturne_instream,
168
outstream = saturne_outstream,
172
c2 = CPPComponent("FSI_SATURNE",
173
services = [saturne_service],
175
exe_path = "./run_solver.sh")
179
milieu_defs = """#include <runmilieu.h>
180
#include <donnees.h>"""
182
milieu_body = """inter_cs_ast_set_nbpdtm(NBPDTM);
183
inter_cs_ast_set_nbssit(NBSSIT);
184
inter_cs_ast_set_isyncp(ISYNCP);
185
inter_cs_ast_set_ntchr(NTCHR);
186
inter_cs_ast_set_dtref(DTREF);
187
inter_cs_ast_set_ttinit(TTINIT);
188
inter_cs_ast_set_epsilo(EPSILO);
189
runmilieu(component);"""
191
milieu_service = Service("inter_run",
192
inport=[("NBPDTM", "long"),
197
("TTINIT", "double"),
198
("EPSILO", "double")],
199
outstream = milieu_outstream,
200
instream = milieu_instream,
204
c3 = CPPComponent("FSI_MILIEU",
205
services = [milieu_service],
206
includes = milieuinc,
209
# Creation of the FSI module
210
# --------------------------
212
m = Module("FSI", components=[c1,c2,c3], prefix="fsi_arch")
213
g = Generator(m, context)
217
# We don't want to compile and install the module by default
223
g.make_appli("fsi_appli", restrict=["KERNEL","GUI","YACS"])