Commit 262b8a32 authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#969 Store explicit contribution as attribute as I can't pass it to the MatShell function directly.

parent 747e5ee5
......@@ -204,6 +204,17 @@ namespace HappyHeart
///@}
/*!
* \brief Accessor to the contribution of the explicit step to the Solid variational
* formulation.
*
* This is what the variational formulation is expected to compute; solution of
* the system is just a step to compute current quantity.
*/
const GlobalVector& GetExplicitContribution() const noexcept;
private:
......
......@@ -138,13 +138,19 @@ namespace HappyHeart
return const_cast<GlobalVector&>(GetModifiedCurrentFluidVelocity());
}
inline GlobalVector& ExplicitStepVariationalFormulation::GetNonCstExplicitContribution() noexcept
inline const GlobalVector& ExplicitStepVariationalFormulation::GetExplicitContribution() const noexcept
{
assert(!(!explicit_contribution_));
return *explicit_contribution_;
}
inline GlobalVector& ExplicitStepVariationalFormulation::GetNonCstExplicitContribution() noexcept
{
return const_cast<GlobalVector&>(GetExplicitContribution());
}
inline const GlobalMatrix& ExplicitStepVariationalFormulation
::GetSystemMatrixBeforeApplyingBoundaryConditions() const noexcept
......
......@@ -180,6 +180,7 @@ namespace HappyHeart
explicit VariationalFormulation(const Wrappers::Mpi& mpi,
const TimeManager& time_manager,
const GodOfDof& god_of_dof,
const GlobalVector& explicit_contribution,
const InterpolatorHolder& interpolator_holder,
VariableHolder& variable_holder,
const inlet_pressure_type& inlet_pressure,
......@@ -210,7 +211,7 @@ namespace HappyHeart
public:
void Perform(const GlobalVector& explicit_contribution);
void Perform();
void UpdateTimeIterationData();
......@@ -372,7 +373,10 @@ namespace HappyHeart
/*!
* \brief Method in charge of the main iterative solve in implicit formulation.
*/
void PerformImpl(const GlobalVector& explicit_contribution, double& abs, double& rel);
const GlobalVector& PerformImpl(double& abs, double& rel);
//! Explicit contribution.
const GlobalVector& GetExplicitContribution() const noexcept;
private:
......@@ -421,6 +425,9 @@ namespace HappyHeart
const inlet_pressure_type& inlet_pressure_;
//! Explicit contribution.
const GlobalVector& explicit_contribution_;
//! Shell matrix used to compute dH.
typename Wrappers::Petsc::ShellMatrix<self>::unique_ptr gmres_shell_matrix_ = nullptr;
};
......
......@@ -26,7 +26,7 @@ namespace HappyHeart
template<class SolidVariationalFormulationPolicyT>
void VariationalFormulation<SolidVariationalFormulationPolicyT>
::Perform(const GlobalVector& explicit_contribution)
::Perform()
{
double absolute_error = 1.e20;
double relative_error = 1.e20;
......@@ -39,15 +39,12 @@ namespace HappyHeart
decltype(auto) solid_displacement_data = this->GetNonCstSolidDisplacementData();
decltype(auto) solid_displacement = solid_displacement_data.GetNew();
while (absolute_error > absolute_tolerance && relative_error > 1.e-6 && implicit_iteration_index <= 100) // \todo #820 Should not remain hardcoded!
// \todo #820 iteration index sup value is obviously temporary for dev purposes...
{
PerformImpl(explicit_contribution, absolute_error, relative_error);
PerformImpl(absolute_error, relative_error);
}
variable_holder.template DevPrint<DevPhase::none>(solid_displacement,
"dispSr_after_implicit");
......@@ -75,12 +72,14 @@ namespace HappyHeart
template<class SolidVariationalFormulationPolicyT>
inline void VariationalFormulation<SolidVariationalFormulationPolicyT>
::PerformImpl(const GlobalVector& explicit_contribution, double& abs, double& rel)
inline const GlobalVector& VariationalFormulation<SolidVariationalFormulationPolicyT>
::PerformImpl(double& abs, double& rel)
{
decltype(auto) explicit_contribution = GetExplicitContribution();
decltype(auto) variable_holder = this->GetNonCstVariableHolder();
auto& implicit_iteration_index = variable_holder.implicit_loop_index;
decltype(auto) solid_displacement_data = this->GetNonCstSolidDisplacementData();
decltype(auto) fluid_mass_data = this->GetFluidmassData();
......@@ -137,7 +136,7 @@ namespace HappyHeart
std::cout << "ABSOLUTE ERROR = " << abs << " REL = " << rel << std::endl;
++implicit_iteration_index;
return delta_displacement;
}
......@@ -268,9 +267,10 @@ namespace HappyHeart
void VariationalFormulation<SolidVariationalFormulationPolicyT>
::ShellMatrixOperation(Vec petsc_input_vector, Vec& petsc_output_vector)
{
// ++this->GetNonCstVariableHolder().dh_index;
// SetSolidVelocityForDifferential(petsc_input_vector);
// ++this->GetNonCstVariableHolder().implicit_loop_index;
//
// GetNonCstVector<SolidIndex::displacement_k0>().SetFromPetscVec(petsc_input_vector);
//
// decltype(auto) delta_displacement = PerformImpl();
//
// // We can't take directly the internal pointer of a wrapped vector which pattern would be similar to
......
......@@ -240,6 +240,14 @@ namespace HappyHeart
return *gmres_shell_matrix_;
}
template<class SolidVariationalFormulationPolicyT>
inline const GlobalVector& VariationalFormulation<SolidVariationalFormulationPolicyT>
::GetExplicitContribution() const noexcept
{
return explicit_contribution_;
}
} // namespace ImplicitStepNS
......
......@@ -29,6 +29,7 @@ namespace HappyHeart
::VariationalFormulation(const Wrappers::Mpi& mpi,
const TimeManager& time_manager,
const GodOfDof& god_of_dof,
const GlobalVector& explicit_contribution,
const InterpolatorHolder& interpolator_holder,
VariableHolder& variable_holder,
const inlet_pressure_type& inlet_pressure,
......@@ -52,7 +53,8 @@ namespace HappyHeart
porosity_data_parent(porosity_data),
solid_displacement_data_parent(solid_displacement_data),
monolithic_data_parent(monolithic_data),
inlet_pressure_(inlet_pressure)
inlet_pressure_(inlet_pressure),
explicit_contribution_(explicit_contribution)
{ }
......
......@@ -29,7 +29,7 @@ namespace HappyHeart
const GlobalVector& explicit_contribution = explicit_step_varf.Perform();
decltype(auto) implicit_step_varf = GetNonCstImplicitStepVariationalFormulation();
implicit_step_varf.Perform(explicit_contribution);
implicit_step_varf.Perform();
}
......
......@@ -246,6 +246,7 @@ namespace HappyHeart
std::make_unique<implicit_step_varf_type>(mpi,
time_manager,
fluid_god_of_dof,
GetExplicitStepVariationalFormulation().GetExplicitContribution(),
interpolator_holder,
GetNonCstVariableHolder(),
GetInletPressure(),
......
......@@ -30,7 +30,7 @@ namespace HappyHeart
assert(petsc_matrix_ != PETSC_NULL);
auto error_code = MatDestroy(&petsc_matrix_);
assert(!error_code && "Error in Mat destruction."); // no exception in destructors!
static_cast<void>(error_code); // to avoid arning in release compilation.
static_cast<void>(error_code); // to avoid warning in release compilation.
}
......
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