Page MenuHomec4science

uniform_mesh1d.hpp
No OneTemporary

File Metadata

Created
Thu, Nov 14, 02:54

uniform_mesh1d.hpp

/*-------------------------------------------------------
- Module : reactmicp/meshes
- File : uniform_mesh1d
- Author : Fabien Georget
Copyright (c) 2014, Fabien Georget, Princeton University
---------------------------------------------------------*/
#ifndef SPECMICP_REACTMICP_MESH_UNIFORMMESH1D_HPP
#define SPECMICP_REACTMICP_MESH_UNIFORMMESH1D_HPP
#include "mesh1d.hpp"
// \file uniform_mesh1d.hpp Uniform 1D mesh
namespace specmicp {
namespace mesh {
//! \brief A uniform 1D mesh
class UniformMesh1D: public Mesh1D
{
public:
UniformMesh1D(index_t nb_nodes, scalar_t dx, scalar_t cross_section):
Mesh1D(nb_nodes), m_dx(dx), m_crosssection(cross_section)
{}
scalar_t get_dx(index_t _) {return m_dx;}
scalar_t get_face_area(index_t _) { return m_crosssection;}
scalar_t get_volume_element(index_t _) {return m_dx*m_crosssection;}
scalar_t get_volume_cell(index_t node) {
if (node ==0 or node == nb_nodes()-1) return m_dx*m_crosssection/2;
else return m_dx*m_crosssection;
}
scalar_t get_volume_cell_element(index_t element, index_t enode) {
return m_dx*m_crosssection/2;
}
private:
scalar_t m_dx;
scalar_t m_crosssection;
};
//! \brief Factory method to build a pointer to a uniform 1D mesh
inline Mesh1DPtr uniform_mesh1d(index_t nb_nodes, scalar_t dx, scalar_t cross_section)
{
return std::static_pointer_cast<Mesh1D>(std::make_shared<UniformMesh1D>(nb_nodes, dx, cross_section));
}
} // end namespace mesh
} // end namespace specmicp
#endif // SPECMICP_REACTMICP_MESH_UNIFORMMESH1D_HPP

Event Timeline