Commit 2f8930cf authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#718 Hyperelasticity: separate AssembleStiffness() in two parts: the one that...

#718 Hyperelasticity: separate AssembleStiffness() in two parts: the one that is used to init current stiffness matrix and vector in half sum is now called  independantly in PrepareDynamicRuns().
parent 18f1030b
......@@ -130,18 +130,33 @@ namespace HappyHeart
* \param[in] domain Domain into which the assembling occurs. Beware: finite element space into which
* AssembleStiffness() is called might also have restricted the integration domain; the integration
* truly occurs at the intersection of \a domain and the domain covered by the whole finite element space.
* \param[in] is_first_dynamic_call_done First dynamic call plays a specific role, hence this boolean
* to tag it.
* \param[in,out] vm Vectors and matrices specifically related to current time scheme.
*/
template<class LawPolicyT>
void AssembleStiffness(const GlobalVariationalOperatorNS::GradOnGradientBasedHyperelasticityTensor<LawPolicyT>& the_operator,
void AssembleStiffness(const GlobalVariationalOperatorNS
::GradOnGradientBasedHyperelasticityTensor<LawPolicyT>& the_operator,
bool is_static_call,
bool is_first_dynamic_call_done,
VectorsAndMatrices<HyperelasticityNS::TimeScheme::half_sum>& vm,
const Domain& domain = Domain());
/*!
* \brief Initializations steps proper to the time scheme done just before first dynamic iteration.
*
* \param[in] the_operator Hyperelastic operator to be assembled.
* \param[in] domain Domain into which the assembling occurs. Beware: finite element space into which
* AssembleStiffness() is called might also have restricted the integration domain; the integration
* truly occurs at the intersection of \a domain and the domain covered by the whole finite element space.
* \param[in,out] vm Vectors and matrices specifically related to current time scheme.
*/
template<class LawPolicyT>
void TimeSchemeInit(const GlobalVariationalOperatorNS
::GradOnGradientBasedHyperelasticityTensor<LawPolicyT>& the_operator,
VectorsAndMatrices<HyperelasticityNS::TimeScheme::half_sum>& vm,
const Domain& domain = Domain());
} // namespace Private
......
......@@ -28,36 +28,36 @@ namespace HappyHeart
void AssembleStiffness(const GlobalVariationalOperatorNS
::GradOnGradientBasedHyperelasticityTensor<LawPolicyT>& the_operator,
bool is_static_call,
bool is_first_dynamic_call,
VectorsAndMatrices<HyperelasticityNS::TimeScheme::half_sum>& vm,
const Domain& domain)
{
GlobalMatrixWithCoefficient mat(vm.GetNonCstMatrixNewStiffness(), is_static_call ? 1. : 0.5);
GlobalVectorWithCoefficient vec(vm.GetNonCstVectorNewStiffness(), 1.);
the_operator.Assemble(std::make_tuple(std::ref(mat), std::ref(vec)),
vm.GetEvaluationState(),
domain);
{
GlobalMatrixWithCoefficient mat(vm.GetNonCstMatrixNewStiffness(), is_static_call ? 1. : 0.5);
GlobalVectorWithCoefficient vec(vm.GetNonCstVectorNewStiffness(), 1.);
the_operator.Assemble(std::make_tuple(std::ref(mat), std::ref(vec)),
vm.GetEvaluationState(),
domain);
}
}
template<class LawPolicyT>
void TimeSchemeInit(const GlobalVariationalOperatorNS::GradOnGradientBasedHyperelasticityTensor<LawPolicyT>& the_operator,
VectorsAndMatrices<HyperelasticityNS::TimeScheme::half_sum>& vm,
const Domain& domain)
{
auto& matrix_current_stiffness = vm.GetNonCstMatrixCurrentStiffness();
auto& vector_current_stiffness = vm.GetNonCstVectorCurrentStiffness();
matrix_current_stiffness.ZeroEntries(__FILE__, __LINE__);
vector_current_stiffness.ZeroEntries(__FILE__, __LINE__);
GlobalMatrixWithCoefficient mat(matrix_current_stiffness, 0.5);
GlobalVectorWithCoefficient vec(vector_current_stiffness, 1.);
if (is_first_dynamic_call)
{
auto& matrix_current_stiffness = vm.GetNonCstMatrixCurrentStiffness();
auto& vector_current_stiffness = vm.GetNonCstVectorCurrentStiffness();
matrix_current_stiffness.ZeroEntries(__FILE__, __LINE__);
vector_current_stiffness.ZeroEntries(__FILE__, __LINE__);
GlobalMatrixWithCoefficient mat(matrix_current_stiffness, 0.5);
GlobalVectorWithCoefficient vec(vector_current_stiffness, 1.);
the_operator.Assemble(std::make_tuple(std::ref(mat), std::ref(vec)),
vm.GetCurrentDisplacement(),
domain);
}
the_operator.Assemble(std::make_tuple(std::ref(mat), std::ref(vec)),
vm.GetCurrentDisplacement(),
domain);
}
......
......@@ -131,18 +131,32 @@ namespace HappyHeart
* \param[in] domain Domain into which the assembling occurs. Beware: finite element space into which
* AssembleStiffness() is called might also have restricted the integration domain; the integration
* truly occurs at the intersection of \a domain and the domain covered by the whole finite element space.
* \param[in] is_first_dynamic_call_done Irrelevant for current time scheme.
* \param[in,out] vm Vectors and matrices specifically related to current time scheme.
*/
template<class LawPolicyT>
void AssembleStiffness(const GlobalVariationalOperatorNS
::GradOnGradientBasedHyperelasticityTensor<LawPolicyT>& the_operator,
bool is_static_call,
bool is_first_dynamic_call_done,
VectorsAndMatrices<HyperelasticityNS::TimeScheme::midpoint>& vm,
const Domain& domain = Domain());
/*!
* \brief Initializations steps proper to the time scheme done just before first dynamic iteration.
*
* \param[in] the_operator Hyperelastic operator to be assembled.
* \param[in] domain Domain into which the assembling occurs. Beware: finite element space into which
* AssembleStiffness() is called might also have restricted the integration domain; the integration
* truly occurs at the intersection of \a domain and the domain covered by the whole finite element space.
* \param[in,out] vm Vectors and matrices specifically related to current time scheme.
*/
template<class LawPolicyT>
void TimeSchemeInit(const GlobalVariationalOperatorNS
::GradOnGradientBasedHyperelasticityTensor<LawPolicyT>& the_operator,
VectorsAndMatrices<HyperelasticityNS::TimeScheme::midpoint>& vm,
const Domain& domain = Domain());
} // namespace Private
......
......@@ -27,12 +27,10 @@ namespace HappyHeart
void AssembleStiffness(const GlobalVariationalOperatorNS
::GradOnGradientBasedHyperelasticityTensor<LawPolicyT>& the_operator,
bool is_static_call,
bool is_first_dynamic_call,
VectorsAndMatrices<HyperelasticityNS::TimeScheme::midpoint>& vm,
const Domain& domain)
{
static_cast<void>(is_static_call);
static_cast<void>(is_first_dynamic_call);
GlobalMatrixWithCoefficient mat(vm.GetNonCstMatrixNewStiffness(), 1.);
GlobalVectorWithCoefficient vec(vm.GetNonCstVectorNewStiffness(), 1.);
......@@ -42,6 +40,19 @@ namespace HappyHeart
domain);
}
template<class LawPolicyT>
void TimeSchemeInit(const GlobalVariationalOperatorNS
::GradOnGradientBasedHyperelasticityTensor<LawPolicyT>& the_operator,
VectorsAndMatrices<HyperelasticityNS::TimeScheme::midpoint>& vm,
const Domain& domain)
{
static_cast<void>(the_operator);
static_cast<void>(vm);
static_cast<void>(domain);
}
} // namespace Private
......
......@@ -57,6 +57,8 @@ namespace HappyHeart
::PrepareDynamicRuns()
{
UpdateDisplacementBetweenTimeStep();
Private::TimeSchemeInit(this->GetStiffnessOperator(), GetNonCstVectorsAndMatrices());
}
......@@ -377,7 +379,6 @@ namespace HappyHeart
// assembling operation(s)).
Private::AssembleStiffness(this->GetStiffnessOperator(),
this->GetTimeManager().GetStaticOrDynamic() == StaticOrDynamic::static_,
is_first_dynamic_call,
vm);
}
......
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