TrioCFD 1.9.9_beta
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 Same as Discr_inst::discretiser_champ(.
43 *
44 * .. , Champ_Inc) but for a 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 Same as Discr_inst::discretiser_champ(.
54 *
55 * .. , Champ_Inc) but for a 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 Same as VEF_discretisation::discretiser_champ(.
64 *
65 * .. , Champ_Inc). Common processing for champ_fonc and champ_don.
66 * This method is private (passing an Objet_U is not clean
67 * from the outside).
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 // Two pointers to easily access the champ_don or the champ_fonc depending on the type of the champ object.
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"; // Create a field at elements (P0 type)
79 motcles[1] = "champ_sommets"; // Create a field at vertices
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 // If the directive was not understood (or if it is a demande_description),
112 // call the ancestor:
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}
class Champ_Don_base base class of Given Fields (not calculated)
class Champ_Fonc_base Base class of fields that are functions of a calculated quantity
Class Champ_Inc_base.
class Discr_inst This class does nothing; it is needed for 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
class Discretisation_base This class represents a spatial discretization scheme, which
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
Returns the number of vertices of the geometric elements that make up the domain.
Definition Domaine.h:474
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
A character string (Nom) in uppercase.
Definition Motcle.h:26
An array of Motcle objects.
Definition Motcle.h:63
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
An array of character strings (VECT(Nom)).
Definition Noms.h:26
Base class for TRUST objects (Objet_U).
Definition Objet_U.h:68
static int dimension
Definition Objet_U.h:94
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