TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_front_t.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// New boundary field
16
17#include <Champ_front_t.h>
18#include <Domaine.h>
19#include <Frontiere_dis_base.h>
20#include <Domaine_VF.h>
21#include <TRUSTTrav.h>
22
23Implemente_instanciable(Champ_front_t,"Champ_front_fonc_t",Ch_front_var_instationnaire_indep);
24// XD champ_front_fonc_t front_field_base champ_front_fonc_t NO_BRACE Boundary field that depends only on time.
25// XD attr val listchaine val REQ Values of field components (mathematical expressions).
26
27
28/*! @brief Print the field to an output stream.
29 *
30 * Prints the field size and the (constant) value on
31 * the boundary.
32 *
33 * @param (Sortie& os) an output stream
34 * @return (Sortie&) the modified output stream
35 */
37{
38
39 const DoubleTab& tab=valeurs();
40 os << tab.size() << " ";
41 for(int i=0; i<tab.size(); i++)
42 os << tab(0,i);
43 return os;
44}
45
46
47/*! @brief Read the field from an input stream.
48 *
49 * Format:
50 * Champ_front_t nb_compo vrel_1 ... [vrel_i]
51 *
52 * @param (Entree& is) an input stream
53 * @return (Entree& is) the modified input stream
54 */
56{
57 int dim;
59 fixer_nb_comp(dim);
60
61 f_t.dimensionner(dim);
62
63
64 for (int i = 0; i<dim; i++)
65 {
66 Nom tmp;
67 is >> tmp;
68 Cerr << "Reading and interpretation of the function " << tmp << finl;
69 f_t[i].setNbVar(1);
70 f_t[i].setString(tmp);
71 f_t[i].addVar("t");
72 f_t[i].parseString();
73 Cerr << "Interpretation of function " << tmp << " Ok" << finl;
74 }
75
76 return is;
77}
78
79
80
81/*! @brief Returns the object upcast to Champ_front_base&
82 *
83 * @param (Champ_front_base& ch)
84 * @return (Champ_front_base&) (*this) upcast to Champ_front_base&
85 */
87{
88 return *this;
89}
90
91
93{
94 int dim=nb_comp();
95 const Frontiere_dis_base& fr_dis=frontiere_dis();
96 int nb_faces=ref_cast(Front_VF, fr_dis).nb_faces();
97 int i,k;
98 DoubleTab& tab=valeurs_au_temps(temps);
99 for( i=0; i<nb_faces; i++)
100 {
101 for( k=0; k<dim; k++)
102 {
103 f_t[k].setVar("t",temps);
104 tab(i,k)=f_t[k].eval();
105 }
106 }
108}
109
110double Champ_front_t::valeur_au_temps(double temps,int som, int k) const
111{
112 Parser_U& f_tk=f_t[k];
113 f_tk.setVar("t",temps);
114 return f_tk.eval();
115}
class Ch_front_var_instationnaire_indep This abstract class represents a field on a boundary,
int lire_dimension(Entree &, const Nom &)
Verification of the field dimension Returns the dimension of the field.
class Champ_front_base Base class for the hierarchy of boundary fields.
virtual const Frontiere_dis_base & frontiere_dis() const
Returns the discretized boundary associated with the field.
virtual DoubleTab & valeurs() override
Returns the array of field values.
class Champ_front_t Derived class of Champ_front_var representing
void mettre_a_jour(double temps) override
DOES NOTHING, to override.
virtual double valeur_au_temps(double temps, int som, int comp) const
Champ_front_base & affecter_(const Champ_front_base &ch) override
Returns the object upcast to Champ_front_base&.
DoubleTab & valeurs_au_temps(double temps) override
Returns the values at the desired time.
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
class Frontiere_dis_base Class representing a discretized boundary.
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
class Parser_U Version of the Parser class, deriving from Objet_U.
Definition Parser_U.h:32
void setVar(const char *sv, double val)
Definition Parser_U.h:149
double eval()
Definition Parser_U.h:125
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")