Commit e55436b7 authored by Gautier Bureau's avatar Gautier Bureau Committed by GILLES Sebastien
Browse files

#860 PK2 modified for the new way of managing inputs for active stress policy....

#860 PK2 modified for the new way of managing inputs for active stress policy. May not compile for all models but works with CardiacMechanicsActive.
parent 70438341
......@@ -29,9 +29,6 @@
# include "Operators/GlobalVariationalOperatorInstances/NonlinearForm/SecondPiolaKirchhoffStressTensor/ActiveStressPolicy/None.hpp"
# include "Operators/Miscellaneous/MatchDofInNumberingSubset.hpp"
namespace HappyHeart
{
......@@ -87,7 +84,7 @@ namespace HappyHeart
typename ActiveStressPolicyT::local_policy
>;
using InputActiveStressPolicyType = typename ActiveStressPolicyT::local_policy::input_active_stress_policy_type;
using input_active_stress_policy_type = typename ActiveStressPolicyT::input_active_stress_policy_type;
//! Returns the name of the operator.
static const std::string& ClassName();
......@@ -127,7 +124,7 @@ namespace HappyHeart
const quadrature_rule_per_topology_type& quadrature_rule_per_topology,
const Solid& solid,
const TimeManager& time_manager,
InputActiveStressPolicyType* input_active_stress_policy = nullptr);
input_active_stress_policy_type* input_active_stress_policy = nullptr);
//! Destructor.
~SecondPiolaKirchhoffStressTensor() = default;
......@@ -355,16 +352,6 @@ namespace HappyHeart
SetComputeEltArrayArguments(const LocalFEltSpace& local_felt_space,
typename parent::local_variational_operator& local_operator,
std::tuple<const GlobalVector&, const GlobalVector&, const GlobalVector&, const bool>&& additional_arguments) const;
private:
//! Constant accessor to GetMatchDofInNumberingSubsetOperator. Used for ActiveStress.
const MatchDofInNumberingSubset& GetMatchDofInNumberingSubsetOperator() const noexcept;
//! Used for ActiveStress for have the electrical activation at each node of the current element to integrate.
const MatchDofInNumberingSubset* match_dof_in_numbering_subset_operator_;
};
......
......@@ -28,7 +28,7 @@ namespace HappyHeart
const quadrature_rule_per_topology_type& quadrature_rule_per_topology,
const Solid& solid,
const TimeManager& time_manager,
InputActiveStressPolicyType* input_active_stress_policy)
input_active_stress_policy_type* input_active_stress_policy)
: parent(felt_space,
vectorial_unknown,
geom_mesh_region_dimension,
......@@ -37,15 +37,10 @@ namespace HappyHeart
DoComputeProcessorWiseLocal2Global::yes,
solid,
time_manager,
input_active_stress_policy),
match_dof_in_numbering_subset_operator_(SecondPiolaKirchhoffStressTensorNS::Private::GetMatchDofInNumberingSubsetOperator<InputActiveStressPolicyType>::Perform(input_active_stress_policy))
input_active_stress_policy)
{
assert(vectorial_unknown.GetNature() == UnknownNS::Nature::vectorial);
// #782 hardcoded. Must be initialized with new arguments and a new structure that will be created later.
// For now it is ok.
const double initial_value = 0.;
const auto god_of_dof_ptr = felt_space.GetGodOfDofFromWeakPtr();
const auto& mesh = god_of_dof_ptr->GetGeometricMeshRegion();
decltype(auto) local_operator_storage = parent::GetLocalOperatorPerRefGeomElt();
......@@ -53,17 +48,15 @@ namespace HappyHeart
const auto& active_stress_ptr = static_cast<ActiveStressPolicyT*>(this);
auto& active_stress = *active_stress_ptr;
SecondPiolaKirchhoffStressTensorNS::Private::InitializeActivePolicy<ActiveStressPolicyT>::Perform(mesh,
quadrature_rule_per_topology,
initial_value,
time_manager,
local_operator_storage,
active_stress);
SecondPiolaKirchhoffStressTensorNS::Private::InitializeActiveStressPolicy<ActiveStressPolicyT>::Perform(mesh,
quadrature_rule_per_topology,
time_manager,
local_operator_storage,
input_active_stress_policy,
active_stress);
}
template <class HyperelasticityPolicyT, class ViscoelasticityPolicyT, class ActiveStressPolicyT>
const std::string& SecondPiolaKirchhoffStressTensor<HyperelasticityPolicyT, ViscoelasticityPolicyT, ActiveStressPolicyT>
::ClassName()
......@@ -205,11 +198,18 @@ namespace HappyHeart
this->GetNthUnknown(),
std::get<1>(additional_arguments),
local_operator.GetNonCstLocalVelocity());
const auto& active_stress_ptr = static_cast<const ActiveStressPolicyT*>(this);
auto& active_stress = *active_stress_ptr;
const MatchDofInNumberingSubset* raw_match_dof_numbering_subset = SecondPiolaKirchhoffStressTensorNS::Private::GetMatchDofInNumberingSubsetOperator<ActiveStressPolicyT>::Perform(active_stress);
assert(!(!raw_match_dof_numbering_subset));
SetComputeEltArrayArgumentsActivePolicy(local_operator,
local_felt_space,
this->GetNthUnknown(),
GetMatchDofInNumberingSubsetOperator(),
*raw_match_dof_numbering_subset,
std::get<2>(additional_arguments),
std::get<3>(additional_arguments),
std::get<4>(additional_arguments));
......@@ -227,25 +227,22 @@ namespace HappyHeart
std::get<0>(additional_arguments),
local_operator.GetNonCstFormerLocalDisplacement());
const auto& active_stress_ptr = static_cast<const ActiveStressPolicyT*>(this);
auto& active_stress = *active_stress_ptr;
const MatchDofInNumberingSubset* raw_match_dof_numbering_subset = SecondPiolaKirchhoffStressTensorNS::Private::GetMatchDofInNumberingSubsetOperator<ActiveStressPolicyT>::Perform(active_stress);
assert(!(!raw_match_dof_numbering_subset));
SetComputeEltArrayArgumentsActivePolicy(local_operator,
local_felt_space,
this->GetNthUnknown(),
GetMatchDofInNumberingSubsetOperator(),
*raw_match_dof_numbering_subset,
std::get<1>(additional_arguments),
std::get<2>(additional_arguments),
std::get<3>(additional_arguments));
}
template <class HyperelasticityPolicyT, class ViscoelasticityPolicyT, class ActiveStressPolicyT>
inline const MatchDofInNumberingSubset&
SecondPiolaKirchhoffStressTensor<HyperelasticityPolicyT, ViscoelasticityPolicyT, ActiveStressPolicyT>
::GetMatchDofInNumberingSubsetOperator() const noexcept
{
assert(!(!match_dof_in_numbering_subset_operator_));
return *match_dof_in_numbering_subset_operator_;
}
namespace // anonymous
{
......
......@@ -88,7 +88,7 @@ namespace HappyHeart
//! Initialize Sigma_c.
template<class LocalOperatorStorageT>
void InitializeActivePolicy(const GeometricMeshRegion& mesh,
void InitializeActiveStressPolicy(const GeometricMeshRegion& mesh,
const quadrature_rule_per_topology_type& quadrature_rule_per_topology,
const double initial_value,
const TimeManager& time_manager,
......
......@@ -30,11 +30,11 @@ namespace HappyHeart
template <unsigned int FiberIndexT>
template<class LocalOperatorStorageT>
void AnalyticalPrestressFiber<FiberIndexT>::InitializeActivePolicy(const GeometricMeshRegion& mesh,
const quadrature_rule_per_topology_type& quadrature_rule_per_topology,
const double initial_value,
const TimeManager& time_manager,
const LocalOperatorStorageT& local_operator_storage)
void AnalyticalPrestressFiber<FiberIndexT>::InitializeActiveStressPolicy(const GeometricMeshRegion& mesh,
const quadrature_rule_per_topology_type& quadrature_rule_per_topology,
const double initial_value,
const TimeManager& time_manager,
const LocalOperatorStorageT& local_operator_storage)
{
sigma_c_ = std::make_unique<ParameterAtQuadraturePoint<ParameterNS::Type::scalar>>("SigmaC",
mesh,
......
......@@ -36,8 +36,12 @@ namespace HappyHeart
{
public:
//!
using local_policy = LocalVariationalOperatorNS::SecondPiolaKirchhoffStressTensorNS::ActiveStressPolicyNS::None;
//! Alias to the type of the input.
using input_active_stress_policy_type = local_policy::input_active_stress_policy_type;
public:
//! Alias to self.
......
......@@ -35,45 +35,45 @@ namespace HappyHeart
template<class ActiveStressPolicyT>
struct InitializeActivePolicy
struct InitializeActiveStressPolicy
{
template<class LocalOperatorStorageT>
static void Perform(const GeometricMeshRegion& mesh,
const quadrature_rule_per_topology_type& quadrature_rule_per_topology,
const double initial_value,
const TimeManager& time_manager,
const LocalOperatorStorageT& local_operator_storage,
typename ActiveStressPolicyT::input_active_stress_policy_type* input_active_stress_policy,
ActiveStressPolicyT& active_stress);
};
template<>
struct InitializeActivePolicy<ActiveStressPolicyNS::None>
struct InitializeActiveStressPolicy<ActiveStressPolicyNS::None>
{
template <class LocalOperatorStorageT>
static void Perform(const GeometricMeshRegion& mesh,
const quadrature_rule_per_topology_type& quadrature_rule_per_topology,
const double initial_value,
const TimeManager& time_manager,
const LocalOperatorStorageT& local_operator_storage,
typename ActiveStressPolicyNS::None::input_active_stress_policy_type* input_active_stress_policy,
ActiveStressPolicyNS::None& active_stress);
};
template<class InputActiveStressPolicyT>
template<class ActiveStressPolicyT>
struct GetMatchDofInNumberingSubsetOperator
{
static const MatchDofInNumberingSubset* Perform(const InputActiveStressPolicyT* input_active_stress_policy);
static const MatchDofInNumberingSubset* Perform(const ActiveStressPolicyT& active_stress);
};
template<>
struct GetMatchDofInNumberingSubsetOperator<ActiveStressPolicyNS::None::local_policy::input_active_stress_policy_type>
struct GetMatchDofInNumberingSubsetOperator<ActiveStressPolicyNS::None>
{
static const MatchDofInNumberingSubset* Perform(const ActiveStressPolicyNS::None::local_policy::input_active_stress_policy_type* input_active_stress_policy);
static const MatchDofInNumberingSubset* Perform(const ActiveStressPolicyNS::None& active_stress);
};
......
......@@ -30,51 +30,51 @@ namespace HappyHeart
template <class ActiveStressPolicyT>
template<class LocalOperatorStorageT>
void InitializeActivePolicy<ActiveStressPolicyT>::Perform(const GeometricMeshRegion& mesh,
const quadrature_rule_per_topology_type& quadrature_rule_per_topology,
const double initial_value,
const TimeManager& time_manager,
const LocalOperatorStorageT& local_operator_storage,
ActiveStressPolicyT& active_stress)
void InitializeActiveStressPolicy<ActiveStressPolicyT>::Perform(const GeometricMeshRegion& mesh,
const quadrature_rule_per_topology_type& quadrature_rule_per_topology,
const TimeManager& time_manager,
const LocalOperatorStorageT& local_operator_storage,
typename ActiveStressPolicyT::input_active_stress_policy_type* input_active_stress_policy,
ActiveStressPolicyT& active_stress)
{
active_stress.template InitializeActivePolicy(mesh,
quadrature_rule_per_topology,
initial_value,
time_manager,
local_operator_storage);
active_stress.template InitializeActiveStressPolicy(mesh,
quadrature_rule_per_topology,
time_manager,
local_operator_storage,
input_active_stress_policy);
}
template <class LocalOperatorStorageT>
void InitializeActivePolicy<ActiveStressPolicyNS::None>
void InitializeActiveStressPolicy<ActiveStressPolicyNS::None>
::Perform(const GeometricMeshRegion& mesh,
const quadrature_rule_per_topology_type& quadrature_rule_per_topology,
const double initial_value,
const TimeManager& time_manager,
const LocalOperatorStorageT& local_operator_storage,
typename ActiveStressPolicyNS::None::input_active_stress_policy_type* input_active_stress_policy,
ActiveStressPolicyNS::None& active_stress)
{
static_cast<void>(mesh);
static_cast<void>(quadrature_rule_per_topology);
static_cast<void>(initial_value);
static_cast<void>(time_manager);
static_cast<void>(local_operator_storage);
static_cast<void>(input_active_stress_policy);
static_cast<void>(active_stress);
}
template<class InputActiveStressPolicyT>
const MatchDofInNumberingSubset* GetMatchDofInNumberingSubsetOperator<InputActiveStressPolicyT>
::Perform(const InputActiveStressPolicyT* input_active_stress_policy)
template<class ActiveStressPolicyT>
const MatchDofInNumberingSubset* GetMatchDofInNumberingSubsetOperator<ActiveStressPolicyT>
::Perform(const ActiveStressPolicyT& active_stress)
{
return input_active_stress_policy->GetMatchDofInNumberingSubsetOperator();
return active_stress.GetMatchDofInNumberingSubsetOperatorPtr();
};
inline const MatchDofInNumberingSubset* GetMatchDofInNumberingSubsetOperator<ActiveStressPolicyNS::None::local_policy::input_active_stress_policy_type>
::Perform(const ActiveStressPolicyNS::None::local_policy::input_active_stress_policy_type* input_active_stress_policy)
inline const MatchDofInNumberingSubset* GetMatchDofInNumberingSubsetOperator<ActiveStressPolicyNS::None>
::Perform(const ActiveStressPolicyNS::None& active_stress)
{
static_cast<void>(input_active_stress_policy);
static_cast<void>(active_stress);
return nullptr;
};
......
......@@ -50,4 +50,4 @@ namespace HappyHeart
} // namespace HappyHeart
#endif // HAPPY_HEART_x_OPERATORS_x_LOCAL_VARIATIONAL_OPERATOR_x_PRIVATE_x_CAUCHY_GREEN_TENSOR_HXX_
#endif // HAPPY_HEART_x_OPERATORS_x_LOCAL_VARIATIONAL_OPERATOR_x_PRIVATE_x_GREEN_LAGRANGE_TENSOR_HXX_
......@@ -37,7 +37,10 @@ namespace HappyHeart
if (local_potential < GetUGate())
{
gate += GetTimeManager().GetTimeStep() * (1/NumericNS::Square(GetUMax()-GetUMin()) - gate) / GetTauOpen();
assert(!NumericNS::IsZero(NumericNS::Square(GetUMax() - GetUMin())));
assert(!NumericNS::IsZero(GetTauOpen()));
gate += GetTimeManager().GetTimeStep() * (1. / NumericNS::Square(GetUMax() - GetUMin()) - gate) / GetTauOpen();
}
else
{
......@@ -59,6 +62,9 @@ namespace HappyHeart
geom_elt,
functor);
assert(!NumericNS::IsZero(GetTauIn()*(GetUMax() - GetUMin())));
assert(!NumericNS::IsZero(GetTauOut()*(GetUMax() - GetUMin())));
return new_gate * NumericNS::Square(local_potential - GetUMin()) * (GetUMax() - local_potential)/(GetTauIn()*(GetUMax() - GetUMin())) -
(local_potential - GetUMin())/(GetTauOut()*(GetUMax() - GetUMin()));
}
......
......@@ -114,7 +114,8 @@ namespace HappyHeart
//! Rejuvenate alias from parent class.
using elementary_data_type = typename parent::elementary_data_type;
using InputActiveStressPolicyType = typename ActiveStressPolicyT::input_active_stress_policy_type;
//!
using input_active_stress_policy_type = typename ActiveStressPolicyT::input_active_stress_policy_type;
public:
......@@ -137,7 +138,7 @@ namespace HappyHeart
elementary_data_type&& elementary_data,
const Solid& solid,
const TimeManager& time_manager,
InputActiveStressPolicyType* input_active_stress_policy);
input_active_stress_policy_type* input_active_stress_policy);
//! Destructor.
virtual ~SecondPiolaKirchhoffStressTensor();
......
......@@ -39,7 +39,7 @@ namespace HappyHeart
elementary_data_type&& a_elementary_data,
const Solid& solid,
const TimeManager& time_manager,
InputActiveStressPolicyType* input_active_stress_policy)
input_active_stress_policy_type* input_active_stress_policy)
: HyperelasticityPolicyT(a_elementary_data.GetGeomMeshRegionDimension(), solid),
ViscoelasticityPolicyT(a_elementary_data.GetGeomMeshRegionDimension(),
a_elementary_data.Ndof(),
......
......@@ -6,8 +6,8 @@
// Copyright © 2016 Inria. All rights reserved.
//
#ifndef HAPPY_HEART_x_OPERATORS_x_LOCAL_VARIATIONAL_OPERATOR_INSTANCES_x_NONLINEAR_FORM_x_SECOND_PIOLA_KIRCHHOFF_STRESS_TENSOR_x_ACTIVE_STRESS_POLICY_x_INPUT_NONE_HPP_
# define HAPPY_HEART_x_OPERATORS_x_LOCAL_VARIATIONAL_OPERATOR_INSTANCES_x_NONLINEAR_FORM_x_SECOND_PIOLA_KIRCHHOFF_STRESS_TENSOR_x_ACTIVE_STRESS_POLICY_x_INPUT_NONE_HPP_
#ifndef HAPPY_HEART_x_OPERATORS_x_GLOBAL_VARIATIONAL_OPERATOR_INSTANCES_x_NONLINEAR_FORM_x_SECOND_PIOLA_KIRCHHOFF_STRESS_TENSOR_x_ACTIVE_STRESS_POLICY_x_INPUT_NONE_HPP_
# define HAPPY_HEART_x_OPERATORS_x_GLOBAL_VARIATIONAL_OPERATOR_INSTANCES_x_NONLINEAR_FORM_x_SECOND_PIOLA_KIRCHHOFF_STRESS_TENSOR_x_ACTIVE_STRESS_POLICY_x_INPUT_NONE_HPP_
......@@ -44,4 +44,4 @@ namespace HappyHeart
} // namespace HappyHeart
#endif // HAPPY_HEART_x_OPERATORS_x_LOCAL_VARIATIONAL_OPERATOR_INSTANCES_x_NONLINEAR_FORM_x_SECOND_PIOLA_KIRCHHOFF_STRESS_TENSOR_x_ACTIVE_STRESS_POLICY_x_INPUT_NONE_HPP_
#endif // HAPPY_HEART_x_OPERATORS_x_GLOBAL_VARIATIONAL_OPERATOR_INSTANCES_x_NONLINEAR_FORM_x_SECOND_PIOLA_KIRCHHOFF_STRESS_TENSOR_x_ACTIVE_STRESS_POLICY_x_INPUT_NONE_HPP_
......@@ -49,7 +49,8 @@ namespace HappyHeart
//! Alias to vector of unique pointers.
using vector_unique_ptr = std::vector<unique_ptr> ;
using input_active_stress_policy_type = InputNone;
// Alias to the type of the input.
using input_active_stress_policy_type = LocalVariationalOperatorNS::SecondPiolaKirchhoffStressTensorNS::ActiveStressPolicyNS::InputNone;
public:
......
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