LifeV
TimeData.cpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3 *******************************************************************************
4 
5  Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
6  Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
7 
8  This file is part of LifeV.
9 
10  LifeV is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  LifeV is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with LifeV. If not, see <http://www.gnu.org/licenses/>.
22 
23 *******************************************************************************
24 */
25 //@HEADER
26 
27 /*!
28  @file
29  @brief File containing a class for handling temporal data.
30 
31  @author M.A. Fernandez
32  @author Cristiano Malossi <cristiano.malossi@epfl.ch>
33  @date 01-06-2009
34 
35  @contributor Matteo Pozzoli <matteo1.pozzoli@mail.polimi.it>
36  @maintainer Matteo Pozzoli <matteo1.pozzoli@mail.polimi.it>
37  */
38 #include <lifev/core/fem/TimeData.hpp>
39 
40 namespace LifeV
41 {
42 
43 // ===================================================
44 // Constructors & Destructor
45 // ===================================================
47  M_initialTime ( 0. ),
48  M_endTime ( 1. ),
49  M_periodTime ( 1. ),
52  M_timeStepNumber ( 0 )
53 {
54 }
55 
56 TimeData::TimeData ( const GetPot& dataFile, const std::string& section ) :
57  M_timeStepNumber ( 0 )
58 {
59  setup ( dataFile, section );
60 }
61 
62 TimeData::TimeData ( const TimeData& timeData )
63 {
64  M_initialTime = timeData.M_initialTime;
65  M_endTime = timeData.M_endTime;
66  M_periodTime = timeData.M_periodTime;
67  M_time = timeData.M_time;
68  M_timeStep = timeData.M_timeStep;
70 }
71 
72 // ===================================================
73 // Methods
74 // ===================================================
75 void
76 TimeData::setup ( const GetPot& dataFile, const std::string& section )
77 {
78  M_initialTime = dataFile ( ( section + "/initialtime" ).data(), 0.);
79  M_endTime = dataFile ( ( section + "/endtime" ).data(), 1.);
80  M_periodTime = dataFile ( ( section + "/periodtime" ).data(), 1.);
82  M_timeStep = dataFile ( ( section + "/timestep" ).data(), M_endTime );
83 }
84 
85 void
86 TimeData::showMe ( std::ostream& output ) const
87 {
88  output << "\n*** TimeData: values for user-defined data\n";
89 
90  output << "\n[/time_discretization]" << std::endl;
91  output << "Initial time = " << M_initialTime << std::endl;
92  output << "End time = " << M_endTime << std::endl;
93  output << "Time = " << M_time << std::endl;
94  output << "TimeStep = " << M_timeStep << std::endl;
95  output << "TimeStepNumber = " << M_timeStepNumber << std::endl;
96 }
97 
98 
99 
100 // ===================================================
101 // Utility methods
102 // ===================================================
103 Real
104 TimeData::round ( const Real& n, const Int& decimal ) const
105 {
106  return std::floor ( n * std::pow (10.0, decimal) + 0.5 ) / std::pow (10.0, decimal);
107 }
108 
109 }
Real M_periodTime
period time
Definition: TimeData.hpp:317
TimeData(const TimeData &TimeData)
Copy constructor.
Definition: TimeData.cpp:62
Real M_endTime
end time
Definition: TimeData.hpp:314
Real M_initialTime
initial time
Definition: TimeData.hpp:311
int32_type Int
Generic integer data.
Definition: LifeV.hpp:188
void updateInverseJacobian(const UInt &iQuadPt)
void setup(const GetPot &dfile, const std::string &section="time_discretization")
Read the dataFile and set all the internal quantities.
Definition: TimeData.cpp:76
Real M_timeStep
time step
Definition: TimeData.hpp:323
Real M_time
current time
Definition: TimeData.hpp:320
UInt M_timeStepNumber
iteration number
Definition: TimeData.hpp:326
double Real
Generic real data.
Definition: LifeV.hpp:175
void showMe(std::ostream &output=std::cout) const
Display general information about the content of the class.
Definition: TimeData.cpp:86
Real round(const Real &n, const Int &decimal=10) const
Definition: TimeData.cpp:104
TimeData()
Empty Constructor.
Definition: TimeData.cpp:46
TimeData(const GetPot &dataFile, const std::string &section="time_discretization")
Constructor.
Definition: TimeData.cpp:56
TimeData - Class for handling temporal discretization.
Definition: TimeData.hpp:61