Page MenuHomec4science

dof_numbering.hpp
No OneTemporary

File Metadata

Created
Fri, Aug 30, 13:16

dof_numbering.hpp

/* =============================================================================
Copyright (c) 2014-2017 F. Georget <fabieng@princeton.edu> Princeton University
Copyright (c) 2017 F. Georget <fabien.georget@epfl.ch> EPFL
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 REACTMICP_CHLORIDE_NUMBERING_HPP
#define REACTMICP_CHLORIDE_NUMBERING_HPP
#include "specmicp_common/types.hpp"
//! \file dof_numbering.hpp
//! \brief DOF numbering for chloride system
namespace specmicp {
namespace reactmicp {
namespace systems {
namespace chloride {
//! DOF numbering for chloride system
class SPECMICP_DLL_PUBLIC DofNumbering
{
public:
DofNumbering(index_t nb_components):
n_components(nb_components),
m_ndof(nb_components-2+1),
m_edof((nb_components-2+1)*2)
{}
//! \brief The number of dofs for a node
index_t ndof() const {
return m_ndof;
}
//! \brief The number of dofs for an element
index_t edof() const {
return m_edof;
}
//! \brief Nodal dof for a component equation
index_t nodal_dof_component(index_t component) const {
specmicp_assert(component < n_components and component > 1); // valid aqueous component
return component - 2;
}
//! \brief Nodal dof for the courant equation
index_t nodal_dof_psi() const {
return n_components - 2;
}
//! \brief Nodal dof for a component equation
index_t element_dof_component(index_t enode, index_t component) const {
return nodal_dof_component(component) + ndof()*enode;
}
//! \brief Nodal dof for the courant equation
index_t element_dof_psi(index_t enode) const {
return nodal_dof_psi() + ndof()*enode;
}
//! \brief Dof for a component equation
index_t dof_component(index_t node, index_t component) const {
return nodal_dof_component(component) + node*m_ndof;
}
//! \brief Dof for the courant equation
index_t dof_psi(index_t node) const {
return m_ndof-1 + node*m_ndof;
}
//! \brief Return a dof from node and ndof
index_t dof(index_t node, index_t ndof) const {
return ndof + node*m_ndof;
}
//! \brief nodal id of concentration in storage vector
index_t nodal_id_conc_component(index_t component) const {
specmicp_assert(component < n_components and component > 1); // valid aqueous component
return component - 2;
}
index_t id_conc_component(index_t node, index_t component) const {
return node*(n_components -2)+nodal_id_conc_component(component);
}
private:
index_t n_components; //!< Number of components
index_t m_ndof; //!< Nodal dofs
index_t m_edof; //!< Element dofs
};
} // namespace chloride
} // namespace systems
} // namespace reactmicp
} // namespace specmicp
#endif // REACTMICP_CHLORIDE_NUMBERING_HPP

Event Timeline