24#ifndef quantlib_trbdf2_hpp
25#define quantlib_trbdf2_hpp
72 template <
class Operator>
109 template <
class Operator>
112 Array aInit(a.size());
113 for (i=0; i<a.size();i++) {
117 for (i=0; i<bcs_.size(); i++)
120 if (L_.isTimeDependent()) {
122 explicitTrapezoidalPart_ = I_ - 0.5*alpha_*dt_*L_;
124 for (i=0; i<bcs_.size(); i++)
125 bcs_[i]->applyBeforeApplying(explicitTrapezoidalPart_);
126 a = explicitTrapezoidalPart_.applyTo(a);
127 for (i=0; i<bcs_.size(); i++)
128 bcs_[i]->applyAfterApplying(a);
131 if (L_.isTimeDependent()) {
133 implicitPart_ = I_ + 0.5*alpha_*dt_*L_;
135 for (i=0; i<bcs_.size(); i++)
136 bcs_[i]->applyBeforeSolving(implicitPart_,a);
137 a = implicitPart_.solveFor(a);
138 for (i=0; i<bcs_.size(); i++)
139 bcs_[i]->applyAfterSolving(a);
143 if (L_.isTimeDependent()) {
146 for (i=0; i<bcs_.size(); i++) {
147 bcs_[i]->applyBeforeApplying(explicitBDF2PartFull_);
149 array_type b0 = explicitBDF2PartFull_.applyTo(aInit_);
150 for (i=0; i<bcs_.size(); i++)
151 bcs_[i]->applyAfterApplying(b0);
153 for (i=0; i<bcs_.size(); i++) {
154 bcs_[i]->applyBeforeApplying(explicitBDF2PartMid_);
156 array_type b1 = explicitBDF2PartMid_.applyTo(a);
157 for (i=0; i<bcs_.size(); i++)
158 bcs_[i]->applyAfterApplying(b1);
162 for (i=0; i<bcs_.size(); i++)
163 bcs_[i]->applyBeforeSolving(implicitPart_,a);
164 a = implicitPart_.solveFor(a);
165 for (i=0; i<bcs_.size(); i++)
166 bcs_[i]->applyAfterSolving(a);
1-D array used in linear algebra.
std::vector< ext::shared_ptr< bc_type > > bc_set
Operator::array_type array_type
condition to be applied at every time step
TR-BDF2 scheme for finite difference methods.
traits::operator_type operator_type
operator_type explicitBDF2PartFull_
operator_type explicitBDF2PartMid_
operator_type explicitTrapezoidalPart_
TRBDF2(const operator_type &L, const bc_set &bcs)
operator_type implicitPart_
traits::condition_type condition_type
OperatorTraits< Operator > traits
traits::array_type array_type
void step(array_type &a, Time t)
generic finite difference model
Real Time
continuous quantity with 1-year units
std::size_t Size
size of a container