~ubuntu-branches/ubuntu/precise/code-saturne/precise

« back to all changes in this revision

Viewing changes to extras/salome/fsi_yacsgen.py

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2011-11-24 00:00:08 UTC
  • mfrom: (6.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20111124000008-2vo99e38267942q5
Tags: 2.1.0-3
Install a missing file

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#-------------------------------------------------------------------------------
 
2
#   This file is part of the Code_Saturne CFD tool.
 
3
#
 
4
#   Copyright (C) 2011 EDF S.A.
 
5
#
 
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.
 
10
#
 
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.
 
15
#
 
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
#-------------------------------------------------------------------------------
 
21
 
 
22
import os, sys
 
23
 
 
24
from module_generator import Generator, Module, Service
 
25
from module_generator import ASTERComponent, CPPComponent
 
26
 
 
27
# Context definition
 
28
# ------------------
 
29
 
 
30
asterdir = os.path.expanduser("~/Code_Aster/NEW11.0")
 
31
 
 
32
milieuinc = "-I$(top_srcdir)/salome/libmilieu"
 
33
milieulib = "$(top_builddir)/salome/libmilieu/libmilieu.la"
 
34
 
 
35
# SALOME environment be must loaded beforehand
 
36
 
 
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")
 
40
    sys.exit(1)
 
41
 
 
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}
 
46
 
 
47
# Definition of all the in/out streams
 
48
# ------------------------------------
 
49
 
 
50
astDisplacement = ("DEPAST","CALCIUM_double","I")
 
51
astVelocity = ("VITAST","CALCIUM_double","I")
 
52
astForces = ("FORAST","CALCIUM_double","I")
 
53
 
 
54
satDisplacement = ("DEPSAT","CALCIUM_double","I")
 
55
satForces = ("FORSAT","CALCIUM_double","I")
 
56
 
 
57
geometricData = ("DONGEO","CALCIUM_integer","I")
 
58
satLengthScale = ("ALMAXI","CALCIUM_double","I")
 
59
 
 
60
nbFor = ("NB_FOR","CALCIUM_integer","I")
 
61
nbDyn = ("NB_DYN","CALCIUM_integer","I")
 
62
 
 
63
nodesXYZ = ("COONOD","CALCIUM_double","I")
 
64
facesXYZ = ("COOFAC","CALCIUM_double","I")
 
65
 
 
66
nodesColor = ("COLNOD","CALCIUM_integer","I")
 
67
facesColor = ("COLFAC","CALCIUM_integer","I")
 
68
 
 
69
nbIter = ("NBPDTM","CALCIUM_integer","I")
 
70
nbSubIter = ("NBSSIT","CALCIUM_integer","I")
 
71
 
 
72
indSync =("ISYNCP","CALCIUM_integer","I")
 
73
frequency = ("NTCHRO","CALCIUM_integer","I")
 
74
 
 
75
epsilon = ("EPSILO","CALCIUM_double","I")
 
76
astConvergence = ("ICVAST","CALCIUM_integer","I")
 
77
satConvergence = ("ICV",   "CALCIUM_integer","I")
 
78
extConvergence = ("ICVEXT","CALCIUM_integer","I")
 
79
 
 
80
prevTime = ("TTINIT","CALCIUM_double","I")
 
81
timeStep = ("PDTREF","CALCIUM_double","I")
 
82
 
 
83
astTimeStep = ("DTAST", "CALCIUM_double","I")
 
84
satTimeStep = ("DTSAT", "CALCIUM_double","I")
 
85
newTimeStep = ("DTCALC","CALCIUM_double","I")
 
86
 
 
87
# Code_Aster streams
 
88
 
 
89
aster_outstream = [astDisplacement, astVelocity, astTimeStep]
 
90
 
 
91
aster_instream = [nbFor, nbDyn,
 
92
                  nodesXYZ, facesXYZ,
 
93
                  nodesColor, facesColor,
 
94
                  astForces,
 
95
                  nbIter, nbSubIter,
 
96
                  epsilon, astConvergence,
 
97
                  indSync, frequency,
 
98
                  prevTime, timeStep, newTimeStep]
 
