TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
IJK_Lata_Swap_JK.cpp
1/****************************************************************************
2* Copyright (c) 2026, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#include <IJK_Lata_Swap_JK.h>
17#include <Param.h>
18#include <Interprete_bloc.h>
19#include <IJK_Lata_writer.h>
20#include <FixedVector.h>
21#include <IJK_Field.h>
22#include <IJK_Field_vector.h>
23#include <Domaine_IJK.h>
24#include <IJK_tools.h>
25#include <IJK_Navier_Stokes_tools.h>
26
27Implemente_instanciable(IJK_Lata_Swap_JK,"IJK_Lata_Swap_JK",Interprete) ;
28
30{
32 return os;
33}
34
36{
38 return is;
39}
40
42{
43 Nom fichier_reprise_vitesse_;
44 int timestep_reprise_vitesse_ = 0;
45 Nom fichier_sortie_vitesse_;
46 Nom ijk_splitting_name;
47 Nom ijk_splitting_name_dest;
48
49 Param param(que_suis_je());
50 param.ajouter("ijk_splitting_source", &ijk_splitting_name, Param::REQUIRED);
51 param.ajouter("ijk_splitting_dest", &ijk_splitting_name_dest, Param::REQUIRED);
52 param.ajouter("fichier_reprise_vitesse", &fichier_reprise_vitesse_);
53 param.ajouter("timestep_reprise_vitesse", &timestep_reprise_vitesse_);
54 param.ajouter("fichier_sortie_vitesse", &fichier_sortie_vitesse_);
55 param.lire_avec_accolades(is);
56
57 Domaine_IJK splitting_;
58 Domaine_IJK splitting_dest_;
59 IJK_Field_vector3_double velocity_;
60 IJK_Field_vector3_double velocity_dest_;
61 IJK_Field_double rho, dest_rho;
62 // Retrieve mesh data
63 splitting_ = ref_cast(Domaine_IJK, Interprete_bloc::objet_global(ijk_splitting_name));
64
65 allocate_velocity(velocity_, splitting_, 1);
66 Cerr << "reading velocity" << finl;
67 lire_dans_lata(fichier_reprise_vitesse_, timestep_reprise_vitesse_, "DOM", "VELOCITY",
68 velocity_[0], velocity_[1], velocity_[2]); // function that reads a field from a lata file
69 Cerr << "swap jk" << finl;
70
71 splitting_dest_ = ref_cast(Domaine_IJK, Interprete_bloc::objet_global(ijk_splitting_name_dest));
72 allocate_velocity(velocity_dest_, splitting_dest_, 1);
73
74 for (int direction = 0; direction < 3; direction++)
75 {
76 int direction2 = -1;
77 switch(direction)
78 {
79 case 0:
80 direction2 = 0;
81 break;
82 case 1:
83 direction2 = 2;
84 break;
85 case 2:
86 direction2 = 1;
87 break;
88 default:
90 }
91 const IJK_Field_double& src = velocity_[direction];
92 IJK_Field_double& dest = velocity_dest_[direction2];
93 const int ni = src.ni();
94 const int nj = src.nj();
95 const int nk = src.nk();
96 for (int k = 0; k < nk; k++)
97 for (int j = 0; j < nj; j++)
98 for (int i = 0; i < ni; i++)
99 dest(i,k,j) = src(i,j,k);
100 }
101 Cerr << "Write " << fichier_sortie_vitesse_ << finl;
102 Nom lata_name(fichier_sortie_vitesse_);
103 dumplata_header(lata_name, velocity_dest_[0] /* on passe un champ pour ecrire la geometrie */);
104 dumplata_newtime(lata_name,0. /* time */);
105 dumplata_vector(lata_name,"VELOCITY", velocity_dest_[0], velocity_dest_[1], velocity_dest_[2], 0);
106
107 rho.allocate(splitting_, Domaine_IJK::ELEM, 0);
108 dest_rho.allocate(splitting_dest_, Domaine_IJK::ELEM, 0);
109 Cerr << "reading rho" << finl;
110 lire_dans_lata(fichier_reprise_vitesse_, timestep_reprise_vitesse_, "DOM", "RHO",
111 rho); // function that reads a field from a lata file
112 Cerr << "swap jk" << finl;
113
114 {
115 const IJK_Field_double& src = rho;
116 IJK_Field_double& dest = dest_rho;
117 const int ni = src.ni();
118 const int nj = src.nj();
119 const int nk = src.nk();
120 for (int k = 0; k < nk; k++)
121 for (int j = 0; j < nj; j++)
122 for (int i = 0; i < ni; i++)
123 dest(i,k,j) = src(i,j,k);
124 }
125 Cerr << "Write rho " << fichier_sortie_vitesse_ << finl;
126 dumplata_scalar(lata_name,"RHO", dest_rho, 0);
127
128
129
130 return is;
131}
This class encapsulates all the information related to the eulerian mesh for TrioIJK.
Definition Domaine_IJK.h:47
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
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)
: class IJK_Lata_Swap_JK
Entree & interpreter(Entree &) override
static Objet_U & objet_global(const Nom &nom)
Searches for the requested object in the current Interprete_bloc (Interprete_bloc::interprete_courant...
Base class for "interpreter" objects.
Definition Interprete.h:38
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
friend class Entree
Definition Objet_U.h:71
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
void ajouter(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
Definition Param.cpp:364
@ REQUIRED
Definition Param.h:115
int lire_avec_accolades(Entree &is)
Alias of lire_avec_accolades_depuis.
Definition Param.h:577
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Base class for output streams.
Definition Sortie.h:52