programmer's documentation
cs_paramedmem_coupling.hxx
Go to the documentation of this file.
1 #ifndef __CS_PARAMEDMEM_HXX__
2 #define __CS_PARAMEDMEM_HXX__
3 
4 /*============================================================================
5  * Coupling using ParaMEDMEM
6  *============================================================================*/
7 
8 /*
9  This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2018 EDF S.A.
12 
13  This program is free software; you can redistribute it and/or modify it under
14  the terms of the GNU General Public License as published by the Free Software
15  Foundation; either version 2 of the License, or (at your option) any later
16  version.
17 
18  This program is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21  details.
22 
23  You should have received a copy of the GNU General Public License along with
24  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25  Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 */
27 
28 /*----------------------------------------------------------------------------*/
29 
30 /*----------------------------------------------------------------------------
31  * Standard C library headers
32  *----------------------------------------------------------------------------*/
33 
34 /*----------------------------------------------------------------------------
35  * MED library headers
36  *----------------------------------------------------------------------------*/
37 
38 #include <ParaFIELD.hxx>
39 #include <ParaMESH.hxx>
40 #include <InterpKernelDEC.hxx>
41 
42 #include <MEDCouplingUMesh.hxx>
43 #include <MEDCouplingField.hxx>
44 #include <MEDCouplingFieldDouble.hxx>
45 
46 /*----------------------------------------------------------------------------
47  * Local headers
48  *----------------------------------------------------------------------------*/
49 
50 #include "cs_base.h"
51 
52 /*----------------------------------------------------------------------------*/
53 
54 using namespace MEDCoupling;
55 
56 /*=============================================================================
57  * Local Macro Definitions
58  *============================================================================*/
59 
60 /*============================================================================
61  * Structure definition
62  *============================================================================*/
63 
64 typedef struct _cs_paramedmem_coupling_t cs_paramedmem_coupling_t;
65 
66 /*============================================================================
67  * Global variables definition
68  *============================================================================*/
69 
70 /*============================================================================
71  * Public function prototypes
72  *============================================================================*/
73 
74 /*----------------------------------------------------------------------------
75  * Define new ParaMEDMEM coupling.
76  *
77  * arguments:
78  * name <-- name of coupling
79  * send_dec <-- send Data Exchange Channel
80  * recv_dec <-- receive Data Exchange Channel
81  *----------------------------------------------------------------------------*/
82 
83 cs_paramedmem_coupling_t *
84 cs_paramedmem_create(const char *name,
85  InterpKernelDEC *send_dec,
86  InterpKernelDEC *recv_dec);
87 
88 /*----------------------------------------------------------------------------
89  * Define new ParaMEDMEM coupling.
90  *
91  * arguments:
92  * name <-- name of coupling
93  * send_dec <-- send Data Exchange Channel
94  * recv_dec <-- receive Data Exchange Channel
95  *----------------------------------------------------------------------------*/
96 
97 void
98 cs_paramedmem_destroy(cs_paramedmem_coupling_t **coupling);
99 
100 /*----------------------------------------------------------------------------
101  * Define nodal mesh for ParaMEDMEM coupling from selection criteria.
102  *
103  * parameters:
104  * coupling <-- partially initialized ParaMEDMEM coupling structure
105  * name <-- name of coupling mesh
106  * select_criteria <-- selection criteria
107  * elt_dim <-- element dimension
108  * is_source <-- true if fields located on mesh are sent
109  * is_dest <-- true if fields located on mesh are received
110  *
111  * returns:
112  * id of created mesh in coupling
113  *----------------------------------------------------------------------------*/
114 
115 int
116 cs_paramedmem_define_mesh(cs_paramedmem_coupling_t *coupling,
117  const char *name,
118  const char *select_criteria,
119  int elt_dim,
120  bool is_source,
121  bool is_dest);
122 
123 /*----------------------------------------------------------------------------
124  * Initialize nodal coupled meshes.
125  *
126  * parameters:
127  * coupling <-- partially initialized ParaMEDMEM coupling structure
128  *----------------------------------------------------------------------------*/
129 
130 void
131 cs_paramedmem_init_meshes(cs_paramedmem_coupling_t *coupling);
132 
133 /*----------------------------------------------------------------------------
134  * Return the ParaMEDMEM mesh id associated with a given mesh name,
135  * or -1 if no association found.
136  *
137  * parameters:
138  * coupling <-- coupling structure
139  * mesh_name <-- mesh name
140  *
141  * returns:
142  * mesh id for this coupling, or -1 if mesh name is not associated
143  * with this coupling.
144  *----------------------------------------------------------------------------*/
145 
146 int
147 cs_paramedmem_mesh_id(cs_paramedmem_coupling_t *coupling,
148  const char *mesh_name);
149 
150 /*----------------------------------------------------------------------------
151  * Get number of associated coupled elements in coupled mesh
152  *
153  * parameters:
154  * coupling <-- ParaMEDMEM coupling structure
155  * mesh_id <-- id of coupled mesh in coupling
156  *
157  * returns:
158  * number of elements in coupled mesh
159  *----------------------------------------------------------------------------*/
160 
161 cs_lnum_t
162 cs_paramedmem_mesh_get_n_elts(const cs_paramedmem_coupling_t *coupling,
163  int mesh_id);
164 
165 /*----------------------------------------------------------------------------
166  * Get local list of coupled elements (0 to n-1 numbering) for a coupled mesh
167  *
168  * parameters:
169  * coupling <-- ParaMEDMEM coupling structure
170  * mesh_id <-- id of coupled mesh in coupling
171  *----------------------------------------------------------------------------*/
172 
173 const cs_lnum_t *
174 cs_paramedmem_mesh_get_elt_list(const cs_paramedmem_coupling_t *coupling,
175  int mesh_id);
176 
177 /*----------------------------------------------------------------------------
178  * Create a MEDCoupling field structure.
179  *
180  * parameters:
181  * coupling <-- MED coupling structure.
182  * name <-- field name.
183  * mesh_id <-- id of associated mesh in structure.
184  * dim <-- number of field components.
185  * type <-- mesh mesh (ON_NODES, ON_CELLS)
186  * td <-- time discretization type
187  * dirflag <-- 1: send, 2: receive
188  *
189  * returns
190  * field id in coupling structure
191  *----------------------------------------------------------------------------*/
192 
193 int
194 cs_paramedmem_field_add(cs_paramedmem_coupling_t *coupling,
195  const char *name,
196  int mesh_id,
197  int dim,
198  TypeOfField type,
199  TypeOfTimeDiscretization td,
200  int dirflag);
201 
202 /*----------------------------------------------------------------------------
203  * Return the ParaMEDMEM field id associated with given mesh and field names,
204  * or -1 if no association found.
205  *
206  * parameters:
207  * coupling <-- coupling structure.
208  * mesh_id <-- id of associated mesh in structure.
209  * name <-- field name.
210  *
211  * returns
212  * field id in coupling structure, or -1 if not found
213  *----------------------------------------------------------------------------*/
214 
215 int
216 cs_paramedmem_field_get_id(cs_paramedmem_coupling_t *coupling,
217  int mesh_id,
218  const char *name);
219 
220 /*----------------------------------------------------------------------------
221  * Return ParaMEDMEM::ParaFIELD object associated with a given field id.
222  *
223  * parameters:
224  * coupling <-- pointer to associated coupling
225  * field_id <-- id of associated field structure
226  *
227  * returns:
228  * pointer to ParaFIELD to which values were assigned
229  *----------------------------------------------------------------------------*/
230 
231 MEDCoupling::ParaFIELD *
232 cs_paramedmem_field_get(cs_paramedmem_coupling_t *coupling,
233  int field_id);
234 
235 /*----------------------------------------------------------------------------
236  * Write field associated with a mesh to MEDCoupling.
237  *
238  * Assigning a negative value to the time step indicates a time-independent
239  * field (in which case the time_value argument is unused).
240  *
241  * parameters:
242  * coupling <-- pointer to associated coupling
243  * field_id <-- id of associated field
244  * on_parent <-- if true, values are defined on parent mesh
245  * field_values <-- array of associated field value arrays
246  *----------------------------------------------------------------------------*/
247 
248 void
249 cs_paramedmem_field_export(cs_paramedmem_coupling_t *coupling,
250  int field_id,
251  bool on_parent,
252  const double field_values[]);
253 
254 /*----------------------------------------------------------------------------
255  * Read field associated with a mesh from MEDCoupling.
256  *
257  * Only double precision floating point values are considered.
258  *
259  * Assigning a negative value to the time step indicates a time-independent
260  * field (in which case the time_value argument is unused).
261  *
262  * parameters:
263  * coupling <-- pointer to associated coupling
264  * field_id <-- id of associated field
265  * on_parent <-- if true, values are defined on parent mesh
266  * field_values <-- array of associated field value arrays
267  *----------------------------------------------------------------------------*/
268 
269 void
270 cs_paramedmem_field_import(cs_paramedmem_coupling_t *coupling,
271  int field_id,
272  bool on_parent,
273  double field_values[]);
274 
275 /*----------------------------------------------------------------------------*/
276 
277 #endif /* __CS_PARAMEDMEM_HXX__ */
const cs_lnum_t * cs_paramedmem_mesh_get_elt_list(const cs_paramedmem_coupling_t *coupling, int mesh_id)
Definition: cs_paramedmem_coupling.cxx:873
MEDCoupling::ParaFIELD * cs_paramedmem_field_get(cs_paramedmem_coupling_t *coupling, int field_id)
Definition: cs_paramedmem_coupling.cxx:1034
void cs_paramedmem_field_export(cs_paramedmem_coupling_t *coupling, int field_id, bool on_parent, const double field_values[])
Definition: cs_paramedmem_coupling.cxx:1059
int cs_paramedmem_field_add(cs_paramedmem_coupling_t *coupling, const char *name, int mesh_id, int dim, TypeOfField type, TypeOfTimeDiscretization td, int dirflag)
Definition: cs_paramedmem_coupling.cxx:901
void cs_paramedmem_field_import(cs_paramedmem_coupling_t *coupling, int field_id, bool on_parent, double field_values[])
Definition: cs_paramedmem_coupling.cxx:1110
int cs_paramedmem_define_mesh(cs_paramedmem_coupling_t *coupling, const char *name, const char *select_criteria, int elt_dim, bool is_source, bool is_dest)
Definition: cs_paramedmem_coupling.cxx:739
void cs_paramedmem_destroy(cs_paramedmem_coupling_t **coupling)
Definition: cs_paramedmem_coupling.cxx:694
int cs_paramedmem_field_get_id(cs_paramedmem_coupling_t *coupling, int mesh_id, const char *name)
Definition: cs_paramedmem_coupling.cxx:1007
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:293
cs_paramedmem_coupling_t * cs_paramedmem_create(const char *name, InterpKernelDEC *send_dec, InterpKernelDEC *recv_dec)
Definition: cs_paramedmem_coupling.cxx:659
cs_lnum_t cs_paramedmem_mesh_get_n_elts(const cs_paramedmem_coupling_t *coupling, int mesh_id)
Definition: cs_paramedmem_coupling.cxx:853
void cs_paramedmem_init_meshes(cs_paramedmem_coupling_t *coupling)
Definition: cs_paramedmem_coupling.cxx:801
int cs_paramedmem_mesh_id(cs_paramedmem_coupling_t *coupling, const char *mesh_name)
Definition: cs_paramedmem_coupling.cxx:821