21#include <Interprete_bloc.h>
23static void extend_array(
const Domaine_IJK& geom1,
const int direction,
const int ncells, ArrOfDouble& delta,
double& origin)
36 for (i = n - 1; i >= 0; i--)
37 delta[i + ncells] = delta[i];
41 Cerr <<
"Error in build_extended_splitting, direction " << direction <<
" extension of " << ncells <<
" not possible because we only have " << n <<
" cells in the domain." << finl;
44 for (i = 0; i < ncells; i++)
47 delta[i] = delta[i + n];
51 delta[ncells + i + n] = delta[ncells + i];
62 double origin_x, origin_y, origin_z;
63 ArrOfDouble dx, dy, dz;
64 extend_array(geom1, DIRECTION_I, n_cells, dx, origin_x);
65 extend_array(geom1, DIRECTION_J, n_cells, dy, origin_y);
66 extend_array(geom1, DIRECTION_K, n_cells, dz, origin_z);
82 const double x0 = geom.
get_origin(DIRECTION_I);
83 const double y0 = geom.
get_origin(DIRECTION_J);
84 const double z0 = geom.
get_origin(DIRECTION_K);
95 char fonction_coord_x[300];
96 snprintf(fonction_coord_x, 300,
"%.16g+x*%.16g", x0, lx);
97 char fonction_coord_y[300];
98 snprintf(fonction_coord_y, 300,
"%.16g+y*%.16g", y0, ly);
99 char fonction_coord_z[300];
100 snprintf(fonction_coord_z, 300,
"%.16g+z*%.16g", z0, lz);
103 instructions <<
"Dimension 3 " << finl;
104 instructions <<
"Domaine " << nom_domaine << finl;
105 instructions <<
"MaillerParallel" << finl;
106 instructions <<
"{" << finl;
107 instructions <<
" domain " << nom_domaine << finl;
108 instructions <<
" nb_nodes 3 " << ni <<
" " << nj <<
" " << nk << finl;
109 instructions <<
" splitting 3 " << nslicei <<
" " << nslicej <<
" " << nslicek << finl;
110 instructions <<
" ghost_thickness 1" << finl;
111 instructions <<
" function_coord_x " << fonction_coord_x << finl;
112 instructions <<
" function_coord_y " << fonction_coord_y << finl;
113 instructions <<
" function_coord_z " << fonction_coord_z << finl;
114 instructions <<
" boundary_xmin xmin" << finl;
115 instructions <<
" boundary_xmax xmax" << finl;
116 instructions <<
" boundary_ymin ymin" << finl;
117 instructions <<
" boundary_ymax ymax" << finl;
118 instructions <<
" boundary_zmin zmin" << finl;
119 instructions <<
" boundary_zmax zmax" << finl;
121 instructions <<
" mapping " << finl;
125 for (
int k = 0; k < nslicek; k++)
126 for (
int j = 0; j < nslicej; j++)
127 for (
int i = 0; i < nslicei; i++)
135 if (min_array(map) < 0)
137 Cerr <<
"Error in creer_domaine_vdf: there are unused processors in the ijk splitting" << finl;
139 Nom pb_name =
Nom(
"pb_") + nom_domaine;
140 instructions << map << finl;
141 instructions <<
"}" << finl;
142 instructions <<
"Probleme_FT_Disc_gen " << pb_name << finl;
143 instructions <<
"Associer " << pb_name <<
" " << nom_domaine << finl;
144 instructions <<
"VDF dis" << nom_domaine << finl;
145 instructions <<
"Schema_Euler_explicite sch" << nom_domaine <<
" Lire sch" << nom_domaine <<
" { nb_pas_dt_max 1 }" << finl;
146 instructions <<
"Associer " << pb_name <<
" sch" << nom_domaine << finl;
147 instructions <<
"Discretiser " << pb_name <<
" dis" << nom_domaine << finl;
148 Cerr <<
"Interpretation of the following string:" << finl << instructions.
get_str();
162static void ijk_interpolate_implementation(
const IJK_Field_double& field,
const DoubleTab& coordinates, ArrOfDouble& result,
int skip_unknown_points,
double value_for_bad_points)
164 const int ghost = field.
ghost();
165 const int ni = field.
ni();
166 const int nj = field.
nj();
167 const int nk = field.
nk();
178 const int nb_coords = coordinates.
dimension(0);
180 for (
int idx = 0; idx < nb_coords; idx++)
182 const double x = coordinates(idx, 0);
183 const double y = coordinates(idx, 1);
184 const double z = coordinates(idx, 2);
185 const double x2 = (x - origin_x) / dx;
186 const double y2 = (y - origin_y) / dy;
187 const double z2 = (z - origin_z) / dz;
192 const double xfact = x2 - floor(x2);
193 const double yfact = y2 - floor(y2);
194 const double zfact = z2 - floor(z2);
197 bool ok = (index_i >= -ghost && index_i < ni + ghost - 1) && (index_j >= -ghost && index_j < nj + ghost - 1) && (index_k >= -ghost && index_k < nk + ghost - 1);
200 if (skip_unknown_points)
202 result[idx] = value_for_bad_points;
208 Cerr <<
"Error in ijk_interpolate_implementation: request interpolation of point " << x <<
" " << y <<
" " << z <<
" which is outside of the domain on processor " <<
Process::me()
214 double r = (((1. - xfact) * field(index_i, index_j, index_k) + xfact * field(index_i + 1, index_j, index_k)) * (1. - yfact)
215 + ((1. - xfact) * field(index_i, index_j + 1, index_k) + xfact * field(index_i + 1, index_j + 1, index_k)) * (yfact)) * (1. - zfact)
216 + (((1. - xfact) * field(index_i, index_j, index_k + 1) + xfact * field(index_i + 1, index_j, index_k + 1)) * (1. - yfact)
217 + ((1. - xfact) * field(index_i, index_j + 1, index_k + 1) + xfact * field(index_i + 1, index_j + 1, index_k + 1)) * (yfact)) * (zfact);
222void ijk_interpolate_skip_unknown_points(
const IJK_Field_double& field,
const DoubleTab& coordinates, ArrOfDouble& result,
const double value_for_bad_points)
224 ijk_interpolate_implementation(field, coordinates, result, 1 , value_for_bad_points);
227void ijk_interpolate(
const IJK_Field_double& field,
const DoubleTab& coordinates, ArrOfDouble& result)
229 ijk_interpolate_implementation(field, coordinates, result, 0 , 0.);
233static double ijk_interpolate_one_value(
const IJK_Field_double& field,
const Vecteur3& coordinates,
int skip_unknown_points,
double value_for_bad_points)
235 const int ghost = field.
ghost();
236 const int ni = field.
ni();
237 const int nj = field.
nj();
238 const int nk = field.
nk();
249 const double x = coordinates[0];
250 const double y = coordinates[1];
251 const double z = coordinates[2];
252 const double x2 = (x - origin_x) / dx;
253 const double y2 = (y - origin_y) / dy;
254 const double z2 = (z - origin_z) / dz;
259 const double xfact = x2 - floor(x2);
260 const double yfact = y2 - floor(y2);
261 const double zfact = z2 - floor(z2);
264 bool ok = (index_i >= -ghost && index_i < ni + ghost - 1) && (index_j >= -ghost && index_j < nj + ghost - 1) && (index_k >= -ghost && index_k < nk + ghost - 1);
267 if (skip_unknown_points)
269 return value_for_bad_points;
274 Cerr <<
"Error in ijk_interpolate_implementation: request interpolation of point " << x <<
" " << y <<
" " << z <<
" which is outside of the domain on processor " <<
Process::me()
280 double r = (((1. - xfact) * field(index_i, index_j, index_k) + xfact * field(index_i + 1, index_j, index_k)) * (1. - yfact)
281 + ((1. - xfact) * field(index_i, index_j + 1, index_k) + xfact * field(index_i + 1, index_j + 1, index_k)) * (yfact)) * (1. - zfact)
282 + (((1. - xfact) * field(index_i, index_j, index_k + 1) + xfact * field(index_i + 1, index_j, index_k + 1)) * (1. - yfact)
283 + ((1. - xfact) * field(index_i, index_j + 1, index_k + 1) + xfact * field(index_i + 1, index_j + 1, index_k + 1)) * (yfact)) * (zfact);
287double ijk_interpolate_skip_unknown_points(
const IJK_Field_double& field,
const Vecteur3& coordinates,
const double value_for_bad_points)
289 return ijk_interpolate_one_value(field, coordinates, 1 , value_for_bad_points);
292double ijk_interpolate(
const IJK_Field_double& field,
const Vecteur3& coordinates)
294 return ijk_interpolate_one_value(field, coordinates, 0 , 0.);
299void build_local_coords(
const IJK_Field_double& f, ArrOfDouble& coord_i, ArrOfDouble& coord_j, ArrOfDouble& coord_k)
309 const int ni = f.
ni();
310 const int nj = f.
nj();
311 const int nk = f.
nk();
318 for (
int i = 0; i < ni; i++)
319 coord_i[i] = nodes_i[i + i_offset];
323 for (
int i = 0; i < ni; i++)
324 coord_i[i] = (nodes_i[i + i_offset] + nodes_i[i + i_offset + 1]) * 0.5;
328 for (
int i = 0; i < nj; i++)
329 coord_j[i] = nodes_j[i + j_offset];
333 for (
int i = 0; i < nj; i++)
334 coord_j[i] = (nodes_j[i + j_offset] + nodes_j[i + j_offset + 1]) * 0.5;
338 for (
int i = 0; i < nk; i++)
339 coord_k[i] = nodes_k[i + k_offset];
343 for (
int i = 0; i < nk; i++)
344 coord_k[i] = (nodes_k[i + k_offset] + nodes_k[i + k_offset + 1]) * 0.5;
349void set_field_data(IJK_Field_double& f,
double func(
double,
double,
double))
351 ArrOfDouble coord_i, coord_j, coord_k;
352 build_local_coords(f, coord_i, coord_j, coord_k);
354 const int ni = f.
ni();
355 const int nj = f.
nj();
356 const int nk = f.
nk();
358 for (
int k = 0; k < nk; k++)
360 double z = coord_k[k];
361 for (
int j = 0; j < nj; j++)
363 double y = coord_j[j];
364 for (
int i = 0; i < ni; i++)
366 double x = coord_i[i];
367 f(i, j, k) = func(x, y, z);
376void compose_field_data(IJK_Field_double& f,
const Nom& parser_expression_of_x_y_z)
378 ArrOfDouble coord_i, coord_j, coord_k;
379 build_local_coords(f, coord_i, coord_j, coord_k);
381 const int ni = f.
ni();
382 const int nj = f.
nj();
383 const int nk = f.
nk();
385 std::string expr(parser_expression_of_x_y_z);
393 for (
int k = 0; k < nk; k++)
395 double z = coord_k[k];
397 for (
int j = 0; j < nj; j++)
399 double y = coord_j[j];
401 for (
int i = 0; i < ni; i++)
403 double x = coord_i[i];
404 parser.
setVar((
int) 0, x);
405 f(i, j, k) += parser.
eval();
414void set_field_data(IJK_Field_double& f,
const Nom& parser_expression_of_x_y_z)
416 ArrOfDouble coord_i, coord_j, coord_k;
417 build_local_coords(f, coord_i, coord_j, coord_k);
419 const int ni = f.
ni();
420 const int nj = f.
nj();
421 const int nk = f.
nk();
423 std::string expr(parser_expression_of_x_y_z);
431 for (
int k = 0; k < nk; k++)
433 double z = coord_k[k];
435 for (
int j = 0; j < nj; j++)
437 double y = coord_j[j];
439 for (
int i = 0; i < ni; i++)
441 double x = coord_i[i];
442 parser.
setVar((
int) 0, x);
443 f(i, j, k) = parser.
eval();
450void set_field_data(IJK_Field_double& f,
const Nom& parser_expression_of_x_y_z_and_t,
const double current_time)
452 ArrOfDouble coord_i, coord_j, coord_k;
453 build_local_coords(f, coord_i, coord_j, coord_k);
455 const int ni = f.
ni();
456 const int nj = f.
nj();
457 const int nk = f.
nk();
459 std::string expr(parser_expression_of_x_y_z_and_t);
468 parser.
setVar(3, current_time);
469 for (
int k = 0; k < nk; k++)
471 double z = coord_k[k];
473 for (
int j = 0; j < nj; j++)
475 double y = coord_j[j];
477 for (
int i = 0; i < ni; i++)
479 double x = coord_i[i];
480 parser.
setVar((
int) 0, x);
481 f(i, j, k) = parser.
eval();
488void set_field_data(IJK_Field_double& f,
const Nom& parser_expression_of_x_y_z_and_t,
const IJK_Field_double& input_f,
const double current_time)
490 ArrOfDouble coord_i, coord_j, coord_k;
491 build_local_coords(f, coord_i, coord_j, coord_k);
493 const int ni = f.
ni();
494 const int nj = f.
nj();
495 const int nk = f.
nk();
497 std::string expr(parser_expression_of_x_y_z_and_t);
507 parser.
setVar(3, current_time);
508 for (
int k = 0; k < nk; k++)
510 double z = coord_k[k];
512 for (
int j = 0; j < nj; j++)
514 double y = coord_j[j];
516 for (
int i = 0; i < ni; i++)
518 double x = coord_i[i];
519 parser.
setVar((
int) 0, x);
520 parser.
setVar(4, input_f(i, j, k));
521 f(i, j, k) = parser.
eval();
528void set_field_data(IJK_Field_double& f,
const Nom& parser_expression_of_x_y_z_and_t,
const IJK_Field_double& input_f1,
const IJK_Field_double& input_f2,
const double current_time)
530 ArrOfDouble coord_i, coord_j, coord_k;
531 build_local_coords(f, coord_i, coord_j, coord_k);
533 const int ni = f.
ni();
534 const int nj = f.
nj();
535 const int nk = f.
nk();
537 std::string expr(parser_expression_of_x_y_z_and_t);
548 parser.
setVar(3, current_time);
549 for (
int k = 0; k < nk; k++)
551 double z = coord_k[k];
553 for (
int j = 0; j < nj; j++)
555 double y = coord_j[j];
557 for (
int i = 0; i < ni; i++)
559 double x = coord_i[i];
560 parser.
setVar((
int) 0, x);
561 parser.
setVar(4, input_f1(i, j, k));
562 parser.
setVar(5, input_f2(i, j, k));
563 f(i, j, k) = parser.
eval();
571void complex_to_trig(
const double re,
const double im,
double& modul,
double& arg)
573 modul = sqrt(re * re + im * im);
584 Cerr <<
"watchout!" << finl;
588 arg = M_PI + atan(im / re);
593void squared_3x3(
double& a11,
double& a12,
double& a13,
double& a21,
double& a22,
double& a23,
double& a31,
double& a32,
double& a33)
595 double aa11 = a11 * a11 + a12 * a21 + a13 * a31;
596 double aa12 = a11 * a12 + a12 * a22 + a13 * a32;
597 double aa13 = a11 * a13 + a12 * a23 + a13 * a33;
598 double aa21 = a21 * a11 + a22 * a21 + a23 * a31;
599 double aa22 = a21 * a12 + a22 * a22 + a23 * a32;
600 double aa23 = a21 * a13 + a22 * a23 + a23 * a33;
601 double aa31 = a31 * a11 + a32 * a21 + a33 * a31;
602 double aa32 = a31 * a12 + a32 * a22 + a33 * a32;
603 double aa33 = a31 * a13 + a32 * a23 + a33 * a33;
618void interpolate_to_center(IJK_Field_vector3_double& cell_center_field,
const IJK_Field_vector3_double& face_field)
621 IJK_Field_vector3_double& face_fld_non_const =
const_cast<IJK_Field_vector3_double&
>(face_field);
624 const int kmax = cell_center_field[0].nk();
625 const int jmax = cell_center_field[0].nj();
626 const int imax = cell_center_field[0].ni();
627 for (
int k = 0; k < kmax; k++)
628 for (
int j = 0; j < jmax; j++)
629 for (
int i = 0; i < imax; i++)
631 cell_center_field[0](i,j,k) = (face_field[0](i,j,k) + face_field[0](i+1, j, k)) * 0.5;
632 cell_center_field[1](i,j,k) = (face_field[1](i,j,k) + face_field[1](i, j+1, k)) * 0.5;
633 cell_center_field[2](i,j,k) = (face_field[2](i,j,k) + face_field[2](i, j, k+1)) * 0.5;
637void interpolate_to_center_compo(IJK_Field_double& cell_center_field_compo,
const IJK_Field_double& face_field_compo)
641 const int kmax = cell_center_field_compo.
nk(),
642 jmax = cell_center_field_compo.
nj(),
643 imax = cell_center_field_compo.
ni();
648 for (
int k = 0; k < kmax; k++)
649 for (
int j = 0; j < jmax; j++)
650 for (
int i = 0; i < imax; i++)
651 cell_center_field_compo(i,j,k) = (face_field_compo(i,j,k) + face_field_compo(i+ci, j+cj, k+ck)) * 0.5;
void construire_elem_virt_pe_num()
This class encapsulates all the information related to the eulerian mesh for TrioIJK.
int get_offset_local(int direction) const
Returns the local offset in requested direction.
int get_processor_by_ijk(const FixedVector< int, 3 > &slice) const
Return the global index of the processor according to its position.
bool get_periodic_flag(int direction) const
Method returns true if periodic in this direction.
double get_domain_length(int direction) const
Returns the length of the entire domain in requested direction.
int get_nprocessor_per_direction(int direction) const
Returns the number of slices in the given direction.
double get_constant_delta(int direction) const
Returns the size of cells in a direction.
const ArrOfDouble & get_delta(int direction) const
Returns the array of mesh cell sizes in requested direction.
double get_origin(int direction) const
Returns the coordinate of the first node (global) of the mesh in the requested direction.
void initialize_splitting(Domaine_IJK &dom, int nproc_i, int nproc_j, int nproc_k, int process_grouping_i=1, int process_grouping_j=1, int process_grouping_k=1)
Buils a splitting of the given deometry on the requested number of processors in each direction.
int get_nb_elem_tot(int direction) const
Returns the total (global) number of mesh cells in requested direction.
const ArrOfDouble & get_node_coordinates(int direction) const
Returns an array with the coordinates of all nodes in the mesh in requested direction.
void initialize_origin_deltas(double x0, double y0, double z0, const ArrOfDouble &delta_x, const ArrOfDouble &delta_y, const ArrOfDouble &delta_z, bool perio_x, bool perio_y, bool perio_z)
Initializes class elements given dataset's parameters.
Localisation
Localisation sub class.
void nommer(const Nom &nom) override
Donne un nom a l'Objet_U Methode virtuelle a surcharger.
const Nom & le_nom() const override
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette implementation.
const Domaine & domaine() const
Une entree dont la source est une chaine de caracteres.
void echange_espace_virtuel(int ghost)
Exchange data over "ghost" number of cells.
Domaine_IJK::Localisation get_localisation() const
const Domaine_IJK & get_domaine() const
void echange_espace_virtuel()
Entree & interpreter_bloc(Entree &is, Bloc_Type bloc_type, int verifier_sans_interpreter)
Interpretation d'un bloc d'instructions prises dans l'entree is.
static Interprete_bloc & interprete_courant()
renvoie l'interprete_bloc en train d'etre lu dans le jeu de donnees.
static Objet_U & objet_global(const Nom &nom)
cherche l'objet demande dans l'Interprete_bloc courant (Interprete_bloc::interprete_courant()) et dan...
class Nom Une chaine de caractere pour nommer les objets de TRUST
Representation des donnees de la classe Parser.
void addVar(const char *)
virtual void setNbVar(int nvar)
void setVar(const char *sv, double val)
void setString(const std::string &s)
virtual void parseString()
classe Probleme_base C'est un Probleme_U qui n'est pas un couplage.
const Domaine_dis_base & domaine_dis() const
Renvoie le domaine discretise associe au probleme.
static int nproc()
renvoie le nombre de processeurs dans le groupe courant Voir Comm_Group::nproc() et PE_Groups::curren...
static int me()
renvoie mon rang dans le groupe de communication courant.
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Cette classe derivee de Sortie empile ce qu'on lui envoie dans une chaine de caracteres.
const char * get_str() const
returns a copy of the string stored by the SChaine
_SIZE_ size_array() const
void resize_array(_SIZE_ new_size, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
_SIZE_ dimension(int d) const