TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
IJK_VDF_converter.cpp
1/****************************************************************************
2* Copyright (c) 2025, 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_VDF_converter.h>
17#include <Param.h>
18#include <Domaine_VF.h>
19#include <Probleme_base.h>
20#include <Interprete_bloc.h>
21
22Implemente_instanciable(IJK_VDF_converter, "IJK_VDF_converter", Objet_U);
23
25{
26 return s;
27}
28
29// The object must be named like this in the interpretor. Operators will implicitely search for this name:
31{
32 return "vdf_to_ijk";
33}
34
36{
38 {
39 Cerr << "error in IJK_VDF_converter: the object MUST be named " << get_conventional_name()
40 << " (sorry, this is a hack)" << finl;
41 exit();
42 }
43 Param param(que_suis_je());
44 Nom vdf_problem;
45 ArrOfInt splitting;
46 ArrOfInt direction_mapping(3);
47 bool perio_flag_x = false;
48 bool perio_flag_y = false;
49 bool perio_flag_z = false;
50 direction_mapping[0] = 0;
51 direction_mapping[1] = 1;
52 direction_mapping[2] = 2;
53 param.ajouter("vdf_problem", &vdf_problem, Param::REQUIRED);
54 param.ajouter("splitting", &splitting);
55 param.ajouter("x_maps_to", &direction_mapping[0]);
56 param.dictionnaire("i",0);
57 param.dictionnaire("j",1);
58 param.dictionnaire("k",2);
59 param.ajouter("y_maps_to", &direction_mapping[1]);
60 param.dictionnaire("i",0);
61 param.dictionnaire("j",1);
62 param.dictionnaire("k",2);
63 param.ajouter("z_maps_to", &direction_mapping[2]);
64 param.dictionnaire("i",0);
65 param.dictionnaire("j",1);
66 param.dictionnaire("k",2);
67
68 param.ajouter_flag("perio_i", &perio_flag_x);
69 param.ajouter_flag("perio_j", &perio_flag_y);
70 param.ajouter_flag("perio_k", &perio_flag_z);
71
72 param.lire_avec_accolades(is);
73
74 // Check parameters
75 if (splitting.size_array() != 3)
76 {
77 Cerr << "Error in IJK_VDF_converter::readOn: splitting must be an array of 3 (ex splitting 3 8 8 8)" << finl;
78 exit();
79 }
80
81 const Probleme_base& pb = ref_cast(Probleme_base, Interprete_bloc::objet_global(vdf_problem));
82 const Domaine_VF& domaine_vdf = ref_cast(Domaine_VF, pb.domaine_dis());
83
84 Domaine_IJK grid_geom;
85 grid_geom.initialize_from_unstructured(domaine_vdf.domaine(),
86 direction_mapping[0], direction_mapping[1], direction_mapping[2],
87 perio_flag_x, perio_flag_y, perio_flag_z);
88
89 domaine_ijk_.initialize_splitting(grid_geom, splitting[0], splitting[1], splitting[2]);
90
91 vdf_to_ijk_i_.initialize(domaine_vdf, domaine_ijk_, Domaine_IJK::FACES_I, direction_mapping[0], direction_mapping[1], direction_mapping[2]);
92 vdf_to_ijk_j_.initialize(domaine_vdf, domaine_ijk_, Domaine_IJK::FACES_J, direction_mapping[0], direction_mapping[1], direction_mapping[2]);
93 vdf_to_ijk_k_.initialize(domaine_vdf, domaine_ijk_, Domaine_IJK::FACES_K, direction_mapping[0], direction_mapping[1], direction_mapping[2]);
94 vdf_to_ijk_elem_.initialize(domaine_vdf, domaine_ijk_, Domaine_IJK::ELEM, direction_mapping[0], direction_mapping[1], direction_mapping[2]);
95 vdf_to_ijk_nodes_.initialize(domaine_vdf, domaine_ijk_, Domaine_IJK::NODES, direction_mapping[0], direction_mapping[1], direction_mapping[2]);
96
97 return is;
98}
99
100
102{
103 switch(loc)
104 {
106 return vdf_to_ijk_i_;
108 return vdf_to_ijk_j_;
110 return vdf_to_ijk_k_;
112 return vdf_to_ijk_elem_;
114 return vdf_to_ijk_nodes_;
115 default:
116 Cerr << "Error in IJK_VDF_converter::get_vdf_to_ijk: unknown loc" << finl;
117 exit();
118 }
119 return vdf_to_ijk_i_;
120}
void initialize_from_unstructured(const Domaine &, int direction_for_x, int direction_for_y, int direction_for_z, bool perio_x, bool perio_y, bool perio_z)
Localisation
Localisation sub class.
Definition Domaine_IJK.h:53
const Domaine & domaine() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
VDF_to_IJK vdf_to_ijk_elem_
static const char * get_conventional_name()
VDF_to_IJK vdf_to_ijk_nodes_
const VDF_to_IJK & get_vdf_to_ijk(Domaine_IJK::Localisation) const
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 TRUST objects (Objet_U).
Definition Objet_U.h:68
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
@ REQUIRED
Definition Param.h:115
const Domaine_dis_base & domaine_dis() const
Returns the discretized domain associated with the problem (const version).
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
_SIZE_ size_array() const