16
16
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
18
18
// First added: 2013-02-15
19
// Last changed: 2013-04-02
19
// Last changed: 2014-03-05
21
21
#ifndef __BUTCHERSCHEME_H
22
22
#define __BUTCHERSCHEME_H
25
#include <boost/shared_ptr.hpp>
27
27
#include <dolfin/common/Variable.h>
28
#include <dolfin/function/FunctionAXPY.h>
29
28
#include <dolfin/function/Function.h>
30
29
#include <dolfin/fem/Form.h>
49
48
/// FIXME: This constructor is a MESS. Needs clean up...
50
MultiStageScheme(std::vector<std::vector<boost::shared_ptr<const Form> > > stage_forms,
51
const FunctionAXPY& last_stage,
52
std::vector<boost::shared_ptr<Function> > stage_solutions,
53
boost::shared_ptr<Function> u,
54
boost::shared_ptr<Constant> t,
55
boost::shared_ptr<Constant> dt,
49
MultiStageScheme(std::vector<std::vector<std::shared_ptr<const Form> > > stage_forms,
50
std::shared_ptr<const Form> last_stage,
51
std::vector<std::shared_ptr<Function> > stage_solutions,
52
std::shared_ptr<Function> u,
53
std::shared_ptr<Constant> t,
54
std::shared_ptr<Constant> dt,
56
55
std::vector<double> dt_stage_offset,
56
std::vector<int> jacobian_indices,
57
57
unsigned int order,
58
58
const std::string name,
59
59
const std::string human_form);
61
61
/// Constructor with Boundary conditions
62
MultiStageScheme(std::vector<std::vector<boost::shared_ptr<const Form> > > stage_forms,
63
const FunctionAXPY& last_stage,
64
std::vector<boost::shared_ptr<Function> > stage_solutions,
65
boost::shared_ptr<Function> u,
66
boost::shared_ptr<Constant> t,
67
boost::shared_ptr<Constant> dt,
62
MultiStageScheme(std::vector<std::vector<std::shared_ptr<const Form> > > stage_forms,
63
std::shared_ptr<const Form> last_stage,
64
std::vector<std::shared_ptr<Function> > stage_solutions,
65
std::shared_ptr<Function> u,
66
std::shared_ptr<Constant> t,
67
std::shared_ptr<Constant> dt,
68
68
std::vector<double> dt_stage_offset,
69
std::vector<int> jacobian_indices,
69
70
unsigned int order,
70
71
const std::string name,
71
72
const std::string human_form,
72
73
std::vector<const DirichletBC* > bcs);
74
75
/// Return the stages
75
std::vector<std::vector<boost::shared_ptr<const Form> > >& stage_forms();
76
std::vector<std::vector<std::shared_ptr<const Form> > >& stage_forms();
77
78
/// Return the last stage
78
FunctionAXPY& last_stage();
79
std::shared_ptr<const Form> last_stage();
80
81
/// Return stage solutions
81
std::vector<boost::shared_ptr<Function> >& stage_solutions();
82
std::vector<std::shared_ptr<Function> >& stage_solutions();
83
84
/// Return solution variable
84
boost::shared_ptr<Function> solution();
85
std::shared_ptr<Function> solution();
86
87
/// Return solution variable (const version)
87
boost::shared_ptr<const Function> solution() const;
88
std::shared_ptr<const Function> solution() const;
89
90
/// Return local time
90
boost::shared_ptr<Constant> t();
91
std::shared_ptr<Constant> t();
92
93
/// Return local timestep
93
boost::shared_ptr<Constant> dt();
94
std::shared_ptr<Constant> dt();
95
96
/// Return local timestep
96
97
const std::vector<double>& dt_stage_offset() const;
116
121
void _check_arguments();
118
123
// Vector of forms for the different RK stages
119
std::vector<std::vector<boost::shared_ptr<const Form> > > _stage_forms;
124
std::vector<std::vector<std::shared_ptr<const Form> > > _stage_forms;
121
126
// A linear combination of solutions for the last stage
122
FunctionAXPY _last_stage;
127
std::shared_ptr<const Form> _last_stage;
124
129
// Solutions for the different stages
125
std::vector<boost::shared_ptr<Function> > _stage_solutions;
130
std::vector<std::shared_ptr<Function> > _stage_solutions;
128
boost::shared_ptr<Function> _u;
133
std::shared_ptr<Function> _u;
130
135
// The local time
131
boost::shared_ptr<Constant> _t;
136
std::shared_ptr<Constant> _t;
133
138
// The local time step
134
boost::shared_ptr<Constant> _dt;
139
std::shared_ptr<Constant> _dt;
136
141
// The time step offset. (c from the ButcherTableau)
137
142
std::vector<double> _dt_stage_offset;
144
// Map for distinct storage of jacobians
145
std::vector<int> _jacobian_indices;
139
147
// The order of the scheme
140
148
unsigned int _order;