CppNoddy  0.92
Loading...
Searching...
No Matches
Equation_3matrix.cpp
Go to the documentation of this file.
1/// \file Equation_3matrix.cpp
2/// Implementation for an equations class that can be inherited from
3/// to allow instantiation of ODE objects using the resulting class.
4
5#include <Equation_3matrix.h>
7#include <Utility.h>
8
9namespace CppNoddy {
10
11 template <typename _Type, typename _Xtype>
13 Equation_2matrix<_Type, _Xtype>(order) {
14 // initialise the container for the extra matrix
15 MATRIX2_AT_LAST_STATE = DenseMatrix<_Type>(order, order, 0.0);
16 // add an extra coordinate to the vector stored in the residual_with_coords baseclass
18 }
19
20 template <typename _Type, typename _Xtype>
22 // timer reporting is done via the Equation (base) class
23 }
24
25 template <typename _Type, typename _Xtype>
27 // call the base class's update method
29 // this has to go after the base class update - otherwise we'll be
30 // resuming the timer twice in a row
31#ifdef TIME
32 this -> T_UPDATER.start();
33#endif
34 // now deal with the additional matrix separately
35 matrix2(state, MATRIX2_AT_LAST_STATE);
36#ifdef TIME
37 this -> T_UPDATER.stop();
38#endif
39 }
40
41 template <typename _Type, typename _Xtype>
43 // we dont need state in the default implementation as its already been set by the update method. You do need it for the user
44 // to overload this method with an explicit analytical version however.
45 //
46 // copy some items for FD computation of Jacobian of mass matrix
47 DenseVector<_Type> copy_of_state(this -> LAST_STATE);
48 DenseMatrix<_Type> copy_of_matrix(MATRIX2_AT_LAST_STATE);
49 std::vector< DenseMatrix<_Type> > jacmatrix;
50 // update the Jacobian of the mass matrix
51 for(std::size_t i = 0; i < this -> ORDER_OF_SYSTEM; ++i) {
52 copy_of_state[ i ] += this -> DELTA;
53 matrix2(copy_of_state, copy_of_matrix);
54 copy_of_state[ i ] -= this -> DELTA;
55 copy_of_matrix.sub(MATRIX2_AT_LAST_STATE);
56 copy_of_matrix.scale(1. / this -> DELTA);
57 // the 3D object that represents the Jacobian of the mass matrix
58 jacmatrix.push_back(copy_of_matrix);
59 }
60 // evaluate the jacabian of mass contribution
61 for(unsigned i = 0; i < this -> ORDER_OF_SYSTEM; ++i) {
62 for(unsigned j = 0; j < this -> ORDER_OF_SYSTEM; ++j) {
63 h(i, j) = Utility::dot(jacmatrix[ j ][ i ], vec);
64 }
65 }
66 }
67
68 // the required templated versions are:
69 template class Equation_3matrix<double>
70 ;
71 template class Equation_3matrix<std::complex<double> >
72 ;
73 template class Equation_3matrix<std::complex<double>, std::complex<double> >
74 ;
75
76} // end namespace
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 a collection of utility functions.
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 PDE_double_IBVP class.
void update(const DenseVector< _Type > &state)
Update the Equation object for the current set of state variables.
virtual ~Equation_3matrix()
An empty destructor, virtual since we have virtual methods.
void update(const DenseVector< _Type > &state)
Update the Equation object for the current set of state variables.
Equation_3matrix(const unsigned &order)
Constructor for equation class.
virtual void get_jacobian_of_matrix2_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...
A base class to be inherited by objects that define residuals.
_Type dot(const DenseVector< _Type > &X, const DenseVector< _Type > &Y)
Templated dot product.
Definition: Utility.h:314
A collection of OO numerical routines aimed at simple (typical) applied problems in continuum mechani...

© 2012

R.E. Hewitt