Commit 72f1075e authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#875 ParameterAtDof: add the third constructor in case we need three...

#875 ParameterAtDof: add the third constructor in case we need three FEltSpaces in one Parameter, and introduce a private method to let only the specific stuff in each of the three constructors.
parent a90cca24
......@@ -24,6 +24,10 @@
# include "FiniteElement/QuadratureRules/QuadraturePoint.hpp"
# include "FiniteElement/FiniteElementSpace/FEltSpace.hpp"
# ifndef NDEBUG
# include "FiniteElement/FiniteElementSpace/GodOfDof.hpp"
# endif // NDEBUG
# include "Core/ParameterType.hpp"
# include "Parameters/Policy/Private/AtDof.hpp"
......@@ -113,6 +117,10 @@ namespace HappyHeart
//! Friendship to fiber manager.
friend FiberList<TypeT>;
static_assert(ParameterNS::Type::matrix != TypeT,
"This type of parameter can't deal with Matrix parameter");
public:
/// \name Special members.
......@@ -155,8 +163,6 @@ namespace HappyHeart
* \brief Constructor when Parameter cover two \a FEltSpace: one for mesh dimension and another for
* the dimension immediately below.
*
* This should be the more frequent case.
*
* \copydetails doxygen_hide_at_dof_impl_constructor_args
* \param[in] felt_space_dim Finite element space that covers the area upon which the parameter should be
* defined for the dimension of the mesh. This finite element space should cover the underlying
......@@ -170,6 +176,27 @@ namespace HappyHeart
const FEltSpace& felt_space_dim_minus_1,
const Unknown& unknown,
const GlobalVector& global_vector);
/*!
* \brief Constructor when Parameter cover three \a FEltSpace: one for mesh dimension, one for dimension
* minus 1 and the last for dimension minus 2.
*
* \copydetails doxygen_hide_at_dof_impl_constructor_args
* \param[in] felt_space_dim Finite element space that covers the area upon which the parameter should be
* defined for the dimension of the mesh. This finite element space should cover the underlying
* \a NumberingSubset of \a global_vector.
* \param[in] felt_space_dim_minus_1 Same as \a felt_space_dim except it covers the dimension minus 1
* (e.g. finite element space that cover borders on a 2D mesh).
* \param[in] felt_space_dim_minus_2 Same as \a felt_space_dim_minus_1 for dimension minus 2.
*
*/
explicit AtDof(const GeometricMeshRegion& mesh,
const FEltSpace& felt_space_dim,
const FEltSpace& felt_space_dim_minus_1,
const FEltSpace& felt_space_dim_minus_2,
const Unknown& unknown,
const GlobalVector& global_vector);
//! Destructor.
......@@ -233,6 +260,18 @@ namespace HappyHeart
//! Access to fictitious unknown.
const Unknown& GetUnknown() const noexcept;
/*!
* \brief Common part to all constructors.
*
* \copydetails doxygen_hide_at_dof_impl_constructor_args
* \param[in] first_felt_space Any of the \a FEltSpace (this argument is used solely in debug mode
* for sanity checks).
*/
void Construct(const GeometricMeshRegion& mesh,
const FEltSpace& first_felt_space,
const Unknown& unknown,
const GlobalVector& global_vector);
private:
......
......@@ -40,23 +40,7 @@ namespace HappyHeart
{
static_assert(Ndim == 1, "This specific constructor should be called only in this case!");
static_cast<void>(mesh);
static_assert(ParameterNS::Type::matrix != TypeT,
"This type of parameter can't deal with Matrix parameter");
assert(felt_space.DoCoverNumberingSubset(global_vector.GetNumberingSubset()));
#ifndef NDEBUG
{
if (TypeT == ParameterNS::Type::scalar && unknown.GetNature() == UnknownNS::Nature::vectorial)
assert(false && "A scalar parameter given at dof can only be matched with a scalar Unknown.");
}
#endif // NDEBUG
assert(felt_space.GetMeshDimension() == mesh.GetDimension());
Private::AtDofNS::InitLocalValue(felt_space.GetMeshDimension(), local_value_);
Construct(mesh, felt_space, unknown, global_vector);
}
......@@ -76,24 +60,36 @@ namespace HappyHeart
{
static_assert(Ndim == 2, "This specific constructor should be called only in this case!");
static_cast<void>(mesh);
static_assert(ParameterNS::Type::matrix != TypeT,
"This type of parameter can't deal with Matrix parameter");
assert(felt_space_dim.DoCoverNumberingSubset(global_vector.GetNumberingSubset()));
Construct(mesh, felt_space_dim, unknown, global_vector);
assert(felt_space_dim_minus_1.GetGodOfDofFromWeakPtr()->GetUniqueId() == mesh.GetUniqueId());
assert(felt_space_dim_minus_1.DoCoverNumberingSubset(global_vector.GetNumberingSubset()));
}
template
<
ParameterNS::Type TypeT,
unsigned int Ndim
>
AtDof<TypeT, Ndim>::AtDof(const GeometricMeshRegion& mesh,
const FEltSpace& felt_space_dim,
const FEltSpace& felt_space_dim_minus_1,
const FEltSpace& felt_space_dim_minus_2,
const Unknown& unknown,
const GlobalVector& global_vector)
: felt_space_storage_(felt_space_dim, felt_space_dim_minus_1, felt_space_dim_minus_2),
unknown_(unknown),
global_vector_(global_vector)
{
static_assert(Ndim == 3, "This specific constructor should be called only in this case!");
#ifndef NDEBUG
{
if (TypeT == ParameterNS::Type::scalar && unknown.GetNature() == UnknownNS::Nature::vectorial)
assert(false && "A scalar parameter given at dof can only be matched with a scalar Unknown.");
}
#endif // NDEBUG
Construct(mesh, felt_space_dim, unknown, global_vector);
assert(felt_space_dim.GetMeshDimension() == mesh.GetDimension());
Private::AtDofNS::InitLocalValue(felt_space_dim.GetMeshDimension(), local_value_);
assert(felt_space_dim_minus_1.GetGodOfDofFromWeakPtr()->GetUniqueId() == mesh.GetUniqueId());
assert(felt_space_dim_minus_1.DoCoverNumberingSubset(global_vector.GetNumberingSubset()));
assert(felt_space_dim_minus_2.GetGodOfDofFromWeakPtr()->GetUniqueId() == mesh.GetUniqueId());
assert(felt_space_dim_minus_2.DoCoverNumberingSubset(global_vector.GetNumberingSubset()));
}
......@@ -208,7 +204,36 @@ namespace HappyHeart
{
return felt_space_storage_.GetFEltSpace(geom_elt);
}
template
<
ParameterNS::Type TypeT,
unsigned int Ndim
>
void AtDof<TypeT, Ndim>::Construct(const GeometricMeshRegion& mesh,
const FEltSpace& first_felt_space,
const Unknown& unknown,
const GlobalVector& global_vector)
{
static_cast<void>(first_felt_space);
static_cast<void>(unknown);
static_cast<void>(global_vector);
assert(first_felt_space.DoCoverNumberingSubset(global_vector.GetNumberingSubset()));
assert(first_felt_space.GetGodOfDofFromWeakPtr()->GetUniqueId() == mesh.GetUniqueId());
#ifndef NDEBUG
{
if (TypeT == ParameterNS::Type::scalar && unknown.GetNature() == UnknownNS::Nature::vectorial)
assert(false && "A scalar parameter given at dof can only be matched with a scalar Unknown.");
}
#endif // NDEBUG
assert(first_felt_space.GetMeshDimension() == mesh.GetDimension());
Private::AtDofNS::InitLocalValue(mesh.GetDimension(), local_value_);
}
} // namespace Policy
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment