4#ifndef ONED_NODE_MESH_H
5#define ONED_NODE_MESH_H
23 template <
typename _Type,
typename _Xtype =
double >
39 for(
unsigned i = 1; i <
m_X.size(); ++i) {
57 template <
typename _sourceType>
64 OneD_Node_Mesh(std::string filename,
const std::size_t nnodes,
const std::size_t nvars ) :
79 _Type&
operator()(
const std::size_t i,
const std::size_t var);
85 const _Type&
operator()(
const std::size_t i,
const std::size_t var)
const;
90 const _Xtype&
coord(
const std::size_t& node)
const;
95 _Xtype&
coord(
const std::size_t& node);
134 _Type
integral2(std::size_t var = 0)
const;
145 _Type
integral4(std::size_t var = 0)
const;
159 const std::vector<DenseVector<_Type> >&
get_vars()
const;
167 void dump_gnu(std::string filename,
int precision = 10)
const;
231 for(
unsigned node = 0; node <
m_X.size(); ++node) {
232 if(std::abs(
m_vars[ node *
m_nv + var ]) > max) {
242 void read( std::string filename,
const bool reset =
false );
257 template<
typename _Type,
typename _Xtype>
258 template<
typename _sourceType>
262 m_nv = source.get_nvars();
263 m_X = source.nodes();
264 m_vars = source.vars_as_vector();
267 template <
typename _Type,
typename _Xtype >
269 return m_vars[ i * m_nv + var ];
272 template <
typename _Type,
typename _Xtype >
274 return m_vars[ i * m_nv + var ];
277 template <
typename _Type,
typename _Xtype >
282 template <
typename _Type,
typename _Xtype >
Specification for a templated DenseVector class – a dense, dynamic, vector object.
An DenseVector class – a dense vector object.
A one dimensional mesh utility object.
void normalise(const std::size_t &var)
Normalise all data in the mesh based on one variable.
OneD_Node_Mesh(std::string filename, const std::size_t nnodes, const std::size_t nvars)
ctor from an existing file
_Xtype squared_integral2(std::size_t var=0) const
Compute the integral of the absolute variable squared: |variable|^2.
std::size_t get_nvars() const
void set_vars_from_vector(const DenseVector< _Type > &vec)
Set the variables of this mesh from a vector.
const DenseVector< _Xtype > & nodes() const
void read(std::string filename, const bool reset=false)
Assign mesh contents using a filename.
DenseVector< _Type > get_nodes_vars(const std::size_t &node) const
Get the variables stored at A SPECIFIED node.
void dump() const
A simple method for dumping data to std::cout.
OneD_Node_Mesh(const DenseVector< _Xtype > &nodes, const std::size_t nvars)
ctor for a given nodal distribution
virtual ~OneD_Node_Mesh()
Destructor.
DenseVector< _Type > get_interpolated_vars(const _Xtype &pos) const
Get the variable data at an interpolated position using a first order scheme.
const _Xtype & coord(const std::size_t &node) const
Access a nodal position.
void set_nodes_vars(const std::size_t node, const DenseVector< _Type > &u)
Set the variables stored at A SPECIFIED node.
OneD_Node_Mesh()
Default constructor.
_Type & operator()(const std::size_t i, const std::size_t var)
Access a variable at a node.
double max_abs(unsigned var)
Find the maximum stored absolute value in the mesh for a given variable in a range of the domain.
const DenseVector< _Type > & vars_as_vector() const
For each nodal point we push each variable into a vector in sequence.
const std::vector< DenseVector< _Type > > & get_vars() const
std::size_t get_nnodes() const
_Xtype & coord(const std::size_t &node)
Access a nodal position.
void scale(_Type x)
Scale the whole contents of the mesh.
DenseVector< _Type > m_vars
_Type integral4(std::size_t var=0) const
Integrate over the domain with a Simpson rule.
DenseVector< _Xtype > m_X
OneD_Node_Mesh(const OneD_Node_Mesh< _sourceType > &source)
implicit conversion ctor for D_complex from double data
DenseVector< double > find_roots1(const std::size_t &var, double value=0.0) const
Find a list of approximate locations at which a specified variable attains a given value.
_Type integral2(std::size_t var=0) const
Integrate over the domain.
void remesh1(const DenseVector< _Xtype > &z)
Interpolate this mesh data (linearly) into a new mesh with nodal points defined in the argument list.
const _Type & operator()(const std::size_t i, const std::size_t var) const
Access a variable at a node.
void dump_gnu(std::string filename, int precision=10) const
A simple method for dumping data to a file for gnuplot.
A collection of OO numerical routines aimed at simple (typical) applied problems in continuum mechani...