Commit 38393025 authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#531 Elasticity is entirely defined with brand new Assembling chain. Old chain...

#531 Elasticity is entirely defined with brand new Assembling chain. Old chain has been commented anyway.
parent 937321fe
......@@ -201,10 +201,10 @@ namespace HappyHeart
* arguments are propagated to the PerformElementaryCalculation() method as a tuple; if there are some
* a method named SupplArgumentsComputeEltArray() must be defined in DerivedT class.
*
*/
template<typename... Args>
void AssembleWithVariadicArguments(double coefficient, GlobalVector& global_vector, const Domain& domain,
Args&&... args) const;
// */
// template<typename... Args>
// void AssembleWithVariadicArguments(double coefficient, GlobalVector& global_vector, const Domain& domain,
// Args&&... args) const;
/*!
* \brief Assemble a global matrix.
......@@ -220,9 +220,9 @@ namespace HappyHeart
* \param[in,out] args Potential additional arguments required by a GlobalVariationalOperator (See
* overload for vectors for more details).
*/
template<typename... Args>
void AssembleWithVariadicArguments(double coefficient, GlobalMatrix& global_matrix, const Domain& domain,
Args&&... args) const;
// template<typename... Args>
// void AssembleWithVariadicArguments(double coefficient, GlobalMatrix& global_matrix, const Domain& domain,
// Args&&... args) const;
/*!
* \brief Assemble a global matrix and a global vector in the same time.
......@@ -235,10 +235,10 @@ namespace HappyHeart
* \param[in,out] args Potential additional arguments required by a GlobalVariationalOperator. (See
* overload for vectors for more details).
*/
template<typename... Args>
void AssembleWithVariadicArguments(double matrix_coefficient, GlobalMatrix& global_matrix,
double vector_coefficient, GlobalVector& global_vector,
const Domain& domain, Args&&... args) const;
// template<typename... Args>
// void AssembleWithVariadicArguments(double matrix_coefficient, GlobalMatrix& global_matrix,
// double vector_coefficient, GlobalVector& global_vector,
// const Domain& domain, Args&&... args) const;
template<class LinearAlgebraTupleT, typename... Args>
void Assemble531(LinearAlgebraTupleT&& linear_algebra_tuple,
......@@ -302,10 +302,10 @@ namespace HappyHeart
* the case of a matrix/vector operator. If I deduced it from the class template parameter, I would
* have been forced to assemble both of them everytime.
*/
template<MatrixVectorNature LinearAlgebraNatureT, typename... Args>
void AssembleImpl(Private::GlobalLinearAlgebraHelper<LinearAlgebraNatureT>& global_linear_algebra,
const Domain& domain,
std::tuple<Args...>&& args) const;
// template<MatrixVectorNature LinearAlgebraNatureT, typename... Args>
// void AssembleImpl(Private::GlobalLinearAlgebraHelper<LinearAlgebraNatureT>& global_linear_algebra,
// const Domain& domain,
// std::tuple<Args...>&& args) const;
/*!
......
......@@ -91,80 +91,80 @@ namespace HappyHeart
}
template
<
class DerivedT,
class LocalVariationalOperatorT,
class UnknownPolicyT
>
template<typename... Args>
void
GlobalVariationalOperator<DerivedT, LocalVariationalOperatorT, UnknownPolicyT>
::AssembleWithVariadicArguments(double coefficient, GlobalVector& global_vector,
const Domain& domain,
Args&& ...args) const
{
static_assert(GetMatrixVectorNature() != MatrixVectorNature::matrix,
"This version of Assemble() makes sense only for vectorial operators!");
Private::GlobalLinearAlgebraHelper<MatrixVectorNature::vector>
vector_and_coeff(GlobalVectorWithCoefficient(global_vector, coefficient));
AssembleImpl(vector_and_coeff, domain, std::forward_as_tuple(args...));
}
template
<
class DerivedT,
class LocalVariationalOperatorT,
class UnknownPolicyT
>
template<typename... Args>
void
GlobalVariationalOperator<DerivedT, LocalVariationalOperatorT, UnknownPolicyT>
::AssembleWithVariadicArguments(double coefficient, GlobalMatrix& global_matrix,
const Domain& domain,
Args&& ...args) const
{
static_assert(GetMatrixVectorNature() != MatrixVectorNature::vector,
"This version of Assemble() makes sense only for matricial operators!");
Private::GlobalLinearAlgebraHelper<MatrixVectorNature::matrix>
matrix_and_coeff(GlobalMatrixWithCoefficient(global_matrix, coefficient));
AssembleImpl(matrix_and_coeff, domain, std::forward_as_tuple(args...));
}
template
<
class DerivedT,
class LocalVariationalOperatorT,
class UnknownPolicyT
>
template<typename... Args>
void
GlobalVariationalOperator<DerivedT, LocalVariationalOperatorT, UnknownPolicyT>
::AssembleWithVariadicArguments(double matrix_coefficient, GlobalMatrix& global_matrix,
double vector_coefficient, GlobalVector& global_vector,
const Domain& domain, Args&&... args) const
{
static_assert(GetMatrixVectorNature() == MatrixVectorNature::vector_and_matrix,
"This version of Assemble() makes sense only for operators with both matricial and "
"vectorial components!");
Private::GlobalLinearAlgebraHelper<MatrixVectorNature::vector_and_matrix>
linear_algebra_and_coeff(GlobalMatrixWithCoefficient(global_matrix, matrix_coefficient),
GlobalVectorWithCoefficient(global_vector, vector_coefficient)
);
AssembleImpl(linear_algebra_and_coeff, domain, std::forward_as_tuple(args...));
}
//
// template
// <
// class DerivedT,
// class LocalVariationalOperatorT,
// class UnknownPolicyT
// >
// template<typename... Args>
// void
// GlobalVariationalOperator<DerivedT, LocalVariationalOperatorT, UnknownPolicyT>
// ::AssembleWithVariadicArguments(double coefficient, GlobalVector& global_vector,
// const Domain& domain,
// Args&& ...args) const
// {
// static_assert(GetMatrixVectorNature() != MatrixVectorNature::matrix,
// "This version of Assemble() makes sense only for vectorial operators!");
//
// Private::GlobalLinearAlgebraHelper<MatrixVectorNature::vector>
// vector_and_coeff(GlobalVectorWithCoefficient(global_vector, coefficient));
//
// AssembleImpl(vector_and_coeff, domain, std::forward_as_tuple(args...));
// }
//
//
// template
// <
// class DerivedT,
// class LocalVariationalOperatorT,
// class UnknownPolicyT
// >
//
// template<typename... Args>
// void
// GlobalVariationalOperator<DerivedT, LocalVariationalOperatorT, UnknownPolicyT>
// ::AssembleWithVariadicArguments(double coefficient, GlobalMatrix& global_matrix,
// const Domain& domain,
// Args&& ...args) const
// {
// static_assert(GetMatrixVectorNature() != MatrixVectorNature::vector,
// "This version of Assemble() makes sense only for matricial operators!");
//
// Private::GlobalLinearAlgebraHelper<MatrixVectorNature::matrix>
// matrix_and_coeff(GlobalMatrixWithCoefficient(global_matrix, coefficient));
//
// AssembleImpl(matrix_and_coeff, domain, std::forward_as_tuple(args...));
// }
//
//
//
// template
// <
// class DerivedT,
// class LocalVariationalOperatorT,
// class UnknownPolicyT
// >
// template<typename... Args>
// void
// GlobalVariationalOperator<DerivedT, LocalVariationalOperatorT, UnknownPolicyT>
// ::AssembleWithVariadicArguments(double matrix_coefficient, GlobalMatrix& global_matrix,
// double vector_coefficient, GlobalVector& global_vector,
// const Domain& domain, Args&&... args) const
// {
// static_assert(GetMatrixVectorNature() == MatrixVectorNature::vector_and_matrix,
// "This version of Assemble() makes sense only for operators with both matricial and "
// "vectorial components!");
//
// Private::GlobalLinearAlgebraHelper<MatrixVectorNature::vector_and_matrix>
// linear_algebra_and_coeff(GlobalMatrixWithCoefficient(global_matrix, matrix_coefficient),
// GlobalVectorWithCoefficient(global_vector, vector_coefficient)
// );
//
// AssembleImpl(linear_algebra_and_coeff, domain, std::forward_as_tuple(args...));
// }
//
template
<
......@@ -207,57 +207,57 @@ namespace HappyHeart
}
template
<
class DerivedT,
class LocalVariationalOperatorT,
class UnknownPolicyT
>
template<MatrixVectorNature LinearAlgebraNatureT, typename... Args>
void
GlobalVariationalOperator<DerivedT, LocalVariationalOperatorT, UnknownPolicyT>
::AssembleImpl(Private::GlobalLinearAlgebraHelper<LinearAlgebraNatureT>& global_linear_algebra,
const Domain& domain,
std::tuple<Args...>&& additional_arguments) const
{
const auto& finite_elt_storage = this->GetFEltSpace().GetLocalFEltSpacePerRefFeltSpace(domain);
for (const auto& pair : finite_elt_storage)
{
auto& ref_felt_space_ptr = pair.first;
assert(!(!ref_felt_space_ptr));
const auto& ref_felt_space = *ref_felt_space_ptr;
const auto& ref_geom_elt_ptr = ref_felt_space.GetRefGeomEltPtr();
if (!DoConsider(ref_geom_elt_ptr))
continue;
auto& local_operator = GetNonCstLocalOperator(ref_geom_elt_ptr);
const auto& local_felt_space_list = pair.second;
for (const auto& local_felt_space_ptr : local_felt_space_list)
{
assert(!(!local_felt_space_ptr));
auto& local_felt_space = *local_felt_space_ptr;
local_operator.SetLocalFEltSpace(local_felt_space);
PerformElementaryCalculation(local_felt_space,
local_operator,
global_linear_algebra,
std::move(additional_arguments));
UnknownPolicyParent::InjectIntoGlobalLinearAlgebra(local_felt_space,
local_operator,
global_linear_algebra);
}
}
Private::Assembly(global_linear_algebra);
}
// template
// <
// class DerivedT,
// class LocalVariationalOperatorT,
// class UnknownPolicyT
// >
// template<MatrixVectorNature LinearAlgebraNatureT, typename... Args>
// void
// GlobalVariationalOperator<DerivedT, LocalVariationalOperatorT, UnknownPolicyT>
// ::AssembleImpl(Private::GlobalLinearAlgebraHelper<LinearAlgebraNatureT>& global_linear_algebra,
// const Domain& domain,
// std::tuple<Args...>&& additional_arguments) const
// {
// const auto& finite_elt_storage = this->GetFEltSpace().GetLocalFEltSpacePerRefFeltSpace(domain);
//
// for (const auto& pair : finite_elt_storage)
// {
// auto& ref_felt_space_ptr = pair.first;
// assert(!(!ref_felt_space_ptr));
// const auto& ref_felt_space = *ref_felt_space_ptr;
//
// const auto& ref_geom_elt_ptr = ref_felt_space.GetRefGeomEltPtr();
//
// if (!DoConsider(ref_geom_elt_ptr))
// continue;
//
// auto& local_operator = GetNonCstLocalOperator(ref_geom_elt_ptr);
//
// const auto& local_felt_space_list = pair.second;
//
// for (const auto& local_felt_space_ptr : local_felt_space_list)
// {
// assert(!(!local_felt_space_ptr));
//
// auto& local_felt_space = *local_felt_space_ptr;
// local_operator.SetLocalFEltSpace(local_felt_space);
//
// PerformElementaryCalculation(local_felt_space,
// local_operator,
// global_linear_algebra,
// std::move(additional_arguments));
//
// UnknownPolicyParent::InjectIntoGlobalLinearAlgebra(local_felt_space,
// local_operator,
// global_linear_algebra);
// }
// }
//
// Private::Assembly(global_linear_algebra);
// }
//
template
<
......
......@@ -111,7 +111,9 @@ namespace HappyHeart
* for Assemble() method rather than figuring out what is a variadic method and which additional
* arguments are required (none for this specific operator).
*/
void Assemble(double coefficient, GlobalMatrix& global_matrix, const Domain& domain = Domain()) const;
template<class LinearAlgebraTupleT>
void Assemble(LinearAlgebraTupleT&& global_matrix_with_coeff, const Domain& domain = Domain()) const;
};
......
......@@ -18,12 +18,13 @@ namespace HappyHeart
{
inline void GradOnGradientBasedElasticityTensor::Assemble(double coefficient,
GlobalMatrix& global_matrix,
const Domain& domain) const
template<class LinearAlgebraTupleT>
inline void GradOnGradientBasedElasticityTensor
::Assemble(LinearAlgebraTupleT&& linear_algebra_tuple, const Domain& domain) const
{
return Parent::AssembleWithVariadicArguments(coefficient, global_matrix, domain);
return Parent::Assemble531(std::move(linear_algebra_tuple), domain);
}
} // namespace GlobalVariationalOperatorNS
......
......@@ -103,7 +103,8 @@ namespace HappyHeart
* for Assemble() method rather than figuring out what is a variadic method and which additional
* arguments are required (none for this specific operator).
*/
void Assemble(double coefficient, GlobalMatrix& global_matrix, const Domain& domain = Domain()) const;
template<class LinearAlgebraTupleT>
void Assemble(LinearAlgebraTupleT&& global_matrix_with_coeff, const Domain& domain = Domain()) const;
};
......
......@@ -17,11 +17,13 @@ namespace HappyHeart
namespace GlobalVariationalOperatorNS
{
inline void GradPhiGradPhi::Assemble(double coefficient, GlobalMatrix& global_matrix, const Domain& domain) const
template<class LinearAlgebraTupleT>
inline void GradPhiGradPhi::Assemble(LinearAlgebraTupleT&& linear_algebra_tuple, const Domain& domain) const
{
return Parent::AssembleWithVariadicArguments(coefficient, global_matrix, domain);
return Parent::Assemble531(std::move(linear_algebra_tuple), domain);
}
} // namespace GlobalVariationalOperatorNS
......
......@@ -111,7 +111,10 @@ namespace HappyHeart
* for Assemble() method rather than figuring out what is a variadic method and which additional
* arguments are required (none for this specific operator).
*/
void Assemble(double coefficient, GlobalVector& global_vector, const Domain& domain = Domain()) const;
template<class LinearAlgebraTupleT>
void Assemble(LinearAlgebraTupleT&& global_vector_with_coeff_tuple,
const Domain& domain = Domain()) const;
};
......
......@@ -18,11 +18,16 @@ namespace HappyHeart
{
inline void Force::Assemble(double coefficient, GlobalVector& global_vector, const Domain& domain) const
template<class LinearAlgebraTupleT>
inline void Force::Assemble(LinearAlgebraTupleT&& global_vector_with_coeff_tuple,
const Domain& domain) const
{
return Parent::AssembleWithVariadicArguments(coefficient, global_vector, domain);
return Parent::Assemble531(std::move(global_vector_with_coeff_tuple),
domain);
}
} // namespace GlobalVariationalOperatorNS
......
......@@ -67,7 +67,7 @@ namespace HappyHeart
template<>
void GradOnGradientBasedElasticityTensor::
ComputeEltArray<MatrixVectorNature::matrix>(const double matrix_coefficient)
ComputeEltArray<MatrixVectorNature::matrix>()
{
auto& elementary_data = GetNonCstElementaryData();
......@@ -87,8 +87,7 @@ namespace HappyHeart
for (const auto& infos_at_quad_pt : infos_at_quad_pt_list)
{
const double factor = infos_at_quad_pt.GetJacobianDeterminant()
* infos_at_quad_pt.GetQuadraturePoint().GetWeight()
* matrix_coefficient;
* infos_at_quad_pt.GetQuadraturePoint().GetWeight();
const LocalMatrix& dPhi = infos_at_quad_pt.GetGradientFEltPhi();
......
......@@ -90,10 +90,9 @@ namespace HappyHeart
*
* For current operator, only matrix makes sense; so only this specialization is actually defined.
*
* \param[in] coefficient Coefficient applied to the computed matrix.
*/
template<MatrixVectorNature MatrixVectorNatureT>
void ComputeEltArray(double coefficient);
void ComputeEltArray();
private:
......@@ -111,7 +110,7 @@ namespace HappyHeart
// Template method specialization.
template<>
void GradOnGradientBasedElasticityTensor::ComputeEltArray<MatrixVectorNature::matrix>(double coefficient);
void GradOnGradientBasedElasticityTensor::ComputeEltArray<MatrixVectorNature::matrix>();
......
......@@ -52,7 +52,7 @@ namespace HappyHeart
template<>
void GradPhiGradPhi::ComputeEltArray<MatrixVectorNature::matrix>(const double coefficient)
void GradPhiGradPhi::ComputeEltArray<MatrixVectorNature::matrix>()
{
auto& elementary_data = GetNonCstElementaryData();
......@@ -74,9 +74,8 @@ namespace HappyHeart
BlockLocalMatrix dPhi_velocity = infos_at_quad_pt.GetGradientFEltPhi(ref_felt);
Wrappers::Seldon::Transpose(dPhi_velocity, transposed_dphi);
const double factor = coefficient
* infos_at_quad_pt.GetQuadraturePoint().GetWeight()
* infos_at_quad_pt.GetJacobianDeterminant();
const double factor = infos_at_quad_pt.GetQuadraturePoint().GetWeight()
* infos_at_quad_pt.GetJacobianDeterminant();
Seldon::Mlt(factor,
dPhi_velocity,
......
......@@ -82,11 +82,9 @@ namespace HappyHeart
* \brief Compute the elementary \a MatrixVectorNatureT.
*
* For current operator, only matrix makes sense; so only this specialization is actually defined.
*
* \param[in] coefficient Coefficient applied to the computed matrix.
*/
template<MatrixVectorNature MatrixVectorNatureT>
void ComputeEltArray(double coefficient);
void ComputeEltArray();
};
......@@ -94,7 +92,7 @@ namespace HappyHeart
// Template method specialization.
template<>
void GradPhiGradPhi::ComputeEltArray<MatrixVectorNature::matrix>(double coefficient);
void GradPhiGradPhi::ComputeEltArray<MatrixVectorNature::matrix>();
......
......@@ -87,8 +87,9 @@ namespace HappyHeart
}
GetNonCstStiffnessOperator().Assemble(1., GetNonCstSystemMatrix(numbering_subset, numbering_subset));
auto&& matrix = GlobalMatrixWithCoefficient(GetNonCstSystemMatrix(numbering_subset, numbering_subset), 1.);
GetNonCstStiffnessOperator().Assemble(std::make_tuple(matrix));
}
......
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