CppNoddy  0.92
Loading...
Searching...
No Matches
PDE_double_IBVP.h
Go to the documentation of this file.
1/// \file PDE_double_IBVP.h
2/// A specification of a class for an \f$ n^{th} \f$-order IBVP of the form
3/// \f[ M_2( {\underline f}(y,x,t), y, x, t )\cdot {\underline f}_x (y,x,t) + M_1( {\underline f}(y,x,t), y,x, t )\cdot {\underline f}_t (y,x,t) + M_0( {\underline f}(y,x,t), y,x, t )\cdot {\underline f}_y (y,x,t) = {\underline R}( {\underline f}(y,x,t), y,x, t )\,, \f]
4/// subject to \f$ n \f$ conditions defined at \f$ y = y_{bottom} \f$ and
5/// \f$ y_{top} \f$ for some components of \f$ {\underline f}(y,x,t) \f$.
6/// Here \f$ M_2 \f$ is a matrix for the x-variation and \f$ M_1 \f$ is the mass
7/// matrix for the t-variation, whilst \f$ M_0 \f$ is not restricted to be an identity matrix (though it often will be).
8/// The solution at the new time step \f$ t+\Delta t \f$ and spatial location \f$ x = x_j \f$ is
9/// \f[ {\underline f}^{new} = {\underline F}_{j} + {\underline g} \f]
10/// where \f$ {\underline F}_{j} \f$ is the current guess at the solution at this point
11/// and \f$ {\underline g} \f$ is the linearised correction.
12/// The solution at the previous time \f$ t \f$ at \f$ x = x_{j} \f$ is
13/// \f[ {\underline f}^{old} = {\underline O}_{j} \f]
14/// A Crank-Nicolson method is employed with the linearised problem at the mid-t-point
15/// \f$ t + \Delta t /2 \f$ and mid-x-point \f$ ( x_{j+1} + x_{j} ) / 2 \f$ being:
16/// \f[ \frac{2}{x_{j+1} - x_{j}}\, M_2 \cdot {\underline g } + \frac{2}{\Delta t}\, M_1 \cdot {\underline g } + M_0 \cdot {\underline g}_y - J \cdot {\underline g} \f]
17/// \f[ + J_{2} \cdot \frac{ ( \underline F_{j+1} + \underline O_{j+1} - \underline F_j - \underline O_j) }{ 2(x_{j+1} - x_j) } \cdot {\underline g} \f]
18/// \f[ + J_{1} \cdot \frac{(\underline F_{j+1} + \underline F_j - \underline O_j - \underline O_{j+1})}{2\Delta t} \cdot {\underline g} \f]
19/// \f[ + J_{0} \cdot \frac{( \underline F_{j+1} + \underline F_j + \underline O_j + \underline O_{j+1})_y}{4} \cdot {\underline g} \f]
20/// \f[ = 4 {\underline R} - M_0 \cdot \biggl ({\underline F_j}_y + {\underline O_j}_y + {\underline F_{j+1}}_y + {\underline O_{j+1}}_y \biggr ) - \frac{2}{x_{j+1}-x_j} M_1 \cdot \biggl ( {\underline F}_{j+1} + {\underline O}_{j+1} - {\underline F}_{j} - {\underline O}_{j} \biggr ) - \frac{2}{\Delta t} M_2 \cdot \biggl ( {\underline F}_{j+1} + {\underline F}_{j} - {\underline O}_{j+1} - {\underline O}_{j} \biggr ) \f]
21/// Where \f$ M_{0,1,2}, J, J_{0,1,2}, R \f$ are evaluated at the mid-t/mid-x step with arguments \f$ \left ( \frac{\underline F_{j} + \underline O_{j} + \underline F_{j+1} + \underline O_{j+1} }{4}, y, ( x_{j+1} + x_{j} ) / 2, t + \frac{\Delta t}{2} \right ) \f$,
22/// with \f$ J_{0,1,2} \f$ denoting the Jacobian of the mass matrices \f$ \partial {M_{0,1,2}}_{ij} / \partial f_k \f$.
23/// This problem is solved by second-order central differencing the equation at
24/// the spatial (\f$ y \f$) inter-node mid points.
25
26#ifndef PDE_DOUBLE_IBVP_H
27#define PDE_DOUBLE_IBVP_H
28
29#include <DenseVector.h>
30#include <DenseMatrix.h>
31#include <BandedMatrix.h>
32#include <Equation_3matrix.h>
34#include <TwoD_Node_Mesh.h>
35#include <Uncopyable.h>
36#include <Timer.h>
37
38namespace CppNoddy {
39
40 /// A templated object for real/complex vector system
41 /// of unsteady equations.
42
43 template <typename _Type>
44 class PDE_double_IBVP : private Uncopyable {
45 public:
46
47 /// The class is defined by a vector function for the system.
48 /// \param equation_ptr A pointer to an inherited Equation object.
49 /// \param xnodes A vector that defines the nodal x-positions.
50 /// \param ynodes A vector that defines the nodal y-positions.
51 /// \param ptr_to_bottom_residual A pointer to a residual object that defines the y=y1 boundary conditions.
52 /// \param ptr_to_top_residual A pointer to a residual object that defines the y=y2 boundary conditions.
54 const DenseVector<double>& xnodes,
55 const DenseVector<double>& ynodes,
56 Residual_with_coords<_Type>* ptr_to_bottom_residual,
57 Residual_with_coords<_Type>* ptr_to_top_residual);
58
59 /// Destructor
61
62 /// Copy the current solution to the previous solution
64 PREV_SOLN = SOLN;
65 UPDATED = true;
66 }
67
68 /// A Crank-Nicolson 'time' stepper.
69 void step2(const double& dt);
70
71 /// Return a reference to the current value of the 'timelike' coordinate
72 /// \return A handle to the current timelinke coordinate stored in the object
73 double& t();
74
75 /// Return a reference to the convergence tolerance
76 double& tolerance() {
77 return TOL;
78 }
79
80 /// \return A handle to the solution mesh
82
83 private:
84
85 /// Assembles the matrix problem for a BVP solve at the current time level
86 /// and for the j+1 x-location.
87 /// \param a The LHS (banded) matrix.
88 /// \param b The RHS (dense) vector.
89 /// \param j The index of the last x-position for which a solution is known.
90 void assemble_matrix_problem(BandedMatrix<_Type>& a, DenseVector<_Type>& b, const std::size_t& j);
91
92 /// The solution mesh at the current time value
94 /// The solution at the previous time step
95 TwoD_Node_Mesh<_Type> PREV_SOLN;
96 /// tolerance
97 double TOL;
98 /// The current value of the timelike variable
99 double T;
100 /// (uniform) temporal step size
101 double DT;
102 /// maximum number of iterations
103 int MAX_ITERATIONS;
104 /// The function associated with this instance.
105 Equation_3matrix<_Type > *p_EQUATION;
106 /// Pointer to the residual defining the 'bottom' BC
107 Residual_with_coords<_Type > *p_BOTTOM_RESIDUAL;
108 /// Pointer to the residual defining the 'top' BC
109 Residual_with_coords<_Type > *p_TOP_RESIDUAL;
110 /// A flag to make sure the update has been done
111 bool UPDATED;
112
113#ifdef TIME
114 /// Timers for debug use
115 Timer T_ASSEMBLE;
116 Timer T_SOLVE;
117#endif
118
119 }
120 ; // end class
121
122 template <typename _Type>
124 return SOLN;
125 }
126
127 template <typename _Type>
128 inline double& PDE_double_IBVP<_Type>::t() {
129 return T;
130 }
131
132} // end namespace
133
134#endif
135
A matrix class that constructs a BANDED matrix.
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 of a (double/complex) residual class that not only defines a vector residual of a vec...
A spec for the CppNoddy Timer object.
A specification for a two dimensional mesh 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 templated object for real/complex vector system of unsteady equations.
void update_previous_solution()
Copy the current solution to the previous solution.
double & t()
Return a reference to the current value of the 'timelike' coordinate.
void step2(const double &dt)
A Crank-Nicolson 'time' stepper.
double & tolerance()
Return a reference to the convergence tolerance.
TwoD_Node_Mesh< _Type > & solution()
A base class to be inherited by objects that define residuals.
A simple CPU-clock-tick timer for timing metods.
Definition: Timer.h:19
A two dimensional mesh utility object.
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