From 0d67b0ae3753e0129023bc1c6d17389801e81441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Intro=C3=AFni?= <32884037+CINTROINI@users.noreply.github.com> Date: Wed, 8 Jul 2026 11:55:04 +0200 Subject: [PATCH 1/4] Initialize rhs_solver_ in constructor and add destructor --- kernel/include/Operators/OperatorBase.hpp | 2 +- kernel/include/Operators/OperatorBase.tpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/kernel/include/Operators/OperatorBase.hpp b/kernel/include/Operators/OperatorBase.hpp index 9c599740..ae615cd6 100644 --- a/kernel/include/Operators/OperatorBase.hpp +++ b/kernel/include/Operators/OperatorBase.hpp @@ -160,7 +160,7 @@ class OperatorBase : public mfem::Operator { void clear_time_specialized(); void clear_iso_time_specialized(); - virtual ~OperatorBase() = default; + virtual ~OperatorBase(); std::string get_description() { return this->description_; } diff --git a/kernel/include/Operators/OperatorBase.tpp b/kernel/include/Operators/OperatorBase.tpp index 45a4450d..3f08f17b 100644 --- a/kernel/include/Operators/OperatorBase.tpp +++ b/kernel/include/Operators/OperatorBase.tpp @@ -205,6 +205,7 @@ OperatorBase::OperatorBase(const std::vector& integrators, : mfem::Operator(this->compute_total_height(spatials), this->compute_total_width(spatials)), params_(default_params_), RHS(NULL), + rhs_solver_(nullptr), current_dt_(0.0), current_time_(0.0), height_(height), @@ -241,6 +242,7 @@ OperatorBase::OperatorBase(const std::vector& integrators, : mfem::Operator(this->compute_total_height(spatials), this->compute_total_width(spatials)), params_(default_params_), RHS(NULL), + rhs_solver_(nullptr), current_dt_(0.0), current_time_(0.0), height_(height), @@ -1117,3 +1119,15 @@ template void OperatorBase::setGeometry(Geometry geometry) { this->geometry_ = geometry; } + +/** + * @brief Destroy the OperatorBase::OperatorBase object + * + * @tparam T Finite Element collection (mfem object) + * @tparam DIM Spatial dimension + */ +template +OperatorBase::~OperatorBase() { + delete this->RHS; + delete this->rhs_solver_; +} \ No newline at end of file From 4e865fa700d68b3ebb19ff6c64d4ec108a5eb0cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Intro=C3=AFni?= <32884037+CINTROINI@users.noreply.github.com> Date: Wed, 8 Jul 2026 11:56:54 +0200 Subject: [PATCH 2/4] Fix Mass Matrix management for explicit calculations --- kernel/include/Operators/TransientOperator.hpp | 5 ++--- kernel/include/Operators/TransientOperator.tpp | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/kernel/include/Operators/TransientOperator.hpp b/kernel/include/Operators/TransientOperator.hpp index 9876a31c..48481277 100644 --- a/kernel/include/Operators/TransientOperator.hpp +++ b/kernel/include/Operators/TransientOperator.hpp @@ -84,9 +84,8 @@ class TransientOperator : public OperatorBase, public mfem::TimeDependen /// Left-Hand-Side mfem::ParBlockNonlinearForm* LHS; - // CCI - mfem::HypreParMatrix* Mmat; - // CCI + std::vector Mmat_; + void build_mass_matrix(const std::vector& u_vect); void build_lhs_nonlinear_form(const double dt, const std::vector& u); bool constant_mass_matrix_{true}; diff --git a/kernel/include/Operators/TransientOperator.tpp b/kernel/include/Operators/TransientOperator.tpp index 797bb3b5..d1754389 100644 --- a/kernel/include/Operators/TransientOperator.tpp +++ b/kernel/include/Operators/TransientOperator.tpp @@ -283,7 +283,10 @@ void TransientOperator::build_mass_matrix(const std::vectorM_solver_.clear(); - + for (auto* mat : this->Mmat_) { + delete mat; + } + this->Mmat_.clear(); for (unsigned int i = 0; i < u_vect.size(); i++) { if (M != nullptr) { delete M; @@ -306,12 +309,13 @@ void TransientOperator::build_mass_matrix(const std::vectorAssemble(0); M->Finalize(0); - Mmat = M->ParallelAssemble(); - std::unique_ptr Me(Mmat->EliminateRowsCols(this->ess_tdof_list_[i])); + this->Mmat_.emplace_back(M->ParallelAssemble()); + std::unique_ptr Me( + this->Mmat_[i]->EliminateRowsCols(this->ess_tdof_list_[i])); this->mass_matrix_solver_ = std::make_shared(this->mass_solver_, this->mass_solver_params_, - this->mass_precond_, this->mass_precond_params_, *Mmat); + this->mass_precond_, this->mass_precond_params_, *this->Mmat_[i]); this->M_solver_.emplace_back(this->mass_matrix_solver_->get_solver()); } } @@ -700,6 +704,11 @@ void TransientOperator::free_memory() { this->LHS = nullptr; delete this->reduced_oper; this->reduced_oper = nullptr; + + for (auto* mat : this->Mmat_) { + delete mat; + } + this->Mmat_.clear(); } /** From 9cd9c940ae999bfb03eb533bcd3342b266484348 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Intro=C3=AFni?= <32884037+CINTROINI@users.noreply.github.com> Date: Wed, 8 Jul 2026 12:02:14 +0200 Subject: [PATCH 3/4] Change default value of Parameter 'enable_save_specialized_at_iter' to true Avoid increase of the stack for very long calculation --- kernel/include/PostProcessing/postprocessing.tpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/include/PostProcessing/postprocessing.tpp b/kernel/include/PostProcessing/postprocessing.tpp index bef34eaf..424eb665 100644 --- a/kernel/include/PostProcessing/postprocessing.tpp +++ b/kernel/include/PostProcessing/postprocessing.tpp @@ -87,7 +87,7 @@ void PostProcessing::get_parameters() { this->enable_compute_energies_ = this->params_.template get_param_value_or_default("enable_compute_energies", true); this->enable_save_specialized_at_iter_ = this->params_.template get_param_value_or_default( - "enable_save_specialized_at_iter", false); + "enable_save_specialized_at_iter", true); this->force_clean_output_dir_ = this->params_.template get_param_value_or_default("force_clean_output_dir", false); if (this->params_.has_parameter("iso_val_to_compute")) { From 0ed79bb7949169b613ded07b410c1d736462593b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Intro=C3=AFni?= <32884037+CINTROINI@users.noreply.github.com> Date: Wed, 8 Jul 2026 12:15:48 +0200 Subject: [PATCH 4/4] Back to default destructor --- kernel/include/Operators/OperatorBase.hpp | 2 +- kernel/include/Operators/OperatorBase.tpp | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/kernel/include/Operators/OperatorBase.hpp b/kernel/include/Operators/OperatorBase.hpp index ae615cd6..9c599740 100644 --- a/kernel/include/Operators/OperatorBase.hpp +++ b/kernel/include/Operators/OperatorBase.hpp @@ -160,7 +160,7 @@ class OperatorBase : public mfem::Operator { void clear_time_specialized(); void clear_iso_time_specialized(); - virtual ~OperatorBase(); + virtual ~OperatorBase() = default; std::string get_description() { return this->description_; } diff --git a/kernel/include/Operators/OperatorBase.tpp b/kernel/include/Operators/OperatorBase.tpp index 3f08f17b..ee7a391d 100644 --- a/kernel/include/Operators/OperatorBase.tpp +++ b/kernel/include/Operators/OperatorBase.tpp @@ -1119,15 +1119,3 @@ template void OperatorBase::setGeometry(Geometry geometry) { this->geometry_ = geometry; } - -/** - * @brief Destroy the OperatorBase::OperatorBase object - * - * @tparam T Finite Element collection (mfem object) - * @tparam DIM Spatial dimension - */ -template -OperatorBase::~OperatorBase() { - delete this->RHS; - delete this->rhs_solver_; -} \ No newline at end of file