TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_Front_Composite.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 <Champ_Front_Composite.h>
17#include <Motcle.h>
18
19Implemente_instanciable(Champ_Front_Composite,"Champ_Front_Composite",Champ_front_base);
20// XD champ_front_composite front_field_base champ_front_composite NO_BRACE Composite front field. Used in multiphase
21// XD_CONT problems to associate data to each phase.
22// XD attr dim entier dim REQ Number of field components.
23// XD attr bloc bloc_lecture bloc REQ Values Various pieces of the field, defined per phase. Part 1 goes to phase 1,
24// XD_CONT etc...
25
27
29{
30 nommer(que_suis_je()); // for printOn
31
32 Motcle motlu, acc_ouv("{"), acc_fer("}");
33 is >> dim_;
34 assert (dim_ > 0);
35 z_fld_.resize(dim_);
36
37 is >> motlu;
38 if (motlu != acc_ouv)
39 {
40 Cerr << "Error in the readOn of Champ_Composite ! We expected a { and not " << motlu << " ! Call the 911 !" << finl;
42 }
43
44 for (int i = 0; i < dim_; i++) is >> z_fld_[i];
45
46 is >> motlu;
47 if (motlu != acc_fer)
48 {
49 Cerr << "Error in the readOn of Champ_Composite ! We expected a } and not " << motlu << " ! Call the 911 !" << finl;
51 }
52
53 // XXX : We verify that we have read the same field types ...
54 for (int i = 1; i < dim_ ; i++)
55 if (z_fld_[i]->que_suis_je() != z_fld_[0]->que_suis_je())
56 {
57 Cerr << "Champ_Front_Composite should define the same field types !" << finl;
59 }
60
61 // for the valeurs() method
62 const int ncompo = z_fld_[0]->nb_comp() * dim_, nnodes = z_fld_[0]->valeurs().dimension_tot(0);
63 fixer_nb_comp(ncompo);
64 les_valeurs->valeurs().resize(nnodes, nb_compo_);
66// set_temps_defaut(z_fld_[0]->get_temps_defaut());
67
68 return is;
69}
70/*
71 * Stored as: X X X ... Y Y Y ... Z Z Z ...
72 */
74{
75 for (int nbp = 0; nbp < dim_; nbp++)
76 for (int i = 0; i < z_fld_[0]->valeurs().dimension_tot(0); i++)
77 for (int j = 0; j < z_fld_[0]->nb_comp(); j++)
78 les_valeurs->valeurs()(i, nbp + j * dim_) = z_fld_[nbp]->valeurs()(i, j);
79}
80
82{
83 for (auto &fld : z_fld_) fld->mettre_a_jour(temps);
84}
85
87{
88 for (auto &fld : z_fld_) fld->initialiser(temps,inco);
89 return 1;
90}
91
92void Champ_Front_Composite::valeurs_face(int face, DoubleVect& var) const
93{
94 // Workaround ....
95 assert (nb_compo_ == z_fld_[0]->nb_comp() * dim_); // sanity check
96 var.resize(nb_compo_);
97 for (int nbp = 0; nbp < dim_; nbp++)
98 {
99 DoubleVect tmp;
100 z_fld_[nbp]->valeurs_face(face,tmp);
101 assert (var.size() == dim_ * tmp.size()); // sanity check
102 for (int j = 0; j < tmp.size(); j++)
103 var(nbp + j * dim_) = tmp(j);
104 }
105}
std::vector< OWN_PTR(Champ_front_base)> z_fld_
void valeurs_face(int, DoubleVect &) const override
Returns the vector of field values for the given face.
void mettre_a_jour(double temps) override
DOES NOTHING, to override.
int initialiser(double temps, const Champ_Inc_base &inco) override
Initialization at the beginning of calculation.
Class Champ_Inc_base.
class Champ_front_base Base class for the hierarchy of boundary fields.
virtual DoubleTab & valeurs() override
Returns the array of field values.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual void fixer_nb_comp(int i)
Sets the number of components of the field.
void nommer(const Nom &) override
Gives a name to the field.
virtual int nb_comp() const
Definition Field_base.h:56
int nb_compo_
Definition Field_base.h:95
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
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() const
Definition TRUSTVect.tpp:45
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTVect.tpp:91