CppNoddy  0.92
Loading...
Searching...
No Matches
Residual_with_coords.h
Go to the documentation of this file.
1/// \file Residual_with_coords.h
2/// A specification of a (double/complex) residual class that
3/// not only defines a vector residual of a vector of state variables
4/// but may also depend upon N additional (double) variables. This is
5/// useful for the specification of boundary conditions in the PDE_IBVP
6/// and PDE_double_IBVP classes where the boundary conditions are
7/// dependent on the time/spatial location.
8
9#ifndef RESIDUAL_WITH_COORDS_H
10#define RESIDUAL_WITH_COORDS_H
11
12#include <Residual.h>
13#include <DenseVector.h>
14#include <DenseMatrix.h>
15
16namespace CppNoddy {
17 /// A base class to be inherited by objects that define residuals
18 template < typename _Type, typename _Xtype = double >
19 class Residual_with_coords : public Residual<_Type> {
20 public:
21 /// Constructor for a 'square' residual object
22 /// that is, N residuals for N unknowns.
23 /// \param order The order of the residual vector
24 /// \param ncoords The number of coordinates to store
25 Residual_with_coords(const unsigned& order, const unsigned& ncoords);
26
27 /// Constructor for a 'non-square' residual object
28 /// that is, there are less residual constraints than unknowns.
29 /// \param order The number of residuals
30 /// \param nvars The number of unknowns/variables
31 /// \param ncoords The number of coordinates to store
32 Residual_with_coords(const unsigned& order, const unsigned& nvars, const unsigned& ncoords);
33
34 /// An empty destructor
35 virtual ~Residual_with_coords();
36
37 /// General handle access to the coordinates
38 /// \return A handle to the i-th coordinate
39 _Xtype& coord(const unsigned& i);
40
41 /// General handle access to the coordinates
42 /// \return A handle to the i-th coordinate
43 const _Xtype& coord(const unsigned& i) const;
44
45 protected:
46
47 /// The coordinates stored for this residual
48 std::vector<_Xtype> coords;
49
50 }
51 ; // end class
52
53 template <typename _Type, typename _Xtype>
54 inline _Xtype& Residual_with_coords<_Type, _Xtype>::coord(const unsigned& i) {
55#ifdef PARANOID
56 /// \todo check range on coord
57#endif
58 return coords[ i ];
59 }
60
61 template <typename _Type, typename _Xtype>
62 inline const _Xtype& Residual_with_coords<_Type, _Xtype>::coord(const unsigned& i) const {
63#ifdef PARANOID
64#endif
65 return coords[ i ];
66 }
67
68} // end namespace
69
70#endif
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 specification of a (double/complex) VECTOR residual class.
A base class to be inherited by objects that define residuals.
const _Xtype & coord(const unsigned &i) const
General handle access to the coordinates.
virtual ~Residual_with_coords()
An empty destructor.
std::vector< _Xtype > coords
The coordinates stored for this residual.
_Xtype & coord(const unsigned &i)
General handle access to the coordinates.
A base class to be inherited by objects that define residuals.
Definition: Residual.h:15
A collection of OO numerical routines aimed at simple (typical) applied problems in continuum mechani...

© 2012

R.E. Hewitt