TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_front_softanalytique.cpp
1/****************************************************************************
2* Copyright (c) 2022, 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_front_softanalytique.h>
17#include <Domaine.h>
18#include <Domaine_VF.h>
19
20Implemente_instanciable(Champ_front_softanalytique,"Champ_front_fonc_xyz",Ch_front_var_stationnaire);
21// XD champ_front_fonc_xyz front_field_base champ_front_fonc_xyz NO_BRACE Boundary field which is not constant in space.
22// XD attr val listchaine val REQ Values of field components (mathematical expressions).
23
24/*! @brief Prints the field to the output stream.
25 *
26 * Prints the size of the field and the (constant) value on
27 * the boundary.
28 *
29 * @param (Sortie& os) an output stream
30 * @return (Sortie&) the modified output stream
31 */
33{
34
35 /* int dim = nb_comp();
36 for (int i = 0;i<dim;i++)
37 {
38 os << fxyz[i]->getString();
39 }
40 return os;*/
41 // Cout << " Dans printOn !!!!!!!!!!!!!!!!!!!!!!" << finl;
42 const DoubleTab& tab=valeurs();
43 os << tab.size() << " ";
44 for(int i=0; i<tab.size(); i++)
45 os << tab(0,i);
46 return os;
47}
48
49
50/*! @brief Reads the field from an input stream.
51 *
52 * Format:
53 * Champ_front_softanalytique nb_compo vrel_1 ... [vrel_i]
54 *
55 * @param (Entree& is) an input stream
56 * @return (Entree& is) the modified input stream
57 */
59{
60 //Cout << "Dans Champ_front_softanalytique.readOn !!!!!!!!!" << finl;
61 int dim;
63 fixer_nb_comp(dim);
64
65 fxyz.dimensionner(dim);
66
67
68 // Cout << "dim = " << dim << finl;
69 for (int i = 0; i<dim; i++)
70 {
71 Nom tmp;
72 //Cout << "i = " << i << finl;
73 is >> tmp;
74 //Cout << "fonc = " << tmp << finl;
75 Cerr << "Reading and interpretation of the function " << tmp << finl;
76
77 fxyz[i].setNbVar(3);
78 fxyz[i].setString(tmp);
79 fxyz[i].addVar("x");
80 fxyz[i].addVar("y");
81 fxyz[i].addVar("z");
82 fxyz[i].parseString();
83 Cerr << "Interpretation of the function " << tmp << " Ok" << finl;
84 // Cout << "end = " << tmp << finl;
85 }
86
87 return is;
88}
89
91{
92
94 return 0;
95
96 int dim=nb_comp();
97 double x,y,z;
98 // int nbsf=faces.nb_som_faces();
99 int k;
100 DoubleTab& tab=valeurs();
101
102 const Domaine_VF& domaine_vf=ref_cast(Domaine_VF,frontiere_dis().domaine_dis());
103 const DoubleTab& xv=domaine_vf.xv();
104
105 const Front_VF& le_bord = ref_cast(Front_VF,frontiere_dis());
106 int nb_faces_bord_tot=le_bord.nb_faces_tot();
107 for (int ind_face=0; ind_face<nb_faces_bord_tot; ind_face++)
108 {
109 int face = le_bord.num_face(ind_face);
110 x=y=z=0;
111 x=xv(face,0);
112 if(dimension>1)
113 y=xv(face,1);
114 if(dimension>2)
115 z=xv(face,2);
116
117 for( k=0; k<dim; k++)
118 {
119 fxyz[k].setVar("x",x);
120 fxyz[k].setVar("y",y);
121 fxyz[k].setVar("z",z);
122 tab(ind_face,k)=fxyz[k].eval();
123 //Cout << " x y z " << x << " " << y << " " << z << " " << tab(i,k) << finl;
124 }
125 }
126
128 return 1;
129}
130
131void Champ_front_softanalytique::valeur_a(DoubleVect& position, DoubleVect& valeur)
132{
133 assert(position.size() == Objet_U::dimension);
134 double x = position[0];
135 double y = position[1];
136 double z = 0.;
137 if (Objet_U::dimension == 3) z = position[2];
138
139 int dim = nb_comp();
140 valeur.resize(dim);
141
142 for (int k=0; k<dim; k++)
143 {
144 fxyz[k].setVar("x",x);
145 fxyz[k].setVar("y",y);
146 fxyz[k].setVar("z",z);
147 valeur[k] = fxyz[k].eval();
148 }
149 return;
150}
class Ch_front_var_stationnaire This abstract class represents a field on a boundary,
Class Champ_Inc_base.
int lire_dimension(Entree &, const Nom &)
Verification of the field dimension Returns the dimension of the field.
virtual int initialiser(double temps, const Champ_Inc_base &inco)
Initialization at the beginning of calculation.
virtual const Frontiere_dis_base & frontiere_dis() const
Returns the discretized boundary associated with the field.
virtual const Domaine_dis_base & domaine_dis() const
virtual DoubleTab & valeurs() override
Returns the array of field values.
Champ_front_softanalytique Class derived from Champ_front_var representing boundary.
int initialiser(double temps, const Champ_Inc_base &inco) override
Initialization at the beginning of calculation.
void valeur_a(DoubleVect &position, DoubleVect &valeur)
class Domaine_VF
Definition Domaine_VF.h:44
double xv(int num_face, int k) const
Definition Domaine_VF.h:76
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual void fixer_nb_comp(int i)
Sets the number of components of the field.
virtual int nb_comp() const
Definition Field_base.h:56
class Front_VF
Definition Front_VF.h:36
int nb_faces_tot() const
Definition Front_VF.h:58
int num_face(const int) const
Definition Front_VF.h:68
static int dimension
Definition Objet_U.h:94
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 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
_SIZE_ size() const
Definition TRUSTVect.tpp:45
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")