TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_Elem_PolyMAC_CDO.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_Elem_PolyMAC_CDO.h>
17#include <TRUSTTab_parts.h>
18#include <Synonyme_info.h>
19
20Implemente_instanciable(Champ_Elem_PolyMAC_CDO, "Champ_Elem_PolyMAC_CDO|Champ_Elem_PolyMAC", Champ_Inc_P0_base);
21//Add_synonym(Champ_Elem_PolyMAC_CDO, "Champ_Elem_PolyMAC");
22
23Sortie& Champ_Elem_PolyMAC_CDO::printOn(Sortie& s) const { return s << que_suis_je() << " " << le_nom(); }
24
26{
27 lire_donnees(s);
28 return s;
29}
30
31int Champ_Elem_PolyMAC_CDO::imprime(Sortie& os, int ncomp) const
32{
33 const Domaine_dis_base& domaine_dis = domaine_dis_base();
34 const Domaine& domaine = domaine_dis.domaine();
35 const DoubleTab& coord=domaine.coord_sommets();
36 const int nb_som = domaine.nb_som();
37 const DoubleTab& val = valeurs();
38 int som;
39 os << nb_som << finl;
40 for (som=0; som<nb_som; som++)
41 {
42 if (dimension==3)
43 os << coord(som,0) << " " << coord(som,1) << " " << coord(som,2) << " " ;
44 if (dimension==2)
45 os << coord(som,0) << " " << coord(som,1) << " " ;
46 if (nb_compo_ == 1)
47 os << val(som) << finl;
48 else
49 os << val(som,ncomp) << finl;
50 }
51 os << finl;
52 Cout << "Champ_Elem_PolyMAC_CDO::imprime FIN >>>>>>>>>> " << finl;
53 return 1;
54}
55
57{
58 if (n == domaine_dis_base().domaine().nb_elem()) //field without face fluxes (e.g. needles)
59 creer_tableau_distribue(domaine_dis_base().domaine().md_vector_elements());
60 else //field with face fluxes
62 return n;
63}
64
66{
67 const Domaine_PolyMAC_CDO& domaine = ref_cast(Domaine_PolyMAC_CDO,le_dom_VF.valeur());
68 DoubleTab_parts part(valeurs());
69 for (int i = 0; i < part.size(); i++) ch.valeur_aux(i ? domaine.xv() : domaine.xp(), part[i]);
71 return *this;
72}
73
74DoubleTab& Champ_Elem_PolyMAC_CDO::valeur_aux_faces(DoubleTab& dst) const
75{
76 const Domaine_VF& domaine = ref_cast(Domaine_VF, le_dom_VF.valeur());
77 const IntTab& f_e = domaine.face_voisins();
78 const DoubleTab& src = valeurs();
79
80 /* vals must be pre-dimensioned */
81 int i, e, f, n, N = (src.nb_dim() == 1 ? 1 : src.dimension(1));
82 assert(dst.dimension(0) == domaine.xv().dimension(0) && N == (dst.nb_dim() == 1 ? 1 : dst.dimension(1)));
83
84 if (src.dimension_tot(0) > domaine.nb_elem_tot()) //face values are available
85 for (f = 0; f < dst.dimension(0); f++)
86 for (n = 0; n < N; n++) dst(f, n) = src(domaine.nb_elem_tot() + f, n);
87 else for (f = 0; f < dst.dimension(0); f++) //take (upstream + downstream) / 2
88 for (i = 0; i < 2 && (e = f_e(f, i)) >= 0; i++)
89 for (n = 0; n < N; n++)
90 dst(f, n) += src(e, n) * (f < domaine.premiere_face_int() ? 1 : 0.5);
91
92 return dst;
93}
Champ_base & affecter_(const Champ_base &ch) override
int imprime(Sortie &, int) const override
int fixer_nb_valeurs_nodales(int n) override
DoubleTab & valeur_aux_faces(DoubleTab &vals) const override
Returns the field value at the faces.
: class Champ_Inc_P0_base
const Domaine & domaine() const
virtual void creer_tableau_distribue(const MD_Vector &, RESIZE_OPTIONS=RESIZE_OPTIONS::COPY_INIT)
int lire_donnees(Entree &)
Reads the field values from an input stream.
const Domaine_dis_base & domaine_dis_base() const override
DoubleTab & valeurs() override
Returns the array of field values at the current time.
Champ_base()
Default constructor of a Champ_base.
virtual DoubleTab & valeur_aux(const DoubleTab &positions, DoubleTab &valeurs) const
Causes an error! Must be overridden by derived classes.
class Domaine_VF
Definition Domaine_VF.h:44
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
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 field.
int nb_compo_
Definition Field_base.h:95
static int dimension
Definition Objet_U.h:94
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
Base class for output streams.
Definition Sortie.h:52
int size() const
int nb_dim() const
Definition TRUSTTab.h:199
_SIZE_ dimension_tot(int) const override
Definition TRUSTTab.tpp:160
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")