Page MenuHomec4science

mesh1d.hpp
No OneTemporary

File Metadata

Created
Sat, Jul 6, 01:57

mesh1d.hpp

/*-------------------------------------------------------
- Module : reactmicp/meshes
- File : mesh1d.hpp
- Author : Fabien Georget
Copyright (c) 2014, Fabien Georget <fabieng@princeton.edu>, Princeton University
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Princeton University nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------*/
#ifndef SPECMICP_REACTMICP_MESH_MESH1D_HPP
#define SPECMICP_REACTMICP_MESH_MESH1D_HPP
#include "common.hpp"
#include <memory>
namespace specmicp {
namespace mesh {
//! AbstractBase class for a 1D mesh
class Mesh1D
{
public:
const index_t nen = 2; //!< Number of elemental nodes
Mesh1D(index_t nb_nodes): m_nb_nodes(nb_nodes) {}
virtual ~Mesh1D() {}
//! \brief Return the number of elements
index_t nb_elements() {return m_nb_nodes-1;}
//! \brief Return the number of nodes
index_t nb_nodes() {return m_nb_nodes;}
//! \brief Return the node from local nod enumber and element
index_t get_node(index_t element, index_t index)
{
specmicp_assert(index < nen);
return element+index;
}
//! \brief Return the length of an element
virtual scalar_t get_dx(index_t element) = 0;
//! \brief Return the area of the face at the middle of an element
virtual scalar_t get_face_area(index_t element) = 0;
//! \brief Return the volume of an element
virtual scalar_t get_volume_element(index_t element) = 0;
//! \brief Return the volume of a cell (element of the dual mesh)
virtual scalar_t get_volume_cell(index_t node) = 0;
//!
virtual scalar_t get_volume_cell_element(index_t element, index_t node) = 0;
//! \brief Range over the elements
range_t range_elements() {return boost::irange((index_t) 0, nb_elements());}
//! \brief Range over the nodes
range_t range_nodes() {return boost::irange((index_t) 0, nb_nodes());}
//! \brief Range over the elemental nodes
range_t range_nen() {return boost::irange((index_t) 0, nen);}
private:
index_t m_nb_nodes; //!< Number of elements
};
//! \brief type of a pointer to a mesh
//!
//! This is a smart pointer allowing the mesh to be shared freely
using Mesh1DPtr = std::shared_ptr<Mesh1D>;
} // end namespace mesh
} // end namespace specmicp
#endif // SPECMICP_REACTMICP_MESH_MESH1D_HPP

Event Timeline