TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Discr_inst.cpp
1/****************************************************************************
2* Copyright (c) 2024, 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 <Discr_inst.h>
17
18
19#include <Motcle.h>
20#include <Domaine_dis_base.h>
21#include <Domaine.h>
22
23Implemente_instanciable(Discr_inst, "VF_inst", Discretisation_base);
24
26{
27 return s;
28}
29
31{
32 return s;
33}
34
35void Discr_inst::discretiser_champ(const Motcle& directive, const Domaine_dis_base& z, Nature_du_champ nature, const Noms& nom, const Noms& unite, int nb_comp, int nb_pas_dt, double temps,
36 OWN_PTR(Champ_Inc_base) &champ,
37 const Nom& sous_type) const
38{
39 assert(0);
40 throw;
41}
42/*! @brief Idem que Discr_inst::discretiser_champ(.
43 *
44 * .. , Champ_Inc) pour un Champ_Fonc.
45 *
46 */
47void Discr_inst::discretiser_champ(const Motcle& directive, const Domaine_dis_base& z, Nature_du_champ nature, const Noms& noms, const Noms& unites, int nb_comp, double temps,
48 OWN_PTR(Champ_Fonc_base)& champ) const
49{
50 discretiser_champ_fonc_don(directive, z, nature, noms, unites, nb_comp, temps, champ);
51}
52
53/*! @brief Idem que Discr_inst::discretiser_champ(.
54 *
55 * .. , Champ_Inc) pour un Champ_Don.
56 *
57 */
58void Discr_inst::discretiser_champ(const Motcle& directive, const Domaine_dis_base& z, Nature_du_champ nature, const Noms& noms, const Noms& unites, int nb_comp, double temps, OWN_PTR(Champ_Don_base)& champ) const
59{
60 discretiser_champ_fonc_don(directive, z, nature, noms, unites, nb_comp, temps, champ);
61}
62
63/*! @brief Idem que VEF_discretisation::discretiser_champ(.
64 *
65 * .. , Champ_Inc) Traitement commun aux champ_fonc et champ_don.
66 * Cette methode est privee (passage d'un Objet_U pas propre vu
67 * de l'exterieur ...)
68 *
69 */
70void Discr_inst::discretiser_champ_fonc_don(const Motcle& directive, const Domaine_dis_base& z, Nature_du_champ nature, const Noms& noms, const Noms& unites, int nb_comp, double temps,
71 Objet_U& champ) const
72{
73 // Deux pointeurs pour acceder facilement au champ_don ou au champ_fonc, suivant le type de l'objet champ.
74 OWN_PTR(Champ_Fonc_base) *champ_fonc = dynamic_cast<OWN_PTR(Champ_Fonc_base)*>(&champ);
75 OWN_PTR(Champ_Don_base) *champ_don = dynamic_cast<OWN_PTR(Champ_Don_base)*>(&champ);
76
77 Motcles motcles(2);
78 motcles[0] = "champ_elem"; // Creer un champ aux elements (de type P0)
79 motcles[1] = "champ_sommets"; // Creer un champ aux sommets
80
81 Nom type;
82 int rang = motcles.search(directive);
83 //int default_nb_comp = 1;
84 const Domaine& domaine = z.domaine();
85 int nb_som_elem = domaine.nb_som_elem();
86 int nb_ddl = -1;
87 switch(rang)
88 {
89 case 0:
90 type = "Champ_Fonc_P0_MED";
91 nb_ddl = domaine.nb_elem();
92 break;
93 case 1:
94 type = "Champ_Fonc_P1_MED";
95 nb_ddl = domaine.nb_som();
96 if (((dimension == 2) && (nb_som_elem == 4)) || ((dimension == 3) && (nb_som_elem == 8)))
97 {
98 type = "Champ_Fonc_Q1_MED";
99 }
100 break;
101
102 default:
103 assert(rang < 0);
104
105 break;
106 }
107
108 if (directive == DEMANDE_DESCRIPTION)
109 Cerr << "Discr_inst : " << motcles;
110
111 // Si on n'a pas compris la directive (ou si c'est une demande_description)
112 // alors on appelle l'ancetre :
113 if (rang < 0)
114 {
115 if (champ_fonc)
116 Discretisation_base::discretiser_champ(directive, z, nature, noms, unites, nb_comp, temps, *champ_fonc);
117 else
118 Discretisation_base::discretiser_champ(directive, z, nature, noms, unites, nb_comp, temps, *champ_don);
119
120 return;
121 }
122
123 if (champ_fonc)
124 {
125 OWN_PTR(Champ_Fonc_base) &ch = *champ_fonc;
126 ch.typer(type);
127 ch->associer_domaine_dis_base(z);
128 ch->fixer_nb_comp(nb_comp);
129 ch->fixer_nature_du_champ(nature);
130 ch->fixer_nb_valeurs_nodales(nb_ddl);
131 }
132 else
133 {
134 assert(0);
135 throw;
136 }
137
138}
classe Champ_Don_base classe de base des Champs donnes (non calcules)
classe Champ_Fonc_base Classe de base des champs qui sont fonction d'une grandeur calculee
Classe Champ_Inc_base.
class Discr_inst Cette classe ne sait rien faire, on en a besoin pour le Pb_MED
Definition Discr_inst.h:30
void discretiser_champ(const Motcle &directive, const Domaine_dis_base &z, Nature_du_champ nature, const Noms &nom, const Noms &unite, int nb_comp, int nb_pas_dt, double temps, OWN_PTR(Champ_Inc_base) &champ, const Nom &sous_type=NOM_VIDE) const override
classe Discretisation_base Cette classe represente un schema de discretisation en espace,...
static const Motcle DEMANDE_DESCRIPTION
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
int nb_som_elem() const
Renvoie le nombre de sommets des elements geometriques constituants le domaine.
Definition Domaine.h:474
classe Domaine_dis_base Cette classe est la base de la hierarchie des domaines discretisees.
const Domaine & domaine() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Une chaine de caractere (Nom) en majuscules.
Definition Motcle.h:26
Un tableau d'objets de la classe Motcle.
Definition Motcle.h:63
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
Un tableau de chaine de caracteres (VECT(Nom)).
Definition Noms.h:26
classe Objet_U Cette classe est la classe de base des Objets de TRUST
Definition Objet_U.h:73
static int dimension
Definition Objet_U.h:99
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
Classe de base des flux de sortie.
Definition Sortie.h:52