TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Solide.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 <Discretisation_base.h>
17#include <Schema_Temps_base.h>
18#include <Champ_Uniforme.h>
19#include <Champ_Fonc_MED.h>
20#include <Probleme_base.h>
21#include <Equation_base.h>
22#include <Solide.h>
23#include <Param.h>
24
25Implemente_instanciable(Solide,"Solide",Milieu_base);
26// XD solide milieu_base solide INHERITS_BRACE Solid with cp and/or rho non-uniform.
27// XD attr rho field_base rho OPT Density (kg.m-3).
28// XD attr cp field_base cp OPT Specific heat (J.kg-1.K-1).
29// XD attr lambda field_base lambda_u OPT Conductivity (W.m-1.K-1).
30// XD attr user_field field_base user_field OPT user defined field.
31
32Sortie& Solide::printOn(Sortie& os) const { return Milieu_base::printOn(os); }
33
35{
37 if (mon_champ_) champs_don_.add(mon_champ_.valeur());
38 return is;
39}
40
41void Solide::set_param(Param& param) const
42{
44 param.ajouter_condition("is_read_rho","Density (rho) has not been read for a Solide type medium.");
45 param.ajouter_condition("is_read_Cp","Heat capacity (Cp) has not been read for a Solide type medium.");
46 param.ajouter_condition("is_read_lambda","Conductivity (lambda) has not been read for a Solide type medium.");
47 param.ajouter_non_std("user_field",(this));
48}
49
50/*! @brief Verifies that the fields characterising the solid medium read by readOn(Entree&) are consistent.
51 *
52 * @throws Conductivity (lambda) is not strictly positive.
53 * @throws One of the physical properties of the solid (density rho, specific heat Cp, or conductivity lambda) has not been defined.
54 */
56{
57 msg="";
58 if (sub_type(Champ_Uniforme,ch_lambda_.valeur()))
59 {
60 if (ch_lambda_->valeurs()(0,0) <= 0)
61 {
62 msg += "The conductivity lambda is not striclty positive. \n";
63 err = 1;
64 }
65 }
66
68}
69
71{
72 if (mot == "user_field")
73 {
74 is >> nom_champ_;
75 is >> mon_champ_;
76 return 1;
77 }
78 else return Milieu_base::lire_motcle_non_standard(mot,is);
79}
80
82{
83 if (has_hydr_diam())
84 {
85 Cerr << "WHAT ?? It makes no sense to define diametre_hyd_champ in a Solid medium !!!" << finl;
87 }
88
90 if (mon_champ_)
91 {
92 is_user_defined_ = true;
93 const Domaine_dis_base& domaine_dis=pb.equation(0).domaine_dis();
94 const double temps = pb.schema_temps().temps_courant();
95 if (sub_type(Champ_Fonc_MED,mon_champ_.valeur()))
96 {
97 Cerr<<"Convert Champ_fonc_MED " << nom_champ_ << " to a OWN_PTR(Champ_Don_base) ..."<<finl;
98 OWN_PTR(Champ_Don_base) tmp_fld;
99 dis.discretiser_champ("champ_elem",domaine_dis,"neant","neant",1,temps,tmp_fld);
100 tmp_fld->affecter(mon_champ_.valeur()); // interpolate ...
101 mon_champ_.detach();
102 dis.discretiser_champ("champ_elem",domaine_dis,nom_champ_,"neant",1,temps,mon_champ_);
103 mon_champ_->valeurs() = tmp_fld->valeurs();
104 }
105 else if (sub_type(Champ_Uniforme,mon_champ_.valeur())) // blabla ...
106 {
107 const double val = mon_champ_->valeurs()(0,0);
108 mon_champ_.detach();
109 dis.discretiser_champ("champ_elem",domaine_dis,nom_champ_,"neant",1,temps,mon_champ_);
110 mon_champ_->valeurs() = val;
111 }
112 else
113 dis.nommer_completer_champ_physique(domaine_dis, nom_champ_, "neant", mon_champ_.valeur(), pb);
114
115 champs_compris_.ajoute_champ(mon_champ_.valeur());
116 }
117}
class Champ_Don_base base class of Given Fields (not calculated)
class Champ_Fonc_MED Load a field from a MED file for a given time.
Champ_Uniforme Represents a field that is constant in space and time.
class Discretisation_base This class represents a spatial discretization scheme, which
void nommer_completer_champ_physique(const Domaine_dis_base &domaine_vdf, const Nom &nom_champ, const Nom &unite, Champ_base &champ, const Probleme_base &pbi) const
void discretiser_champ(const Motcle &directive, const Domaine_dis_base &z, const Nom &nom, const Nom &unite, int nb_comp, int nb_pas_dt, double temps, OWN_PTR(Champ_Inc_base)&champ, const Nom &sous_type=NOM_VIDE) const
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Domaine_dis_base & domaine_dis()
Returns the discretized domain associated with the equation.
Milieu_base This class is the base of the (physical) medium hierarchy.
Definition Milieu_base.h:50
virtual void discretiser(const Probleme_base &pb, const Discretisation_base &dis)
virtual void verifier_coherence_champs(int &err, Nom &message)
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
Champs_compris champs_compris_
virtual void set_param(Param &param) const override
const bool & has_hydr_diam()
A character string (Nom) in uppercase.
Definition Motcle.h:26
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
friend class Entree
Definition Objet_U.h:71
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_condition(const char *condition, const char *message, const char *name=0)
Declare a post-read logical condition that must hold on the parameter values.
Definition Param.cpp:496
void ajouter_non_std(const char *keyword, const Objet_U *value, Param::Nature nat=Param::OPTIONAL)
Register a keyword handled by Objet_U::lire_motcle_non_standard.
Definition Param.cpp:489
class Probleme_base It is a Probleme_U that is not a coupling.
const Schema_Temps_base & schema_temps() const
Returns the time scheme associated with the problem.
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
double temps_courant() const
Returns the current time.
Class Solide: represents a solid medium and its physical properties.
Definition Solide.h:26
void verifier_coherence_champs(int &err, Nom &message) override
Verifies that the fields characterising the solid medium read by readOn(Entree&) are consistent.
Definition Solide.cpp:55
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
Definition Solide.cpp:70
void discretiser(const Probleme_base &pb, const Discretisation_base &dis) override
Definition Solide.cpp:81
void set_param(Param &param) const override
Definition Solide.cpp:41
Base class for output streams.
Definition Sortie.h:52