libMesh
Loading...
Searching...
No Matches
rb_temporal_discretization.C
Go to the documentation of this file.
1// rbOOmit: An implementation of the Certified Reduced Basis method.
2// Copyright (C) 2009, 2010 David J. Knezevic
3
4// This file is part of rbOOmit.
5
6// rbOOmit is free software; you can redistribute it and/or
7// modify it under the terms of the GNU Lesser General Public
8// License as published by the Free Software Foundation; either
9// version 2.1 of the License, or (at your option) any later version.
10
11// rbOOmit 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
16// You should have received a copy of the GNU Lesser General Public
17// License along with this library; if not, write to the Free Software
18// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20// rbOOmit includes
21#include "libmesh/rb_temporal_discretization.h"
22
23// libMesh includes
24#include "libmesh/getpot.h"
25
26namespace libMesh
27{
28
30 : _delta_t(0.),
31 _euler_theta(0.),
32 _current_time_step(0),
33 _n_time_steps(0)
34{}
35
40
42{
43 _delta_t = delta_t_in;
44}
45
50
52{
53 libmesh_assert((0. <= euler_theta_in ) && (euler_theta_in <= 1.));
54 _euler_theta = euler_theta_in;
55}
56
58{
59 return _current_time_step;
60}
61
63{
64 libmesh_assert_less_equal (k, get_n_time_steps());
65 this->_current_time_step = k;
66}
67
69{
70 return _n_time_steps;
71}
72
74{
75 _n_time_steps = K;
76 _control.assign(_n_time_steps+1,1.0);
77}
78
80{
81 libmesh_assert_less_equal (k, get_n_time_steps());
82 return _control[k];
83}
84
85void RBTemporalDiscretization::set_control(const std::vector<Real> & control)
86{
87 libmesh_assert_less_equal(control.size(),_n_time_steps+1);
88 _control = control;
89 // If the input vector is smaller than the number of time steps (+1), we complete it with zeros
90 _control.resize(_n_time_steps+1);
91}
92
93void RBTemporalDiscretization::process_temporal_parameters_file (const std::string & parameters_filename)
94{
95 // Read in data from parameters_filename
96 GetPot infile(parameters_filename);
97
98 // Read in parameters related to temporal discretization
99 unsigned int n_time_steps_in = infile("n_time_steps", get_n_time_steps());
100 const Real delta_t_in = infile("delta_t", get_delta_t());
101 const Real euler_theta_in = infile("euler_theta", get_euler_theta());
102
103 // and set the relevant member variables
104 set_n_time_steps(n_time_steps_in);
105 set_delta_t(delta_t_in);
106 set_euler_theta(euler_theta_in);
107 set_time_step(0);
108}
109
111{
112 this->set_delta_t( other.get_delta_t() );
113 this->set_euler_theta( other.get_euler_theta() );
114 this->set_n_time_steps( other.get_n_time_steps() );
115 this->set_time_step( other.get_time_step() );
116 this->set_control( other._control );
117}
118
119}
Define a class that encapsulates the details of a "generalized Euler" temporal discretization to be u...
void set_control(const std::vector< Real > &control)
unsigned int _n_time_steps
The number of time-steps.
Real get_control(const unsigned int k) const
Get/set the RHS control.
void set_euler_theta(const Real euler_theta_in)
void pull_temporal_discretization_data(RBTemporalDiscretization &other)
Pull the temporal discretization data from other.
std::vector< Real > _control
The RHS control (scalar function of time).
Real get_delta_t() const
Get/set delta_t, the time-step size.
Real get_euler_theta() const
Get/set euler_theta, parameter that determines the temporal discretization.
void process_temporal_parameters_file(const std::string &parameters_filename)
Read in and initialize parameters from parameters_filename.
unsigned int _current_time_step
The current time-step.
unsigned int get_n_time_steps() const
Get/set the total number of time-steps.
unsigned int get_time_step() const
Get/set the current time-step.
Real _euler_theta
The parameter that determines the generalized Euler scheme discretization that we employ.
The libMesh namespace provides an interface to certain functionality in the library.
libmesh_assert(ctx)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real