TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_front_var_instationnaire.cpp
1/****************************************************************************
2* Copyright (c) 2025, 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_var_instationnaire.h>
17
18Implemente_base(Champ_front_var_instationnaire,"Champ_front_var_instationnaire",Champ_front_var);
19
20/*! @brief Prints the field name on an output stream
21 *
22 * @param (Sortie& s) an output stream
23 * @return (Sortie&) the modified output stream
24 */
26{
27 return s << que_suis_je() << " " << le_nom();
28}
29
30
31/*! @brief DOES NOTHING TO override in derived classes
32 *
33 * @param (Entree& is) an input stream
34 * @return (Entree&) the modified input stream
35 */
37{
38 return s ;
39}
40
41
42/*! @brief Overrides Champ_front_base::fixer_nb_valeurs_temporelles
43 *
44 */
46{
47 les_valeurs->fixer_nb_cases(nb_cases);
48}
49
50/*! @brief Initializes the current time and Gpoint
51 *
52 * @param (double tps) the update time
53 */
55{
56 if (!Champ_front_var::initialiser(temps,inco))
57 return 0;
58
59 temps_defaut=temps;
60 changer_temps_futur(temps,0);
62 return 1;
63}
64
65inline void print(const Roue_ptr& les_valeurs)
66{
67 Cerr << "The times available are :" << finl;
68 for(int i=1; i<les_valeurs->nb_cases(); i++)
69 Cerr << " " << les_valeurs[i].temps() << finl;
70}
71
73{
74 for (int i = 0; i < les_valeurs->nb_cases(); i++)
75 if (est_egal(les_valeurs[i].temps(), temps))
76 {
77 if (les_valeurs->valeurs().size() > 0)
78 return true;
79 else return false;
80 }
81
82 return false;
83}
84
85/*! @brief Returns the values at the desired time.
86 *
87 * Otherwise, exits with an error.
88 *
89 */
91{
92
93 for(int i=0; i<les_valeurs->nb_cases(); i++)
94 {
95 if(est_egal(les_valeurs[i].temps(),temps))
96 return les_valeurs[i].valeurs();
97 }
98
99 Cerr << "In Champ_front_var_instationnaire::valeurs(double), "
100 << "time " << temps << " not found." << finl;
101 print(les_valeurs);
102 exit();
103 return valeurs(); // For compilers
104}
105
106/*! @brief Returns the values at the desired time.
107 *
108 * Otherwise, exits with an error.
109 *
110 */
111const DoubleTab& Champ_front_var_instationnaire::valeurs_au_temps(double temps) const
112{
113
114 for(int i=0; i<les_valeurs->nb_cases(); i++)
115 {
116 if(est_egal(les_valeurs[i].temps(),temps))
117 return les_valeurs[i].valeurs();
118 }
119
120 Cerr << "In Champ_front_var_instationnaire::valeurs(double), "
121 << "time " << temps << " not found." << finl;
122 print(les_valeurs);
123 exit();
124 return valeurs(); // For compilers
125}
126
127/*! @brief Advances to the desired time.
128 *
129 * Otherwise, exits with an error.
130 *
131 */
133{
134
135 // Is it indeed an advance in time?
136 assert(temps>les_valeurs->temps());
137
138 for(int i=1; i<les_valeurs->nb_cases(); i++)
139 {
140 if(est_egal(les_valeurs[i].temps(),temps))
141 {
143 return 1;
144 }
145 }
146 Cerr << "In Champ_front_var_instationnaire::avancer(double), "
147 << "time " << temps << " not found." << finl;
148 print(les_valeurs);
149 exit();
150 return 0;
151}
152
153/*! @brief Goes back to the desired time.
154 *
155 * Otherwise, exits with an error.
156 *
157 */
159{
160
161 // Is it indeed a rewind in time?
162 assert(temps<les_valeurs->temps());
163
164 for(int i=les_valeurs->nb_cases()-1; i>=1; i++)
165 {
166 if(est_egal(les_valeurs[i].temps(),temps))
167 {
169 return 1;
170 }
171 }
172 Cerr << "In Champ_front_var_instationnaire::reculer(double), "
173 << "time " << temps << " not found." << finl;
174 print(les_valeurs);
175 exit();
176 return 0;
177}
Class Champ_Inc_base.
virtual void changer_temps_futur(double temps, int i)
Changes the time value for the i-th temporal value after the present.
virtual DoubleTab & valeurs() override
Returns the array of field values.
virtual void set_instationnaire(bool flag)
class Champ_front_var_instationnaire Derived class from Champ_front_var that represents fields on
void fixer_nb_valeurs_temporelles(int nb_cases) override
Overrides Champ_front_base::fixer_nb_valeurs_temporelles.
int reculer(double temps) override
Goes back to the desired time.
int initialiser(double temps, const Champ_Inc_base &inco) override
Initializes the current time and Gpoint.
DoubleTab & valeurs_au_temps(double temps) override
Returns the values at the desired time.
bool has_valeurs_au_temps(double temps) const override
int avancer(double temps) override
Advances to the desired time.
class Champ_front_var Derived class from Champ_front_base that represents a field on
int initialiser(double temps, const Champ_Inc_base &inco) override
Initialization at the beginning of the calculation.
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.
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
int nb_cases() const
Returns the number of slots in the Roue.
Definition Roue.h:188
Base class for output streams.
Definition Sortie.h:52
Pointer to a wheel.
Definition Roue.h:33