7#ifndef TWOD_MAPPED_NODE_MESH_H
8#define TWOD_MAPPED_NODE_MESH_H
20 template <
typename _Type>
28 virtual double FnComp_X(
const double& zeta)
const {
30 problem =
"The TwoD_Mapped_Node_Mesh::FnComp_X method has not been implemented.\n";
31 problem +=
"You have to implement this method to define the mesh.\n";
39 virtual double FnComp_Xd(
const double& zeta)
const {
41 problem =
"The TwoD_Mapped_Node_Mesh::FnComp_Xd method has not been implemented.\n";
42 problem +=
"You have to implement this method to define the mesh.\n";
52 problem =
"The TwoD_Mapped_Node_Mesh::FnComp_Xdd method has not been implemented.\n";
53 problem +=
"You have to implement this method to define the mesh.\n";
61 virtual double FnComp_Y(
const double& eta)
const {
63 problem =
"The TwoD_Mapped_Node_Mesh::FnComp_Y method has not been implemented.\n";
64 problem +=
"You have to implement this method to define the mesh.\n";
74 problem =
"The TwoD_Mapped_Node_Mesh::FnComp_Yd method has not been implemented.\n";
75 problem +=
"You have to implement this method to define the mesh.\n";
85 problem =
"The TwoD_Mapped_Node_Mesh::FnComp_Ydd method has not been implemented.\n";
86 problem +=
"You have to implement this method to define the mesh.\n";
94 TwoD_Mapped_Node_Mesh(
const double left,
const double right,
const double bottom,
const double top,
const std::size_t nx,
const std::size_t ny,
const std::size_t nvars) :
m_left(left),
m_right(right),
m_bottom(bottom),
m_top(top),
m_nx(nx),
m_ny(ny),
m_nv(nvars) {
96 std::cout <<
"[DEBUG] making a blank TwoD_Mapped_Node_Mesh\n";
97 std::cout <<
"[DEBUG] a " << nx <<
" by " << ny <<
" mesh with " << nvars <<
" variables.\n";
108 std::cout <<
"[DEBUG] leaving the TwoD_Mapped_Node_Mesh ctor.\n";
124 read(filename,
true);
156 _Type&
operator()(
const std::size_t nodex,
const std::size_t nodey,
const std::size_t var);
162 const _Type&
operator()(
const std::size_t nodex,
const std::size_t nodey,
const std::size_t var)
const;
168 std::pair<double, double>
coord(
const std::size_t nodex,
const std::size_t nodey)
const;
184 std::pair< std::size_t, std::size_t >
get_nnodes()
const;
212 void read(std::string filename,
const bool reset =
false);
234 double max(
unsigned var) {
237 for(
unsigned nodex = 0; nodex <
m_nx; ++nodex) {
238 for(
unsigned nodey = 0; nodey <
m_ny; ++nodey) {
255 const double tol(1.e-8);
259 problem =
" The TwoD_Node_Mesh.get_interpolated_vars method has been called with \n";
260 problem +=
" an x coordinate that lies outside the mesh. \n";
266 problem =
" The TwoD_Node_Mesh.get_interpolated_vars method has been called with \n";
267 problem +=
" a y coordinate that lies outside the mesh. \n";
271 for (
unsigned j = 0; j <
m_ny-1; ++j) {
272 if ((compY >=
m_compY[j] - tol) && (compY <=
m_compY[j+1] + tol)) {
276 if (bottom_j == -1) {
278 problem =
" The TwoD_Node_Mesh.get_interpolated_vars method is broken.\n";
284 for (std::size_t i = 0; i <
m_nx; ++i ) {
288 const double compY1 =
m_compY[ bottom_j ];
289 const double compY2 =
m_compY[ bottom_j+1 ];
318 template <
typename _Type>
321 if(nodex > m_nx - 1 || nodey > m_ny - 1) {
323 problem =
" The TwoD_Mapped_Node_Mesh.operator() method is trying to \n";
324 problem +=
" access a nodal point that is not in the mesh. \n";
328 return get_nodes_vars(nodex,nodey);
332 template <
typename _Type>
335 if(nodex > m_nx - 1 || nodey > m_ny - 1) {
337 problem =
" The TwoD_Mapped_Node_Mesh.operator() method is trying to \n";
338 problem +=
" access a nodal point that is not in the mesh. \n";
343 problem =
" The TwoD_Mapped_Node_Mesh.operator() method is trying to \n";
344 problem +=
" access a variable index that is not in the mesh. \n";
348 return m_vars[(nodex * m_ny + nodey) * m_nv + var ];
351 template <
typename _Type>
354 if(nodex > m_nx - 1 || nodey > m_ny - 1) {
356 problem =
" The TwoD_Mapped_Node_Mesh.operator() method is trying to \n";
357 problem +=
" access a nodal point that is not in the mesh. \n";
362 problem =
" The TwoD_Mapped_Node_Mesh.operator() method is trying to \n";
363 problem +=
" access a variable index that is not in the mesh. \n";
367 return m_vars[(nodex * m_ny + nodey) * m_nv + var ];
370 template <
typename _Type>
373 if(nodex > m_nx - 1 || nodey > m_ny - 1) {
375 problem =
" The TwoD_Mapped_Node_Mesh.coord method is trying to \n";
376 problem +=
" access a nodal point that is not in the mesh. \n";
380 std::pair< double, double > pos;
381 pos.first = m_X[ nodex ];
382 pos.second = m_Y[ nodey ];
Specification for a templated DenseVector class – a dense, dynamic, vector object.
A specification for a one dimensional mesh object.
An DenseVector class – a dense vector object.
An exception to indicate that a CppNoddy container has been accessed with index/indices outside the m...
A generic runtime exception.
A one dimensional mesh utility object.
DenseVector< _Type > get_interpolated_vars(const _Xtype &pos) const
Get the variable data at an interpolated position using a first order scheme.
void set_nodes_vars(const std::size_t node, const DenseVector< _Type > &u)
Set the variables stored at A SPECIFIED node.
A two dimensional (mapped) mesh utility object.
virtual double FnComp_X(const double &zeta) const
Mapping function that provides a computational X coordinate from a physical coordinate.
DenseVector< _Type > get_interpolated_vars(const double &x, const double &y)
Get a bilinearly interpolated value at a specified point.
void read(std::string filename, const bool reset=false)
A simple method for reading data from a file.
DenseVector< _Type > get_nodes_vars(const std::size_t nodex, const std::size_t nodey) const
Get the variables stored at A SPECIFIED node – equivalent to mesh(nodex,nodey).
DenseVector< double > m_compY
DenseVector< double > & xnodes()
Access the vector of x-nodal positions.
std::pair< double, double > get_comp_step_sizes() const
void init_mapping()
Sometimes a useful mapping is painful to invert analytically.
virtual double FnComp_Ydd(const double &eta) const
Mapping function that provides the second derivative of the computational Y coordinate as a function ...
OneD_Node_Mesh< _Type > get_xsection_at_xnode(const std::size_t nodex) const
Get a cross section of the 2D mesh at a specified (constant) x node.
double max(unsigned var)
Find the maximum stored absolute value in the mesh for a given variable – no interpolation is used.
void set_nodes_vars(const std::size_t nodex, const std::size_t nodey, const DenseVector< _Type > &U)
Set the variables stored at A SPECIFIED node.
void scale(const _Type &value)
Rescale all values stored in the mapped mesh by a scalar.
std::pair< std::size_t, std::size_t > get_nnodes() const
Get the number of nodes in the two directions of the 2D mesh.
void normalise(const std::size_t &var)
Normalise all data in the mesh based on one variable.
DenseVector< double > & ynodes()
Access the vector of y-nodal positions.
virtual double FnComp_Yd(const double &eta) const
Mapping function that provides the first derivative of the computational Y coordinate as a function o...
virtual double FnComp_Xdd(const double &zeta) const
Mapping function that provides the second derivative of the computational X coordinate as a function ...
DenseVector< _Type > m_vars
TwoD_Mapped_Node_Mesh(std::string filename, const std::size_t nx, const std::size_t ny, const std::size_t nv)
DenseVector< _Type > operator()(const std::size_t nodex, const std::size_t nodey)
Access operator for a nodal point that returns a vector.
std::size_t get_nvars() const
Get the number of variables that are stored at each node.
virtual double FnComp_Y(const double &eta) const
Mapping function that provides the computational Y coordinate as a function of the physical coordinat...
TwoD_Mapped_Node_Mesh(const double left, const double right, const double bottom, const double top, const std::size_t nx, const std::size_t ny, const std::size_t nvars)
ctor of a blank mesh
virtual double FnComp_Xd(const double &zeta) const
Mapping function that provides the first derivative of the computational m_X coordinate as a function...
void dump_gnu(std::string filename) const
A simple method for dumping data to a file for gnuplot surface plotting.
DenseVector< double > m_Y
std::pair< double, double > coord(const std::size_t nodex, const std::size_t nodey) const
Access the physical nodal position - as a pair.
DenseVector< double > m_compX
OneD_Node_Mesh< _Type > get_xsection_at_ynode(const std::size_t nodey) const
Get a cross section of the 2D mesh at a specified (constant) y node.
virtual ~TwoD_Mapped_Node_Mesh()
dtor
DenseVector< double > m_X
A collection of OO numerical routines aimed at simple (typical) applied problems in continuum mechani...