TRUST 1.9.8
HPC thermohydraulic platform
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 Verifie que les champs caracterisant le milieu solide qui on ete lu par readOn(Entree&) sont coherents.
51 *
52 * @throws la conductivite (lambda) n'est pas strictement positive
53 * @throws l'une des proprietes physique du solide: masse volumique (rho),
54 * capacite calorifique (Cp) ou conductivite (lambda) n'a pas
55 * ete definie.
56 */
58{
59 msg="";
60 if (sub_type(Champ_Uniforme,ch_lambda_.valeur()))
61 {
62 if (ch_lambda_->valeurs()(0,0) <= 0)
63 {
64 msg += "The conductivity lambda is not striclty positive. \n";
65 err = 1;
66 }
67 }
68
70}
71
73{
74 if (mot == "user_field")
75 {
76 is >> nom_champ_;
77 is >> mon_champ_;
78 return 1;
79 }
80 else return Milieu_base::lire_motcle_non_standard(mot,is);
81}
82
84{
85 if (has_hydr_diam())
86 {
87 Cerr << "WHAT ?? It makes no sense to define diametre_hyd_champ in a Solid medium !!!" << finl;
89 }
90
92 if (mon_champ_)
93 {
94 is_user_defined_ = true;
95 const Domaine_dis_base& domaine_dis=pb.equation(0).domaine_dis();
96 const double temps = pb.schema_temps().temps_courant();
97 if (sub_type(Champ_Fonc_MED,mon_champ_.valeur()))
98 {
99 Cerr<<"Convert Champ_fonc_MED " << nom_champ_ << " to a OWN_PTR(Champ_Don_base) ..."<<finl;
100 OWN_PTR(Champ_Don_base) tmp_fld;
101 dis.discretiser_champ("champ_elem",domaine_dis,"neant","neant",1,temps,tmp_fld);
102 tmp_fld->affecter(mon_champ_.valeur()); // interpolate ...
103 mon_champ_.detach();
104 dis.discretiser_champ("champ_elem",domaine_dis,nom_champ_,"neant",1,temps,mon_champ_);
105 mon_champ_->valeurs() = tmp_fld->valeurs();
106 }
107 else if (sub_type(Champ_Uniforme,mon_champ_.valeur())) // blabla ...
108 {
109 const double val = mon_champ_->valeurs()(0,0);
110 mon_champ_.detach();
111 dis.discretiser_champ("champ_elem",domaine_dis,nom_champ_,"neant",1,temps,mon_champ_);
112 mon_champ_->valeurs() = val;
113 }
114 else
115 dis.nommer_completer_champ_physique(domaine_dis, nom_champ_, "neant", mon_champ_.valeur(), pb);
116
117 champs_compris_.ajoute_champ(mon_champ_.valeur());
118 }
119}
classe Champ_Don_base classe de base des Champs donnes (non calcules)
classe Champ_Fonc_MED Load a field from a MED file for a given time.
classe Champ_Uniforme Represente un champ constant dans l'espace et dans le temps.
classe Discretisation_base Cette classe represente un schema de discretisation en espace,...
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
classe Domaine_dis_base Cette classe est la base de la hierarchie des domaines discretisees.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Domaine_dis_base & domaine_dis()
Renvoie le domaine discretise associe a l'equation.
classe Milieu_base Cette classe est la base de la hierarchie des milieux (physiques)
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
Lecture des parametres de type non simple d'un objet_U a partir d'un flot d'entree.
Champs_compris champs_compris_
virtual void set_param(Param &param) const override
const bool & has_hydr_diam()
Une chaine de caractere (Nom) en majuscules.
Definition Motcle.h:26
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
friend class Entree
Definition Objet_U.h:76
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
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
classe Probleme_base C'est un Probleme_U qui n'est pas un couplage.
const Schema_Temps_base & schema_temps() const
Renvoie le schema en temps associe au probleme.
virtual const Equation_base & equation(int) const =0
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
double temps_courant() const
Renvoie le temps courant.
Classe Solide Cette classe represente un milieu solide et ses proprietes.
Definition Solide.h:26
void verifier_coherence_champs(int &err, Nom &message) override
Verifie que les champs caracterisant le milieu solide qui on ete lu par readOn(Entree&) sont coherent...
Definition Solide.cpp:57
int lire_motcle_non_standard(const Motcle &, Entree &) override
Lecture des parametres de type non simple d'un objet_U a partir d'un flot d'entree.
Definition Solide.cpp:72
void discretiser(const Probleme_base &pb, const Discretisation_base &dis) override
Definition Solide.cpp:83
void set_param(Param &param) const override
Definition Solide.cpp:41
Classe de base des flux de sortie.
Definition Sortie.h:52