Commit 4aca1fe9 authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#1022 Fluidmass: use array of unique pointers to group more together data attributes.

parent 8ab97a5d
......@@ -50,15 +50,21 @@ namespace HappyHeart
decltype(auto) solid_mesh = solid_god_of_dof.GetGeometricMeshRegion();
constexpr auto solid_index = EnumUnderlyingType(InternalMeshIndex::solid);
constexpr auto fluid_index = EnumUnderlyingType(InternalMeshIndex::fluid);
{
from_monolithic_parent::Init(solid_god_of_dof, solid_numbering_subset);
decltype(auto) new_value = from_monolithic_parent::GetNew();
global_vector_temporary_solid_parent::InitGlobalVectorTemporary(new_value);
current_value_ = std::make_unique<GlobalVector>(new_value);
former_value_ = std::make_unique<GlobalVector>(new_value);
new_minus_current_on_solid_ = std::make_unique<GlobalVector>(new_value);
current_minus_former_on_solid_ = std::make_unique<GlobalVector>(new_value);
current_value_[solid_index] = std::make_unique<GlobalVector>(new_value);
former_value_[solid_index] = std::make_unique<GlobalVector>(new_value);
new_minus_current_[solid_index] = std::make_unique<GlobalVector>(new_value);
current_minus_former_[solid_index] = std::make_unique<GlobalVector>(new_value);
delta_on_solid_ = std::make_unique<GlobalVector>(new_value);
}
......@@ -67,13 +73,16 @@ namespace HappyHeart
decltype(auto) fluid_numbering_subset =
fluid_god_of_dof.GetNumberingSubset(EnumUnderlyingType(NumberingSubsetIndex::fluid_mass));
current_value_on_fluid_ = std::make_unique<GlobalVector>(fluid_numbering_subset);
auto& value = *current_value_on_fluid_;
current_value_[fluid_index] = std::make_unique<GlobalVector>(fluid_numbering_subset);
auto& value = *current_value_[fluid_index];
AllocateGlobalVector(fluid_god_of_dof, value);
new_minus_current_on_fluid_ = std::make_unique<GlobalVector>(value);
current_minus_former_on_fluid_ = std::make_unique<GlobalVector>(value);
former_value_[fluid_index] = std::make_unique<GlobalVector>(value);
new_minus_current_[fluid_index] = std::make_unique<GlobalVector>(value);
current_minus_former_[fluid_index] = std::make_unique<GlobalVector>(value);
global_vector_temporary_fluid_parent::InitGlobalVectorTemporary(value);
}
......@@ -88,32 +97,32 @@ namespace HappyHeart
const auto& fluid_mass_unknown =
unknown_manager.GetUnknown(EnumUnderlyingType(UnknownIndex::fluid_mass));
new_as_param_ = std::make_unique<scalar_at_dof_type>("Fluid mass",
new_as_param_[solid_index] = std::make_unique<scalar_at_dof_type>("Fluid mass",
solid_mesh,
felt_space,
fluid_mass_unknown,
GetNew());
current_value_as_param_ = std::make_unique<scalar_at_dof_type>("Current fluid mass",
current_value_as_param_[solid_index] = std::make_unique<scalar_at_dof_type>("Current fluid mass",
solid_mesh,
felt_space,
fluid_mass_unknown,
GetCurrent());
former_value_as_param_ = std::make_unique<scalar_at_dof_type>("Former fluid mass",
former_value_as_param_[solid_index] = std::make_unique<scalar_at_dof_type>("Former fluid mass",
solid_mesh,
felt_space,
fluid_mass_unknown,
GetFormer());
new_minus_current_on_solid_as_param_ =
new_minus_current_as_param_[solid_index] =
std::make_unique<scalar_at_dof_type>("New - current fluid mass",
solid_mesh,
felt_space,
fluid_mass_unknown,
GetNewMinusCurrentOnSolid());
current_minus_former_on_solid_as_param_ =
current_minus_former_as_param_[solid_index] =
std::make_unique<scalar_at_dof_type>("Current - former fluid mass",
solid_mesh,
felt_space,
......@@ -125,14 +134,14 @@ namespace HappyHeart
const auto& fluid_felt_space = fluid_god_of_dof.GetFEltSpace(EnumUnderlyingType(FEltSpaceIndex::fluid));
new_minus_current_on_fluid_as_param_ =
new_minus_current_as_param_[fluid_index] =
std::make_unique<scalar_at_dof_type>("New - current fluid mass on fluid",
fluid_mesh,
fluid_felt_space,
fluid_mass_unknown,
GetNewMinusCurrentOnFluid());
current_minus_former_on_fluid_as_param_ =
current_minus_former_as_param_[fluid_index] =
std::make_unique<scalar_at_dof_type>("Current - former fluid mass on fluid",
fluid_mesh,
fluid_felt_space,
......@@ -189,10 +198,11 @@ namespace HappyHeart
const GlobalVector& Fluidmass::GetNewMinusCurrentOnSolid() const noexcept
{
assert(!(!new_minus_current_on_solid_));
constexpr auto solid_index = EnumUnderlyingType(InternalMeshIndex::solid);
assert(!(!new_minus_current_[solid_index]));
decltype(auto) new_value = GetNew();
auto& ret = *new_minus_current_on_solid_;
auto& ret = *new_minus_current_[solid_index];
if (new_minus_current_on_solid_tag_ != GetValueTag())
{
......@@ -206,17 +216,17 @@ namespace HappyHeart
new_minus_current_on_solid_tag_ = GetValueTag();
}
return *new_minus_current_on_solid_;
return *new_minus_current_[solid_index];
}
const GlobalVector& Fluidmass::GetCurrentMinusFormerOnSolid() const noexcept
{
assert(!(!current_minus_former_on_solid_));
constexpr auto solid_index = EnumUnderlyingType(InternalMeshIndex::solid);
assert(!(!current_minus_former_[solid_index]));
decltype(auto) current_value = GetCurrent();
auto& ret = *current_minus_former_on_solid_;
auto& ret = *current_minus_former_[solid_index];
if (current_minus_former_on_solid_tag_ != GetValueTag())
{
......@@ -230,15 +240,15 @@ namespace HappyHeart
current_minus_former_on_solid_tag_ = GetValueTag();
}
return *current_minus_former_on_solid_;
return *current_minus_former_[solid_index];
}
const GlobalVector& Fluidmass::GetNewMinusCurrentOnFluid() const noexcept
{
assert(!(!new_minus_current_on_fluid_));
auto& ret = *new_minus_current_on_fluid_;
constexpr auto fluid_index = EnumUnderlyingType(InternalMeshIndex::fluid);
assert(!(!new_minus_current_[fluid_index]));
auto& ret = *new_minus_current_[fluid_index];
if (new_minus_current_on_fluid_tag_ != GetValueTag())
{
......@@ -251,15 +261,15 @@ namespace HappyHeart
new_minus_current_on_fluid_tag_ = GetValueTag();
}
return *new_minus_current_on_fluid_;
return *new_minus_current_[fluid_index];
}
const GlobalVector& Fluidmass::GetCurrentMinusFormerOnFluid() const noexcept
{
assert(!(!current_minus_former_on_fluid_));
auto& ret = *current_minus_former_on_fluid_;
constexpr auto fluid_index = EnumUnderlyingType(InternalMeshIndex::fluid);
assert(!(!current_minus_former_[fluid_index]));
auto& ret = *current_minus_former_[fluid_index];
if (current_minus_former_on_fluid_tag_ != GetValueTag())
{
......@@ -272,9 +282,8 @@ namespace HappyHeart
current_minus_former_on_fluid_tag_ = GetValueTag();
}
return *current_minus_former_on_fluid_;
return *current_minus_former_[fluid_index];
}
} // namespace DataNS
......
......@@ -46,6 +46,15 @@ namespace HappyHeart
public GlobalLinearAlgebraNS::GlobalVectorTemporary<Fluidmass, GlobalVector, 1ul, EnumUnderlyingType(MeshIndex::solid)>,
public GlobalLinearAlgebraNS::GlobalVectorTemporary<Fluidmass, GlobalVector, 1ul, EnumUnderlyingType(MeshIndex::fluid)>
{
static_assert(EnumUnderlyingType(MeshIndex::fluid) == 1, "Internal storage assumes that.");
static_assert(EnumUnderlyingType(MeshIndex::solid) == 2, "Internal storage assumes that.");
enum class InternalMeshIndex
{
fluid = EnumUnderlyingType(MeshIndex::fluid) - 1,
solid = EnumUnderlyingType(MeshIndex::solid) - 1,
};
public:
......@@ -271,17 +280,17 @@ namespace HappyHeart
*/
//! Fluid mass expressed at dofs of the solid mesh from iteration {n}.
GlobalVector::unique_ptr current_value_ = nullptr;
//! Fluid mass expressed at dofs from iteration {n}. First value is for fluid mesh, the other for solid.
GlobalVector::array_unique_ptr<2> current_value_ = { { nullptr, nullptr } };
//! Fluid mass expressed at dofs of the solid mesh from iteration {n - 1}.
GlobalVector::unique_ptr former_value_ = nullptr;
//! Fluid mass expressed at dofs from iteration {n - 1}. . First value is for fluid mesh, the other for solid.
GlobalVector::array_unique_ptr<2> former_value_ = { { nullptr, nullptr } };
//! Difference new - current expressed at dofs of the solid mesh.
GlobalVector::unique_ptr new_minus_current_on_solid_ = nullptr;
//! Difference new - current expressed at dofs. First value is for fluid mesh, the other for solid.
GlobalVector::array_unique_ptr<2> new_minus_current_ = { { nullptr, nullptr } };
//! Difference current - former expressed at dofs of the solid mesh.
GlobalVector::unique_ptr current_minus_former_on_solid_ = nullptr;
//! Difference current - former expressed at dofs. First value is for fluid mesh, the other for solid.
GlobalVector::array_unique_ptr<2> current_minus_former_ = { { nullptr, nullptr } };
/*!
......@@ -331,62 +340,27 @@ namespace HappyHeart
*/
///@{
//! Parameter that encapsulates new fluid_mass_vector (i.e. iteration {n + 1}), expressed on the solid mesh.
ParameterAtDof<ParameterNS::Type::scalar>::unique_ptr new_as_param_ = nullptr;
//! Parameter that encapsulates new fluid_mass_vector (i.e. iteration {n + 1}).
ParameterAtDof<ParameterNS::Type::scalar>::array_unique_ptr<2> new_as_param_ = { { nullptr, nullptr } };
//! Parameter that encapsulates current fluid_mass_vector (i.e. iteration {n}), expressed on the solid mesh.
ParameterAtDof<ParameterNS::Type::scalar>::unique_ptr current_value_as_param_ = nullptr;
//! Parameter that encapsulates current fluid_mass_vector (i.e. iteration {n}).
ParameterAtDof<ParameterNS::Type::scalar>::array_unique_ptr<2> current_value_as_param_ = { { nullptr, nullptr } };
//! Parameter that encapsulates former fluid_mass_vector (i.e. iteration {n - 1}), expressed on the solid mesh.
ParameterAtDof<ParameterNS::Type::scalar>::unique_ptr former_value_as_param_ = nullptr;
//! Parameter that encapsulates former fluid_mass_vector (i.e. iteration {n - 1}).
ParameterAtDof<ParameterNS::Type::scalar>::array_unique_ptr<2> former_value_as_param_ = { { nullptr, nullptr } };
//! Parameter that encapsulates new minus current fluid_mass_vector, expressed on the solid mesh.
ParameterAtDof<ParameterNS::Type::scalar>::unique_ptr new_minus_current_on_solid_as_param_ = nullptr;
ParameterAtDof<ParameterNS::Type::scalar>::array_unique_ptr<2> new_minus_current_as_param_ = { { nullptr, nullptr } };
//! Parameter that encapsulates new minus current fluid_mass_vector, expressed on the solid mesh.
ParameterAtDof<ParameterNS::Type::scalar>::unique_ptr current_minus_former_on_solid_as_param_ = nullptr;
ParameterAtDof<ParameterNS::Type::scalar>::array_unique_ptr<2> current_minus_former_as_param_ = { { nullptr, nullptr } };
//! Parameter that encapsulates current fluid_mass_vector, expressed on the solid mesh.
ParameterAtDof<ParameterNS::Type::scalar, ParameterNS::TimeDependencyNS::None>::unique_ptr
current_value_on_inlet_border_as_param_ = nullptr;
//! Parameter that encapsulates new minus current fluid_mass_vector, expressed on the fluid mesh.
ParameterAtDof<ParameterNS::Type::scalar>::unique_ptr new_minus_current_on_fluid_as_param_ = nullptr;
//! Parameter that encapsulates new minus current fluid_mass_vector, expressed on the fluid mesh.
ParameterAtDof<ParameterNS::Type::scalar>::unique_ptr current_minus_former_on_fluid_as_param_ = nullptr;
///@}
private:
/*!
* \name Vectors defined on fluid mesh.
*
* More specifically, they are defined on \a NumberingSubset NumberingSubsetIndex::fluid_mass.
*/
///@{
//! Fluid mass expressed at dofs of the fluid mesh for iteration {n}.
GlobalVector::unique_ptr current_value_on_fluid_ = nullptr;
//! Fluid mass expressed at dofs of the fluid mesh for iteration {n - 1}.
GlobalVector::unique_ptr former_value_on_fluid_ = nullptr;
//! Difference new - current expressed at dofs of the fluid mesh.
GlobalVector::unique_ptr new_minus_current_on_fluid_ = nullptr;
//! Difference current - former expressed at dofs of the fluid mesh.
GlobalVector::unique_ptr current_minus_former_on_fluid_ = nullptr;
///@}
private:
/*!
......
......@@ -26,8 +26,8 @@ namespace HappyHeart
inline const GlobalVector& Fluidmass::GetCurrent() const noexcept
{
assert(!(!current_value_));
return *current_value_;
assert(!(!current_value_[EnumUnderlyingType(InternalMeshIndex::solid)]));
return *current_value_[EnumUnderlyingType(InternalMeshIndex::solid)];
}
......@@ -39,8 +39,8 @@ namespace HappyHeart
inline const GlobalVector& Fluidmass::GetFormer() const noexcept
{
assert(!(!former_value_));
return *former_value_;
assert(!(!former_value_[EnumUnderlyingType(InternalMeshIndex::solid)]));
return *former_value_[EnumUnderlyingType(InternalMeshIndex::solid)];
}
......@@ -56,8 +56,8 @@ namespace HappyHeart
{
Reevaluate(); // lazy reevaluation may occur here.
assert(!(!new_as_param_));
return *new_as_param_;
assert(!(!new_as_param_[EnumUnderlyingType(InternalMeshIndex::solid)]));
return *new_as_param_[EnumUnderlyingType(InternalMeshIndex::solid)];
}
......@@ -75,8 +75,8 @@ namespace HappyHeart
Fluidmass
::GetCurrentAsParam() const noexcept
{
assert(!(!current_value_as_param_));
return *current_value_as_param_;
assert(!(!current_value_as_param_[EnumUnderlyingType(InternalMeshIndex::solid)]));
return *current_value_as_param_[EnumUnderlyingType(InternalMeshIndex::solid)];
}
......@@ -84,8 +84,8 @@ namespace HappyHeart
Fluidmass
::GetFormerAsParam() const noexcept
{
assert(!(!former_value_as_param_));
return *former_value_as_param_;
assert(!(!former_value_as_param_[EnumUnderlyingType(InternalMeshIndex::solid)]));
return *former_value_as_param_[EnumUnderlyingType(InternalMeshIndex::solid)];
}
......@@ -95,8 +95,8 @@ namespace HappyHeart
{
ReevaluateNewMinusCurrentOnSolid();
assert(!(!new_minus_current_on_solid_as_param_));
return *new_minus_current_on_solid_as_param_;
assert(!(!new_minus_current_as_param_[EnumUnderlyingType(InternalMeshIndex::solid)]));
return *new_minus_current_as_param_[EnumUnderlyingType(InternalMeshIndex::solid)];
}
......@@ -106,8 +106,8 @@ namespace HappyHeart
{
ReevaluateCurrentMinusFormerOnSolid();
assert(!(!current_minus_former_on_solid_as_param_));
return *current_minus_former_on_solid_as_param_;
assert(!(!current_minus_former_as_param_[EnumUnderlyingType(InternalMeshIndex::solid)]));
return *current_minus_former_as_param_[EnumUnderlyingType(InternalMeshIndex::solid)];
}
......@@ -134,8 +134,8 @@ namespace HappyHeart
inline const GlobalVector& Fluidmass::GetCurrentOnFluid() const noexcept
{
assert(!(!current_value_on_fluid_));
return *current_value_on_fluid_;
assert(!(!current_value_[EnumUnderlyingType(InternalMeshIndex::fluid)]));
return *current_value_[EnumUnderlyingType(InternalMeshIndex::fluid)];
}
inline GlobalVector& Fluidmass::GetNonCstCurrentOnFluid() noexcept
......@@ -153,8 +153,8 @@ namespace HappyHeart
inline const GlobalVector& Fluidmass::GetFormerOnFluid() const noexcept
{
assert(!(!current_value_on_fluid_));
return *current_value_on_fluid_;
assert(!(!former_value_[EnumUnderlyingType(InternalMeshIndex::fluid)]));
return *former_value_[EnumUnderlyingType(InternalMeshIndex::fluid)];
}
......
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