Loading...
Searching...
No Matches
MultiStageScheme.h
// Copyright (C) 2013 Johan Hake
//
// This file is part of DOLFIN.
//
// DOLFIN is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// DOLFIN is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
//
// First added: 2013-02-15
// Last changed: 2014-03-05
#ifndef __BUTCHERSCHEME_H
#define __BUTCHERSCHEME_H
#include <memory>
#include <vector>
#include <dolfin/common/Variable.h>
#include <dolfin/function/Function.h>
#include <dolfin/fem/Form.h>
namespace dolfin
{
// Forward declarations
class Form;
class Function;
class DirichletBC;
class Constant;
class MultiStageScheme : public Variable
{
public:
MultiStageScheme(std::vector<std::vector<std::shared_ptr<const Form>>> stage_forms,
std::shared_ptr<const Form> last_stage,
std::vector<std::shared_ptr<Function> > stage_solutions,
std::shared_ptr<Function> u,
std::shared_ptr<Constant> t,
std::shared_ptr<Constant> dt,
std::vector<double> dt_stage_offset,
std::vector<int> jacobian_indices,
unsigned int order,
const std::string name,
const std::string human_form,
std::vector<std::shared_ptr<const DirichletBC>> bcs = {});
std::vector<std::vector<std::shared_ptr<const Form>>>& stage_forms();
std::shared_ptr<const Form> last_stage();
std::vector<std::shared_ptr<Function> >& stage_solutions();
std::shared_ptr<Function> solution();
std::shared_ptr<const Function> solution() const;
std::shared_ptr<Constant> t();
std::shared_ptr<Constant> dt();
const std::vector<double>& dt_stage_offset() const;
unsigned int order() const;
std::vector<std::shared_ptr<const DirichletBC>> bcs() const;
bool implicit(unsigned int stage) const;
bool implicit() const;
int jacobian_index(unsigned int stage) const;
virtual std::string str(bool verbose) const;
private:
// Check sanity of arguments
void _check_arguments();
// Vector of forms for the different RK stages
std::vector<std::vector<std::shared_ptr<const Form>>> _stage_forms;
// A linear combination of solutions for the last stage
std::shared_ptr<const Form> _last_stage;
// Solutions for the different stages
std::vector<std::shared_ptr<Function>> _stage_solutions;
// The solution
std::shared_ptr<Function> _u;
// The local time
std::shared_ptr<Constant> _t;
// The local time step
std::shared_ptr<Constant> _dt;
// The time step offset. (c from the ButcherTableau)
std::vector<double> _dt_stage_offset;
// Map for distinct storage of jacobians
std::vector<int> _jacobian_indices;
// The order of the scheme
unsigned int _order;
// Is the scheme implicit
bool _implicit;
// A pretty print representation of the form
std::string _human_form;
// The boundary conditions
std::vector<std::shared_ptr<const DirichletBC>> _bcs;
};
}
#endif
dolfin::Constant
This class represents a constant-valued expression.
Definition Constant.h:36
dolfin::DirichletBC
Interface for setting (strong) Dirichlet boundary conditions.
Definition DirichletBC.h:125
dolfin::Form
Base class for UFC code generated by FFC for DOLFIN with option -l.
Definition Form.h:86
dolfin::Function
Definition Function.h:66
dolfin::MultiStageScheme::dt_stage_offset
const std::vector< double > & dt_stage_offset() const
Return local timestep.
Definition MultiStageScheme.cpp:89
dolfin::MultiStageScheme::dt
std::shared_ptr< Constant > dt()
Return local timestep.
Definition MultiStageScheme.cpp:84
dolfin::MultiStageScheme::jacobian_index
int jacobian_index(unsigned int stage) const
Definition MultiStageScheme.cpp:123
dolfin::MultiStageScheme::t
std::shared_ptr< Constant > t()
Return local time.
Definition MultiStageScheme.cpp:79
dolfin::MultiStageScheme::order
unsigned int order() const
Return the order of the scheme.
Definition MultiStageScheme.cpp:94
dolfin::MultiStageScheme::solution
std::shared_ptr< Function > solution()
Return solution variable.
Definition MultiStageScheme.cpp:69
dolfin::MultiStageScheme::last_stage
std::shared_ptr< const Form > last_stage()
Return the last stage.
Definition MultiStageScheme.cpp:59
dolfin::MultiStageScheme::MultiStageScheme
MultiStageScheme(std::vector< std::vector< std::shared_ptr< const Form > > > stage_forms, std::shared_ptr< const Form > last_stage, std::vector< std::shared_ptr< Function > > stage_solutions, std::shared_ptr< Function > u, std::shared_ptr< Constant > t, std::shared_ptr< Constant > dt, std::vector< double > dt_stage_offset, std::vector< int > jacobian_indices, unsigned int order, const std::string name, const std::string human_form, std::vector< std::shared_ptr< const DirichletBC > > bcs={})
Constructor.
Definition MultiStageScheme.cpp:32
dolfin::MultiStageScheme::stage_forms
std::vector< std::vector< std::shared_ptr< const Form > > > & stage_forms()
Return the stages.
Definition MultiStageScheme.cpp:54
dolfin::MultiStageScheme::stage_solutions
std::vector< std::shared_ptr< Function > > & stage_solutions()
Return stage solutions.
Definition MultiStageScheme.cpp:64
dolfin::MultiStageScheme::bcs
std::vector< std::shared_ptr< const DirichletBC > > bcs() const
Return boundary conditions.
Definition MultiStageScheme.cpp:99
dolfin::MultiStageScheme::str
virtual std::string str(bool verbose) const
Return informal string representation (pretty-print).
Definition MultiStageScheme.cpp:136
dolfin::MultiStageScheme::implicit
bool implicit() const
Return true if the whole scheme is implicit.
Definition MultiStageScheme.cpp:118
dolfin::Variable::name
std::string name() const
Return name.
Definition Variable.cpp:71
dolfin::Variable::Variable
Variable()
Create unnamed variable.
Definition Variable.cpp:31
dolfin
Definition adapt.h:30