Page MenuHomec4science

generic_mesh1d.hpp
No OneTemporary

File Metadata

Created
Tue, May 7, 09:51

generic_mesh1d.hpp

/* =============================================================================
Copyright (c) 2014 - 2016
F. 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:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. 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.
3. Neither the name of the copyright holder 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 HOLDER 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_DFPM_MESHES_GENERICMESH1D_HPP
#define SPECMICP_DFPM_MESHES_GENERICMESH1D_HPP
//! \file generic_mesh1d.hpp
//! \brief A cartesian 1D mesh
#include "mesh1d.hpp"
namespace specmicp {
namespace mesh {
//! \brief A cartesian 1D mesh
class SPECMICP_DLL_PUBLIC GenericMesh1D: public Mesh1D
{
public:
const index_t coord = 0;
const index_t cell_vol_0 = 1;
const index_t cell_vol_1 = 2;
//! \brief Build 1D mesh
//!
//! \param coords a vector of coordinates
//! \param section the section of the mesh
GenericMesh1D(const Vector& coords, scalar_t section);
//! \brief Return the cooordinates of 'enode' in 'element'
scalar_t get_coord(index_t element, index_t enode) {return m_data(get_node(element, enode), coord);}
//! \brief Return the position (meaning may vary with the mesh) of the node
scalar_t get_position(index_t node) {return m_data(node, coord);}
//! \brief Return the length of an element
scalar_t get_dx(index_t element) {
return get_coord(element, 1) - get_coord(element, 0);}
//! \brief Return the area of the face at the middle of an element
scalar_t get_face_area(index_t element) {
return m_section;}
//! \brief Return the volume of an element
scalar_t get_volume_element(index_t element) {
return (m_data(get_node(element, 0), cell_vol_1)
+ m_data(get_node(element, 1), cell_vol_0));}
//! \brief Return the volume of a cell (element of the dual mesh)
scalar_t get_volume_cell(index_t node) {
return (m_data(node, cell_vol_0) + m_data(node, cell_vol_1));}
//! \brief Return the volume of a cell inside an element
virtual scalar_t get_volume_cell_element(index_t element, index_t enode) {
if (enode == 0)
return m_data(get_node(element, enode), cell_vol_1);
else
return m_data(get_node(element, enode), cell_vol_0);
}
private:
scalar_t m_section;
Matrix m_data;
Vector m_face_coord;
};
//! \brief Information needed to build a uniform linear 1D mesh
//!
//! \sa uniform_mesh_1d(const Uniform1DMeshGeometry&)
struct SPECMICP_DLL_PUBLIC Uniform1DMeshGeometry
{
scalar_t dx;
index_t nb_nodes;
scalar_t section;
};
//! \brief Return a uniform 1D mesh
Mesh1DPtr SPECMICP_DLL_PUBLIC uniform_mesh1d(const Uniform1DMeshGeometry& geometry);
//! \brief Geometry information for a ramp1D
//!
//! \sa ramp_mesh1d
struct SPECMICP_DLL_PUBLIC Ramp1DMeshGeometry
{
scalar_t dx_max;
scalar_t dx_min;
scalar_t length_ramp;
scalar_t length_plateau;
scalar_t section;
};
//! \brief Generate a 'ramp' mesh
//!
//! this version cares about space discretization, not the total length
Mesh1DPtr SPECMICP_DLL_PUBLIC ramp_mesh1d(const Ramp1DMeshGeometry& geometry);
//! \brief Return a shared_ptr to an axisymmetric mesh
//!
//! \param coords is a vector of the position of the nodes
//! \param section is the section of the sample (or depth)
Mesh1DPtr SPECMICP_DLL_PUBLIC generic_mesh1d(const Vector& coords, scalar_t section);
} // end namespace mesh
} // end namespace specmicp
#endif // SPECMICP_DFPM_MESHES_GENERICMESH1D_HPP

Event Timeline