CppNoddy  0.92
Loading...
Searching...
No Matches
Equation_1matrix.h
Go to the documentation of this file.
1/// \file Equation_1matrix.h
2/// A templated class for equations that can be inherited from
3/// to allow instantiation of PDE_IBVP objects (amongst others).
4
5#ifndef EQUATION_1MATRIX_H
6#define EQUATION_1MATRIX_H
7
9
10namespace CppNoddy {
11
12 /// An equation object base class used in the IBVP classes (and others).
13 /// An equation object is essentially a ('square') residual object with an independent variable
14 /// data member and access methods. By 'square' we mean that it defines
15 /// N residuals and N state variables. The equation is defined
16 /// using an NxN matrix that multiplies the derivative of unknowns and a residual RHS.
17 template < typename _Type, typename _Xtype = double >
18 class Equation_1matrix : public Residual_with_coords<_Type, _Xtype> {
19 public:
20 /// Constructor for equation class.
21 /// \param order The order of the system
22 explicit Equation_1matrix(const unsigned &order);
23
24 /// An empty destructor, virtual since we have virtual methods.
25 virtual ~Equation_1matrix();
26
27 /// Update the Equation object for the current set of state variables
28 /// \param state The state vector at which to set the equation object
29 void update(const DenseVector<_Type> &state);
30
31 /// Return a handle to the matrix
33
34 /// Return the product of the Jacobian-of-the-matrix and a vector 'vec'
35 /// when the equation has a given 'state'. The user should overload this
36 /// if concerned about performance of the solver. If not overloaded, the
37 /// default is to finite difference the Jacobian-of-the-matrix.
38 /// \param state The current state variables -- used for clarity when
39 /// overloaded by the user instead of expecting the user to access the member data.
40 /// \param vec The vector that will be multiplied by the Jacobian-of-the-matrix
41 /// \param h The resulting 2D matrix
43 const DenseVector<_Type> &vec, DenseMatrix<_Type> &h) const;
44
45
46 protected:
47
48 /// Define the matrix in terms of the current state vector.
49 /// \param x The current state vector.
50 /// \param m The matrix.
51 virtual void matrix0(const DenseVector<_Type> &x, DenseMatrix<_Type> &m) const {
52 std::string problem;
53 problem = "The equation::matrix0 method has not been implemented!\n";
54 problem += "You have to implement this method to define the equation.\n";
55 throw ExceptionRuntime(problem);
56 }
57
58 private:
59 /// Matrix0 evaluated for the last state vector
60 DenseMatrix<_Type> MATRIX0_AT_LAST_STATE;
61
62 }
63 ; // end class
64
65 template <typename _Type, typename _Xtype>
67 return MATRIX0_AT_LAST_STATE;
68 }
69
70} // end namespace
71
72#endif
A specification of a (double/complex) residual class that not only defines a vector residual of a vec...
A matrix class that constructs a DENSE matrix as a row major std::vector of DenseVectors.
Definition: DenseMatrix.h:25
An DenseVector class – a dense vector object.
Definition: DenseVector.h:34
An equation object base class used in the IBVP classes (and others).
virtual void get_jacobian_of_matrix0_mult_vector(const DenseVector< _Type > &state, const DenseVector< _Type > &vec, DenseMatrix< _Type > &h) const
Return the product of the Jacobian-of-the-matrix and a vector 'vec' when the equation has a given 'st...
void update(const DenseVector< _Type > &state)
Update the Equation object for the current set of state variables.
virtual ~Equation_1matrix()
An empty destructor, virtual since we have virtual methods.
const DenseMatrix< _Type > & matrix0() const
Return a handle to the matrix.
virtual void matrix0(const DenseVector< _Type > &x, DenseMatrix< _Type > &m) const
Define the matrix in terms of the current state vector.
A generic runtime exception.
Definition: Exceptions.h:158
A base class to be inherited by objects that define residuals.
A collection of OO numerical routines aimed at simple (typical) applied problems in continuum mechani...

© 2012

R.E. Hewitt