TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_Generique_Divergence.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_Generique_Divergence.h>
17#include <Champ_Generique_refChamp.h>
18#include <Discretisation_base.h>
19#include <Synonyme_info.h>
20
21Implemente_instanciable(Champ_Generique_Divergence,"Divergence",Champ_Generique_Operateur_base);
22// XD divergence champ_post_operateur_base divergence INHERITS_BRACE To calculate divergency of a given field.
23
24Add_synonym(Champ_Generique_Divergence,"Champ_Post_Operateur_Divergence");
25
27{
28 return s << que_suis_je() << " " << le_nom();
29}
30
32{
34
35 return s ;
36}
37
39{
41 const Probleme_base& Pb = get_ref_pb_base();
42 //We only complete the operator if it concerns the velocity field
43
44 if (sub_type(Champ_Generique_refChamp,get_source(0)))
45 {
46 OWN_PTR(Champ_base) espace_stockage;
47 if (get_source(0).get_champ(espace_stockage).le_nom()=="vitesse")
48 {
49 const Equation_base& eqn = Pb.equation(0);
50 Op_Div_.associer_eqn(eqn);
51 Op_Div_.typer();
52 Op_Div_.l_op_base().associer_eqn(eqn);
53
54 //The completer() method triggers the association of the discretized domain
55 //which is retrieved by the equation associated with the operator
56 Op_Div_->completer();
57 }
58 }
59}
60
62{
63
64
65 if (Op_Div_)
66 {
68 espace_stockage = creer_espace_stockage(scalaire,1,es_tmp);
69 }
70 else
71 {
72 //const Noms nom = get_source(0).get_property("nom");
73 Cerr<<"We can apply a Champ_Generique_Divergence only to the velocity field"<<finl;
74 exit();
75 }
76 return espace_stockage;
77}
79{
80
81 OWN_PTR(Champ_base) source_espace_stockage;
82 const Champ_base& source = get_source(0).get_champ(source_espace_stockage);
83
84 if (Op_Div_)
85 {
87 espace_stockage = creer_espace_stockage(scalaire,1,es_tmp);
88 Op_Div_.calculer(source.valeurs(),espace_stockage->valeurs());
89 }
90 else
91 {
92 const Noms nom = get_source(0).get_property("nom");
93 Cerr<<"We can apply a Champ_Generique_Divergence only to the velocity field"<<finl;
94 Cerr<<"The field treated here "<<nom[0]<<" concerns "<<source.le_nom()<<finl;
95 exit();
96 }
97
98 DoubleTab& espace_valeurs = espace_stockage->valeurs();
99 espace_valeurs.echange_espace_virtuel();
100 return espace_stockage;
101}
102
103
105{
106 Entity loc;
107 Nom type_op = Op_Div_->que_suis_je();
108 if (((type_op=="Op_Div_VEF_P1NC") || (type_op=="Op_Div_VDF_Face")) && (index <= 0))
109 loc = Entity::ELEMENT;
110 else
111 {
112 Cerr << "Error of type : Divergence operator " << type_op << " is not possible for the defined field " << nom_post_ << finl;
113 throw Champ_Generique_erreur("INVALID");
114 }
115 return loc;
116}
118{
119
120 Motcles motcles(2);
121 motcles[0] = "composantes";
122 motcles[1] = "unites";
123
124 int rang = motcles.search(query);
125 switch(rang)
126 {
127 case 0:
128 {
129 Noms compo(1);
130 Nom nume((int)0);
131 compo[0] = nom_post_+nume;
132
133 return compo;
134 }
135
136 case 1:
137 {
138
139 Noms unites(1);
140 Noms source_unites = get_source(0).get_property("unites");
141 unites[0] = source_unites[0]+"/m";
142
143 return unites;
144 }
145 }
147}
148
149//Name the field as a source by default
150//"Divergence_" + nom_champ_source
152{
153 if (nom_post_=="??")
154 {
155 Nom nom_post_source, nom_champ_source;
156 const Noms nom = get_source(0).get_property("nom");
157 nom_champ_source = nom[0];
158 nom_post_source = "Divergence_";
159 nom_post_source += nom_champ_source;
160 nommer(nom_post_source);
161 }
162}
163
165{
166 Motcle directive;
167 directive = "divergence_vitesse";
168 return directive;
169}
class Champ_Fonc_base Base class of fields that are functions of a calculated quantity
const Noms get_property(const Motcle &query) const override
Returns the requested property.
virtual OWN_PTR(Champ_Fonc_base) &creer_espace_stockage(const Nature_du_champ &nature
void completer(const Postraitement_base &post) override
const Probleme_base & get_ref_pb_base() const override
Returns the problem that carries the target field.
virtual const Champ_Generique_base & get_source(int i) const
class Champ_Generique_Divergence
const Champ_base & get_champ_without_evaluation(OWN_PTR(Champ_base)&espace_stockage) const override
Entity get_localisation(const int index=-1) const override
Returns the type of geometric entities on which the discrete values are attached (NODE for a P1 field...
void completer(const Postraitement_base &post) override
const Noms get_property(const Motcle &query) const override
Returns the requested property.
const Champ_base & get_champ(OWN_PTR(Champ_base)&espace_stockage) const override
const Motcle get_directive_pour_discr() const override
Returns the directive (champ_elem, champ_sommets, champ_face or pression) to launch the discretizatio...
Classe Champ_Generique_Operateur_base Base class for generic field classes dedicated to applying an o...
virtual const Noms get_property(const Motcle &query) const
Returns the requested property.
virtual const Champ_base & get_champ(OWN_PTR(Champ_base) &espace_stockage) const =0
void nommer(const Nom &nom) override
Assigns a name to the Objet_U. Virtual method to override.
Special field class that encapsulates a reference to a volume field of TRUST of type Champ_base.
virtual DoubleTab & valeurs()=0
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
class Equation_base The role of an equation is the calculation of one or more fields....
const Nom & le_nom() const override
Returns the name of the field.
A character string (Nom) in uppercase.
Definition Motcle.h:26
An array of Motcle objects.
Definition Motcle.h:63
int search(const Motcle &t) const
Definition Motcle.cpp:319
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
An array of character strings (VECT(Nom)).
Definition Noms.h:26
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 const Nom & le_nom() const
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Objet_U.cpp:317
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
Base class for all post-processing objects.
class Probleme_base It is a Probleme_U that is not a coupling.
virtual const Equation_base & equation(int) const =0
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
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")