"src/language/modules/MeshModule.cpp" did not exist on "9e1d457250304a71b129f39263ba2af79cc9fd98"
Select Git revision
SchemeModule.cpp
DiscreteFunctionP0.hpp 9.43 KiB
#ifndef DISCRETE_FUNCTION_P0_HPP
#define DISCRETE_FUNCTION_P0_HPP
#include <scheme/IDiscreteFunction.hpp>
#include <language/utils/InterpolateItemValue.hpp>
#include <mesh/Connectivity.hpp>
#include <mesh/Mesh.hpp>
#include <mesh/MeshData.hpp>
#include <mesh/MeshDataManager.hpp>
#include <scheme/DiscreteFunctionDescriptorP0.hpp>
template <size_t Dimension, typename DataType>
class DiscreteFunctionP0 : public IDiscreteFunction
{
public:
using data_type = DataType;
using MeshType = Mesh<Connectivity<Dimension>>;
static constexpr HandledItemDataType handled_data_type = HandledItemDataType::value;
private:
std::shared_ptr<const MeshType> m_mesh;
CellValue<DataType> m_cell_values;
DiscreteFunctionDescriptorP0 m_discrete_function_descriptor;
public:
PUGS_INLINE
ASTNodeDataType
dataType() const final
{
return ast_node_data_type_from<DataType>;
}
PUGS_INLINE
const CellValue<DataType>&
cellValues() const
{
return m_cell_values;
}
PUGS_INLINE
std::shared_ptr<const IMesh>
mesh() const
{
return m_mesh;
}
PUGS_INLINE
const IDiscreteFunctionDescriptor&
descriptor() const final
{
return m_discrete_function_descriptor;
}
PUGS_FORCEINLINE
operator DiscreteFunctionP0<Dimension, const DataType>() const
{
return DiscreteFunctionP0<Dimension, const DataType>(m_mesh, m_cell_values);
}
PUGS_INLINE
void
fill(const DataType& data) const noexcept
{
static_assert(not std::is_const_v<DataType>, "Cannot modify ItemValue of const");
m_cell_values.fill(data);
}