QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
boundarycondition.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2000, 2001, 2002, 2003 RiskMap srl
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
24#ifndef quantlib_boundary_condition_hpp
25#define quantlib_boundary_condition_hpp
26
27#include <ql/utilities/null.hpp>
28#include <ql/methods/finitedifferences/tridiagonaloperator.hpp>
29
30namespace QuantLib {
31
33
34 template <class Operator>
36 public:
37 // types and enumerations
38 typedef Operator operator_type;
39 typedef typename Operator::array_type array_type;
41 enum Side { None, Upper, Lower };
42 // destructor
43 virtual ~BoundaryCondition() = default;
44 // interface
48 virtual void applyBeforeApplying(operator_type&) const = 0;
51 virtual void applyAfterApplying(array_type&) const = 0;
56 array_type& rhs) const = 0;
59 virtual void applyAfterSolving(array_type&) const = 0;
62 virtual void setTime(Time t) = 0;
63 };
64
65 // Time-independent boundary conditions for tridiagonal operators
66
68
76 class NeumannBC : public BoundaryCondition<TridiagonalOperator> {
77 public:
78 NeumannBC(Real value, Side side);
79 // interface
80 void applyBeforeApplying(TridiagonalOperator&) const override;
81 void applyAfterApplying(Array&) const override;
82 void applyBeforeSolving(TridiagonalOperator&, Array& rhs) const override;
83 void applyAfterSolving(Array&) const override;
84 void setTime(Time) override {}
85
86 private:
89 };
90
92
96 class DirichletBC : public BoundaryCondition<TridiagonalOperator> {
97 public:
98 DirichletBC(Real value, Side side);
99 // interface
100 void applyBeforeApplying(TridiagonalOperator&) const override;
101 void applyAfterApplying(Array&) const override;
102 void applyBeforeSolving(TridiagonalOperator&, Array& rhs) const override;
103 void applyAfterSolving(Array&) const override;
104 void setTime(Time) override {}
105
106 private:
109 };
110
111}
112
113
114
115
116#endif
1-D array used in linear algebra.
Definition: array.hpp:52
Abstract boundary condition class for finite difference problems.
virtual void applyAfterSolving(array_type &) const =0
virtual void applyBeforeSolving(operator_type &, array_type &rhs) const =0
virtual void applyBeforeApplying(operator_type &) const =0
Operator::array_type array_type
virtual void applyAfterApplying(array_type &) const =0
virtual ~BoundaryCondition()=default
virtual void setTime(Time t)=0
Neumann boundary condition (i.e., constant value)
void applyAfterApplying(Array &) const override
void applyBeforeApplying(TridiagonalOperator &) const override
void applyAfterSolving(Array &) const override
void applyBeforeSolving(TridiagonalOperator &, Array &rhs) const override
void setTime(Time) override
Neumann boundary condition (i.e., constant derivative)
void applyAfterApplying(Array &) const override
void applyBeforeApplying(TridiagonalOperator &) const override
void applyAfterSolving(Array &) const override
void applyBeforeSolving(TridiagonalOperator &, Array &rhs) const override
void setTime(Time) override
Base implementation for tridiagonal operator.
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
QL_REAL Real
real number
Definition: types.hpp:50
Definition: any.hpp:35