LifeV
HyperbolicData.hpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3 *******************************************************************************
4  Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
5  Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
6  This file is part of LifeV.
7  LifeV is free software; you can redistribute it and/or modify
8  it under the terms of the GNU Lesser General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11  LifeV is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15  You should have received a copy of the GNU Lesser General Public License
16  along with LifeV. If not, see <http://www.gnu.org/licenses/>.
17 *******************************************************************************
18 */
19 //@HEADER
20 /*!
21  * @file
22  * @brief Data for hyperbolic scalar equations.
23  *
24  *
25  * @date 30-09-2010
26  *
27  * @author Alessio Fumagalli <alessio.fumagalli@mail.polimi.it>
28  * @author Michel Kern <michel.kern@inria.fr>
29  *
30  * @contributor
31  *
32  * @mantainer Alessio Fumagalli <alessio.fumagalli@mail.polimi.it>
33  *
34  */
35 
36 #ifndef _HYPERBOLICDATA_H_
37 #define _HYPERBOLICDATA_H_ 1
38 
39 #include <lifev/core/mesh/MeshData.hpp>
40 
41 #include <lifev/core/fem/TimeData.hpp>
42 
43 // LifeV namespace
44 namespace LifeV
45 {
46 /*!
47  @class HyperbolicData
48 
49  @author Alessio Fumagalli <alessio.fumagalli@mail.polimi.it>
50  @author Michel Kern <michel.kern@inria.fr>
51 
52  This class contain the basic data for the hyperbolic solver. In particoular it stores
53  <ol>
54  <li> the GetPot data file; </li>
55  <li> the time class handler; </li>
56  <li> the mesh class handler; </li>
57  <li> the level of verbosity of the solver hyperbolic; </li>
58  <li> the section for the GetPot data file; </li>
59  <li> the relax parameter for the CFL condition. </li>
60  </ol>
61  @todo class not finished!
62  */
63 template <typename Mesh>
65 {
66 public:
67 
68  //! @name Public Types
69  //@{
70 
71  typedef GetPot Data_Type;
73 
74  typedef TimeData Time_Type;
76 
79 
80  //@}
81 
82  //! @name Constructor & Destructor
83  //@{
84 
85  //! Empty Constructor
87 
88  //! Constructor using a data file.
89  /*!
90  @param dataFile GetPot data file for setup the problem
91  @param section the section for the Hyperbolic data
92  */
93  HyperbolicData ( const GetPot& dataFile, const std::string& section = "hyperbolic" );
94 
95  //! Copy constructor.
96  /*!
97  @param hyperbolicData object to take a copy
98  */
99  HyperbolicData ( const HyperbolicData& hyperbolicData );
100 
101  //! Virtual destructor
102  virtual ~HyperbolicData();
103 
104  //@}
105 
106  //! @name Operators
107  //@{
108 
109  //! Assign operator overloading
110  /*!
111  @param hyperbolicData The hyperbolicData to be copied
112  */
113  HyperbolicData& operator= ( const HyperbolicData& hyperbolicData );
114 
115  //@}
116 
117  //! @name Methods
118  //@{
119 
120  //! External setup
121  /*!
122  @param dataFile The data file with all the data.
123  @param section The global section.
124  */
125  void setup ( const Data_Type& dataFile, const std::string& section = "hyperbolic" );
126 
127  //! Print attributes of the class
128  /*!
129  @param output Stream to put the output
130  */
131  void showMe ( std::ostream& output = std::cout ) const;
132 
133  //@}
134 
135  //! @name Set Methods
136  //@{
137 
138  //! Set data time container
139  /*!
140  @param TimeData Boost shared_ptr to TimeData container
141  */
142  inline void setTimeData ( const TimePtr_Type TimeData )
143  {
144  M_time = TimeData;
145  }
146 
147  //! Set mesh container
148  /*!
149  @param MeshData Boost shared_ptr to meshData container
150  */
151  inline void setMeshData ( const MeshPtr_Type MeshData )
152  {
153  M_mesh = MeshData;
154  }
155 
156  //! @name Get Methods
157  //@{
158 
159  //! Get the level of verbosity of the problem.
160  inline UInt verbose () const
161  {
162  return M_verbose;
163  }
164 
165  //! Get the main section of the data file.
166  inline const std::string section () const
167  {
168  return M_section;
169  }
170 
171  //! Get the data file of the problem.
172  inline DataPtr_Type dataFile () const
173  {
174  return M_data;
175  }
176 
177  //! Get data time container.
178  /*!
179  @return shared_ptr to TimeData container
180  */
181  inline TimePtr_Type dataTime () const
182  {
183  return M_time;
184  }
185 
186  //! Get mesh container
187  /*!
188  @return shared_ptr to meshData container
189  */
190  inline MeshPtr_Type meshData () const
191  {
192  return M_mesh;
193  }
194 
195  //! Get the relaxation parameter for the CFL condition
196  /* Get the parameter to compute \f$ CFL_{\rm used} = \alpha CFL_{\rm computed} \f$
197  @return CFL relaxation parameter
198  */
199  inline Real getCFLRelaxParameter () const
200  {
201  return M_relaxCFL;
202  }
203 
204  //@}
205 
206 protected:
207 
208  //! Data containers for time and mesh
212 
213  //! Miscellaneous
216 
217  //! Relax parameter for the CFL condition
219 
220 };
221 
222 // ===================================================
223 // Constructors & Destructor
224 // ===================================================
225 
226 template < typename Mesh >
228  // Data containers
229  M_data ( ),
230  M_time ( ),
231  M_mesh ( ),
232  // Miscellaneous
233  M_verbose ( static_cast<UInt> (0) ),
234  M_section ( ),
235  // CFL
236  M_relaxCFL ( static_cast<Real> (0.) )
237 {
238 
239 }
240 
241 // Copy constructor
242 template < typename Mesh >
243 HyperbolicData<Mesh>::HyperbolicData ( const HyperbolicData& hyperbolicData ) :
244  // Data containers
245  M_data ( hyperbolicData.M_data ),
246  M_time ( hyperbolicData.M_time ),
247  M_mesh ( hyperbolicData.M_mesh ),
248  // Miscellaneous
249  M_verbose ( hyperbolicData.M_verbose ),
251  // CFL
252  M_relaxCFL ( hyperbolicData.M_relaxCFL )
253 {
254 
255 }
256 
257 // Virtual destructor
258 template < typename Mesh >
260 {
261 
262 }
263 
264 // ===================================================
265 // Operators
266 // ===================================================
267 
268 // Overloading of the operator =
269 template < typename Mesh >
270 HyperbolicData<Mesh>&
271 HyperbolicData<Mesh>::operator= ( const HyperbolicData& hyperbolicData )
272 {
273  // Avoid auto-copy
274  if ( this != &hyperbolicData )
275  {
276  // Data containers
277  M_data = hyperbolicData.M_data;
278  M_time = hyperbolicData.M_time;
279  M_mesh = hyperbolicData.M_mesh;
280  // Mescellaneous
281  M_verbose = hyperbolicData.M_verbose;
282  // CFL
283  M_relaxCFL = hyperbolicData.M_relaxCFL;
284  }
285 
286  return *this;
287 
288 }
289 
290 // ===================================================
291 // Methods
292 // ===================================================
293 
294 // External set up method
295 template < typename Mesh >
296 void
297 HyperbolicData<Mesh>::setup ( const Data_Type& dataFile,
298  const std::string& section )
299 {
300 
301  M_section = section;
302 
303  // If data has not been set
304  if ( !M_data.get() )
305  {
306  M_data.reset ( new Data_Type ( dataFile ) );
307  }
308 
309  // If data time has not been set
310  if ( !M_time.get() )
311  {
312  M_time.reset ( new Time_Type ( dataFile, M_section + "/time_discretization" ) );
313  }
314 
315  // If data mesh has not been set
316  if ( !M_mesh.get() )
317  {
318  M_mesh.reset ( new Mesh_Type ( dataFile, M_section + "/space_discretization" ) );
319  }
320 
321  // Miscellaneous
322  M_verbose = dataFile ( ( M_section + "/miscellaneous/verbose" ).data(), 1 );
323 
324  // CFL
325  M_relaxCFL = dataFile ( (M_section + "/numerical_flux/CFL/relax").data(), 0.9 );
326 
327 }
328 
329 // Print attiributes of the class
330 template < typename Mesh >
331 void
332 HyperbolicData<Mesh>::showMe ( std::ostream& output ) const
333 {
334  output << "Class HyperbolicData:" << std::endl;
335  M_time->showMe ( output );
336  M_mesh->showMe ( output );
337  output << "Verbosity level " << M_verbose << std::endl
338  << "Section of GetPot " << M_section << std::endl
339  << "Relax CFL parameter " << M_relaxCFL << std::endl
340  << std::flush;
341 }
342 
343 } // Namespace LifeV
344 
345 #endif /* _HYPERBOLICDATA_H_ */
void setMeshData(const MeshPtr_Type MeshData)
Set mesh container.
Real M_relaxCFL
Relax parameter for the CFL condition.
virtual ~HyperbolicData()
Virtual destructor.
DataPtr_Type dataFile() const
Get the data file of the problem.
Real getCFLRelaxParameter() const
Get the relaxation parameter for the CFL condition.
HyperbolicData(const HyperbolicData &hyperbolicData)
Copy constructor.
DataPtr_Type M_data
Data containers for time and mesh.
HyperbolicData(const GetPot &dataFile, const std::string &section="hyperbolic")
Constructor using a data file.
std::shared_ptr< Mesh_Type > MeshPtr_Type
std::shared_ptr< Time_Type > TimePtr_Type
void showMe(std::ostream &output=std::cout) const
Print attributes of the class.
HyperbolicData()
Empty Constructor.
TimePtr_Type dataTime() const
Get data time container.
void setup(const Data_Type &dataFile, const std::string &section="hyperbolic")
External setup.
void setTimeData(const TimePtr_Type TimeData)
Set data time container.
MeshData - class for handling spatial discretization.
Definition: MeshData.hpp:72
std::shared_ptr< Data_Type > DataPtr_Type
const std::string section() const
Get the main section of the data file.
double Real
Generic real data.
Definition: LifeV.hpp:175
UInt M_verbose
Miscellaneous.
UInt verbose() const
Get the level of verbosity of the problem.
HyperbolicData & operator=(const HyperbolicData &hyperbolicData)
Assign operator overloading.
MeshPtr_Type meshData() const
Get mesh container.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191