TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_front_base.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 <Champ_front_base.h>
17#include <Frontiere_dis_base.h>
18#include <Frontiere.h>
19
20Implemente_base_sans_constructeur(Champ_front_base,"Champ_front_base",Field_base);
21// XD front_field_base objet_u champ_front_base INHERITS_BRACE Basic class for fields at domain boundaries.
22
24/*! @brief Prints the field name to an output stream
25 *
26 * @param (Sortie& s) an output stream
27 * @return (Sortie&) the modified output stream
28 */
29Sortie& Champ_front_base::printOn(Sortie& s ) const { return s << que_suis_je() << " " << le_nom(); }
30
31/*! @brief DOES NOTHING - to override in derived classes.
32 *
33 * @param (Entree& s) an input stream
34 * @return (Entree&) the input stream
35 */
36Entree& Champ_front_base::readOn(Entree& s ) { return s ; }
37
38
39/*! @brief Initialization at the beginning of calculation.
40 *
41 * Imperatively this method must not use data
42 * external to the equation (coupling). If mettre_a_jour does,
43 * then initializer must not call mettre_a_jour.
44 *
45 * @return (0 in case of error, 1 otherwise.)
46 */
47int Champ_front_base::initialiser(double temps, const Champ_Inc_base& inco)
48{
49 return 1;
50}
51
52/*! @brief Associates a discretized boundary with the field.
53 *
54 * @param (Frontiere_dis_base& fr) the discretized boundary to associate with the field
55 */
57{
58 la_frontiere_dis = fr;
59}
60
61
62/*! @brief DOES NOTHING, to override.
63 *
64 * This method is called at the beginning of each time step or
65 * sub-time-step, it may possibly use data
66 * external to the equation. It is up to the algorithm to ensure
67 * that this data is relevant...
68 * Calculates the value of the boundary condition at the requested time.
69 *
70 * @param (double)
71 */
73{
74}
75
76/*! @brief Called by Conds_lim::completer. By default does nothing.
77 *
78 * To override in unsteady front fields.
79 *
80 */
84
85/*! @brief DOES NOTHING, to override. This method can calculate and store useful data for the
86 *
87 * BC, and depending only on the unknown on which it acts
88 * this BC (not from outside). cf Champ_front_contact_VEF for example.
89 * It is called when the unknown is modified.
90 *
91 * @param (double)
92 */
96
97/*! @brief Returns the vector of field values for the given face.
98 *
99 * By default for func fields, we assume that the values array
100 * holds nb_faces * nb_compo_ values.
101 * Special case example: champ_front_uniforme::valeurs_face
102 *
103 * @param (num_face) the index of a face on the boundary 0 <= num_face < frontiere_dis().frontiere().nb_faces()
104 * @param (val) Resize this array and fill it.
105 */
106void Champ_front_base::valeurs_face(int num_face, DoubleVect& val) const
107{
108#ifndef NDEBUG
109 const int nb_faces = frontiere_dis().frontiere().nb_faces();
110 // If crash here, it means the values array does not contain a
111 // value for each face, you need to reimimplement the method in the
112 // derived class...
113 assert(num_face >= 0 && num_face < nb_faces);
114 assert(valeurs().dimension(0) == nb_faces);
115#endif
116 const int n = nb_compo_;
117 val.resize(n);
118 const DoubleTab& valeurs_a_copier=valeurs();
119 for (int i = 0; i < n; i++)
120 val[i] = valeurs_a_copier(num_face, i);
121}
122
127
128
129/*! @brief To implement in derived classes.
130 *
131 * Advances in time: the new current time will be the time passed
132 * as a parameter.
133 *
134 * @return (int) 1 if OK, 0 otherwise
135 */
137{
138 Cerr << "Champ_front_base::avancer(double temps) should be overloaded" << finl;
140 return 0;
141}
142
143/*! @brief To implement in derived classes.
144 *
145 * Rewinds in time: the new current time will be the time passed
146 * as a parameter.
147 *
148 * @return (int) 1 if OK, 0 otherwise
149 */
151{
152 Cerr << "Champ_front_base::reculer(double temps) should be overloaded " << "by " << que_suis_je() << finl;
154 return 0;
155}
156
157/*! @brief Changes the time value for the i-th temporal value after the present
158 *
159 */
161{
162 les_valeurs->futur(i).changer_temps(temps);
163}
164
165/*! @brief Computes the rate of change of the field between t1 and t2 and stores it in Gpoint_
166 *
167 */
169{
170 if (std::abs(t2-t1) < DMINFLOAT)
171 {
172 Gpoint_ = 0;
173 }
174 else
175 {
176 const DoubleTab& v1 = valeurs_au_temps(t1);
177 const DoubleTab& v2 = valeurs_au_temps(t2);
178 if (!Gpoint_.get_md_vector() && v1.dimension(0) == 1)
179 {
180 // Uniform unsteady field
181 int dim = v1.dimension(1);
182 Gpoint_.resize(dim);
183 for (int i = 0; i < dim; i++)
184 Gpoint_(i) = (v2(0, i) - v1(0, i)) / (t2 - t1);
185 }
186 else
187 {
188 // Variable unsteady field
189 Gpoint_ = v1;
190 Gpoint_ *= -1;
191 Gpoint_ += v2;
192 Gpoint_ /= (t2 - t1);
193 }
194 }
195}
196
Class Champ_Inc_base.
class Champ_front_base Base class for the hierarchy of boundary fields.
virtual int initialiser(double temps, const Champ_Inc_base &inco)
Initialization at the beginning of calculation.
virtual void associer_fr_dis_base(const Frontiere_dis_base &)
Associates a discretized boundary with the field.
virtual void changer_temps_futur(double temps, int i)
Changes the time value for the i-th temporal value after the present.
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 void calculer_coeffs_echange(double temps)
DOES NOTHING, to override. This method can calculate and store useful data for the.
virtual DoubleTab & valeurs() override
Returns the array of field values.
virtual DoubleTab & valeurs_au_temps(double temps)=0
virtual void fixer_nb_valeurs_temporelles(int nb_cases)
Called by Conds_lim::completer. By default does nothing.
virtual int reculer(double temps)
To implement in derived classes.
virtual int avancer(double temps)
To implement in derived classes.
virtual void mettre_a_jour(double temps)
DOES NOTHING, to override.
virtual void valeurs_face(int, DoubleVect &) const
Returns the vector of field values for the given face.
virtual void calculer_derivee_en_temps(double t1, double t2)
Computes the rate of change of the field between t1 and t2 and stores it in Gpoint_.
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
const Nom & le_nom() const override
Returns the name of the field.
int nb_compo_
Definition Field_base.h:95
int_t nb_faces() const
Returns the number of faces of the boundary.
Definition Frontiere.h:59
class Frontiere_dis_base Class representing a discretized boundary.
const Frontiere & frontiere() const
Returns the associated geometric boundary.
const Domaine_dis_base & domaine_dis() const
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
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Base class for output streams.
Definition Sortie.h:52
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTVect.tpp:91