CppNoddy  0.92
Loading...
Searching...
No Matches
PDE_IBVP.h
Go to the documentation of this file.
1/// \file PDE_IBVP.h
2/// A specification of a class for an \f$ n^{th} \f$-order IBVP of the form
3/// \f[ M_1( {\underline f}(y,t), y, t )\cdot {\underline f}_t (y,t)+ M_0( {\underline f}(y,t), y, t ) \cdot {\underline f}_y (y,t) = {\underline R}( {\underline f}(y,t), y, t )\,, \f]
4/// subject to \f$ n \f$ conditions defined at \f$ y = y_{left} \f$ and
5/// \f$ y_{right} \f$ for some components of \f$ {\underline f}(y) \f$.
6/// Here \f$ M_{0,1} \f$ are matrices.
7/// The solution at the new time step \f$ t+\Delta t \f$ is
8/// \f[ {\underline f}^{new} = {\underline F} + {\underline g} \f]
9/// where \f$ {\underline F} \f$ is the current guess at the solution
10/// and \f$ {\underline g} \f$ is the linearised correction.
11/// The solution at the previous time \f$ t \f$ is
12/// \f[ {\underline f}^{old} = {\underline O} \f]
13/// A Crank-Nicolson method is employed with the linearised problem at the mid-time point
14/// \f$ t + \Delta t /2 \f$ being:
15/// \f[ \frac{2}{\Delta t} M_1 \cdot {\underline g } + 2 M_0 \cdot {\underline g}_y - J \cdot {\underline g} + J_2 \cdot \frac{\underline F - \underline O}{\Delta t} \cdot {\underline g} + J_1 \cdot \frac{\underline F_y + \underline O_y}{2} \cdot {\underline g} = 2 {\underline R} - \frac{2}{\Delta t} M_2 \cdot ( {\underline F} - {\underline O} ) - M_1 \cdot ( {\underline F}_y + {\underline O}_y )\f]
16/// Where \f$ M_{0,1}, J, J_{1,2}, R \f$ are evaluated at the mid-time step with arguments \f$ \left ( \frac{\underline F + \underline O}{2}, y, t + \frac{\Delta t}{2} \right ) \f$,
17/// with \f$ J_{1,2} \f$ denoting the Jacobian of the matrices \f$ \partial {(M_{0,1})}_{ij} / \partial f_k \f$.
18/// This problem is solved by second-order central differencing at the spatial (\f$ y \f$) inter-node mid points.
19
20#ifndef PDE_IBVP_H
21#define PDE_IBVP_H
22
23#include <DenseVector.h>
24#include <DenseMatrix.h>
25#include <Equation_2matrix.h>
27#include <OneD_Node_Mesh.h>
28#include <Uncopyable.h>
29#include <Timer.h>
30
31namespace CppNoddy {
32
33 /// A templated object for real/complex vector system
34 /// of unsteady equations.
35
36 template <typename _Type>
37 class PDE_IBVP : private Uncopyable {
38 public:
39
40 /// The class is defined by a vector function for the system.
41 /// \param equation_ptr A pointer to an inherited Equation object.
42 /// \param nodes A vector that defines the nodal positions.
43 /// \param ptr_to_left_residual A pointer to a residual object that defines the LHS boundary conditions.
44 /// \param ptr_to_right_residual A pointer to a residual object that defines the RHS boundary conditions.
46 const DenseVector<double>& nodes,
47 Residual_with_coords<_Type>* ptr_to_left_residual,
48 Residual_with_coords<_Type>* ptr_to_right_residual);
49
50 /// Destructor
51 ~PDE_IBVP();
52
53 /// A Crank-Nicolson 'time' stepper.
54 void step2(const double& dt);
55
56 /// Assembles the matrix problem for a BVP solve at the
57 /// current time level.
58 /// \param a The LHS (banded) matrix.
59 /// \param b The RHS (dense) vector.
60 /// \param dt The 'time step' to be taken.
62
63 /// Return a reference to the current value of the 'timelike/parabolic' coordinate
64 /// \return A handle to the current time stored in the object
65 double& coord() {
66 return T;
67 }
68
69 /// \return A handle to the solution mesh
71
72 /// \return A handle to the previous step's solution mesh
74
75 /// Access method to the tolerance
76 /// \return A handle to the private member data TOL
77 double& tolerance() {
78 return TOL;
79 }
80
81 /// Access method to the maximum number of iterations
82 /// \return A handle to the private member data MAX_ITERATIONS
83 int& max_itns() {
84 return MAX_ITERATIONS;
85 }
86
88 return p_EQUATION;
89 }
90
92 return p_LEFT_RESIDUAL;
93 }
94
96 return p_RIGHT_RESIDUAL;
97 }
98
99 private:
100 /// The solution at the current time level
102 /// The solution at the previous time step
103 OneD_Node_Mesh<_Type> PREV_SOLN;
104 /// tolerance
105 double TOL;
106 /// The current value of the timelike variable
107 double T;
108 /// maximum number of iterations
109 int MAX_ITERATIONS;
110 /// The function associated with this instance.
111 Equation_2matrix<_Type > *p_EQUATION;
112 /// Pointer to the residual defining the LHS BC
113 Residual_with_coords<_Type > *p_LEFT_RESIDUAL;
114 /// Pointer to the residual defining the RHS BC
115 Residual_with_coords<_Type > *p_RIGHT_RESIDUAL;
116
117#ifdef TIME
118 /// Timers for debug use
119 Timer T_ASSEMBLE;
120 Timer T_SOLVE;
121#endif
122
123 }
124 ; // end class
125
126 template <typename _Type>
128 return SOLN;
129 }
130
131 template <typename _Type>
133 return PREV_SOLN;
134 }
135
136} // end namespace
137
138#endif
139
A matrix class that constructs a DENSE matrix as an STL Vector of DenseVectors.
Specification for a templated DenseVector class – a dense, dynamic, vector object.
A templated class for equations that can be inherited from to allow instantiation of PDE_double_IBVP ...
A specification for a one dimensional mesh object.
A specification of a (double/complex) residual class that not only defines a vector residual of a vec...
A spec for the CppNoddy Timer object.
A matrix class that constructs a BANDED matrix.
Definition: BandedMatrix.h:16
An DenseVector class – a dense vector object.
Definition: DenseVector.h:34
An equation object base class used in the PDE_double_IBVP class.
A one dimensional mesh utility object.
A templated object for real/complex vector system of unsteady equations.
Definition: PDE_IBVP.h:37
void step2(const double &dt)
A Crank-Nicolson 'time' stepper.
Definition: PDE_IBVP.cpp:72
OneD_Node_Mesh< _Type > & solution()
Definition: PDE_IBVP.h:127
double & coord()
Return a reference to the current value of the 'timelike/parabolic' coordinate.
Definition: PDE_IBVP.h:65
double & tolerance()
Access method to the tolerance.
Definition: PDE_IBVP.h:77
void assemble_matrix_problem(BandedMatrix< _Type > &a, DenseVector< _Type > &b, const double &dt)
Assembles the matrix problem for a BVP solve at the current time level.
Definition: PDE_IBVP.cpp:143
~PDE_IBVP()
Destructor.
Definition: PDE_IBVP.cpp:61
OneD_Node_Mesh< _Type > & previous_solution()
Definition: PDE_IBVP.h:132
Residual_with_coords< _Type > * get_p_left()
Definition: PDE_IBVP.h:91
Equation_2matrix< _Type > * get_p_equation()
Definition: PDE_IBVP.h:87
Residual_with_coords< _Type > * get_p_right()
Definition: PDE_IBVP.h:95
int & max_itns()
Access method to the maximum number of iterations.
Definition: PDE_IBVP.h:83
A base class to be inherited by objects that define residuals.
A simple CPU-clock-tick timer for timing metods.
Definition: Timer.h:19
An object to block copying.
Definition: Uncopyable.h:8
A collection of OO numerical routines aimed at simple (typical) applied problems in continuum mechani...

© 2012

R.E. Hewitt