99
 
 
100
# Code_Saturne streams
 
101
 
 
102
saturne_instream = [satDisplacement,
 
103
                    epsilon,
 
104
                    newTimeStep,
 
105
                    prevTime,
 
106
                    timeStep,
 
107
                    nbIter, nbSubIter,
 
108
                    extConvergence]
 
109
 
 
110
saturne_outstream = [satTimeStep,
 
111
                     satForces,
 
112
                     satLengthScale,
 
113
                     nodesXYZ, facesXYZ,
 
114
                     nodesColor, facesColor,
 
115
                     satConvergence,
 
116
                     geometricData]
 
117
 
 
118
# Milieu streams
 
119
 
 
120
milieu_outstream = [newTimeStep,
 
121
                    epsilon,
 
122
                    prevTime, timeStep,
 
123
                    satDisplacement, astForces,
 
124
                    nbIter, nbSubIter,
 
125
                    indSync, frequency,
 
126
                    extConvergence, astConvergence,
 
127
                    nbDyn, nbFor]
 
128
 
 
129
milieu_instream = [satLengthScale,
 
130
                   satTimeStep, astTimeStep,
 
131
                   astDisplacement, astVelocity,
 
132
                   satForces,
 
133
                   geometricData,
 
134
                   satConvergence]
 
135
 
 
136
# Creation of the different components
 
137
# ------------------------------------
 
138
 
 
139
# Code_Aster component
 
140
 
 
141
aster_service = Service("op0117",
 
142
                        instream = aster_instream,
 
143
                        outstream = aster_outstream)
 
144
 
 
145
c1 = ASTERComponent("FSI_ASTER",
 
146
                    services = [aster_service],
 
147
                    aster_dir = asterdir,
 
148
                    kind = "exe",
 
149
                    exe_path = "./aster_by_yacs.sh")
 
150
 
 
151
# Code_Saturne component
 
152
 
 
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);
 
156
  void cs_run(void);
 
157
}"""
 
158
 
 
159
saturne_body = """cs_calcium_set_component(0, component);
 
160
cs_calcium_set_verbosity(verbosity);
 
161
cs_run();"""
 
162
 
 
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,
 
169
                          defs = saturne_defs,
 
170
                          body = saturne_body)
 
171
 
 
172
c2 = CPPComponent("FSI_SATURNE",
 
173
                  services = [saturne_service],
 
174
                  kind = "exe",
 
175
                  exe_path = "./run_solver.sh")
 
176
 
 
177
# Milieu component
 
178
 
 
179
milieu_defs = """#include <runmilieu.h>
 
180
#include <donnees.h>"""
 
181
 
 
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);"""
 
190
 
 
191
milieu_service = Service("inter_run",
 
192
                         inport=[("NBPDTM", "long"),
 
193
                                 ("NBSSIT", "long"),
 
194
                                 ("ISYNCP", "long"),
 
195
                                 ("NTCHR",  "long"),
 
196
                                 ("DTREF",  "double"),
 
197
                                 ("TTINIT", "double"),
 
198
                                 ("EPSILO", "double")],
 
199
                         outstream = milieu_outstream,
 
200
                         instream = milieu_instream,
 
201
                         defs = milieu_defs,
 
202
                         body = milieu_body)
 
203
 
 
204
c3 = CPPComponent("FSI_MILIEU",
 
205
                  services = [milieu_service],
 
206
                  includes = milieuinc,
 
207
                  libs = milieulib)
 
208
 
 
209
# Creation of the FSI module
 
210
# --------------------------
 
211
 
 
212
m = Module("FSI", components=[c1,c2,c3], prefix="fsi_arch")
 
213
g = Generator(m, context)
 
214
 
 
215
g.generate()
 
216
 
 
217
# We don't want to compile and install the module by default
 
218
if False:
 
219
    g.bootstrap()
 
220
    g.configure()
 
221
    g.make()
 
222
    g.install()
 
223
    g.make_appli("fsi_appli", restrict=["KERNEL","GUI","YACS"])