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

#860 ParamterAtQuadPoint added.

parent 871abcd7
......@@ -87,6 +87,8 @@ namespace HappyHeart
typename ActiveStressPolicyT::local_policy
>;
using InputActiveStressPolicyType = typename ActiveStressPolicyT::local_policy::input_active_stress_policy_type;
//! Returns the name of the operator.
static const std::string& ClassName();
......@@ -117,7 +119,7 @@ namespace HappyHeart
* Must be equal or higher than felt_space_dimension.
* \param[in] solid Object which provides the required material parameters for the solid.
* \param[in] time_manager Time manager need for Viscoelasticity and Active Stress.
* \param[in] match_dof_in_numbering_subset_operator Object required only for Active Stress to compute U0 and U1 locally.
* \param[in] input_active_stress_policy Object required only for Active Stress to compute U0 and U1 locally.
*/
explicit SecondPiolaKirchhoffStressTensor(const FEltSpace& felt_space,
const Unknown& vectorial_unknown,
......@@ -125,7 +127,7 @@ namespace HappyHeart
const quadrature_rule_per_topology_type& quadrature_rule_per_topology,
const Solid& solid,
const TimeManager& time_manager,
const MatchDofInNumberingSubset* match_dof_in_numbering_subset_operator = nullptr);
InputActiveStressPolicyType* input_active_stress_policy = nullptr);
//! Destructor.
~SecondPiolaKirchhoffStressTensor() = default;
......
......@@ -28,7 +28,7 @@ namespace HappyHeart
const quadrature_rule_per_topology_type& quadrature_rule_per_topology,
const Solid& solid,
const TimeManager& time_manager,
const MatchDofInNumberingSubset* match_dof_in_numbering_subset_operator)
InputActiveStressPolicyType* input_active_stress_policy)
: parent(felt_space,
vectorial_unknown,
geom_mesh_region_dimension,
......@@ -36,8 +36,9 @@ namespace HappyHeart
AllocateGradientFEltPhi::yes,
DoComputeProcessorWiseLocal2Global::yes,
solid,
time_manager),
match_dof_in_numbering_subset_operator_(match_dof_in_numbering_subset_operator)
time_manager,
input_active_stress_policy),
match_dof_in_numbering_subset_operator_(SecondPiolaKirchhoffStressTensorNS::Private::GetMatchDofInNumberingSubsetOperator<InputActiveStressPolicyType>::Perform(input_active_stress_policy))
{
assert(vectorial_unknown.GetNature() == UnknownNS::Nature::vectorial);
......@@ -52,12 +53,12 @@ namespace HappyHeart
const auto& active_stress_ptr = static_cast<ActiveStressPolicyT*>(this);
auto& active_stress = *active_stress_ptr;
SecondPiolaKirchhoffStressTensorNS::Private::InitializeSigmaC<ActiveStressPolicyT>::Perform(mesh,
quadrature_rule_per_topology,
initial_value,
time_manager,
local_operator_storage,
active_stress);
SecondPiolaKirchhoffStressTensorNS::Private::InitializeActivePolicy<ActiveStressPolicyT>::Perform(mesh,
quadrature_rule_per_topology,
initial_value,
time_manager,
local_operator_storage,
active_stress);
}
......
......@@ -88,11 +88,11 @@ namespace HappyHeart
//! Initialize Sigma_c.
template<class LocalOperatorStorageT>
void InitializeSigmaC(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 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);
private:
......
......@@ -30,11 +30,11 @@ namespace HappyHeart
template <unsigned int FiberIndexT>
template<class LocalOperatorStorageT>
void AnalyticalPrestressFiber<FiberIndexT>::InitializeSigmaC(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>::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)
{
sigma_c_ = std::make_unique<ParameterAtQuadraturePoint<ParameterNS::Type::scalar>>("SigmaC",
mesh,
......
......@@ -32,7 +32,6 @@ namespace HappyHeart
namespace ActiveStressPolicyNS
{
class None
{
public:
......@@ -48,7 +47,7 @@ namespace HappyHeart
using unique_ptr = std::unique_ptr<self>;
//! Alias to vector of unique pointers.
using vector_unique_ptr = std::vector<unique_ptr> ;
using vector_unique_ptr = std::vector<unique_ptr>;
public:
......@@ -78,6 +77,7 @@ namespace HappyHeart
};
} // namespace ActiveStressPolicyNS
......
......@@ -15,6 +15,7 @@
# include <vector>
# include "Operators/GlobalVariationalOperatorInstances/NonlinearForm/SecondPiolaKirchhoffStressTensor/ActiveStressPolicy/None.hpp"
# include "Operators/Miscellaneous/MatchDofInNumberingSubset.hpp"
namespace HappyHeart
......@@ -34,7 +35,7 @@ namespace HappyHeart
template<class ActiveStressPolicyT>
struct InitializeSigmaC
struct InitializeActivePolicy
{
template<class LocalOperatorStorageT>
......@@ -49,7 +50,7 @@ namespace HappyHeart
template<>
struct InitializeSigmaC<ActiveStressPolicyNS::None>
struct InitializeActivePolicy<ActiveStressPolicyNS::None>
{
template <class LocalOperatorStorageT>
......@@ -60,6 +61,20 @@ namespace HappyHeart
const LocalOperatorStorageT& local_operator_storage,
ActiveStressPolicyNS::None& active_stress);
};
template<class InputActiveStressPolicyT>
struct GetMatchDofInNumberingSubsetOperator
{
static const MatchDofInNumberingSubset* Perform(const InputActiveStressPolicyT* input_active_stress_policy);
};
template<>
struct GetMatchDofInNumberingSubsetOperator<ActiveStressPolicyNS::None::local_policy::input_active_stress_policy_type>
{
static const MatchDofInNumberingSubset* Perform(const ActiveStressPolicyNS::None::local_policy::input_active_stress_policy_type* input_active_stress_policy);
};
} // namespace Private
......
......@@ -30,23 +30,23 @@ namespace HappyHeart
template <class ActiveStressPolicyT>
template<class LocalOperatorStorageT>
void InitializeSigmaC<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 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)
{
active_stress.template InitializeSigmaC(mesh,
quadrature_rule_per_topology,
initial_value,
time_manager,
local_operator_storage);
active_stress.template InitializeActivePolicy(mesh,
quadrature_rule_per_topology,
initial_value,
time_manager,
local_operator_storage);
}
template <class LocalOperatorStorageT>
void InitializeSigmaC<ActiveStressPolicyNS::None>
void InitializeActivePolicy<ActiveStressPolicyNS::None>
::Perform(const GeometricMeshRegion& mesh,
const quadrature_rule_per_topology_type& quadrature_rule_per_topology,
const double initial_value,
......@@ -61,6 +61,23 @@ namespace HappyHeart
static_cast<void>(local_operator_storage);
static_cast<void>(active_stress);
}
template<class InputActiveStressPolicyT>
const MatchDofInNumberingSubset* GetMatchDofInNumberingSubsetOperator<InputActiveStressPolicyT>
::Perform(const InputActiveStressPolicyT* input_active_stress_policy)
{
return input_active_stress_policy->GetMatchDofInNumberingSubsetOperator();
};
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)
{
static_cast<void>(input_active_stress_policy);
return nullptr;
};
} // namespace Private
......
//
// GreenLagrangeTensor.cpp
// HappyHeart
//
// Created by Gautier Bureau on 16/03/15.
// Copyright (c) 2015 Inria. All rights reserved.
//
#include "Utilities/Numeric/Numeric.hpp"
#include "Operators/LocalVariationalOperator/Private/GreenLagrangeTensor.hpp"
namespace HappyHeart
{
namespace LocalVariationalOperatorNS
{
namespace Private
{
GreenLagrangeTensor::GreenLagrangeTensor(unsigned int mesh_dimension)
: mesh_dimension_(mesh_dimension)
{
auto& vector = GetNonCstVector();
switch(mesh_dimension)
{
case 2u:
vector.Resize(3);
break;
case 3u:
vector.Resize(6);
break;
default:
assert(false && "Only implemented for dimensions 2 and 3.");
exit(EXIT_FAILURE);
}
}
namespace // anonymous
{
void Update2D(const CauchyGreenTensor& cauchy_green_tensor, LocalVector& result);
void Update3D(const CauchyGreenTensor& cauchy_green_tensor, LocalVector& result);
} // namespace anonymous
const LocalVector& GreenLagrangeTensor::Update(const CauchyGreenTensor& cauchy_green_tensor)
{
const auto mesh_dimension = GetMeshDimension();
auto& ret = GetNonCstVector();
switch (mesh_dimension)
{
case 2u:
Update2D(cauchy_green_tensor, ret);
return ret;
case 3u:
Update3D(cauchy_green_tensor, ret);
return ret;
default:
assert(false && "Only implemented for dimensions 2 and 3.");
exit(EXIT_FAILURE);
}
}
namespace // anonymous
{
void Update2D(const CauchyGreenTensor& cauchy_green_tensor, LocalVector& result)
{
assert(result.GetM() == 3);
result(0) = 0.5*(cauchy_green_tensor.xx() - 1.);
result(1) = 0.5*(cauchy_green_tensor.yy() - 1.);
result(2) = cauchy_green_tensor.xy();
}
void Update3D(const CauchyGreenTensor& cauchy_green_tensor, LocalVector& result)
{
assert(result.GetM() == 6);
result(0) = 0.5*(cauchy_green_tensor.xx() - 1.);
result(1) = 0.5*(cauchy_green_tensor.yy() - 1.);
result(2) = 0.5*(cauchy_green_tensor.zz() - 1.);
result(3) = cauchy_green_tensor.xy();
result(4) = cauchy_green_tensor.yz();
result(5) = cauchy_green_tensor.xz();
}
} // namespace anonymous
} // namespace Private
} // namespace LocalVariationalOperatorNS
} // namespace HappyHeart
//
// GreenLagrangeTensor.hpp
// HappyHeart
//
// Created by Gautier Bureau on 16/03/15.
// Copyright (c) 2015 Inria. All rights reserved.
//
#ifndef HAPPY_HEART_x_OPERATORS_x_LOCAL_VARIATIONAL_OPERATOR_x_PRIVATE_x_GREEN_LAGRANGE_TENSOR_HPP_
# define HAPPY_HEART_x_OPERATORS_x_LOCAL_VARIATIONAL_OPERATOR_x_PRIVATE_x_GREEN_LAGRANGE_TENSOR_HPP_
# include <memory>
# include <vector>
# include <array>
# include "Utilities/MatrixOrVector.hpp"
#include "Operators/LocalVariationalOperator/Private/CauchyGreenTensor.hpp"
namespace HappyHeart
{
namespace LocalVariationalOperatorNS
{
namespace Private
{
/*!
* \brief Class in charge of computing Cauchy-Green tensor.
*/
class GreenLagrangeTensor final
{
public:
//! Alias to unique pointer.
using unique_ptr = std::unique_ptr<GreenLagrangeTensor>;
public:
//! Constructor.
explicit GreenLagrangeTensor(unsigned int mesh_dimension);
//! Destructor.
~GreenLagrangeTensor() = default;
//! Copy constructor.
GreenLagrangeTensor(const GreenLagrangeTensor&) = delete;
//! Move constructor.
GreenLagrangeTensor(GreenLagrangeTensor&&) = default;
//! Copy affectation.
GreenLagrangeTensor& operator=(const GreenLagrangeTensor&) = delete;
//! Move affectation.
GreenLagrangeTensor& operator=(GreenLagrangeTensor&&) = delete;
//! Update the values.
const LocalVector& Update(const CauchyGreenTensor& cauchy_green_tensor);
private:
//! Dimension of the mesh considered.
unsigned int GetMeshDimension() const noexcept;
/*!
* \brief Access to the matrix.
*
* \internal This one is at the moment private because all uses are currently covered by Update().
*/
const LocalVector& GetVector() const noexcept;
//! Non constant access to the matrix.
LocalVector& GetNonCstVector() noexcept;
private:
//! Mesh dimension.
const unsigned int mesh_dimension_;
//! The matrix.
LocalVector vector_;
};
} // namespace Private
} // namespace LocalVariationalOperatorNS
} // namespace HappyHeart
#include "Operators/LocalVariationalOperator/Private/GreenLagrangeTensor.hxx"
#endif // HAPPY_HEART_x_OPERATORS_x_LOCAL_VARIATIONAL_OPERATOR_x_PRIVATE_x_GREEN_LAGRANGE_TENSOR_HPP_
//
// GreenLagrangeTensor.hxx
// HappyHeart
//
// Created by Gautier Bureau on 16/03/15.
// Copyright (c) 2015 Inria. All rights reserved.
//
#ifndef HAPPY_HEART_x_OPERATORS_x_LOCAL_VARIATIONAL_OPERATOR_x_PRIVATE_x_GREEN_LAGRANGE_TENSOR_HXX_
# define HAPPY_HEART_x_OPERATORS_x_LOCAL_VARIATIONAL_OPERATOR_x_PRIVATE_x_GREEN_LAGRANGE_TENSOR_HXX_
namespace HappyHeart
{
namespace LocalVariationalOperatorNS
{
namespace Private
{
inline unsigned int GreenLagrangeTensor::GetMeshDimension() const noexcept
{
assert(mesh_dimension_ == 2u || mesh_dimension_ == 3u);
return mesh_dimension_;
}
inline const LocalVector& GreenLagrangeTensor::GetVector() const noexcept
{
return vector_;
}
inline LocalVector& GreenLagrangeTensor::GetNonCstVector() noexcept
{
return const_cast<LocalVector&>(GetVector());
}
} // namespace Private
} // namespace LocalVariationalOperatorNS
} // namespace HappyHeart
#endif // HAPPY_HEART_x_OPERATORS_x_LOCAL_VARIATIONAL_OPERATOR_x_PRIVATE_x_CAUCHY_GREEN_TENSOR_HXX_
......@@ -153,11 +153,11 @@ namespace HappyHeart
private:
std::array<ScalarParameterAtQuadPt::unique_ptr, 30> parameter_list_;
std::array<ParameterAtQuadaturePoint<ParameterNS::Type::scalar>::unique_ptr, 30> parameter_list_;
ScalarParameterAtQuadPt& GetNonCstParameter(parameter_index index) noexcept;
ParameterAtQuadaturePoint<ParameterNS::Type::scalar>& GetNonCstParameter(parameter_index index) noexcept;
const ScalarParameterAtQuadPt& GetParameter(parameter_index index) const noexcept;
const ParameterAtQuadaturePoint<ParameterNS::Type::scalar>& GetParameter(parameter_index index) const noexcept;
private:
......
......@@ -276,7 +276,7 @@ namespace HappyHeart
inline ReactionLaw<ReactionLawName::CourtemancheRamirezNattel>::ScalarParameterAtQuadPt&
ReactionLaw<ReactionLawName::CourtemancheRamirezNattel>::GetNonCstParameter(parameter_index index) noexcept
{
return const_cast<ScalarParameterAtQuadPt&>(GetParameter(index));
return const_cast<ParameterAtQuadaturePoint<ParameterNS::Type::scalar>&>(GetParameter(index));
}
......
......@@ -125,14 +125,14 @@ namespace HappyHeart
double GetC() const noexcept;
ScalarParameterAtQuadPt& GetNonCstGate() noexcept;
ParameterAtQuadaturePoint<ParameterNS::Type::scalar>& GetNonCstGate() noexcept;
const ScalarParameterAtQuadPt& GetGate() const noexcept;
const ParameterAtQuadaturePoint<ParameterNS::Type::scalar>& GetGate() const noexcept;
private:
//! Gate.
ScalarParameterAtQuadPt::unique_ptr gate_ = nullptr;
ParameterAtQuadaturePoint<ParameterNS::Type::scalar>::unique_ptr gate_ = nullptr;
private:
......