16#include <Probleme_FTD_IJK_tools.h>
17#include <Probleme_FTD_IJK_base.h>
19void copy_field_values(IJK_Field_double& field,
const IJK_Field_double& field_to_copy)
21 const int ni = field.
ni(), nj = field.
nj(), nk = field.
nk();
23 const int ni_to_copy = field_to_copy.
ni(), nj_to_copy = field_to_copy.
nj(), nk_to_copy = field_to_copy.
nk();
25 const bool bool_dim = (ni == ni_to_copy && nj == nj_to_copy && nk == nk_to_copy);
30 for (
int k = 0; k < nk; k++)
31 for (
int j = 0; j < nj; j++)
32 for (
int i = 0; i < ni; i++)
33 field(i,j,k) = field_to_copy(i,j,k);
39IJK_Field_double scalar_product(
const Probleme_FTD_IJK_base& pb,
const IJK_Field_vector3_double& V1,
const IJK_Field_vector3_double& V2)
44 IJK_Field_double resu;
47 const int nk = V1[0].nk();
49 Cerr <<
"scalar product of fields with different dimensions (nk)" << finl;
51 const int nj = V1[0].nj();
53 Cerr <<
"scalar product of fields with different dimensions (nj)" << finl;
55 const int ni = V1[0].ni();
57 Cerr <<
"scalar product of fields with different dimensions (ni)" << finl;
59 for (
int k = 0; k < nk; ++k)
60 for (
int j = 0; j < nj; ++j)
61 for (
int i = 0; i < ni; ++i)
63 resu(i, j, k) = 0.25 * ((V1[0](i, j, k) + V1[0](i + 1, j, k)) * (V2[0](i, j, k) + V2[0](i + 1, j, k)) +
64 (V1[1](i, j, k) + V1[1](i, j + 1, k)) * (V2[1](i, j, k) + V2[1](i, j + 1, k))
65 + (V1[2](i, j, k) + V1[2](i, j, k + 1)) * (V2[2](i, j, k) + V2[2](i, j, k + 1)));
71IJK_Field_vector3_double scalar_times_vector(
const Probleme_FTD_IJK_base& pb,
const IJK_Field_double& Sca,
const IJK_Field_vector3_double& Vec)
80 IJK_Field_vector3_double resu;
83 const int nk = Vec[0].nk();
85 Cerr <<
"scalar fields has different dimension from vector field (nk)" << finl;
87 const int nj = Vec[0].nj();
89 Cerr <<
"scalar fields has different dimension from vector field (nj)" << finl;
91 const int ni = Vec[0].ni();
93 Cerr <<
"scalar fields has different dimension from vector field (ni)" << finl;
95 for (
int k = 0; k < nk; ++k)
96 for (
int j = 0; j < nj; ++j)
97 for (
int i = 0; i < ni; ++i)
99 resu[0](i, j, k) = 0.5 * (Sca(i - 1, j, k) + Sca(i, j, k)) * Vec[0](i, j, k);
100 resu[1](i, j, k) = 0.5 * (Sca(i, j - 1, k) + Sca(i, j, k)) * Vec[1](i, j, k);
101 resu[2](i, j, k) = 0.5 * (Sca(i, j, k - 1) + Sca(i, j, k)) * Vec[2](i, j, k);
107IJK_Field_double scalar_fields_product(
const Probleme_FTD_IJK_base& pb,
const IJK_Field_double& S1,
const IJK_Field_double& S2,
int dir)
114 IJK_Field_double resu;
117 const int nk = S1.
nk();
119 Cerr <<
"scalar fields have different dimensions for the product (nk)" << finl;
121 const int nj = S1.
nj();
123 Cerr <<
"scalar fields have different dimensions for the product (nj)" << finl;
125 const int ni = S1.
ni();
127 Cerr <<
"scalar fields have different dimensions for the product (ni)" << finl;
129 for (
int k = 0; k < nk; ++k)
130 for (
int j = 0; j < nj; ++j)
131 for (
int i = 0; i < ni; ++i)
134 resu(i, j, k) = 0.5 * (S1(i - 1, j, k) + S1(i, j, k)) * S2(i, j, k);
137 resu(i, j, k) = 0.5 * (S1(i, j - 1, k) + S1(i, j, k)) * S2(i, j, k);
140 resu(i, j, k) = 0.5 * (S1(i, j, k - 1) + S1(i, j, k)) * S2(i, j, k);
146void ecrire_donnees(
const Probleme_FTD_IJK_base& pb,
const IJK_Field_vector3_double& f3compo,
SFichier& le_fichier,
const int compo,
bool binary)
148 const IJK_Field_double& f = f3compo[compo];
150 ArrOfDouble coord_i, coord_j, coord_k;
151 build_local_coords(f, coord_i, coord_j, coord_k);
153 const int ni = f.
ni();
154 const int nj = f.
nj();
155 const int nk = f.
nk();
158 for (
int k = 0; k < nk; k++)
159 for (
int j = 0; j < nj; j++)
160 for (
int i = 0; i < ni; i++)
163 le_fichier << coord_i[i] << coord_j[j] << coord_k[k] << f(i,j,k);
174 Cerr <<
"compo 0: " << l <<
" " << coord_i[0] << finl;
175 for (
int k = 0; k < nk; k++)
176 for (
int j = 0; j < nj; j++)
178 le_fichier << l << coord_j[j] << coord_k[k] << f(0,j,k);
184 Cerr <<
"compo 1: " << l <<
" " << coord_j[0] << finl;
185 for (
int k = 0; k < nk; k++)
186 for (
int i = 0; i < ni; i++)
188 le_fichier << coord_i[i] << l << coord_k[k] << f(i,0,k);
194 for (
int j = 0; j < nj; j++)
195 for (
int i = 0; i < ni; i++)
197 le_fichier << coord_i[i] << coord_j[j] << l << f(i,j,0);
203 Cerr <<
"Written " << cnt <<
" items with (ni, nj, nk)." << ni <<
" " << nj <<
" " << nk << finl;
207void dumpxyz_vector(
const Probleme_FTD_IJK_base& pb,
const IJK_Field_vector3_double& f3compo,
const char * filename,
bool binary)
219 le_fichier.
ouvrir(filename);
220 for (
unsigned compo=0; compo<3; compo++)
221 ecrire_donnees(pb, f3compo, le_fichier, compo, binary);
223 envoyer(token, rank, rank+1, 2345);
228 recevoir(rcv, rank-1, rank, 2345);
232 le_fichier.
ouvrir(filename, ios::app);
233 for (
unsigned compo=0; compo<3; compo++)
234 ecrire_donnees(pb, f3compo, le_fichier, compo, binary);
237 envoyer(token, rank, rank+1, 2345);
241 Cerr <<
"Fin de l ecriture dans le fichier XYZ: " << filename << finl;
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.
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.
double get_origin(int direction) const
Returns the coordinate of the first node (global) of the mesh in the requested direction.
void allocate(const Domaine_IJK &d, Domaine_IJK::Localisation l, int ghost_size, int additional_k_layers=0, int nb_compo=1, const Nom &name=Nom(), bool external_storage=false, int monofluide=0, double rov=0., double rol=0., int use_inv_rho_in_pressure_solver=0)
void echange_espace_virtuel(int ghost)
Exchange data over "ghost" number of cells.
const Domaine_IJK & get_domaine() const
const Domaine_IJK & domaine_ijk() const
const Domaine_IJK & get_domaine() const
static int nproc()
Returns the number of processors in the current group. See Comm_Group::nproc() and PE_Groups::current...
static void barrier()
Synchronizes all processors in the current group (waits until all processors have reached the barrier...
static int me()
Returns the rank of the local processor in the current communication group. See Comm_Group::rank() an...
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
static int je_suis_maitre()
Returns 1 if on the master processor of the current group (i.e. me() == 0), 0 otherwise.
SFichier is to the C++ ofstream class what Sortie is to the C++ ostream class.
virtual int ouvrir(const char *name, IOS_OPEN_MODE mode=ios::out)
Sortie & flush() override
Forces the data in the buffer to be written to disk. Uses the ofstream class implementation.
void set_bin(bool bin) override
Changes the write mode of the file.