Commit 1a4e016d authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#873 Parameter/time dependency: introduce much code to avoid the allocation...

#873 Parameter/time dependency: introduce much code to avoid the allocation each time of the vector and matrices.
parent 4fafbade
......@@ -180,11 +180,12 @@ namespace HappyHeart
*/
virtual return_type SupplGetValue(const QuadraturePoint& quad_pt, const GeometricElt& geom_elt) const override final;
//! \copydoc doxygen_hide_parameter_suppl_get_any_value
virtual return_type SupplGetAnyValue() const override final;
/*!
* \brief Write the content of the Parameter in a stream.
*
* \para,
*/
virtual void SupplWrite(std::ostream& out) const override final;
......
......@@ -83,6 +83,13 @@ namespace HappyHeart
}
template<ParameterNS::Type TypeT>
inline typename FiberList<TypeT>::return_type FiberList<TypeT>::SupplGetAnyValue() const
{
return GetUnderlyingParameter().SupplGetAnyValue();
}
template<ParameterNS::Type TypeT>
inline typename FiberList<TypeT>::return_type FiberList<TypeT>
::SupplGetValue(const QuadraturePoint& quad_pt,
......
......@@ -116,6 +116,11 @@ namespace HappyHeart
//! \copydoc doxygen_hide_parameter_suppl_time_update
void SupplTimeUpdate() override;
/*!
*
* \copydoc doxygen_hide_parameter_suppl_get_any_value
*/
return_type SupplGetAnyValue() const override;
private:
......
......@@ -107,7 +107,7 @@ namespace HappyHeart
{
assert(IsConstant());
return helper_.GetValue();
return helper_.GetResult();
}
......@@ -137,6 +137,16 @@ namespace HappyHeart
assert(!GetPoissonRatio().IsTimeDependent());
}
template
<
GradientBasedElasticityTensorConfiguration ConfigurationT
>
typename GradientBasedElasticityTensor<ConfigurationT>::return_type
GradientBasedElasticityTensor<ConfigurationT>::SupplGetAnyValue() const
{
return helper_.GetResult();
}
} // namespace ParameterNS
......
......@@ -52,6 +52,11 @@ namespace HappyHeart
}
double LameLambda::SupplGetAnyValue() const
{
return 0.;
}
} // namespace ParameterNS
......
......@@ -103,7 +103,11 @@ namespace HappyHeart
//! \copydoc doxygen_hide_parameter_suppl_time_update
void SupplTimeUpdate() override;
/*!
*
* \copydoc doxygen_hide_parameter_suppl_get_any_value
*/
return_type SupplGetAnyValue() const override;
private:
......
......@@ -53,6 +53,13 @@ namespace HappyHeart
double LameMu::SupplGetAnyValue() const
{
return 0.;
}
} // namespace ParameterNS
......
......@@ -103,6 +103,12 @@ namespace HappyHeart
return_type SupplGetConstantValue() const override;
/*!
*
* \copydoc doxygen_hide_parameter_suppl_get_any_value
*/
return_type SupplGetAnyValue() const override;
private:
//! Young modulus.
......
......@@ -74,9 +74,9 @@ namespace HappyHeart
* \brief Returns the value of the gradient based elasticity tensor.
*
* Should not be called in non constant case (this is up to GradientBasedElasticityTensor class
* to ensure that; only this class is expected to manipulate present one).
* to ensure that (except for GetAnyValue()); only this class is expected to manipulate present one).
*/
const LocalMatrix& GetValue() const;
const LocalMatrix& GetResult() const noexcept;
//! Whether the tensor has already been computed. Meaningful only for spatially constant parameters.
bool IsAlreadyComputed() const;
......
......@@ -32,13 +32,19 @@ namespace HappyHeart
engineering_elasticity_tensor_.Zero();
intermediate_product_.Resize(traits::engineering_size, traits::result_size);
}
template<GradientBasedElasticityTensorConfiguration ConfigurationT>
inline LocalMatrix& ComputeGradientBasedElasticityTensor<ConfigurationT>
::GetNonCstResult()
{
return const_cast<LocalMatrix&>(GetResult());
}
template<GradientBasedElasticityTensorConfiguration ConfigurationT>
inline const LocalMatrix& ComputeGradientBasedElasticityTensor<ConfigurationT>
::GetResult() const noexcept
{
assert(result_.GetM() == traits::result_size);
assert(result_.GetN() == traits::result_size);
......@@ -88,13 +94,7 @@ namespace HappyHeart
return result_;
}
template<GradientBasedElasticityTensorConfiguration ConfigurationT>
const LocalMatrix& ComputeGradientBasedElasticityTensor<ConfigurationT>::GetValue() const
{
return result_;
}
} // namespace Private
......
......@@ -103,6 +103,12 @@ namespace HappyHeart
//! \copydoc doxygen_hide_parameter_suppl_time_update
void SupplTimeUpdate() override;
/*!
*
* \copydoc doxygen_hide_parameter_suppl_get_any_value
*/
return_type SupplGetAnyValue() const override;
private:
......
......@@ -158,7 +158,16 @@ namespace HappyHeart
GetScalarParameterZ().TimeUpdate();
}
template
<
template<ParameterNS::Type> class TimeDependencyT
>
typename ThreeDimensionalParameter<TimeDependencyT>::return_type
ThreeDimensionalParameter<TimeDependencyT>::SupplGetAnyValue() const
{
return content_;
}
} // namespace ParameterNS
......
......@@ -244,6 +244,17 @@ namespace HappyHeart
virtual return_type SupplGetConstantValue() const = 0;
/*!
* \class doxygen_hide_parameter_suppl_get_any_value
*
* \brief Returns a stored value.
*
* \internal <b><tt>[internal]</tt></b> The point here is not the value itself, but the informations that
* might be retrieved from it, such as number of rows and columns if TypeT == Type::matrix.
*/
virtual return_type SupplGetAnyValue() const = 0;
/*!
* \brief Get the value of the parameter at a given quadrature point in a given \a geom_elt.
*
......
......@@ -105,7 +105,10 @@ namespace HappyHeart
assert(time_dependency_ == nullptr && "Should be assigned only once!");
assert(!(!time_dependency));
time_dependency_ = std::move(time_dependency);
time_dependency_->Init(SupplGetAnyValue());
}
......
......@@ -230,6 +230,10 @@ namespace HappyHeart
//! Get the value.
return_type GetValueFromPolicy(const QuadraturePoint& quadrature_point,
const GeometricElt& geom_elt) const;
//! \copydoc doxygen_hide_parameter_suppl_get_any_value
return_type GetAnyValueFromPolicy() const;
protected:
......
......@@ -137,6 +137,18 @@ namespace HappyHeart
}
template
<
ParameterNS::Type TypeT,
unsigned int Ndim
>
typename AtDof<TypeT, Ndim>::return_type AtDof<TypeT, Ndim>
::GetAnyValueFromPolicy() const
{
return local_value_;
}
template
<
ParameterNS::Type TypeT,
......
......@@ -128,6 +128,10 @@ namespace HappyHeart
//! Get the value.
return_type GetValueFromPolicy(const QuadraturePoint& quadrature_point,
const GeometricElt& geom_elt) const;
//! \copydoc doxygen_hide_parameter_suppl_get_any_value
return_type GetAnyValueFromPolicy() const;
public:
......
......@@ -82,6 +82,17 @@ namespace HappyHeart
}
template<ParameterNS::Type TypeT>
inline typename AtQuadraturePoint<TypeT>::return_type
AtQuadraturePoint<TypeT>::GetAnyValueFromPolicy() const
{
decltype(auto) storage = GetStorage();
assert(!storage.empty());
decltype(auto) geom_elt_content = storage.cbegin()->second;
assert(!geom_elt_content.empty());
return geom_elt_content.back().value;
}
template<ParameterNS::Type TypeT>
const typename AtQuadraturePoint<TypeT>::value_holder_type&
......
......@@ -94,7 +94,10 @@ namespace HappyHeart
//! Provided here to make the code compile, but should never be called.
[[noreturn]] return_type GetValueFromPolicy(const QuadraturePoint& quadrature_point,
const GeometricElt& geom_elt) const;
const GeometricElt& geom_elt) const;
//! \copydoc doxygen_hide_parameter_suppl_get_any_value
return_type GetAnyValueFromPolicy() const;
protected:
......
......@@ -51,6 +51,12 @@ namespace HappyHeart
}
template<ParameterNS::Type TypeT>
inline typename Constant<TypeT>::return_type Constant<TypeT>::GetAnyValueFromPolicy() const
{
return GetConstantValueFromPolicy();
}
template<ParameterNS::Type TypeT>
inline bool Constant<TypeT>::IsConstant() const
......
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