TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Champ_Fonc_MED_Tabule.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 <Champ_Fonc_MED_Tabule.h>
17
18Implemente_instanciable( Champ_Fonc_MED_Tabule, "Champ_Fonc_MED_Tabule", Champ_Fonc_MED );
19// XD Champ_Fonc_MED_Tabule champ_fonc_med Champ_Fonc_MED_Tabule INHERITS_BRACE not_set
21{
23 return os;
24}
25
27{
29 return is;
30}
31
33{
34
35 // temps1_ temps2_ such that time is in [temps1_, temps2_[
36 if (est_egal(le_temps, temps_calc_))
37 return;
38
39 if ((temps2_ < -1e8) || (le_temps <= temps_calc_))
40 {
41 // initialization: from -1e9 to T[0], set the same value
42 lire(temps_sauv_[0]);
43 tab1_ = valeurs();
44 tab2_ = valeurs();
46 }
47 if (le_temps >= temps2_)
48 {
49 int i, nbt = temps_sauv_.size_array();
50 int trouve = 0;
51 for (i = 0; i < nbt - 1; i++)
52 {
53 if ((le_temps >= temps_sauv_[i]) && (le_temps <= temps_sauv_[i + 1]))
54 {
55 trouve = 1;
58 tab1_ = valeurs();
59 temps2_ = temps_sauv_[i + 1];
61 tab2_ = valeurs();
62 }
63 }
64 if (trouve == 0)
65 {
66 temps1_ = temps_sauv_[nbt - 1];
67 assert(le_temps >= temps_sauv_[nbt - 1]);
69 tab1_ = valeurs();
70 tab2_ = tab1_;
71 temps2_ = DMAXFLOAT;
72 }
73 else
75 }
76
77 if ((le_temps >= temps1_) && (le_temps < temps2_))
78 {
79 valeurs() = tab2_;
80 valeurs() -= tab1_;
81 valeurs() *= (le_temps - temps1_) / (temps2_ - temps1_);
82 valeurs() += tab1_;
83 temps_calc_ = le_temps;
84 // Cerr<<temps_calc_<<" YYYYYY "<<valeurs()[0]<<" "<< tab2_[0]<< " "<<tab1_[0]<<finl;
85 }
86 else
87 {
88 Cerr << "internal error" << finl;
89 exit();
90 }
91
92}
virtual void set_instationnaire(bool flag)
: class Champ_Fonc_MED_Tabule
void mettre_a_jour(double temps) override
Time update of the field.
class Champ_Fonc_MED Load a field from a MED file for a given time.
virtual void lire(double tps, int given_iteration=-1)
ArrOfDouble temps_sauv_
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
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