TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Roue.h
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#ifndef Roue_included
17#define Roue_included
18
19#include <TRUSTTabs_forward.h>
20class Roue;
21
22/*! @brief Pointer to a wheel.
23 *
24 * The wheel is created in the constructor, destroyed in the destructor.
25 * It is copied in the copy constructor
26 * and in the assignment operator from one Roue_ptr to another.
27 * In all other cases only the pointers are manipulated.
28 *
29 * @sa Champ_Inc
30 */
31
33{
34
35
36 inline Roue* operator ->() const;
37 inline Roue* operator ->();
38 Roue_ptr(const Roue_ptr& );
39 Roue_ptr& operator =(const Roue_ptr& x);
40 Roue_ptr(Roue& );
41 Roue_ptr();
42 inline Roue_ptr(Roue*);
43 ~Roue_ptr();
45 inline Roue& valeur()
46 {
47 return *ptr;
48 }
49 inline const Roue& valeur() const
50 {
51 return *ptr;
52 }
53 inline void annule()
54 {
55 ptr=0;
56 }
57 inline operator bool() const
58 {
59 return (ptr!=0);
60 }
61 inline Roue& operator =(Roue& x)
62 {
63 ptr=&x;
64 return *ptr;
65 }
66 inline Roue* operator =(Roue* x)
67 {
68 return ptr=x;
69 }
70
71 Roue& operator[](int i);
72 const Roue& operator[](int i) const;
73};
74
75
76/*! @brief Roue class used in Champ_Inc_Base.
77 *
78 * Manages the number of time values for which the field
79 * must remain in memory.
80 *
81 * @sa Champ_Inc
82 */
83
84
85class Roue
86{
87public :
88 inline const DoubleTab& valeurs() const;
89 inline DoubleTab& valeurs();
90 Roue();
91 Roue(const Roue&);
92 ~Roue();
93 void dimensionner(int nb_val);
94 void dimensionner(int nb_val, int nb_comp);
95 int nb_cases() const;
96 int fixer_nb_cases(int );
97 void ajouter_case(int n=1);
98 void supprimer_case(int n=1);
99 inline double temps() const;
100 inline double changer_temps(const double t);
101 const Roue& futur(int i =1) const;
102 Roue& futur(int i =1);
103 const Roue& passe(int i =1) const;
104 Roue& passe(int i =1);
105 Roue& operator=(const Roue&);
106 inline void avancer(Roue_ptr& ptr)
107 {
108 ptr=ptr->futur_.valeur();
109 };
110 inline void reculer(Roue_ptr& ptr)
111 {
112 ptr=ptr->passe_.valeur();
113 };
114
115private :
116
117 double temps_;
118 int nb_cases_;
119 DoubleTab valeurs_;
120 Roue_ptr passe_;
121 Roue_ptr futur_;
122};
123
124/*! @brief
125 *
126 */
127inline Roue_ptr::Roue_ptr(Roue *x): ptr(x) {}
128
129/*! @brief
130 *
131 */
133{
134 return ptr;
135}
136
137/*! @brief
138 *
139 */
141{
142 return ptr;
143}
144
145/*! @brief Returns the value array of the Roue.
146 *
147 * @return (const DoubleTab&) const reference to the value array
148 */
149inline const DoubleTab& Roue::valeurs() const
150{
151 return valeurs_;
152}
153
154
155/*! @brief Returns the value array of the Roue.
156 *
157 * @return (const DoubleTab&) reference to the value array
158 */
159inline DoubleTab& Roue::valeurs()
160{
161 return valeurs_;
162}
163
164
165/*! @brief Returns the time value of the Roue.
166 *
167 * @return (double) the time
168 */
169inline double Roue::temps() const
170{
171 return temps_;
172}
173
174
175/*! @brief Changes the time of the Roue.
176 *
177 * @param t the new time value
178 * @return (double) the new time value
179 */
180inline double Roue::changer_temps(const double t)
181{
182 return temps_=t;
183}
184/*! @brief Returns the number of slots in the Roue.
185 *
186 * @return (int) the number of slots in the Roue
187 */
188inline int Roue::nb_cases() const
189{
190 return nb_cases_;
191}
192
193#endif
Roue class used in Champ_Inc_Base.
Definition Roue.h:86
double temps() const
Returns the time value of the Roue.
Definition Roue.h:169
double changer_temps(const double t)
Changes the time of the Roue.
Definition Roue.h:180
int fixer_nb_cases(int)
Changes the number of slots in the Roue.
Definition Roue.cpp:237
void avancer(Roue_ptr &ptr)
Definition Roue.h:106
void reculer(Roue_ptr &ptr)
Definition Roue.h:110
~Roue()
Destructor.
Definition Roue.cpp:121
Roue & operator=(const Roue &)
Assignment operator for a Roue. Copies the time, values, number of slots, and future slot values.
Definition Roue.cpp:324
const DoubleTab & valeurs() const
Returns the value array of the Roue.
Definition Roue.h:149
void ajouter_case(int n=1)
Adds n slots to the Roue.
Definition Roue.cpp:254
int nb_cases() const
Returns the number of slots in the Roue.
Definition Roue.h:188
const Roue & futur(int i=1) const
Returns the Roue corresponding to the i-th future slot.
Definition Roue.cpp:136
void dimensionner(int nb_val)
Resizes (1D) the values of the Roue and its future wheels.
Definition Roue.cpp:205
void supprimer_case(int n=1)
Removes n slots from the Roue.
Definition Roue.cpp:278
Roue()
Default constructor. Builds a wheel with a single slot at time t=0.
Definition Roue.cpp:98
const Roue & passe(int i=1) const
Returns the Roue corresponding to the i-th past slot.
Definition Roue.cpp:168
Pointer to a wheel.
Definition Roue.h:33
const Roue & valeur() const
Definition Roue.h:49
Roue & valeur()
Definition Roue.h:45
Roue * operator->() const
Definition Roue.h:132
Roue & operator[](int i)
Definition Roue.cpp:80
Roue_ptr()
Definition Roue.cpp:25
~Roue_ptr()
Definition Roue.cpp:68
Roue * ptr
Definition Roue.h:44
void annule()
Definition Roue.h:53
Roue_ptr(const Roue_ptr &)
Copy constructor.
Definition Roue.cpp:38
Roue_ptr & operator=(const Roue_ptr &x)
Copy assignment operator.
Definition Roue.cpp:50