Commit 5aafb11e authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#1347 Improve the error message when a Parameter with constant per domain...

#1347 Improve the error message when a Parameter with constant per domain policy is poorly defined: the name of the parameter and the two domains that clash are now specified. To do so, policies now have access to the name of the Parameter.
parent 036f560a
......@@ -42,7 +42,7 @@ namespace MoReFEM
const Domain& domain,
ConstructorArgs&&... arguments)
: parent(std::forward<T>(name), domain),
nature_policy(domain, std::forward<ConstructorArgs>(arguments)...)
nature_policy(parent::GetName(), domain, std::forward<ConstructorArgs>(arguments)...)
{ }
......
......@@ -25,7 +25,7 @@ namespace MoReFEM
>
template<class T>
Parameter<TypeT, LocalCoordsT, TimeDependencyT>::Parameter(T&& name,
const Domain& domain)
const Domain& domain)
: name_(name),
domain_(domain)
{
......
......@@ -31,6 +31,14 @@
*/
/*!
* \class doxygen_hide_parameter_name_and_domain_arg
*
* \param[in] name Name of the Parameter.
* \copydoc doxygen_hide_parameter_domain_arg
*/
/*!
* \class doxygen_hide_parameter_local_coords_type
*
......
......@@ -172,6 +172,7 @@ namespace MoReFEM
/*!
* \class doxygen_hide_at_dof_impl_constructor_args
*
* \param[in] name Name of the Parameter.
* \param[in] domain \a Domain considered. It is actually unused in this policy, but this is
* a staple of policy usage and must be provided.
* \param[in] unknown A scalar or vectorial unknown that acts a bit as a strawman: dofs are defined only
......@@ -196,7 +197,8 @@ namespace MoReFEM
* defined. This finite element space should cover the underlying \a NumberingSubset of \a global_vector.
*
*/
explicit AtDof(const Domain& domain,
explicit AtDof(const std::string& name,
const Domain& domain,
const FEltSpace& felt_space,
const Unknown& unknown,
const GlobalVector& global_vector);
......@@ -214,7 +216,8 @@ namespace MoReFEM
* (e.g. finite element space that cover borders on a 2D mesh).
*
*/
explicit AtDof(const Domain& domain,
explicit AtDof(const std::string& name,
const Domain& domain,
const FEltSpace& felt_space_dim,
const FEltSpace& felt_space_dim_minus_1,
const Unknown& unknown,
......@@ -234,7 +237,8 @@ namespace MoReFEM
* \param[in] felt_space_dim_minus_2 Same as \a felt_space_dim_minus_1 for dimension minus 2.
*
*/
explicit AtDof(const Domain& domain,
explicit AtDof(const std::string& name,
const Domain& domain,
const FEltSpace& felt_space_dim,
const FEltSpace& felt_space_dim_minus_1,
const FEltSpace& felt_space_dim_minus_2,
......@@ -321,7 +325,8 @@ namespace MoReFEM
* \param[in] first_felt_space Any of the \a FEltSpace (this argument is used solely in debug mode
* for sanity checks).
*/
void Construct(const Domain& domain,
void Construct(const std::string& name,
const Domain& domain,
const FEltSpace& first_felt_space,
const Unknown& unknown,
const GlobalVector& global_vector);
......
......@@ -30,7 +30,8 @@ namespace MoReFEM
ParameterNS::Type TypeT,
unsigned int Ndim
>
AtDof<TypeT, Ndim>::AtDof(const Domain& domain,
AtDof<TypeT, Ndim>::AtDof(const std::string& name,
const Domain& domain,
const FEltSpace& felt_space,
const Unknown& unknown,
const GlobalVector& global_vector)
......@@ -40,7 +41,7 @@ namespace MoReFEM
{
static_assert(Ndim == 1, "This specific constructor should be called only in this case!");
Construct(domain, felt_space, unknown, global_vector);
Construct(name, domain, felt_space, unknown, global_vector);
}
......@@ -49,7 +50,8 @@ namespace MoReFEM
ParameterNS::Type TypeT,
unsigned int Ndim
>
AtDof<TypeT, Ndim>::AtDof(const Domain& domain,
AtDof<TypeT, Ndim>::AtDof(const std::string& name,
const Domain& domain,
const FEltSpace& felt_space_dim,
const FEltSpace& felt_space_dim_minus_1,
const Unknown& unknown,
......@@ -60,7 +62,7 @@ namespace MoReFEM
{
static_assert(Ndim == 2, "This specific constructor should be called only in this case!");
Construct(domain, felt_space_dim, unknown, global_vector);
Construct(name, domain, felt_space_dim, unknown, global_vector);
assert(felt_space_dim_minus_1.GetGodOfDofFromWeakPtr()->GetUniqueId() == domain.GetMeshIdentifier());
assert(felt_space_dim_minus_1.DoCoverNumberingSubset(global_vector.GetNumberingSubset()));
......@@ -72,7 +74,8 @@ namespace MoReFEM
ParameterNS::Type TypeT,
unsigned int Ndim
>
AtDof<TypeT, Ndim>::AtDof(const Domain& domain,
AtDof<TypeT, Ndim>::AtDof(const std::string& name,
const Domain& domain,
const FEltSpace& felt_space_dim,
const FEltSpace& felt_space_dim_minus_1,
const FEltSpace& felt_space_dim_minus_2,
......@@ -84,7 +87,7 @@ namespace MoReFEM
{
static_assert(Ndim == 3, "This specific constructor should be called only in this case!");
Construct(domain, felt_space_dim, unknown, global_vector);
Construct(name, domain, felt_space_dim, unknown, global_vector);
assert(felt_space_dim_minus_1.GetGodOfDofFromWeakPtr()->GetUniqueId() == domain.GetMeshIdentifier());
assert(felt_space_dim_minus_1.DoCoverNumberingSubset(global_vector.GetNumberingSubset()));
......@@ -224,11 +227,13 @@ namespace MoReFEM
ParameterNS::Type TypeT,
unsigned int Ndim
>
void AtDof<TypeT, Ndim>::Construct(const Domain& domain,
void AtDof<TypeT, Ndim>::Construct(const std::string& name,
const Domain& domain,
const FEltSpace& first_felt_space,
const Unknown& unknown,
const GlobalVector& global_vector)
{
static_cast<void>(name);
static_cast<void>(first_felt_space);
static_cast<void>(unknown);
static_cast<void>(global_vector);
......
......@@ -96,7 +96,7 @@ namespace MoReFEM
/*!
* \brief Constructor.
*
* \copydoc doxygen_hide_parameter_domain_arg
* \copydoc doxygen_hide_parameter_name_and_domain_arg
* \param[in] quadrature_rule_per_topology Specify which quadrature rule to use for each topology that
* might be considered.
* \param[in] initial_value When the object is built the convention is to set this value at all of the
......@@ -104,7 +104,8 @@ namespace MoReFEM
* from a file for instance); if you need such feature don't hesitate to ask for it!
* \param[in] time_manager Object in c
*/
explicit AtQuadraturePoint(const Domain& domain,
explicit AtQuadraturePoint(const std::string& name,
const Domain& domain,
const QuadratureRulePerTopology& quadrature_rule_per_topology,
storage_value_type initial_value,
const TimeManager& time_manager);
......
......@@ -27,7 +27,8 @@ namespace MoReFEM
template<ParameterNS::Type TypeT>
AtQuadraturePoint<TypeT>
::AtQuadraturePoint(const Domain& domain,
::AtQuadraturePoint(const std::string& name,
const Domain& domain,
const QuadratureRulePerTopology& quadrature_rule_per_topology,
storage_value_type initial_value,
const TimeManager& time_manager)
......@@ -36,6 +37,7 @@ namespace MoReFEM
quadrature_rule_per_topology_(quadrature_rule_per_topology),
time_manager_(time_manager)
{
static_cast<void>(name);
auto& storage = GetNonCstStorage();
storage.max_load_factor(Utilities::DefaultMaxLoadFactor());
......
......@@ -69,8 +69,14 @@ namespace MoReFEM
/// \name Special members.
///@{
//! Constructor.
explicit Constant(const Domain& domain,
/*!
* \brief Constructor.
*
* \copydoc doxygen_hide_parameter_name_and_domain_arg
* \param[in] value Numerical value of the constant Parameter.
*/
explicit Constant(const std::string& name,
const Domain& domain,
storage_type value);
//! Destructor.
......
......@@ -26,7 +26,8 @@ namespace MoReFEM
template<ParameterNS::Type TypeT>
Constant<TypeT>::Constant(const Domain& ,
Constant<TypeT>::Constant(const std::string&,
const Domain& ,
typename Constant<TypeT>::storage_type value)
: value_(value)
{ }
......
......@@ -86,8 +86,14 @@ namespace MoReFEM
/// \name Special members.
///@{
//! Constructor.
explicit LuaFunction(const Domain& domain,
/*!
* \brief Constructor.
*
* \copydoc doxygen_hide_parameter_name_and_domain_arg
* \param[in] lua_function The lua function that returns the value of the Parameter.
*/
explicit LuaFunction(const std::string& name,
const Domain& domain,
storage_type lua_function);
//! Destructor.
......
......@@ -26,7 +26,8 @@ namespace MoReFEM
template<ParameterNS::Type TypeT, class SettingsSpatialFunctionT>
LuaFunction<TypeT, SettingsSpatialFunctionT>::LuaFunction(const Domain& ,
LuaFunction<TypeT, SettingsSpatialFunctionT>::LuaFunction(const std::string&,
const Domain& ,
storage_type lua_function)
: lua_function_(lua_function)
{ }
......
......@@ -79,14 +79,15 @@ namespace MoReFEM
/*!
* \brief Constructor for the paramter policy PiecewiseConstantByDomain.
*
* \copydoc doxygen_hide_parameter_domain_arg
* \copydoc doxygen_hide_parameter_name_and_domain_arg
* \param[in] value An associative container which key is the index of the domain and the value
* the scalar value the parameter takes in the matching domain.
*
* It is expected that the \a Domain defined here are actually subsets of the \a Domain upon which
* the \a Parameter is defined.
*/
explicit PiecewiseConstantByDomain(const Domain& domain,
explicit PiecewiseConstantByDomain(const std::string& name,
const Domain& domain,
const storage_type& value);
//! Destructor.
......
......@@ -27,7 +27,8 @@ namespace MoReFEM
template<ParameterNS::Type TypeT>
PiecewiseConstantByDomain<TypeT>
::PiecewiseConstantByDomain(const Domain& domain,
::PiecewiseConstantByDomain(const std::string& name,
const Domain& domain,
const storage_type& value)
: stored_values_per_domain_(value)
{
......@@ -59,9 +60,12 @@ namespace MoReFEM
if (!(check.second))
{
throw Exception("A geometric element is in two domains with two different values for "
"the PiecewiseConstantByDomain parameter.",
__FILE__, __LINE__);
std::ostringstream oconv;
oconv << "A geometric element is in two domains (" << current_domain.GetUniqueId()
<< " and " << check.first->second << ") with two different values for the "
<< name << " parameter.";
throw Exception(oconv.str(), __FILE__, __LINE__);
}
}
}
......
......@@ -43,7 +43,7 @@ namespace MoReFEM
{
/*!
* \brief Generates a deformed mesh form a domain of the mesh.
* \brief Generates a deformed mesh from a domain of the mesh.
*
*/
class OutputDeformedMesh
......
Markdown is supported
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