diff --git a/kernel/include/Coefficients/MfemCoefficient.hpp b/kernel/include/Coefficients/MfemCoefficient.hpp index cd69fa72..2a1a200b 100644 --- a/kernel/include/Coefficients/MfemCoefficient.hpp +++ b/kernel/include/Coefficients/MfemCoefficient.hpp @@ -27,46 +27,70 @@ #include #include +#include "Coefficients/Coefficient.hpp" #include "Coefficients/Coefficients.hpp" #include "mfem.hpp" // NOLINT [no include the directory when naming mfem include file] +/** + * @brief Wraps a SLOTH ::Coefficient as an mfem::Coefficient, so it can be + * projected onto a grid function or plugged into an mfem + * integrator. + */ class MfemCoefficient : public mfem::Coefficient { private: int id_ = 0; - Coefficients sloth_coefficient_; - const mfem::ParGridFunction& gf_; + ::Coefficient sloth_coefficient_; + + const std::vector& gf_; + const std::vector& gfn_; const std::vector& vaux_gf_; mutable std::vector vaux_gf_at_ip_; + mutable std::vector gf_at_ip_; + mutable std::vector gfn_at_ip_; public: - MfemCoefficient(int id, const Coefficients& coef, const mfem::ParGridFunction& vun, + MfemCoefficient(::Coefficient coef, const std::vector& vu, + const std::vector& vun, const std::vector& vauxn); double Eval(mfem::ElementTransformation& T, const mfem::IntegrationPoint& ip) override; + + mfem::ParGridFunction ProjectToGridFunction(mfem::ParFiniteElementSpace& fespace); + mfem::ParGridFunction ProjectToGridFunction(); + virtual ~MfemCoefficient() = default; }; /** - * @brief Construct a new Mfem Coefficient:: Mfem Coefficient object + * @brief Construct a new MfemCoefficient object. * - * @param coef - * @param vun - * @param vauxn + * @param coef SLOTH coefficient to wrap. + * @param vu Current-time vector of grid function for the coefficient's own variable. + * @param vun Previous-time vector of grid function for the coefficient's own variable. + * @param vauxn Grid functions of the auxiliary variables. */ -MfemCoefficient::MfemCoefficient(int id, const Coefficients& coef, const mfem::ParGridFunction& vun, +MfemCoefficient::MfemCoefficient(::Coefficient coef, const std::vector& vu, + const std::vector& vun, const std::vector& vauxn) - : id_(id), sloth_coefficient_(coef), gf_(vun), vaux_gf_(vauxn) {} + : sloth_coefficient_(coef), gf_(vu), gfn_(vun), vaux_gf_(vauxn) { + MFEM_VERIFY(this->gf_.size() == this->gfn_.size(), + "Error of consistency between Current-time and Previous-time vectors of grid " + "function. Please check their sizes."); +} /** - * @brief Eval MfemCoefficient at the integration point + * @brief Evaluate the wrapped coefficient at an integration point. + * + * Dispatches on the coefficient's scheme (scalar/semi-implicit/ + * explicit/implicit) to call the matching ::Coefficient::compute overload. * - * @param T - * @param ip - * @return double + * @param T Element transformation at the integration point. + * @param ip Integration point. + * @return Coefficient value. */ double MfemCoefficient::Eval(mfem::ElementTransformation& T, const mfem::IntegrationPoint& ip) { - if (this->sloth_coefficient_[id_].is_scalar()) { - return this->sloth_coefficient_[id_].compute(); + if (this->sloth_coefficient_.is_scalar()) { + return this->sloth_coefficient_.compute(); } this->vaux_gf_at_ip_.resize(this->vaux_gf_.size()); @@ -74,8 +98,43 @@ double MfemCoefficient::Eval(mfem::ElementTransformation& T, const mfem::Integra this->vaux_gf_at_ip_[k] = this->vaux_gf_[k].GetValue(T, ip); } - double var_at_ip = this->gf_.GetValue(T, ip); - std::array var = {var_at_ip}; - return this->sloth_coefficient_[id_].compute(std::span(var), - std::span(this->vaux_gf_at_ip_)); + this->gf_at_ip_.resize(this->gf_.size()); + this->gfn_at_ip_.resize(this->gfn_.size()); + for (size_t k = 0; k < this->gf_.size(); ++k) { + this->gf_at_ip_[k] = this->gf_[k].GetValue(T, ip); + this->gfn_at_ip_[k] = this->gfn_[k].GetValue(T, ip); + } + + if (this->sloth_coefficient_.is_semi_implicit()) { + return this->sloth_coefficient_.compute(std::span(this->gf_at_ip_), + std::span(this->gfn_at_ip_), + std::span(this->vaux_gf_at_ip_)); + } else if (this->sloth_coefficient_.is_explicit()) { + return this->sloth_coefficient_.compute(std::span(this->gfn_at_ip_), + std::span(this->vaux_gf_at_ip_)); + } else { + return this->sloth_coefficient_.compute(std::span(this->gf_at_ip_), + std::span(this->vaux_gf_at_ip_)); + } +} +/** + * @brief Project the coefficient onto a grid function on a given space. + * + * @param fespace Finite element space to project onto. + * @return Grid function holding the projected values. + */ +mfem::ParGridFunction MfemCoefficient::ProjectToGridFunction(mfem::ParFiniteElementSpace& fespace) { + mfem::ParGridFunction result(&fespace); + result.ProjectCoefficient(*this); + return result; +} + +/** + * @brief Project the coefficient onto a grid function, using the finite + * element space of the first index in `gf_` (assumption of homogeneous FESpace) + * + * @return Grid function holding the projected values. + */ +mfem::ParGridFunction MfemCoefficient::ProjectToGridFunction() { + return ProjectToGridFunction(*gf_[0].ParFESpace()); } diff --git a/kernel/include/Coefficients/SlothBaseCoefficient.hpp b/kernel/include/Coefficients/SlothBaseCoefficient.hpp index 2d06a7e8..2a928dfb 100644 --- a/kernel/include/Coefficients/SlothBaseCoefficient.hpp +++ b/kernel/include/Coefficients/SlothBaseCoefficient.hpp @@ -44,6 +44,7 @@ */ class SlothBaseCoefficient { private: + std::string name_; GlossaryQuantity coefficient_quantity_; std::shared_ptr coefficient_; std::vector bdr_index_; @@ -116,6 +117,9 @@ class SlothBaseCoefficient { bool is_scalar() const; void set_time(double time); + + std::string get_name(); + void set_name(const std::string& name); void set_bdr_index_coef(std::vector ids); std::vector get_bdr_index_coef() const; }; diff --git a/kernel/include/Couplings/Coupling.hpp b/kernel/include/Couplings/Coupling.hpp index f721e3aa..43799819 100644 --- a/kernel/include/Couplings/Coupling.hpp +++ b/kernel/include/Couplings/Coupling.hpp @@ -69,6 +69,7 @@ class Coupling { void initialize(const int& iter, const double& initial_time, const double time_step, bool vtk_unified, std::vector all_vars); void collect_vtk_fields(std::map& all_fields); + void collect_vtk_coefficients(std::map& all_coefficients); auto get_shared_dc() { return std::get<0>(this->problems_).get_shared_dc(); } void check_duplicate_post_processing_directory(std::size_t nb_couplings, const std::map& directory_count); diff --git a/kernel/include/Couplings/Coupling.tpp b/kernel/include/Couplings/Coupling.tpp index 11cb101f..4af8bf7a 100644 --- a/kernel/include/Couplings/Coupling.tpp +++ b/kernel/include/Couplings/Coupling.tpp @@ -240,6 +240,23 @@ void Coupling::collect_vtk_fields( this->problems_); } +/** + * @brief Collect the grid functions of every Problem in this coupling + * into a shared coefficient map. + * + * @tparam Args Problem types in this coupling. + * @param all_coefficients Output map, accumulated across every Problem, for a + * single unified VTK save (see + * `TimeDiscretization::save_vtk_unified()`). + */ +template +void Coupling::collect_vtk_coefficients( + std::map& all_coefficients) { + std::apply([&all_coefficients]( + auto&... problem) { (problem.collect_vtk_coefficients(all_coefficients), ...); }, + this->problems_); +} + /** * @brief Solve all the problems inside the coupling * diff --git a/kernel/include/Factory/BoundaryConditionsFactory.hpp b/kernel/include/Factory/BoundaryConditionsFactory.hpp new file mode 100644 index 00000000..9f789f06 --- /dev/null +++ b/kernel/include/Factory/BoundaryConditionsFactory.hpp @@ -0,0 +1,61 @@ +/** + * @file BoundaryConditionsFactory.hpp + * @author Clément Introïni (clement.introini@cea.fr) + * @brief BoundaryConditions factory to manage boundary conditions + * @version 2.1 + * @date 2026-09-05 + * + * @anchor bcs + * + * @copyright CEA (C) 2026 + * + * This file is part of SLOTH. + * + * SLOTH is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SLOTH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include +#include + +#include "BCs/BoundaryConditions.hpp" +/** + * @brief Build N BoundaryConditions, one per element of `spatials`, + * all sharing the same `boundaries...` list. + * + * @tparam T Finite element collection type. + * @tparam DIM Spatial dimension. + * @tparam BoundaryArgs Deduced argument types forwarded to every + * BoundaryConditions constructor call. + * @param N Number of BoundaryConditions to build. Must match spatials.size(). + * @param spatials One SpatialDiscretization* per grain (SPAS). + * @param boundaries Forwarded as-is to each BoundaryConditions constructor. + * @return std::vector> of size N. + */ +template +std::vector> setBoundaryConditions( + std::size_t N, const std::vector*>& spatials, + const BoundaryArgs&... boundaries) { + MFEM_VERIFY(N >= 1, "setBoundaryConditions: N must be >= 1"); + MFEM_VERIFY(spatials.size() == N, + "setBoundaryConditions: spatials must contain exactly N elements"); + + std::vector> bcs; + bcs.reserve(N); + for (std::size_t i = 0; i < N; ++i) { + bcs.emplace_back(spatials[i], boundaries...); + } + return bcs; +} \ No newline at end of file diff --git a/kernel/include/Factory/CouplingFactory.hpp b/kernel/include/Factory/CouplingFactory.hpp new file mode 100644 index 00000000..10916b5f --- /dev/null +++ b/kernel/include/Factory/CouplingFactory.hpp @@ -0,0 +1,75 @@ +/** + * @file CouplingFactory.hpp + * @brief Helper building Coupling (N times) from + * a std::vector, with N given explicitly as a template parameter. + * @version 0.1 + * + * @anchor couplings + * + * @copyright CEA (C) 2026 + * + * This file is part of SLOTH. + * + * SLOTH is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SLOTH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + */ +#pragma once +#include +#include +#include +#include +#include + +#include "Couplings/Coupling.hpp" + +/** + * @brief Maps an index to PB, whatever the index -> used to repeat PB N times + * in a template parameter pack (Coupling, + * RepeatedProblemType, ...> = Coupling). + * + * @tparam PB Problem type to repeat. + */ +template +using RepeatedProblemType = PB; + +/** + * @brief Implementation detail of HomogeneousCoupling: expands the index sequence + * to build the Coupling return type and forward each + * vector element by index. + */ +template +Coupling...> HomogeneousCoupling(const std::string& name, + std::vector vect, + std::index_sequence) { + return Coupling...>(name, std::move(vect[I])...); +} + +/** + * @brief Build a Coupling (N times) from a std::vector + * whose size is only known at runtime. + * + * + * @tparam N Number of problems in `vect`. Must match `vect.size()` exactly + * (checked with assert in debug builds). + * @tparam PB Problem type shared by every element of `vect`. + * @param name Name of the coupling. + * @param vect Problems to couple, all of type PB, size exactly N. + * @return Coupling (N times), ready to pass to + * TimeDiscretization. + */ +template +auto setCoupling(const std::string& name, std::vector vect) { + MFEM_VERIFY(vect.size() == N, "setCoupling: vect must contain exactly N elements"); + return HomogeneousCoupling(name, std::move(vect), std::make_index_sequence{}); +} \ No newline at end of file diff --git a/kernel/include/Factory/ListFactory.hpp b/kernel/include/Factory/ListFactory.hpp new file mode 100644 index 00000000..80facf4e --- /dev/null +++ b/kernel/include/Factory/ListFactory.hpp @@ -0,0 +1,31 @@ +/** + * @file ListFactory.hpp + * @author ci230846 (clement.introini@cea.fr) + * @brief List of Factory used to simplify tests setup + * @version 0.1 + * @date 2026-09-05 + * + * @copyright CEA (C) 2026 + * + * This file is part of SLOTH. + * + * SLOTH is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SLOTH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + */ + +#pragma once + +#include "Factory/BoundaryConditionsFactory.hpp" +#include "Factory/CouplingFactory.hpp" +#include "Factory/SpatialDiscretizationFactory.hpp" diff --git a/kernel/include/Factory/SpatialDiscretizationFactory.hpp b/kernel/include/Factory/SpatialDiscretizationFactory.hpp new file mode 100644 index 00000000..88e79125 --- /dev/null +++ b/kernel/include/Factory/SpatialDiscretizationFactory.hpp @@ -0,0 +1,121 @@ +/** + * @file SpatialDiscretizationFactory.hpp + * @brief Helper building N SpatialDiscretization objects sharing the + * same underlying mesh, from any of SpatialDiscretization's + * constructors. + * @version 0.1 + * + * @copyright CEA (C) 2026 + * + * This file is part of SLOTH. + * + * SLOTH is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SLOTH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + */ +#pragma once +#include +#include +#include +#include +#include +#include + +#include "Spatial/Spatial.hpp" + +/** + * @brief Build N SpatialDiscretization objects sharing the same mesh, + * returned directly as a `SPAS`-compatible `std::vector*>`: + * the first one is built by forwarding `args...` verbatim to whichever + * `SpatialDiscretization` constructor they match - any of the + * four (mesh-file, inline-mesh, periodic inline-mesh, or + * existing-mesh overloads) - and the remaining N-1 share that first + * one's mesh, exactly like building `spatial_phi1`, `spatial_phi2`, + * ... from `spatial_phi0.get_mesh()` by hand. + * + * + * @tparam T Finite element collection type. Must be given explicitly. + * @tparam DIM Spatial dimension. Must be given explicitly. + * @tparam Args Deduced argument types, forwarded as-is to the + * `SpatialDiscretization` constructor used to build the + * first element. + * @param N Total number of SpatialDiscretization objects to build (must be + * >= 1). The first is built from `args...`, the remaining N-1 + * share its mesh. + * @param shared_is_periodic Value passed as `is_periodic_mesh` to the N-1 + * mesh-sharing elements. Unused when N == 1. + * @param args Arguments forwarded verbatim to the `SpatialDiscretization` + * constructor used for the first element. + * @return std::vector*> of size N, owned by + * the caller - release with `deleteSpatialDiscretization`. + */ +template +std::vector*> setSpatialDiscretization(std::size_t N, + bool shared_is_periodic, + Args&&... args) { + static_assert(sizeof...(Args) >= 2, + "setSpatialDiscretization: args must match one of " + "SpatialDiscretization's constructors, e.g. (mesh_type, fe_order, ...) " + "or (existing_mesh, fe_order, ...)."); + MFEM_VERIFY(N >= 1, "setSpatialDiscretization: N must be >= 1"); + + // Phase 1: build safely. Each element is owned by a std::unique_ptr in + // `storage`, so std::vector reallocation (if capacity were ever exceeded) + // would only move unique_ptr's themselves, never touch the pointee - + // sidesteps SpatialDiscretization having no move constructor entirely. + std::vector>> storage; + storage.reserve(N); + + // fe_order is always the 2nd parameter of every SpatialDiscretization + // constructor - grab it before args... is consumed by forwarding. + const int fe_order = std::get<1>(std::forward_as_tuple(args...)); + + // storage[0]: built by forwarding args... to whichever constructor matches. + storage.push_back(std::make_unique>(std::forward(args)...)); + + // storage[1..N-1]: share storage[0]'s mesh, own their own FE space. + mfem::ParMesh* shared_mesh = storage.front()->get_mesh(); + for (std::size_t i = 1; i < N; ++i) { + storage.push_back( + std::make_unique>(shared_mesh, fe_order, shared_is_periodic)); + } + + // Phase 2: transfer ownership to the caller as raw pointers (SPAS). Each + // unique_ptr::release() hands off ownership without deleting anything; + // `storage` itself is emptied of ownership responsibility as it goes out + // of scope right after (its destructor runs on now-null unique_ptr's). + std::vector*> result; + result.reserve(N); + for (auto& ptr : storage) { + result.push_back(ptr.release()); + } + + return result; +} + +/** + * @brief Release a `SPAS`-shaped vector produced by `setSpatialDiscretization`. + * + * + * @tparam T Finite element collection type. + * @tparam DIM Spatial dimension. + * @param spatials Vector produced by `setSpatialDiscretization`. Left empty + * after the call. + */ +template +void deleteSpatialDiscretization(std::vector*>& spatials) { + for (auto it = spatials.rbegin(); it != spatials.rend(); ++it) { + delete *it; + } + spatials.clear(); +} \ No newline at end of file diff --git a/kernel/include/Operators/TransientOperator.tpp b/kernel/include/Operators/TransientOperator.tpp index c5486773..f2247614 100644 --- a/kernel/include/Operators/TransientOperator.tpp +++ b/kernel/include/Operators/TransientOperator.tpp @@ -310,8 +310,9 @@ void TransientOperator::build_mass_matrix(const std::vectorfes_[i]); un.SetFromTrueDofs(u_vect[i]); - auto coef_a_exp = MfemCoefficient(0, this->explicit_time_coefficients_, un, vauxn); - auto coef_b_exp = MfemCoefficient(1, this->explicit_time_coefficients_, un, vauxn); + + auto coef_a_exp = MfemCoefficient(this->explicit_time_coefficients_[0], {un}, {un}, vauxn); + auto coef_b_exp = MfemCoefficient(this->explicit_time_coefficients_[1], {un}, {un}, vauxn); mfem::ProductCoefficient mass_coefficient = mfem::ProductCoefficient(coef_a_exp, coef_b_exp); M->AddDomainIntegrator(new mfem::LumpedIntegrator(new mfem::MassIntegrator(mass_coefficient))); diff --git a/kernel/include/PostProcessing/postprocessing.hpp b/kernel/include/PostProcessing/postprocessing.hpp index 35acbcd6..2e5d24bf 100644 --- a/kernel/include/PostProcessing/postprocessing.hpp +++ b/kernel/include/PostProcessing/postprocessing.hpp @@ -75,7 +75,7 @@ class PostProcessing { const Parameters& params_; std::map fields_to_save_; std::string post_processing_directory_; - + std::vector projected_coeffs_; void get_parameters(); void get_specialized_parameters(); void get_restart_parameters(); @@ -93,6 +93,14 @@ class PostProcessing { PostProcessing(SpatialDiscretization* space, const Parameters& params); void save_variables(Variables& vars, const int& iter, const double& time); + + std::map project_coefficients( + std::vector& coeffs, Variables& vars, + std::vector*> vect_aux_var); + void save_coefficients(std::vector& coefficients, Variables& vars, + std::vector*> vect_aux_var, const int& iter, + const double& time); + void save_specialized(const std::multimap& mmap_results, std::string filename = "time_specialized.csv"); void save_iso_specialized(const std::multimap& mmap_results, diff --git a/kernel/include/PostProcessing/postprocessing.tpp b/kernel/include/PostProcessing/postprocessing.tpp index 824b5ddd..6e14fa69 100644 --- a/kernel/include/PostProcessing/postprocessing.tpp +++ b/kernel/include/PostProcessing/postprocessing.tpp @@ -223,6 +223,81 @@ void PostProcessing::save_variables(Variables& vars, const i } } +/** + * @brief Projects each Coefficient in `coeffs` onto a grid function, using + * `vars` and the flattened auxiliary-variable grid functions from + * `vect_aux_var`. Results are stored in this->projected_coeffs_ + * (cleared and refilled by this call) so ownership stays in one + * place - callers (including ProblemBase via its PST member) don't + * need to manage their own storage vector. + * + * @return Map from coefficient name to a pointer into this->projected_coeffs_. + */ +template +std::map PostProcessing::project_coefficients( + std::vector& coeffs, Variables& vars, + std::vector*> vect_aux_var) { + // Auxiliary variables + std::vector vaux_gf; + for (const auto& auxvar_vec : vect_aux_var) { + std::map map_aux_var = auxvar_vec->get_map_gridfunction(); + for (const auto& [aux_name, vgf] : map_aux_var) { + vaux_gf.emplace_back(*vgf); + } + } + + this->projected_coeffs_.clear(); + this->projected_coeffs_.reserve(coeffs.size()); + + // TODO: v_gf is passed both as current-time and previous-time values below + // (vu == vun), so explicit/semi-implicit coefficients cannot actually see + // a different state at t^n vs t^{n-1}. Needs Variables to expose + // the previous-time grid functions (e.g. get_gf_previous()) so a distinct + // vgf_prev can be built and passed as the 3rd argument instead of v_gf. + + std::vector v_gf; + for (const auto& v : vars.getVariables()) { + v_gf.emplace_back(v.get_gf()); + } + + std::map result; + + for (auto& coef : coeffs) { + MfemCoefficient mfem_coef(coef, v_gf, v_gf, vaux_gf); + this->projected_coeffs_.push_back(mfem_coef.ProjectToGridFunction()); + result.emplace(coef.get_name(), &this->projected_coeffs_.back()); + } + + return result; +} + +/** + * @brief Save Coefficients at a given iteration/time + * + * @tparam T mfem FECollection + * @tparam DC mfem DataCollection + * @tparam DIM Spatial dimension + * @param vars + * @param iter + * @param time + */ +template +void PostProcessing::save_coefficients(std::vector& coeffs, + Variables& vars, + std::vector*> vect_aux_var, + const int& iter, const double& time) { + // VTK + if (this->need_to_be_saved(iter, time)) { + this->dc_->SetCycle(iter); + this->dc_->SetTime(time); + auto field_map = this->project_coefficients(coeffs, vars, vect_aux_var); + for (const auto& [name, gf_ptr] : field_map) { + this->dc_->RegisterField(name, gf_ptr); + } + this->dc_->Save(); + } +} + /** * @brief Get the frequency of post-processing in terms of number of iterations (1 means each * iteration) diff --git a/kernel/include/Problems/ProblemBase.hpp b/kernel/include/Problems/ProblemBase.hpp index de0d59c4..2a685ac5 100644 --- a/kernel/include/Problems/ProblemBase.hpp +++ b/kernel/include/Problems/ProblemBase.hpp @@ -79,6 +79,7 @@ class ProblemBase { std::vector auxvariables_; std::vector coefficients_; + std::vector vect_vtk_coefficient_; std::optional> pst_; @@ -97,6 +98,8 @@ class ProblemBase { void initialize_amr(const std::vector& all_vars); void save_amr(const std::vector& all_vars); + void save_coefficients(const int iter, const double current_time); + void set_vtk_coefficients(const std::vector& Coeff); // With PST object template ... Args> @@ -154,6 +157,8 @@ class ProblemBase { std::vector> get_convergence(); void setGeometry(Geometry geometry); + + void set_auxvariables(std::vector auxiliary_variables); ///////////////////////////////////////////////////// virtual void initialize([[maybe_unused]] const double& initial_time, @@ -177,6 +182,7 @@ class ProblemBase { virtual void set_time_coefficients(double) {} void collect_vtk_fields(std::map& all_fields); + void collect_vtk_coefficients(std::map& all_coefficients); auto get_shared_dc() { return this->pst_->get().get_shared_dc(); } }; diff --git a/kernel/include/Problems/ProblemBase.tpp b/kernel/include/Problems/ProblemBase.tpp index 3ee936cf..695aeb2a 100644 --- a/kernel/include/Problems/ProblemBase.tpp +++ b/kernel/include/Problems/ProblemBase.tpp @@ -289,6 +289,22 @@ void ProblemBase::set_name(const std::string& new_name) { this->name_ = new_name; } +/** + * @brief Set the vector of Coefficient to save in VTK files + * + * @param vtk_coeffs + */ +template +void ProblemBase::set_vtk_coefficients(const std::vector& vtk_coeffs) { + this->vect_vtk_coefficient_ = vtk_coeffs; + for (auto& coef : this->vect_vtk_coefficient_) { + std::string coef_name = coef.get_name(); + MFEM_VERIFY(!coef_name.empty(), + "Error while loading VTK coefficients. Please use define the name of the " + "coefficients using set_name()"); + } +} + /** * * @brief Set the name for global specialized CSV file of the problem @@ -468,6 +484,11 @@ void ProblemBase::save_vtk(const int iter, const double& current_time) if (this->has_pst()) { auto vars = this->get_problem_variables(); this->get_pst().save_variables(vars, iter, current_time); + + if (!this->vect_vtk_coefficient_.empty()) { + this->get_pst().save_coefficients(this->vect_vtk_coefficient_, vars, this->auxvariables_, + iter, current_time); + } } } @@ -552,3 +573,35 @@ void ProblemBase::collect_vtk_fields( this->get_pst().collect_vtk_fields(this->variables_, all_fields); } } + +/** + * @brief Collect this Problem's grid functions into a shared coefficient map, + * if a PostProcessing object is attached. + * + * @tparam VAR Type representing the problem Variables. + * @tparam PST Type representing the post-processing. + * @param all_fields Output map, accumulated across every Problem for a + * unified VTK save (see `Coupling`/`TimeDiscretization`). + */ +template +void ProblemBase::collect_vtk_coefficients( + std::map& all_coefficients) { + if (this->has_pst()) { + auto field_map = this->get_pst().project_coefficients(this->vect_vtk_coefficient_, + this->variables_, this->auxvariables_); + + all_coefficients.insert(field_map.begin(), field_map.end()); + } +} +/** + * @brief Set (replace) the auxiliary variables of this problem + * + * + * @param auxiliary_variables Pointers to auxiliary VAR objects, replacing + * any previously set (via the constructor's + * variadic pack or a prior call to this method). + */ +template +void ProblemBase::set_auxvariables(std::vector auxiliary_variables) { + this->auxvariables_ = std::move(auxiliary_variables); +} diff --git a/kernel/include/Sloth/sloth.hpp b/kernel/include/Sloth/sloth.hpp index 0fa42435..2a910366 100644 --- a/kernel/include/Sloth/sloth.hpp +++ b/kernel/include/Sloth/sloth.hpp @@ -42,6 +42,7 @@ #include "Convergence/Convergence.hpp" #include "Convergence/PhysicalConvergence.hpp" #include "Couplings/Coupling.hpp" +#include "Factory/ListFactory.hpp" #include "Operators/ListOperators.hpp" #include "PostProcessing/postprocessing.hpp" #include "Problems/ListProblems.hpp" diff --git a/kernel/include/Sloth/tests.hpp b/kernel/include/Sloth/tests.hpp index 1600b431..a4e39c38 100644 --- a/kernel/include/Sloth/tests.hpp +++ b/kernel/include/Sloth/tests.hpp @@ -25,6 +25,9 @@ */ #pragma once +#include + +#include "Factory/ListFactory.hpp" /** * @brief Usefull aliases for tests depending on the dimension of space @@ -100,3 +103,173 @@ struct Test<3> { /// @brief Boundary condition object (SLOTH object) using BCS = BoundaryConditions; }; + +/** + * @brief Define the DIM, FE/mesh/post-processing aliases, the + * set(Periodic)SpatialDiscretization factories, and the + * scheme-independent problem aliases (PB_MPI, PB_CALPHAD, + * PB_PROPERTY - none of them depend on OPERATOR_TYPE, so unlike + * OPE/PB they are defined once here rather than duplicated per + * scheme) shared by every scheme (Transient/Steady) for one spatial + * dimension. + */ +#define SLOTH_DEFINE_COMMON(DIM_VALUE) \ + constexpr int DIM = DIM_VALUE; \ + using FECollection = Test::FECollection; \ + using VARS = Test::VARS; \ + using VAR = Test::VAR; \ + using PST = Test::PST; \ + using SPA = Test::SPA; \ + using SPAS = std::vector; \ + using BCS = Test::BCS; \ + using PB_MPI = MPI_Problem; \ + template \ + using PB_CALPHAD = Calphad_Problem; \ + template \ + using PB_PROPERTY = Property_problem; \ + template \ + SPAS setSpatialDiscretization(std::size_t N, Args&&... args) { \ + return ::setSpatialDiscretization(N, false, std::forward(args)...); \ + } \ + template \ + SPAS setPeriodicSpatialDiscretization(std::size_t N, Args&&... args) { \ + return ::setSpatialDiscretization(N, true, std::forward(args)...); \ + } + +/** + * @brief Re-import the DIM-common aliases from COMMON_NS into the current + * namespace, one at a time (using-declarations, not `using + * namespace`), so qualified lookups such as SlothTransient2D::DIM + * stay valid. Each imported name still refers to the same entity as + * in COMMON_NS, so importing from several namespaces at once is + * never ambiguous. + */ +#define SLOTH_IMPORT_COMMON(COMMON_NS) \ + using COMMON_NS::DIM; \ + using COMMON_NS::FECollection; \ + using COMMON_NS::VARS; \ + using COMMON_NS::VAR; \ + using COMMON_NS::PST; \ + using COMMON_NS::SPA; \ + using COMMON_NS::SPAS; \ + using COMMON_NS::BCS; \ + using COMMON_NS::PB_MPI; \ + using COMMON_NS::PB_CALPHAD; \ + using COMMON_NS::PB_PROPERTY; \ + using COMMON_NS::setSpatialDiscretization; \ + using COMMON_NS::setPeriodicSpatialDiscretization; + +/** + * @brief Define only the PREFIX-prefixed, scheme-specific PDE aliases + * (TransientOPE/TransientPB or SteadyOPE/SteadyPB) - the only two + * that actually depend on OPERATOR_TYPE. Does not define the + * unprefixed OPE/PB names, so it can be invoked more than once in + * the same namespace (one call per scheme) without any redefinition + * clash. FECollection/VARS/PST/DIM must already be visible where + * this macro is invoked. + */ +#define SLOTH_DEFINE_SCHEME_ONLY(OPERATOR_TYPE, PREFIX) \ + using PREFIX##OPE = OPERATOR_TYPE; \ + using PREFIX##PB = Problem; + +/** + * @brief Import the DIM-common aliases (including PB_MPI/PB_CALPHAD/ + * PB_PROPERTY) from COMMON_NS, define the usual + * unprefixed PDE aliases (OPE, PB) for backward-compatible + * single-scheme usage, and additionally define their + * PREFIX-prefixed counterparts via SLOTH_DEFINE_SCHEME_ONLY. + */ +#define SLOTH_DEFINE_SCHEME(COMMON_NS, OPERATOR_TYPE, PREFIX) \ + SLOTH_IMPORT_COMMON(COMMON_NS) \ + using OPE = OPERATOR_TYPE; \ + using PB = Problem; \ + SLOTH_DEFINE_SCHEME_ONLY(OPERATOR_TYPE, PREFIX) + +/** + * @brief 1D aliases: DIM-common (incl. PB_MPI/PB_CALPHAD/ + * PB_PROPERTY, each defined once) + both PDE schemes, + * already prefixed (TransientPB, SteadyPB, ...) - a single + * `using namespace Sloth1D` brings in everything needed for mixed + * transient/steady usage. + */ +namespace Sloth1D { +SLOTH_DEFINE_COMMON(1) +SLOTH_DEFINE_SCHEME_ONLY(TransientOperator, Transient) +SLOTH_DEFINE_SCHEME_ONLY(SteadyOperator, Steady) +} // namespace Sloth1D + +/** + * @brief 2D aliases: DIM-common (incl. PB_MPI/PB_CALPHAD/ + * PB_PROPERTY, each defined once) + both PDE schemes, + * already prefixed (TransientPB, SteadyPB, ...) - a single + * `using namespace Sloth2D` brings in everything needed for mixed + * transient/steady usage. + */ +namespace Sloth2D { +SLOTH_DEFINE_COMMON(2) +SLOTH_DEFINE_SCHEME_ONLY(TransientOperator, Transient) +SLOTH_DEFINE_SCHEME_ONLY(SteadyOperator, Steady) +} // namespace Sloth2D + +/** + * @brief 3D aliases: DIM-common (incl. PB_MPI/PB_CALPHAD/ + * PB_PROPERTY, each defined once) + both PDE schemes, + * already prefixed (TransientPB, SteadyPB, ...) - a single + * `using namespace Sloth3D` brings in everything needed for mixed + * transient/steady usage. + */ +namespace Sloth3D { +SLOTH_DEFINE_COMMON(3) +SLOTH_DEFINE_SCHEME_ONLY(TransientOperator, Transient) +SLOTH_DEFINE_SCHEME_ONLY(SteadyOperator, Steady) +} // namespace Sloth3D + +/** + * @brief 1D transient aliases (OPE, PB, ... unprefixed, plus TransientOPE, + * TransientPB, ... prefixed) for single-scheme usage. + */ +namespace SlothTransient1D { +SLOTH_DEFINE_SCHEME(Sloth1D, TransientOperator, Transient) +} +/** + * @brief 2D transient aliases (OPE, PB, ... unprefixed, plus TransientOPE, + * TransientPB, ... prefixed) for single-scheme usage. + */ +namespace SlothTransient2D { +SLOTH_DEFINE_SCHEME(Sloth2D, TransientOperator, Transient) +} +/** + * @brief 3D transient aliases (OPE, PB, ... unprefixed, plus TransientOPE, + * TransientPB, ... prefixed) for single-scheme usage. + */ +namespace SlothTransient3D { +SLOTH_DEFINE_SCHEME(Sloth3D, TransientOperator, Transient) +} + +/** + * @brief 1D steady aliases (OPE, PB, ... unprefixed, plus SteadyOPE, + * SteadyPB, ... prefixed) for single-scheme usage. + */ +namespace SlothSteady1D { +SLOTH_DEFINE_SCHEME(Sloth1D, SteadyOperator, Steady) +} +/** + * @brief 2D steady aliases (OPE, PB, ... unprefixed, plus SteadyOPE, + * SteadyPB, ... prefixed) for single-scheme usage. + */ +namespace SlothSteady2D { +SLOTH_DEFINE_SCHEME(Sloth2D, SteadyOperator, Steady) +} + +/** + * @brief 3D steady aliases (OPE, PB, ... unprefixed, plus SteadyOPE, + * SteadyPB, ... prefixed) for single-scheme usage. + */ +namespace SlothSteady3D { +SLOTH_DEFINE_SCHEME(Sloth3D, SteadyOperator, Steady) +} + +#undef SLOTH_DEFINE_COMMON +#undef SLOTH_IMPORT_COMMON +#undef SLOTH_DEFINE_SCHEME_ONLY +#undef SLOTH_DEFINE_SCHEME \ No newline at end of file diff --git a/kernel/include/Time/Time.tpp b/kernel/include/Time/Time.tpp index 62dee9a7..7e3df4fd 100644 --- a/kernel/include/Time/Time.tpp +++ b/kernel/include/Time/Time.tpp @@ -376,12 +376,21 @@ void TimeDiscretization::save_vtk_unified(const int& iter, const double std::apply([&all_fields](auto&... coupling) { (coupling.collect_vtk_fields(all_fields), ...); }, this->couplings_); + std::map all_coefficients; + + std::apply([&all_coefficients]( + auto&... coupling) { (coupling.collect_vtk_coefficients(all_coefficients), ...); }, + this->couplings_); + auto dc = std::get<0>(this->couplings_).get_shared_dc(); dc->SetCycle(iter); dc->SetTime(current_time); for (auto& [name, gf_ptr] : all_fields) { dc->RegisterField(name, gf_ptr); } + for (auto& [name, coef_ptr] : all_coefficients) { + dc->RegisterField(name, coef_ptr); + } dc->Save(); } diff --git a/kernel/src/Coefficients/SlothBaseCoefficient.cpp b/kernel/src/Coefficients/SlothBaseCoefficient.cpp index 13166b4a..a876d7fd 100644 --- a/kernel/src/Coefficients/SlothBaseCoefficient.cpp +++ b/kernel/src/Coefficients/SlothBaseCoefficient.cpp @@ -363,3 +363,17 @@ void SlothBaseCoefficient::set_bdr_index_coef(std::vector ids) { this->bdr_ * @return Vector of boundary ids where the coefficient is applied. */ std::vector SlothBaseCoefficient::get_bdr_index_coef() const { return this->bdr_index_; } + +/** + * @brief Get the name of the coefficient + * + * @return std::string + */ +std::string SlothBaseCoefficient::get_name() { return this->name_; } + +/** + * @brief Set the name of the coefficient + * + * @param name Name of the coefficient. + */ +void SlothBaseCoefficient::set_name(const std::string& name) { this->name_ = name; } \ No newline at end of file diff --git a/tests/AllenCahn/1D/test1/main.cpp b/tests/AllenCahn/1D/test1/main.cpp index c7fe4830..5f3340de 100644 --- a/tests/AllenCahn/1D/test1/main.cpp +++ b/tests/AllenCahn/1D/test1/main.cpp @@ -34,16 +34,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 1; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth1D; // ########################################### // ########################################### // Spatial Discretization // @@ -140,11 +131,11 @@ int main(int argc, char* argv[]) { Parameter("level_of_detail", level_of_detail)); // Problem 1: - OPE oper({&spatial}, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); + TransientOPE oper({&spatial}, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); Coefficients coef_pb1(double_well_imp, capillary, mobility, grad_energy, explicit_time_A, explicit_time_B); auto pst = PST(&spatial, p_pst1); - PB problem1(oper, vars, {coef_pb1}, pst); + TransientPB problem1(oper, vars, {coef_pb1}, pst); // Problem 2: calculation_path = "Problem2"; @@ -152,11 +143,11 @@ int main(int argc, char* argv[]) { Parameters(Parameter("main_folder_path", main_folder_path), Parameter("calculation_path", calculation_path), Parameter("frequency", frequency), Parameter("level_of_detail", level_of_detail)); - OPE oper2({&spatial}, {"AllenCahn"}, TimeScheme::EulerExplicit, "TimeDerivative"); + TransientOPE oper2({&spatial}, {"AllenCahn"}, TimeScheme::EulerExplicit, "TimeDerivative"); Coefficients coef_pb2(double_well_exp, capillary, mobility, grad_energy, explicit_time_A, explicit_time_B); auto pst2 = PST(&spatial, p_pst2); - PB problem2(oper2, vars2, {coef_pb2}, pst2); + TransientPB problem2(oper2, vars2, {coef_pb2}, pst2); // Problem 3: calculation_path = "Problem3"; @@ -164,9 +155,9 @@ int main(int argc, char* argv[]) { Parameters(Parameter("main_folder_path", main_folder_path), Parameter("calculation_path", calculation_path), Parameter("frequency", frequency), Parameter("level_of_detail", level_of_detail)); - OPE oper3({&spatial}, {"AllenCahn"}, TimeScheme::SDIRK33, "TimeDerivative"); + TransientOPE oper3({&spatial}, {"AllenCahn"}, TimeScheme::SDIRK33, "TimeDerivative"); auto pst3 = PST(&spatial, p_pst3); - PB problem3(oper3, vars3, {coef_pb1}, pst3); + TransientPB problem3(oper3, vars3, {coef_pb1}, pst3); // Problem 4: calculation_path = "Problem4"; @@ -174,9 +165,9 @@ int main(int argc, char* argv[]) { Parameters(Parameter("main_folder_path", main_folder_path), Parameter("calculation_path", calculation_path), Parameter("frequency", frequency), Parameter("level_of_detail", level_of_detail)); - OPE oper4({&spatial}, {"AllenCahn"}, TimeScheme::SDIRK23, "TimeDerivative"); + TransientOPE oper4({&spatial}, {"AllenCahn"}, TimeScheme::SDIRK23, "TimeDerivative"); auto pst4 = PST(&spatial, p_pst4); - PB problem4(oper4, vars4, {coef_pb1}, pst4); + TransientPB problem4(oper4, vars4, {coef_pb1}, pst4); // Problem 5: calculation_path = "Problem5"; @@ -184,9 +175,9 @@ int main(int argc, char* argv[]) { Parameters(Parameter("main_folder_path", main_folder_path), Parameter("calculation_path", calculation_path), Parameter("frequency", frequency), Parameter("level_of_detail", level_of_detail)); - OPE oper5({&spatial}, {"AllenCahn"}, TimeScheme::RungeKutta4, "TimeDerivative"); + TransientOPE oper5({&spatial}, {"AllenCahn"}, TimeScheme::RungeKutta4, "TimeDerivative"); auto pst5 = PST(&spatial, p_pst5); - PB problem5(oper5, vars5, {coef_pb1}, pst5); + TransientPB problem5(oper5, vars5, {coef_pb1}, pst5); // Coupling 1 auto cc = Coupling("coupling 1 ", problem1, problem2, problem3, problem4, problem5); diff --git a/tests/AllenCahn/1D/test2/main.cpp b/tests/AllenCahn/1D/test2/main.cpp index 3798d015..390c64ce 100644 --- a/tests/AllenCahn/1D/test2/main.cpp +++ b/tests/AllenCahn/1D/test2/main.cpp @@ -34,18 +34,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 1; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - - using OPE = TransientOperator; - - using PB = Problem; + using namespace Sloth1D; // ########################################### // ########################################### @@ -131,10 +120,10 @@ int main(int argc, char* argv[]) { // Problem 1: std::vector spatials{&spatial}; - OPE oper(spatials, {"AllenCahn", "MeltingConstant"}, params, TimeScheme::EulerImplicit, - "TimeDerivative"); + TransientOPE oper(spatials, {"AllenCahn", "MeltingConstant"}, params, TimeScheme::EulerImplicit, + "TimeDerivative"); auto pst = PST(&spatial, p_pst1); - PB problem1(oper, vars, {coef_ac}, pst); + TransientPB problem1(oper, vars, {coef_ac}, pst); // Coupling 1 auto cc = Coupling("coupling 1 ", problem1); diff --git a/tests/AllenCahn/2D/regression_split_meshes_test2/main.cpp b/tests/AllenCahn/2D/regression_split_meshes_test2/main.cpp index 6b5aa765..1a1705ca 100644 --- a/tests/AllenCahn/2D/regression_split_meshes_test2/main.cpp +++ b/tests/AllenCahn/2D/regression_split_meshes_test2/main.cpp @@ -35,17 +35,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -128,10 +118,10 @@ int main(int argc, char* argv[]) { // Problem 1: std::vector spatials{&spatial}; - OPE oper(spatials, {"AllenCahn", "MeltingConstant"}, params, TimeScheme::EulerImplicit, - "TimeDerivative"); + TransientOPE oper(spatials, {"AllenCahn", "MeltingConstant"}, params, TimeScheme::EulerImplicit, + "TimeDerivative"); - PB problem1("AllenCahn", oper, vars, {coef_ac}, pst); + TransientPB problem1("AllenCahn", oper, vars, {coef_ac}, pst); // Coupling 1 auto cc = Coupling("Default Coupling", problem1); diff --git a/tests/AllenCahn/2D/test1/main.cpp b/tests/AllenCahn/2D/test1/main.cpp index b8f0e7ff..a7fbc65a 100644 --- a/tests/AllenCahn/2D/test1/main.cpp +++ b/tests/AllenCahn/2D/test1/main.cpp @@ -35,16 +35,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -146,7 +137,7 @@ int main(int argc, char* argv[]) { // Problem 1: std::vector spatials{&spatial}; - OPE oper(spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); + TransientOPE oper(spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); oper.overload_nl_solver( NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("print_level", 1), @@ -162,7 +153,7 @@ int main(int argc, char* argv[]) { auto pst = PST(&spatial, p_pst); Coefficients coef_pb1(double_well, capillary, mobility, grad_energy); - PB problem1(oper, vars, {coef_pb1}, CVG, pst); + TransientPB problem1(oper, vars, {coef_pb1}, CVG, pst); // Coupling 1 auto cc = Coupling("AllenCahn Coupling", problem1); diff --git a/tests/AllenCahn/2D/test10/main.cpp b/tests/AllenCahn/2D/test10/main.cpp index ad3e6ed3..d71e933f 100644 --- a/tests/AllenCahn/2D/test10/main.cpp +++ b/tests/AllenCahn/2D/test10/main.cpp @@ -34,17 +34,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -114,15 +104,15 @@ int main(int argc, char* argv[]) { // Problem 1: std::vector spatials{&spatial}; - OPE oper(spatials, {"AllenCahn", "MeltingConstant"}, params, TimeScheme::EulerImplicit, - "TimeDerivative"); + TransientOPE oper(spatials, {"AllenCahn", "MeltingConstant"}, params, TimeScheme::EulerImplicit, + "TimeDerivative"); auto nl_params = Parameters(Parameter("description", "Newton Algorithm"), Parameter("abs_tol", 1.e-20), Parameter("rel_tol", 1.e-20)); oper.overload_nl_solver(NLSolverType::NEWTON, nl_params); - PB problem1("AllenCahn", oper, vars, {coef_ac}, pst); + TransientPB problem1("AllenCahn", oper, vars, {coef_ac}, pst); // Coupling 1 auto cc = Coupling("Default Coupling", problem1); diff --git a/tests/AllenCahn/2D/test1_splitting/main.cpp b/tests/AllenCahn/2D/test1_splitting/main.cpp index 81dce17a..ece503f3 100644 --- a/tests/AllenCahn/2D/test1_splitting/main.cpp +++ b/tests/AllenCahn/2D/test1_splitting/main.cpp @@ -35,16 +35,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -131,9 +122,9 @@ int main(int argc, char* argv[]) { // Problem 1: std::vector spatials{&spatial, &spatial}; - OPE oper(spatials, {"SplitAllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); + TransientOPE oper(spatials, {"SplitAllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); auto pst = PST(&spatial, p_pst); - PB problem1(oper, vars, {coef_ac, coef_ac}, pst); + TransientPB problem1(oper, vars, {coef_ac, coef_ac}, pst); // Coupling 1 auto cc = Coupling("AllenCahn-Splitting Coupling", problem1); diff --git a/tests/AllenCahn/2D/test2/main.cpp b/tests/AllenCahn/2D/test2/main.cpp index 687146dc..d1e25be6 100644 --- a/tests/AllenCahn/2D/test2/main.cpp +++ b/tests/AllenCahn/2D/test2/main.cpp @@ -34,17 +34,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - using OPE = TransientOperator; - - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -127,10 +117,10 @@ int main(int argc, char* argv[]) { // Problem 1: std::vector spatials{&spatial}; - OPE oper(spatials, {"AllenCahn", "MeltingConstant"}, params, TimeScheme::EulerImplicit, - "TimeDerivative"); + TransientOPE oper(spatials, {"AllenCahn", "MeltingConstant"}, params, TimeScheme::EulerImplicit, + "TimeDerivative"); - PB problem1("AllenCahn", oper, vars, {coef_ac}, pst); + TransientPB problem1("AllenCahn", oper, vars, {coef_ac}, pst); // Coupling 1 auto cc = Coupling("Default Coupling", problem1); diff --git a/tests/AllenCahn/2D/test2_amr/main.cpp b/tests/AllenCahn/2D/test2_amr/main.cpp index f582863b..4b96e464 100644 --- a/tests/AllenCahn/2D/test2_amr/main.cpp +++ b/tests/AllenCahn/2D/test2_amr/main.cpp @@ -35,17 +35,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - using OPE = TransientOperator; - - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -128,10 +118,10 @@ int main(int argc, char* argv[]) { // Problem 1: std::vector spatials{&spatial}; - OPE oper(spatials, {"AllenCahn", "MeltingConstant"}, params, TimeScheme::EulerImplicit, - "TimeDerivative"); + TransientOPE oper(spatials, {"AllenCahn", "MeltingConstant"}, params, TimeScheme::EulerImplicit, + "TimeDerivative"); - PB problem1("AllenCahn", oper, vars, {coef_ac}, pst); + TransientPB problem1("AllenCahn", oper, vars, {coef_ac}, pst); // AMR mfem::ConstantCoefficient amr_coef{1.0}; diff --git a/tests/AllenCahn/2D/test3/main.cpp b/tests/AllenCahn/2D/test3/main.cpp index 86029bd0..45eaf314 100644 --- a/tests/AllenCahn/2D/test3/main.cpp +++ b/tests/AllenCahn/2D/test3/main.cpp @@ -33,19 +33,7 @@ int main(int argc, char* argv[]) { // //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - - using OPE = SteadyOperator; - - using PB = Problem; - using PB1 = MPI_Problem; + using namespace Sloth2D; // ########################################### // ########################################### @@ -138,8 +126,8 @@ int main(int argc, char* argv[]) { std::vector> src_term; src_term.emplace_back(AnalyticalFunctions(user_func_source_term)); std::vector spatials{&spatial}; - OPE oper(spatials, {"AllenCahn"}, src_term); - PB problem1("Steady AllenCahn", oper, vars, {coef_ac}, pst); + SteadyOPE oper(spatials, {"AllenCahn"}, src_term); + SteadyPB problem1("Steady AllenCahn", oper, vars, {coef_ac}, pst); auto vars1 = VARS(VAR(&spatial, bcs, "MPI rank", Glossary::MPI, 2, 0.)); @@ -149,7 +137,7 @@ int main(int argc, char* argv[]) { Parameter("frequency", frequency), Parameter("level_of_detail", level_of_detail)); auto pst2 = PST(&spatial, p_pst2); - PB1 problem2(vars1, pst2); + PB_MPI problem2(vars1, pst2); // Coupling 1 auto cc = Coupling("Steady AllenCahn-MPI Coupling", problem2, problem1); diff --git a/tests/AllenCahn/2D/test4/main.cpp b/tests/AllenCahn/2D/test4/main.cpp index 87ea6df4..c1ba1f7d 100644 --- a/tests/AllenCahn/2D/test4/main.cpp +++ b/tests/AllenCahn/2D/test4/main.cpp @@ -32,18 +32,7 @@ int main(int argc, char* argv[]) { // //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - - using OPE = SteadyOperator; - - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -141,8 +130,8 @@ int main(int argc, char* argv[]) { std::vector > src_term; src_term.emplace_back(AnalyticalFunctions(user_func_source_term)); std::vector spatials{&spatial}; - OPE oper(spatials, {"AllenCahn"}, src_term); - PB problem1("Steady AllenCahn", oper, vars, {coef_ac}, pst); + SteadyOPE oper(spatials, {"AllenCahn"}, src_term); + SteadyPB problem1("Steady AllenCahn", oper, vars, {coef_ac}, pst); // Coupling 1 auto cc = Coupling("Defaut Coupling ", problem1); diff --git a/tests/AllenCahn/2D/test5/main.cpp b/tests/AllenCahn/2D/test5/main.cpp index 4510773e..8c320839 100644 --- a/tests/AllenCahn/2D/test5/main.cpp +++ b/tests/AllenCahn/2D/test5/main.cpp @@ -35,18 +35,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - - using OPE = SteadyOperator; - - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -128,9 +117,9 @@ int main(int argc, char* argv[]) { // Problem 1: std::vector spatials{&spatial}; - OPE oper(spatials, {"AllenCahn"}); + SteadyOPE oper(spatials, {"AllenCahn"}); auto pst = PST(&spatial, p_pst); - PB problem1("Steady AllenCahn", oper, vars, {coef_ac}, pst); + SteadyPB problem1("Steady AllenCahn", oper, vars, {coef_ac}, pst); // Coupling 1 auto cc = Coupling("Default Coupling", problem1); diff --git a/tests/AllenCahn/2D/test6/main.cpp b/tests/AllenCahn/2D/test6/main.cpp index 0dd3714c..3d59a19c 100644 --- a/tests/AllenCahn/2D/test6/main.cpp +++ b/tests/AllenCahn/2D/test6/main.cpp @@ -35,16 +35,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### @@ -214,10 +205,11 @@ int main(int argc, char* argv[]) { src_term.emplace_back(AnalyticalFunctions(user_func_source_term)); std::vector spatials{&spatial}; - OPE oper(spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative", src_term); + TransientOPE oper(spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative", + src_term); auto pst = PST(&spatial, p_pst); - PB problem1(oper, vars, {coef_ac}, pst); + TransientPB problem1(oper, vars, {coef_ac}, pst); // Coupling 1 auto cc = Coupling("Default Coupling", problem1); diff --git a/tests/AllenCahn/2D/test7/main.cpp b/tests/AllenCahn/2D/test7/main.cpp index af0a2391..20cf7771 100644 --- a/tests/AllenCahn/2D/test7/main.cpp +++ b/tests/AllenCahn/2D/test7/main.cpp @@ -33,19 +33,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - - using OPE = TransientOperator; - using OPE2 = TransientOperator; - using PB = Problem; - using PB2 = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -135,18 +123,18 @@ int main(int argc, char* argv[]) { // Problem 1: std::vector spatials{&spatial}; - OPE oper(spatials, {"AllenCahn"}, TimeScheme::EulerExplicit, "TimeDerivative"); + TransientOPE oper(spatials, {"AllenCahn"}, TimeScheme::EulerExplicit, "TimeDerivative"); auto pst = PST(&spatial, p_pst); - PB problem1(oper, vars, {coef_ac}, pst); + TransientPB problem1(oper, vars, {coef_ac}, pst); // Problem 2: Coefficient D(Glossary::Diffusivity, mob); Coefficients CoeffDiffusion(D); - OPE2 oper2(spatials, {"Fick"}, TimeScheme::EulerExplicit, "TimeDerivative"); + TransientOPE oper2(spatials, {"Fick"}, TimeScheme::EulerExplicit, "TimeDerivative"); auto pst2 = PST(&spatial, p_pst2); - PB2 problem2(oper2, vars2, {CoeffDiffusion}, pst2); + TransientPB problem2(oper2, vars2, {CoeffDiffusion}, pst2); // Coupling 1 auto cc = Coupling("AllenCahn + Diffusion", problem1, problem2); diff --git a/tests/AllenCahn/2D/test8/main.cpp b/tests/AllenCahn/2D/test8/main.cpp index 25d5c3af..0b19a6fe 100644 --- a/tests/AllenCahn/2D/test8/main.cpp +++ b/tests/AllenCahn/2D/test8/main.cpp @@ -34,16 +34,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -131,12 +122,12 @@ int main(int argc, char* argv[]) { // Problem 1: std::vector spatials{&spatial}; - OPE oper(spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); + TransientOPE oper(spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); oper.overload_solver(solver); oper.overload_preconditioner(precond); auto pst = PST(&spatial, p_pst); - PB problem1(oper, vars, {coef_ac}, pst); + TransientPB problem1(oper, vars, {coef_ac}, pst); // Coupling auto cc = Coupling("AllenCahn with ", problem1); diff --git a/tests/AllenCahn/2D/test9/main.cpp b/tests/AllenCahn/2D/test9/main.cpp index 6c46c24d..efb9ddfd 100644 --- a/tests/AllenCahn/2D/test9/main.cpp +++ b/tests/AllenCahn/2D/test9/main.cpp @@ -34,16 +34,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -129,12 +120,12 @@ int main(int argc, char* argv[]) { // #################### // Problem 1: std::vector spatials{&spatial}; - OPE oper(spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); + TransientOPE oper(spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); oper.overload_solver(solver); oper.overload_preconditioner(precond); auto pst = PST(&spatial, p_pst); - PB problem1(oper, vars, {coef_ac}, pst); + TransientPB problem1(oper, vars, {coef_ac}, pst); // Coupling auto cc = Coupling("AllenCahn with ", problem1); diff --git a/tests/AllenCahn/2D_periodic/test1/main.cpp b/tests/AllenCahn/2D_periodic/test1/main.cpp index 47f85c39..7b538970 100644 --- a/tests/AllenCahn/2D_periodic/test1/main.cpp +++ b/tests/AllenCahn/2D_periodic/test1/main.cpp @@ -37,17 +37,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -126,10 +116,11 @@ int main(int argc, char* argv[]) { std::vector spatials{&spatial}; std::vector > src_term; src_term.emplace_back(AnalyticalFunctions(AnalyticalFunctionsType::Sinusoide2, omega)); - OPE oper(spatials, {"AllenCahn"}, TimeScheme::from(time_scheme), "TimeDerivative", src_term); + TransientOPE oper(spatials, {"AllenCahn"}, TimeScheme::from(time_scheme), "TimeDerivative", + src_term); auto pst = PST(&spatial, p_pst); - PB problem1("AllenCahn", oper, vars, {coef_ac}, pst); + TransientPB problem1("AllenCahn", oper, vars, {coef_ac}, pst); // Coupling 1 auto cc = Coupling("AllenCahn Coupling", problem1); diff --git a/tests/AllenCahn/2D_periodic/test2/main.cpp b/tests/AllenCahn/2D_periodic/test2/main.cpp index 333af9b5..f0e458d8 100644 --- a/tests/AllenCahn/2D_periodic/test2/main.cpp +++ b/tests/AllenCahn/2D_periodic/test2/main.cpp @@ -35,17 +35,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -125,9 +115,9 @@ int main(int argc, char* argv[]) { // Problem 1: std::vector spatials{&spatial}; - OPE oper(spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); + TransientOPE oper(spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); auto pst = PST(&spatial, p_pst); - PB problem1("AllenCahn", oper, vars, {coef_ac}, pst); + TransientPB problem1("AllenCahn", oper, vars, {coef_ac}, pst); // Coupling 1 auto cc = Coupling("Default Coupling", problem1); diff --git a/tests/AllenCahn/2D_periodic/test3/main.cpp b/tests/AllenCahn/2D_periodic/test3/main.cpp index bffb2942..b150be83 100644 --- a/tests/AllenCahn/2D_periodic/test3/main.cpp +++ b/tests/AllenCahn/2D_periodic/test3/main.cpp @@ -31,18 +31,7 @@ int main(int argc, char* argv[]) { // // --------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - - using OPE = SteadyOperator; - - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -148,9 +137,9 @@ int main(int argc, char* argv[]) { std::vector > src_term; src_term.emplace_back(AnalyticalFunctions(user_func_source_term)); std::vector spatials{&spatial}; - OPE oper(spatials, {"AllenCahn"}, src_term); + SteadyOPE oper(spatials, {"AllenCahn"}, src_term); auto pst = PST(&spatial, p_pst); - PB problem1("PSteady AllenCahn", oper, vars, {coef_ac}, pst); + SteadyPB problem1("PSteady AllenCahn", oper, vars, {coef_ac}, pst); // Coupling 1 auto cc = Coupling("Default Coupling", problem1); diff --git a/tests/AllenCahn/3D/test1/main.cpp b/tests/AllenCahn/3D/test1/main.cpp index 7290f4e1..cbc67a5b 100644 --- a/tests/AllenCahn/3D/test1/main.cpp +++ b/tests/AllenCahn/3D/test1/main.cpp @@ -35,16 +35,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 3; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth3D; // ########################################### // ########################################### // Spatial Discretization // @@ -63,7 +54,7 @@ int main(int argc, char* argv[]) { // ############################## // Boundary conditions // // ############################## - auto boundaries = {Boundary("rear", 0, "Neumann"), Boundary("lower", 1, "Neumann"), + auto boundaries = {Boundary("rear", 0, "Neumann"), Boundary("lower", 1, "Neumann"), Boundary("right", 2, "Dirichlet", 1.), Boundary("upper", 3, "Neumann"), Boundary("left", 4, "Dirichlet", 0.), Boundary("front", 5, "Neumann")}; auto bcs = BCS(&spatial, boundaries); @@ -130,10 +121,10 @@ int main(int argc, char* argv[]) { // Problem 1: std::vector spatials{&spatial}; - OPE oper(spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); + TransientOPE oper(spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); auto pst = PST(&spatial, p_pst); - PB problem1("AllenCahn", oper, vars, {coef_ac}, pst); + TransientPB problem1("AllenCahn", oper, vars, {coef_ac}, pst); // Coupling 1 auto cc = Coupling("Default Coupling", problem1); diff --git a/tests/AllenCahn/3D/test2/main.cpp b/tests/AllenCahn/3D/test2/main.cpp index ee5f2c3f..96a9755f 100644 --- a/tests/AllenCahn/3D/test2/main.cpp +++ b/tests/AllenCahn/3D/test2/main.cpp @@ -34,17 +34,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 3; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth3D; // ########################################### // ########################################### @@ -129,8 +119,8 @@ int main(int argc, char* argv[]) { // Problem 1: std::vector spatials{&spatial}; - OPE oper(spatials, {"AllenCahn", "MeltingConstant"}, params, TimeScheme::EulerImplicit, - "TimeDerivative"); + TransientOPE oper(spatials, {"AllenCahn", "MeltingConstant"}, params, TimeScheme::EulerImplicit, + "TimeDerivative"); auto nl_params = Parameters(Parameter("description", "Newton Algorithm"), Parameter("abs_tol", 1.e-20), Parameter("rel_tol", 1.e-20)); @@ -139,7 +129,7 @@ int main(int argc, char* argv[]) { auto pst = PST(&spatial, p_pst); - PB problem1("AllenCahn", oper, vars, {coef_ac}, pst); + TransientPB problem1("AllenCahn", oper, vars, {coef_ac}, pst); // Coupling 1 auto cc = Coupling("Default Coupling", problem1); diff --git a/tests/AllenCahn/3D/test3/main.cpp b/tests/AllenCahn/3D/test3/main.cpp index d3f321f5..a81b3036 100644 --- a/tests/AllenCahn/3D/test3/main.cpp +++ b/tests/AllenCahn/3D/test3/main.cpp @@ -36,16 +36,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 3; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth3D; // ########################################### // ########################################### // Spatial Discretization // @@ -125,12 +116,12 @@ int main(int argc, char* argv[]) { // operator // // #################### std::vector spatials{&spatial}; - OPE oper(spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); + TransientOPE oper(spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); // #################### // Problem // // #################### - PB problem1(oper, vars, {coef_ac}, pst); + TransientPB problem1(oper, vars, {coef_ac}, pst); // #################### // Coupling // diff --git a/tests/Bench/main.cpp b/tests/Bench/main.cpp index 4f376353..52d0db93 100644 --- a/tests/Bench/main.cpp +++ b/tests/Bench/main.cpp @@ -114,17 +114,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().active_trace(); //--------------------------------------- ///////////////////////// - const int DIM = 3; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth3D; // ################ // // ################ // @@ -268,7 +258,7 @@ int main(int argc, char* argv[]) { // Problem 1: std::vector spatials{&spatial, &spatial}; - OPE oper(spatials, {"CahnHilliard"}, TimeScheme::EulerImplicit, "SplitTimeDerivative"); + TransientOPE oper(spatials, {"CahnHilliard"}, TimeScheme::EulerImplicit, "SplitTimeDerivative"); oper.overload_nl_solver( NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("print_level", p.verbosity), @@ -292,7 +282,7 @@ int main(int argc, char* argv[]) { } auto pst = PST(&spatial, p_pst); - PB problem1(oper, vars, {coef_ch, coef_ch}, pst); + TransientPB problem1(oper, vars, {coef_ch, coef_ch}, pst); // Coupling 1 auto cc = Coupling("CahnHilliard Coupling", problem1); diff --git a/tests/CahnHilliard/2D/test1/main.cpp b/tests/CahnHilliard/2D/test1/main.cpp index 66c15861..bd7ce075 100644 --- a/tests/CahnHilliard/2D/test1/main.cpp +++ b/tests/CahnHilliard/2D/test1/main.cpp @@ -36,16 +36,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -161,7 +152,8 @@ int main(int argc, char* argv[]) { // Problem 1: Coefficients coef_pb1(double_well, capillary, mobility, grad_energy); std::vector spatials{&spatial, &spatial}; - OPE oper(spatials, {"CahnHilliard"}, params, TimeScheme::EulerImplicit, "SplitTimeDerivative"); + TransientOPE oper(spatials, {"CahnHilliard"}, params, TimeScheme::EulerImplicit, + "SplitTimeDerivative"); oper.overload_nl_solver( NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("print_level", -1), @@ -172,7 +164,7 @@ int main(int argc, char* argv[]) { oper.overload_preconditioner(precond); auto pst = PST(&spatial, p_pst); - PB problem1(oper, vars, {coef_pb1, coef_pb1}, pst); + TransientPB problem1(oper, vars, {coef_pb1, coef_pb1}, pst); // Coupling 1 auto cc = Coupling("CahnHilliard Coupling", problem1); diff --git a/tests/CahnHilliard/2D/test1_dt_variable/main.cpp b/tests/CahnHilliard/2D/test1_dt_variable/main.cpp index f7c0f535..62a67663 100644 --- a/tests/CahnHilliard/2D/test1_dt_variable/main.cpp +++ b/tests/CahnHilliard/2D/test1_dt_variable/main.cpp @@ -36,16 +36,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -161,7 +152,8 @@ int main(int argc, char* argv[]) { // Problem 1: Coefficients coef_pb1(double_well, capillary, mobility, grad_energy); std::vector spatials{&spatial, &spatial}; - OPE oper(spatials, {"CahnHilliard"}, params, TimeScheme::EulerImplicit, "SplitTimeDerivative"); + TransientOPE oper(spatials, {"CahnHilliard"}, params, TimeScheme::EulerImplicit, + "SplitTimeDerivative"); oper.overload_nl_solver( NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("print_level", -1), @@ -172,7 +164,7 @@ int main(int argc, char* argv[]) { oper.overload_preconditioner(precond); auto pst = PST(&spatial, p_pst); - PB problem1(oper, vars, {coef_pb1, coef_pb1}, pst); + TransientPB problem1(oper, vars, {coef_pb1, coef_pb1}, pst); // Coupling 1 auto cc = Coupling("CahnHilliard Coupling", problem1); diff --git a/tests/CahnHilliard/2D/test2/main.cpp b/tests/CahnHilliard/2D/test2/main.cpp index 148fad7a..6d8f9a8a 100644 --- a/tests/CahnHilliard/2D/test2/main.cpp +++ b/tests/CahnHilliard/2D/test2/main.cpp @@ -36,17 +36,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using SPA = Test::SPA; - using BCS = Test::BCS; - using PST = Test::PST; - ///////////////////////// - - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -147,7 +137,8 @@ int main(int argc, char* argv[]) { // Problem 1: Coefficients coef_pb1(double_well, capillary, mobility, grad_energy); std::vector spatials{&spatial, &spatial}; - OPE oper(spatials, {"CahnHilliard"}, params, TimeScheme::EulerImplicit, "SplitTimeDerivative"); + TransientOPE oper(spatials, {"CahnHilliard"}, params, TimeScheme::EulerImplicit, + "SplitTimeDerivative"); oper.overload_nl_solver(NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("print_level", -1), Parameter("rel_tol", 1.e-12), @@ -158,7 +149,7 @@ int main(int argc, char* argv[]) { oper.overload_preconditioner(precond); auto pst = PST(&spatial, p_pst); - PB problem1(oper, vars, {coef_pb1, coef_pb1}, pst); + TransientPB problem1(oper, vars, {coef_pb1, coef_pb1}, pst); // Coupling 1 auto cc = Coupling("CahnHilliard Coupling", problem1); diff --git a/tests/CahnHilliard/2D/test2_amr/main.cpp b/tests/CahnHilliard/2D/test2_amr/main.cpp index 200edf96..58fbae55 100644 --- a/tests/CahnHilliard/2D/test2_amr/main.cpp +++ b/tests/CahnHilliard/2D/test2_amr/main.cpp @@ -23,6 +23,7 @@ /// Main program ///--------------- int main(int argc, char* argv[]) { + using namespace Sloth2D; //--------------------------------------- // Initialize MPI and HYPRE //--------------------------------------- @@ -36,17 +37,6 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using SPA = Test::SPA; - using BCS = Test::BCS; - using PST = Test::PST; - ///////////////////////// - - using OPE = TransientOperator; - using PB = Problem; // ########################################### // ########################################### // Spatial Discretization // @@ -162,8 +152,9 @@ int main(int argc, char* argv[]) { // Problem 1: Coefficients coef_pb1(double_well, capillary, mobility, grad_energy); - std::vector spatials{&spatial_phi, &spatial_mu}; - OPE oper(spatials, {"CahnHilliard"}, params, TimeScheme::EulerImplicit, "SplitTimeDerivative"); + SPAS spatials{&spatial_phi, &spatial_mu}; + TransientOPE oper(spatials, {"CahnHilliard"}, params, TimeScheme::EulerImplicit, + "SplitTimeDerivative"); oper.overload_nl_solver(NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("print_level", -1), Parameter("rel_tol", 1.e-12), @@ -174,7 +165,7 @@ int main(int argc, char* argv[]) { oper.overload_preconditioner(precond); auto pst = PST(&spatial_phi, p_pst); - PB problem1(oper, vars, {coef_pb1, coef_pb1}, pst); + TransientPB problem1(oper, vars, {coef_pb1, coef_pb1}, pst); // AMR mfem::ConstantCoefficient amr_coef{1.0}; diff --git a/tests/CahnHilliard/2D/test3/main.cpp b/tests/CahnHilliard/2D/test3/main.cpp index fb44c8eb..a2d732ab 100644 --- a/tests/CahnHilliard/2D/test3/main.cpp +++ b/tests/CahnHilliard/2D/test3/main.cpp @@ -35,17 +35,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -153,7 +143,8 @@ int main(int argc, char* argv[]) { // Problem 1: Coefficients coef_pb1(double_well, capillary, mobility, grad_energy); std::vector spatials{&spatial, &spatial}; - OPE oper(spatials, {"CahnHilliard"}, params, TimeScheme::EulerImplicit, "SplitTimeDerivative"); + TransientOPE oper(spatials, {"CahnHilliard"}, params, TimeScheme::EulerImplicit, + "SplitTimeDerivative"); oper.overload_nl_solver( NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("print_level", 1), @@ -164,7 +155,7 @@ int main(int argc, char* argv[]) { oper.overload_preconditioner(precond); auto pst = PST(&spatial, p_pst); - PB problem1(oper, vars, {coef_pb1, coef_pb1}, pst); + TransientPB problem1(oper, vars, {coef_pb1, coef_pb1}, pst); // Coupling 1 auto cc = Coupling("CahnHilliard Coupling", problem1); diff --git a/tests/CahnHilliard/2D/test4/main.cpp b/tests/CahnHilliard/2D/test4/main.cpp index ee2592a5..4bbce9a8 100644 --- a/tests/CahnHilliard/2D/test4/main.cpp +++ b/tests/CahnHilliard/2D/test4/main.cpp @@ -35,17 +35,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -76,9 +66,8 @@ int main(int argc, char* argv[]) { // ############################## // Boundary conditions // // ############################## - auto boundaries_phi = { - Boundary("lower", 0, "Neumann"), Boundary("right", 1, "Neumann"), - Boundary("upper", 2, "Neumann"), Boundary("left", 3, "Neumann")}; + auto boundaries_phi = {Boundary("lower", 0, "Neumann"), Boundary("right", 1, "Neumann"), + Boundary("upper", 2, "Neumann"), Boundary("left", 3, "Neumann")}; auto boundaries_mu = { Boundary("lower", 0, "Neumann"), Boundary("right", 1, "Dirichlet", 0.), Boundary("upper", 2, "Neumann"), Boundary("left", 3, "Dirichlet", 0.)}; @@ -178,8 +167,8 @@ int main(int argc, char* argv[]) { // Problem 1: Coefficients coef_pb1(double_well, capillary, mobility, grad_energy); std::vector spatials{&spatial, &spatial}; - OPE oper(spatials, {"CahnHilliard"}, params, TimeScheme::EulerImplicit, - "SplitTimeDerivative"); + TransientOPE oper(spatials, {"CahnHilliard"}, params, TimeScheme::EulerImplicit, + "SplitTimeDerivative"); oper.overload_nl_solver( NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("print_level", 1), @@ -195,7 +184,7 @@ int main(int argc, char* argv[]) { auto CVG = Convergence(phi_cvg, mu_cvg); auto pst = PST(&spatial, p_pst); - PB problem1(oper, vars, {coef_pb1, coef_pb1}, CVG, pst); + TransientPB problem1(oper, vars, {coef_pb1, coef_pb1}, CVG, pst); // Coupling 1 auto cc = Coupling("CahnHilliard Coupling", problem1); diff --git a/tests/CahnHilliard/2D/test5/main.cpp b/tests/CahnHilliard/2D/test5/main.cpp index 139ade53..25e7ebe4 100644 --- a/tests/CahnHilliard/2D/test5/main.cpp +++ b/tests/CahnHilliard/2D/test5/main.cpp @@ -42,17 +42,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -82,9 +72,8 @@ int main(int argc, char* argv[]) { // ############################## // Boundary conditions // // ############################## - auto boundaries = { - Boundary("lower", 0, "Neumann"), Boundary("right", 1, "Dirichlet", 0.), - Boundary("upper", 2, "Neumann"), Boundary("left", 3, "Dirichlet", 0.)}; + auto boundaries = {Boundary("lower", 0, "Neumann"), Boundary("right", 1, "Dirichlet", 0.), + Boundary("upper", 2, "Neumann"), Boundary("left", 3, "Dirichlet", 0.)}; auto bcs_phi = BCS(&spatial, boundaries); auto boundaries_mu = { Boundary("lower", 0, "Neumann"), Boundary("right", 1, "Dirichlet", 0.), @@ -202,8 +191,8 @@ int main(int argc, char* argv[]) { src_term.emplace_back(AnalyticalFunctions(user_func_source_term)); // OPE oper(spatials, params, src_term); - OPE oper(spatials, {"CahnHilliard"}, params, TimeScheme::EulerImplicit, - "SplitTimeDerivative", src_term); + TransientOPE oper(spatials, {"CahnHilliard"}, params, TimeScheme::EulerImplicit, + "SplitTimeDerivative", src_term); oper.overload_nl_solver( NLSolverType::NEWTON, @@ -215,7 +204,7 @@ int main(int argc, char* argv[]) { oper.overload_preconditioner(precond, Parameters(Parameter("type", 1))); auto pst = PST(&spatial, p_pst); - PB problem1(oper, vars, {coef_pb1, coef_pb1}, pst); + TransientPB problem1(oper, vars, {coef_pb1, coef_pb1}, pst); // Coupling 1 auto cc = Coupling("CahnHilliard Coupling", problem1); diff --git a/tests/CahnHilliard/2D/test_logo/main.cpp b/tests/CahnHilliard/2D/test_logo/main.cpp index 63fa7ef7..f31bec39 100644 --- a/tests/CahnHilliard/2D/test_logo/main.cpp +++ b/tests/CahnHilliard/2D/test_logo/main.cpp @@ -37,17 +37,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -143,7 +133,8 @@ int main(int argc, char* argv[]) { // Problem 1: Coefficients coef_pb1(double_well, capillary, mobility, grad_energy); std::vector spatials{&spatial, &spatial}; - OPE oper(spatials, {"CahnHilliard"}, params, TimeScheme::EulerImplicit, "SplitTimeDerivative"); + TransientOPE oper(spatials, {"CahnHilliard"}, params, TimeScheme::EulerImplicit, + "SplitTimeDerivative"); oper.overload_nl_solver(NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("print_level", -1), Parameter("rel_tol", 1.e-11), @@ -154,7 +145,7 @@ int main(int argc, char* argv[]) { oper.overload_preconditioner(precond); auto pst = PST(&spatial, p_pst); - PB problem1(oper, vars, {coef_pb1, coef_pb1}, pst); + TransientPB problem1(oper, vars, {coef_pb1, coef_pb1}, pst); // Coupling 1 auto cc = Coupling("CahnHilliard Coupling", problem1); diff --git a/tests/Calphad/AnalyticalIdealSolution/test1/main.cpp b/tests/Calphad/AnalyticalIdealSolution/test1/main.cpp index 049d1a80..eb687c35 100644 --- a/tests/Calphad/AnalyticalIdealSolution/test1/main.cpp +++ b/tests/Calphad/AnalyticalIdealSolution/test1/main.cpp @@ -34,19 +34,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - using PB = Calphad_Problem, VARS, PST>; - - // Heat - using OPE2 = TransientOperator; - using PB2 = Problem; + using namespace Sloth2D; // ########################################### // ########################################### @@ -62,12 +50,10 @@ int main(int argc, char* argv[]) { // ############################## // Boundary conditions // // ############################## - auto Calphadboundaries = {Boundary("lower", 0, "Neumann"), - Boundary("external", 2, "Neumann"), + auto Calphadboundaries = {Boundary("lower", 0, "Neumann"), Boundary("external", 2, "Neumann"), Boundary("upper", 1, "Neumann")}; auto Calphadbcs = BCS(&spatial, Calphadboundaries); - auto Tboundaries = {Boundary("lower", 0, "Neumann"), - Boundary("external", 2, "Dirichlet", 750.), + auto Tboundaries = {Boundary("lower", 0, "Neumann"), Boundary("external", 2, "Dirichlet", 750.), Boundary("upper", 1, "Neumann")}; auto Tbcs = BCS(&spatial, Tboundaries); // #################### @@ -163,19 +149,21 @@ int main(int argc, char* argv[]) { Coefficient conductivity(Glossary::Conductivity, cond); Coefficients coef_heat(density, heat_capacity, conductivity); - std::vector > src_term; + std::vector> src_term; src_term.emplace_back(AnalyticalFunctions(src_func)); std::vector spatials{&spatial}; - OPE2 Heat_op(spatials, {"Fourier"}, TimeScheme::EulerImplicit, "HeatTimeDerivative", src_term); + TransientOPE Heat_op(spatials, {"Fourier"}, TimeScheme::EulerImplicit, "HeatTimeDerivative", + src_term); Heat_op.overload_nl_solver( NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("abs_tol", 1.e-10))); - PB2 Heat_pb("Heat", Heat_op, heat_vars, {coef_heat}, Heat_pst); + TransientPB Heat_pb("Heat", Heat_op, heat_vars, {coef_heat}, Heat_pst); //--------------- // Calphad //--------------- - PB Calphad_pb(calphad_parameters, outputs, Calphad_pst, heat_vars, p_vars, compo_vars); + PB_CALPHAD> Calphad_pb( + calphad_parameters, outputs, Calphad_pst, heat_vars, p_vars, compo_vars); // #################### // Coupling // diff --git a/tests/Diffusion/1D/test1/main.cpp b/tests/Diffusion/1D/test1/main.cpp index 92a55492..afa4d56d 100644 --- a/tests/Diffusion/1D/test1/main.cpp +++ b/tests/Diffusion/1D/test1/main.cpp @@ -35,17 +35,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 1; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth1D; // ########################################### // ########################################### // Spatial Discretization // @@ -115,11 +105,11 @@ int main(int argc, char* argv[]) { // Problem 1: std::vector spatials{&spatial}; - OPE oper(spatials, {"Fick"}, TimeScheme::EulerImplicit, "TimeDerivative"); + TransientOPE oper(spatials, {"Fick"}, TimeScheme::EulerImplicit, "TimeDerivative"); auto pst = PST(&spatial, p_pst); - PB problem1("Problem 1", oper, vars, {CoeffDiffusion}, pst); + TransientPB problem1("Problem 1", oper, vars, {CoeffDiffusion}, pst); // Coupling 1 auto cc = Coupling("coupling 1 ", problem1); diff --git a/tests/Diffusion/1D/test2/main.cpp b/tests/Diffusion/1D/test2/main.cpp index f426a658..6376a2a8 100644 --- a/tests/Diffusion/1D/test2/main.cpp +++ b/tests/Diffusion/1D/test2/main.cpp @@ -35,17 +35,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 1; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth1D; // ########################################### // ########################################### // Spatial Discretization // @@ -123,11 +113,11 @@ int main(int argc, char* argv[]) { // Problem 1: std::vector spatials{&spatial}; - OPE oper(spatials, {"Fick"}, TimeScheme::EulerImplicit, "TimeDerivative"); + TransientOPE oper(spatials, {"Fick"}, TimeScheme::EulerImplicit, "TimeDerivative"); auto pst = PST(&spatial, p_pst); - PB problem1("Problem 1", oper, vars, {CoeffDiffusion}, pst); + TransientPB problem1("Problem 1", oper, vars, {CoeffDiffusion}, pst); // Coupling 1 auto cc = Coupling("coupling 1 ", problem1); diff --git a/tests/Diffusion/1D/test3/main.cpp b/tests/Diffusion/1D/test3/main.cpp index 34f3049b..12454f7d 100644 --- a/tests/Diffusion/1D/test3/main.cpp +++ b/tests/Diffusion/1D/test3/main.cpp @@ -36,17 +36,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 1; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth1D; // ########################################### // ########################################### // Spatial Discretization // @@ -157,11 +147,13 @@ int main(int argc, char* argv[]) { Coefficient Dstab(Glossary::Diffusivity, stabCoeff); Coefficients coef_pb(Dstab); std::vector spatials{&spatial}; - OPE oper(spatials, {"MassFlux"}, td_parameters, TimeScheme::EulerImplicit, "TimeDerivative"); + TransientOPE oper(spatials, {"MassFlux"}, td_parameters, TimeScheme::EulerImplicit, + "TimeDerivative"); auto pst = PST(&spatial, p_pst); - PB problem1(oper, vars, {coef_pb}, pst, mua_var, mub_var, moba_var, mobb_var, fictitious_Mob); + TransientPB problem1(oper, vars, {coef_pb}, pst, mua_var, mub_var, moba_var, mobb_var, + fictitious_Mob); // Coupling 1 auto cc = Coupling("coupling 1 ", problem1); diff --git a/tests/Diffusion/2D/test1/main.cpp b/tests/Diffusion/2D/test1/main.cpp index 4ed81f46..013a341e 100644 --- a/tests/Diffusion/2D/test1/main.cpp +++ b/tests/Diffusion/2D/test1/main.cpp @@ -34,16 +34,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - // - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -112,11 +103,11 @@ int main(int argc, char* argv[]) { // Problem 1: std::vector spatials{&spatial}; - OPE oper(spatials, {"Fick"}, TimeScheme::EulerImplicit, "TimeDerivative"); + TransientOPE oper(spatials, {"Fick"}, TimeScheme::EulerImplicit, "TimeDerivative"); auto pst = PST(&spatial, p_pst); - PB problem1("Problem 1", oper, vars, coeffs, pst); + TransientPB problem1("Problem 1", oper, vars, coeffs, pst); // Coupling 1 auto cc = Coupling("coupling 1 ", problem1); diff --git a/tests/Diffusion/2D/test2/main.cpp b/tests/Diffusion/2D/test2/main.cpp index 3b50711d..576efea4 100644 --- a/tests/Diffusion/2D/test2/main.cpp +++ b/tests/Diffusion/2D/test2/main.cpp @@ -34,16 +34,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - // - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -111,11 +102,11 @@ int main(int argc, char* argv[]) { // Problem 1: std::vector spatials{&spatial}; - OPE oper(spatials, {"Fick"}, TimeScheme::EulerImplicit, "TimeDerivative"); + TransientOPE oper(spatials, {"Fick"}, TimeScheme::EulerImplicit, "TimeDerivative"); auto pst = PST(&spatial, p_pst); - PB problem1("Problem 1", oper, vars, coeffs, pst); + TransientPB problem1("Problem 1", oper, vars, coeffs, pst); // Coupling 1 auto cc = Coupling("coupling 1 ", problem1); diff --git a/tests/Diffusion/2D/test3/main.cpp b/tests/Diffusion/2D/test3/main.cpp index 29de8b98..75f3a515 100644 --- a/tests/Diffusion/2D/test3/main.cpp +++ b/tests/Diffusion/2D/test3/main.cpp @@ -35,16 +35,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - // - using OPE = SteadyOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -112,10 +103,10 @@ int main(int argc, char* argv[]) { // Problem 1: std::vector spatials{&spatial}; - OPE oper(spatials, {"Fick"}, src_term); + SteadyOPE oper(spatials, {"Fick"}, src_term); auto pst = PST(&spatial, p_pst); - PB problem1("Problem 1", oper, vars, coeffs, pst); + SteadyPB problem1("Problem 1", oper, vars, coeffs, pst); // Coupling 1 auto cc = Coupling("coupling 1 ", problem1); diff --git a/tests/Diffusion/2D/test4/main.cpp b/tests/Diffusion/2D/test4/main.cpp index 06018c94..201258f4 100644 --- a/tests/Diffusion/2D/test4/main.cpp +++ b/tests/Diffusion/2D/test4/main.cpp @@ -34,13 +34,7 @@ int main(int argc, char* argv[]) { //--------------------------------------- // Common aliases //--------------------------------------- - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; + using namespace Sloth2D; //--------------------------------------- // Meshing & Boundary Conditions //--------------------------------------- @@ -94,8 +88,7 @@ int main(int argc, char* argv[]) { Coefficients coef_fick(D); auto diffu_vars = VARS(VAR(&spatial, bcs, "c", Glossary::MoleFraction, level_of_storage, initial_compo, analytical_compo)); - TransientOperator diffu_oper(spatials, {"Fick"}, TimeScheme::SDIRK33, - "TimeDerivative"); + TransientOPE diffu_oper(spatials, {"Fick"}, TimeScheme::SDIRK33, "TimeDerivative"); //========================================== //====== Inter-diffusion ====== @@ -117,8 +110,8 @@ int main(int argc, char* argv[]) { Coefficient Dstab(Glossary::Diffusivity, stabCoeff); Coefficients coef_inter(Dstab); - TransientOperator interdiffu_oper(spatials, {"MassFlux"}, td_parameters, - TimeScheme::SDIRK33, "TimeDerivative"); + TransientOPE interdiffu_oper(spatials, {"MassFlux"}, td_parameters, TimeScheme::SDIRK33, + "TimeDerivative"); //========================================== //====== CALPHAD Analytical ====== @@ -181,21 +174,20 @@ int main(int argc, char* argv[]) { //----------------------- // Problems //----------------------- - Calphad_Problem, VARS, PST> cc_problem( - calphad_parameters, mu_var, cc_pst, heat_vars, p_vars, compo_vars); + PB_CALPHAD> cc_problem(calphad_parameters, mu_var, cc_pst, + heat_vars, p_vars, compo_vars); auto pp_parameters = Parameters(Parameter("Description", "A Mobilities"), Parameter("first_component", "A"), Parameter("last_component", "B"), Parameter("primary_phase", "SOLID")); - Property_problem a_interdiffusion_mobilities( + PB_PROPERTY a_interdiffusion_mobilities( "A inter-diffusion mobilities", pp_parameters, MA, mob_pst_a, compo_vars, heat_vars, mobilities); - Problem, VARS, PST> interdiffu_problem( - "InterDiffusion", interdiffu_oper, compo_vars, {coef_inter}, interdiffu_pst, mu_var, MA); + TransientPB interdiffu_problem("InterDiffusion", interdiffu_oper, compo_vars, {coef_inter}, + interdiffu_pst, mu_var, MA); - Problem, VARS, PST> diffu_problem( - "Fick", diffu_oper, diffu_vars, {coef_fick}, diffu_pst); + TransientPB diffu_problem("Fick", diffu_oper, diffu_vars, {coef_fick}, diffu_pst); //----------------------- // Coupling diff --git a/tests/Diffusion/2D/test5/main.cpp b/tests/Diffusion/2D/test5/main.cpp index 6d10ff1f..b3eec59c 100644 --- a/tests/Diffusion/2D/test5/main.cpp +++ b/tests/Diffusion/2D/test5/main.cpp @@ -34,13 +34,7 @@ int main(int argc, char* argv[]) { //--------------------------------------- // Common aliases //--------------------------------------- - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; + using namespace Sloth2D; //--------------------------------------- // Meshing & Boundary Conditions //--------------------------------------- @@ -118,11 +112,11 @@ int main(int argc, char* argv[]) { Coefficient explicit_time_B(Glossary::ExplicitTime_B, 1.0); Coefficient Dstab(Glossary::Diffusivity, stabCoeff); Coefficients coef_inter(Dstab, explicit_time_A, explicit_time_B); - TransientOperator interdiffu_oper(spatials, {"MassFlux"}, td_parameters, - TimeScheme::RungeKutta4, "TimeDerivative"); + TransientOPE interdiffu_oper(spatials, {"MassFlux"}, td_parameters, TimeScheme::RungeKutta4, + "TimeDerivative"); - TransientOperator interdiffu_oper_b(spatials, {"MassFlux"}, td_parameters, - TimeScheme::RungeKutta4, "TimeDerivative"); + TransientOPE interdiffu_oper_b(spatials, {"MassFlux"}, td_parameters, TimeScheme::RungeKutta4, + "TimeDerivative"); //========================================== //====== CALPHAD Analytical ====== @@ -196,30 +190,30 @@ int main(int argc, char* argv[]) { //====================== // Calphad //====================== - Calphad_Problem, VARS, PST> cc_problem( - calphad_parameters, mu_var, cc_pst, heat_vars, p_vars, var_a, var_b); + PB_CALPHAD> cc_problem(calphad_parameters, mu_var, cc_pst, + heat_vars, p_vars, var_a, var_b); auto ppa_parameters = Parameters(Parameter("Description", "A Mobilities"), Parameter("first_component", "A"), Parameter("last_component", "C"), Parameter("primary_phase", "SOLID")); - Property_problem a_interdiffusion_mobilities( + PB_PROPERTY a_interdiffusion_mobilities( "A inter-diffusion mobilities", ppa_parameters, MA, mob_pst_a, var_a, var_b, heat_vars, mobilities); - Problem, VARS, PST> interdiffu_problem_a( - "Interdiffusion A", interdiffu_oper, var_a, {coef_inter}, interdiffu_pst, mu_var, MA); + TransientPB interdiffu_problem_a("Interdiffusion A", interdiffu_oper, var_a, {coef_inter}, + interdiffu_pst, mu_var, MA); auto ppb_parameters = Parameters(Parameter("Description", "B Mobilities"), Parameter("first_component", "B"), Parameter("last_component", "C"), Parameter("primary_phase", "SOLID")); - Property_problem b_interdiffusion_mobilities( + PB_PROPERTY b_interdiffusion_mobilities( "B inter-diffusion mobilities", ppb_parameters, MB, mob_pst_b, var_a, var_b, heat_vars, mobilities); - Problem, VARS, PST> interdiffu_problem_b( - "Interdiffusion B", interdiffu_oper_b, var_b, {coef_inter}, interdiffu_pst_b, mu_var, MB); + TransientPB interdiffu_problem_b("Interdiffusion B", interdiffu_oper_b, var_b, {coef_inter}, + interdiffu_pst_b, mu_var, MB); //----------------------- // Coupling diff --git a/tests/HeatTransfer/1D/test1/main.cpp b/tests/HeatTransfer/1D/test1/main.cpp index 4166babf..cc9e861f 100644 --- a/tests/HeatTransfer/1D/test1/main.cpp +++ b/tests/HeatTransfer/1D/test1/main.cpp @@ -34,15 +34,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 1; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth1D; // ########################################### // ########################################### @@ -126,12 +118,12 @@ int main(int argc, char* argv[]) { // Heat Coefficients coef_pb(density, heat_capacity, conductivity, neumann); std::vector spatials{&spatial}; - OPE oper(spatials, {"Fourier"}, TimeScheme::EulerImplicit, "HeatTimeDerivative"); + TransientOPE oper(spatials, {"Fourier"}, TimeScheme::EulerImplicit, "HeatTimeDerivative"); oper.overload_nl_solver(NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("print_level", 1), Parameter("abs_tol", 1.e-10))); - PB Heat_pb("Heat", oper, heat_vars, {coef_pb}, pst); + TransientPB Heat_pb("Heat", oper, heat_vars, {coef_pb}, pst); // Coupling 1 auto cc = Coupling("Heat transfer", Heat_pb); diff --git a/tests/HeatTransfer/1D/test2/main.cpp b/tests/HeatTransfer/1D/test2/main.cpp index 8851671a..aa046bef 100644 --- a/tests/HeatTransfer/1D/test2/main.cpp +++ b/tests/HeatTransfer/1D/test2/main.cpp @@ -34,16 +34,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 1; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth1D; // ########################################### // ########################################### @@ -131,12 +122,12 @@ int main(int argc, char* argv[]) { // Heat Coefficients coef_pb(density, heat_capacity, conductivity, robin_a, robin_b); std::vector spatials{&spatial}; - OPE oper(spatials, {"Fourier"}, TimeScheme::EulerImplicit, "HeatTimeDerivative"); + TransientOPE oper(spatials, {"Fourier"}, TimeScheme::EulerImplicit, "HeatTimeDerivative"); oper.overload_nl_solver(NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("print_level", 1), Parameter("abs_tol", 1.e-10))); - PB Heat_pb("Heat", oper, heat_vars, {coef_pb}, pst); + TransientPB Heat_pb("Heat", oper, heat_vars, {coef_pb}, pst); // Coupling 1 auto cc = Coupling("Heat transfer", Heat_pb); diff --git a/tests/HeatTransfer/1D/test3/main.cpp b/tests/HeatTransfer/1D/test3/main.cpp index 9e780a6d..615ea7f9 100644 --- a/tests/HeatTransfer/1D/test3/main.cpp +++ b/tests/HeatTransfer/1D/test3/main.cpp @@ -33,16 +33,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 1; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - // - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth1D; // ########################################### // ########################################### @@ -140,7 +131,8 @@ int main(int argc, char* argv[]) { std::vector > src_term; src_term.emplace_back(AnalyticalFunctions(src_func)); std::vector spatials{&spatial}; - OPE oper(spatials, {"Fourier"}, TimeScheme::EulerImplicit, "HeatTimeDerivative", src_term); + TransientOPE oper(spatials, {"Fourier"}, TimeScheme::EulerImplicit, "HeatTimeDerivative", + src_term); oper.overload_nl_solver( NLSolverType::NEWTON, @@ -150,7 +142,7 @@ int main(int argc, char* argv[]) { auto T_cvg = PhysicalConvergence(ConvergenceType::ABSOLUTE_MAX, 1.e-16); auto CVG = Convergence(T_cvg); - PB Heat_pb("Heat", oper, heat_vars, {coef_pb}, CVG, pst); + TransientPB Heat_pb("Heat", oper, heat_vars, {coef_pb}, CVG, pst); Heat_pb.setGeometry(Geometry::Axisymmetric); // Coupling 1 auto cc = Coupling("Heat transfer", Heat_pb); diff --git a/tests/HeatTransfer/2D/test1/main.cpp b/tests/HeatTransfer/2D/test1/main.cpp index 9f5f032d..bf037e0a 100644 --- a/tests/HeatTransfer/2D/test1/main.cpp +++ b/tests/HeatTransfer/2D/test1/main.cpp @@ -33,16 +33,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - // - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### @@ -58,8 +49,7 @@ int main(int argc, char* argv[]) { // ############################## // Boundary conditions // // ############################## - auto Tboundaries = {Boundary("lower", 0, "Neumann"), - Boundary("external", 2, "Dirichlet", 750.), + auto Tboundaries = {Boundary("lower", 0, "Neumann"), Boundary("external", 2, "Dirichlet", 750.), Boundary("upper", 1, "Neumann")}; auto Tbcs = BCS(&spatial, Tboundaries); // ########################################### @@ -118,12 +108,13 @@ int main(int argc, char* argv[]) { std::vector > src_term; src_term.emplace_back(AnalyticalFunctions(src_func)); std::vector spatials{&spatial}; - OPE oper(spatials, {"Fourier"}, TimeScheme::EulerImplicit, "HeatTimeDerivative", src_term); + TransientOPE oper(spatials, {"Fourier"}, TimeScheme::EulerImplicit, "HeatTimeDerivative", + src_term); oper.overload_nl_solver(NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("print_level", 1), Parameter("abs_tol", 1.e-10))); - PB Heat_pb("Heat", oper, heat_vars, {coef_pb}, pst); + TransientPB Heat_pb("Heat", oper, heat_vars, {coef_pb}, pst); // Coupling 1 auto cc = Coupling("Heat transfer", Heat_pb); diff --git a/tests/HeatTransfer/2D/test2/main.cpp b/tests/HeatTransfer/2D/test2/main.cpp index 1ba6c049..e1794f09 100644 --- a/tests/HeatTransfer/2D/test2/main.cpp +++ b/tests/HeatTransfer/2D/test2/main.cpp @@ -36,16 +36,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - - using OPE = SteadyOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### @@ -118,13 +109,13 @@ int main(int argc, char* argv[]) { // Heat Coefficients coef_pb(conductivity, robin_a, robin_b); std::vector spatials{&spatial}; - OPE oper(spatials, {"Fourier"}); + SteadyOPE oper(spatials, {"Fourier"}); oper.overload_nl_solver( NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("print_level", 1), Parameter("rel_tol", 1.e-10), Parameter("abs_tol", 1.e-12))); - PB Heat_pb("Heat", oper, heat_vars, {coef_pb}, pst); + SteadyPB Heat_pb("Heat", oper, heat_vars, {coef_pb}, pst); // Coupling 1 auto cc = Coupling("Heat transfer", Heat_pb); diff --git a/tests/HeatTransfer/2D/test3/main.cpp b/tests/HeatTransfer/2D/test3/main.cpp index 36c2b254..32ba0af2 100644 --- a/tests/HeatTransfer/2D/test3/main.cpp +++ b/tests/HeatTransfer/2D/test3/main.cpp @@ -33,16 +33,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - // - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### @@ -148,14 +139,15 @@ int main(int argc, char* argv[]) { std::vector > src_term; src_term.emplace_back(AnalyticalFunctions(src_func)); - OPE oper(spatials, {"Fourier"}, TimeScheme::EulerImplicit, "HeatTimeDerivative", src_term); + TransientOPE oper(spatials, {"Fourier"}, TimeScheme::EulerImplicit, "HeatTimeDerivative", + src_term); oper.overload_nl_solver( NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("print_level", 1), Parameter("rel_tol", 1.e-9), Parameter("abs_tol", 1.e-9))); - PB Heat_pb("Heat", oper, heat_vars, {coef_pb}, pst); + TransientPB Heat_pb("Heat", oper, heat_vars, {coef_pb}, pst); Heat_pb.setGeometry(Geometry::Axisymmetric); // Coupling 1 auto cc = Coupling("Heat transfer", Heat_pb); diff --git a/tests/HeatTransfer/2D/test4/main.cpp b/tests/HeatTransfer/2D/test4/main.cpp index eba3bd9a..7baf407b 100644 --- a/tests/HeatTransfer/2D/test4/main.cpp +++ b/tests/HeatTransfer/2D/test4/main.cpp @@ -33,16 +33,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - // - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### @@ -153,14 +144,15 @@ int main(int argc, char* argv[]) { std::vector > src_term; src_term.emplace_back(AnalyticalFunctions(src_func)); - OPE oper(spatials, {"Fourier"}, TimeScheme::EulerImplicit, "HeatTimeDerivative", src_term); + TransientOPE oper(spatials, {"Fourier"}, TimeScheme::EulerImplicit, "HeatTimeDerivative", + src_term); oper.overload_nl_solver( NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("print_level", 1), Parameter("rel_tol", 1.e-9), Parameter("abs_tol", 1.e-9))); - PB Heat_pb("Heat", oper, heat_vars, {coef_pb}, pst); + TransientPB Heat_pb("Heat", oper, heat_vars, {coef_pb}, pst); Heat_pb.setGeometry(Geometry::Axisymmetric); // Coupling 1 auto cc = Coupling("Heat transfer", Heat_pb); diff --git a/tests/HeatTransfer/2D/test5/main.cpp b/tests/HeatTransfer/2D/test5/main.cpp index 2648af43..c31f8edc 100644 --- a/tests/HeatTransfer/2D/test5/main.cpp +++ b/tests/HeatTransfer/2D/test5/main.cpp @@ -36,16 +36,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### @@ -78,11 +69,11 @@ int main(int argc, char* argv[]) { // ############################## auto boundaries = {Boundary("lower", 0, "Neumann"), Boundary("right", 1, "Dirichlet"), - Boundary("upper", 2, "Neumann"), Boundary("left", 3, "Dirichlet")}; + Boundary("upper", 2, "Neumann"), Boundary("left", 3, "Dirichlet")}; auto bcs = BCS(&spatial, boundaries); auto Xboundaries = {Boundary("lower", 0, "Neumann"), Boundary("right", 1, "Neumann"), - Boundary("upper", 2, "Neumann"), Boundary("left", 3, "Neumann")}; + Boundary("upper", 2, "Neumann"), Boundary("left", 3, "Neumann")}; auto Xbcs = BCS(&spatial, Xboundaries); // ########################################### @@ -100,8 +91,9 @@ int main(int argc, char* argv[]) { Coefficient conductivity(Glossary::Conductivity, 1.); Coefficient neumann(Glossary::Neumann, Scheme::Implicit, NeumannCoefficient()); Coefficient dirichlet_left(Glossary::Dirichlet, Scheme::Implicit, DirichletCoefficient()); - Coefficient dirichlet_right(Glossary::Dirichlet, Scheme::Implicit, DirichletCoefficient(-1)); - neumann.set_bdr_index_coef(std::vector{0,2}); + Coefficient dirichlet_right(Glossary::Dirichlet, Scheme::Implicit, + DirichletCoefficient(-1)); + neumann.set_bdr_index_coef(std::vector{0, 2}); dirichlet_left.set_bdr_index_coef(std::vector{3}); dirichlet_right.set_bdr_index_coef(std::vector{1}); @@ -110,26 +102,26 @@ int main(int argc, char* argv[]) { // #################### auto user_func = std::function( - [](const mfem::Vector& x, double time) { - const auto xx = x[0]; - const auto yy = x[1]; - const auto func = time * std::cos(M_PI*xx) * std::sin(M_PI*yy); - return func; - }); + [](const mfem::Vector& x, double time) { + const auto xx = x[0]; + const auto yy = x[1]; + const auto func = time * std::cos(M_PI * xx) * std::sin(M_PI * yy); + return func; + }); auto T_analytical = AnalyticalFunctions(user_func); - auto heat_vars = VARS(VAR(&spatial, bcs, "T", Glossary::Temperature, 2, 0, T_analytical)); + auto heat_vars = VARS(VAR(&spatial, bcs, "T", Glossary::Temperature, 2, 0, T_analytical)); // Coord auto xcoord = std::function( - [](const mfem::Vector& vcoord, double time) { return vcoord[0]; }); + [](const mfem::Vector& vcoord, double time) { return vcoord[0]; }); auto ycoord = std::function( - [](const mfem::Vector& vcoord, double time) { return vcoord[1]; }); + [](const mfem::Vector& vcoord, double time) { return vcoord[1]; }); auto XC = VAR(&spatial, Xbcs, "XCOORD", Glossary::Coordinate, 2, - AnalyticalFunctions(xcoord)); + AnalyticalFunctions(xcoord)); XC.set_additional_information("XCOORD"); auto YC = VAR(&spatial, Xbcs, "YCOORD", Glossary::Coordinate, 2, - AnalyticalFunctions(ycoord)); + AnalyticalFunctions(ycoord)); YC.set_additional_information("YCOORD"); auto coord = VARS(XC, YC); @@ -144,10 +136,11 @@ int main(int argc, char* argv[]) { const auto& frequency = 1; // Heat const std::string& calculation_path = "Problem1"; - auto p_pst = Parameters( - Parameter("main_folder_path", main_folder_path), - Parameter("calculation_path", calculation_path), Parameter("frequency", frequency), - Parameter("level_of_detail", level_of_detail), Parameter("enable_compute_energies", false)); + auto p_pst = Parameters(Parameter("main_folder_path", main_folder_path), + Parameter("calculation_path", calculation_path), + Parameter("frequency", frequency), + Parameter("level_of_detail", level_of_detail), + Parameter("enable_compute_energies", false)); auto pst = PST(&spatial, p_pst); // #################### @@ -155,26 +148,29 @@ int main(int argc, char* argv[]) { // #################### auto user_func_source_term = std::function( - [](const mfem::Vector& x, [[maybe_unused]] double time) { - const auto xx = x[0]; - const auto yy = x[1]; - const auto func = (1+2*M_PI*M_PI*time) * std::cos(M_PI*xx) * std::sin(M_PI*yy); - return func; - }); + [](const mfem::Vector& x, [[maybe_unused]] double time) { + const auto xx = x[0]; + const auto yy = x[1]; + const auto func = + (1 + 2 * M_PI * M_PI * time) * std::cos(M_PI * xx) * std::sin(M_PI * yy); + return func; + }); std::vector > src_term; src_term.emplace_back(AnalyticalFunctions(user_func_source_term)); - + // Heat - Coefficients coef_pb(density, heat_capacity, conductivity, neumann, dirichlet_left, dirichlet_right); + Coefficients coef_pb(density, heat_capacity, conductivity, neumann, dirichlet_left, + dirichlet_right); std::vector spatials{&spatial}; - OPE oper(spatials, {"Fourier"}, TimeScheme::EulerImplicit, "HeatTimeDerivative", src_term); + TransientOPE oper(spatials, {"Fourier"}, TimeScheme::EulerImplicit, "HeatTimeDerivative", + src_term); oper.overload_nl_solver( NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("print_level", 1), - Parameter("rel_tol", 1.e-10), Parameter("abs_tol", 1.e-12))); - PB Heat_pb("Heat", oper, heat_vars, {coef_pb}, pst, coord); + Parameter("rel_tol", 1.e-10), Parameter("abs_tol", 1.e-12))); + TransientPB Heat_pb("Heat", oper, heat_vars, {coef_pb}, pst, coord); // Coupling 1 auto cc = Coupling("Heat transfer", Heat_pb); diff --git a/tests/SimpleCoupling/2D/test1/main.cpp b/tests/SimpleCoupling/2D/test1/main.cpp index 7392c679..10617f10 100644 --- a/tests/SimpleCoupling/2D/test1/main.cpp +++ b/tests/SimpleCoupling/2D/test1/main.cpp @@ -35,22 +35,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - - // ALLEN-CAHN - using AC_OPE = TransientOperator; - using AC_PB = Problem; - - // Heat - using HEAT_OPE = TransientOperator; - using HEAT_PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### @@ -186,23 +171,23 @@ int main(int argc, char* argv[]) { // AllenCahn: Coefficients ac_coef(double_well, capillary, mobility, interpolation, grad_energy); std::vector spatials{&spatial}; - AC_OPE oper(spatials, {"AllenCahn", "MeltingTemperature"}, ac_params, TimeScheme::EulerImplicit, - "TimeDerivative"); + TransientOPE oper(spatials, {"AllenCahn", "MeltingTemperature"}, ac_params, + TimeScheme::EulerImplicit, "TimeDerivative"); - AC_PB allencahn_pb("AllenCahn", oper, ac_vars, {ac_coef}, pst, heat_vars); + TransientPB allencahn_pb("AllenCahn", oper, ac_vars, {ac_coef}, pst, heat_vars); // Heat: Coefficients heat_coef(density, heat_capacity, conductivity); std::vector > src_term; src_term.emplace_back(AnalyticalFunctions(src_func)); - HEAT_OPE oper_heat(spatials, {"Fourier"}, TimeScheme::EulerImplicit, "HeatTimeDerivative", - src_term); + TransientOPE oper_heat(spatials, {"Fourier"}, TimeScheme::EulerImplicit, "HeatTimeDerivative", + src_term); oper_heat.overload_nl_solver( NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("print_level", 1), Parameter("rel_tol", 1.e-11), Parameter("abs_tol", 1.e-11), Parameter("iter_max", 1000))); - HEAT_PB heat_pb("Heat", oper_heat, heat_vars, {heat_coef}, pst2); + TransientPB heat_pb("Heat", oper_heat, heat_vars, {heat_coef}, pst2); // Coupling 1 auto cc = Coupling("AC-Heat coupling", allencahn_pb, heat_pb); diff --git a/tests/SimpleCoupling/3D/test1/main.cpp b/tests/SimpleCoupling/3D/test1/main.cpp index 66a7a4f4..d6bd8d11 100644 --- a/tests/SimpleCoupling/3D/test1/main.cpp +++ b/tests/SimpleCoupling/3D/test1/main.cpp @@ -35,22 +35,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 3; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - - // ALLEN-CAHN - using AC_OPE = TransientOperator; - using AC_PB = Problem; - - // Heat - using HEAT_OPE = TransientOperator; - using HEAT_PB = Problem; + using namespace Sloth3D; // ########################################### // ########################################### @@ -72,11 +57,10 @@ int main(int argc, char* argv[]) { Boundary("FrontSurface", 3, "Neumann"), Boundary("BehindSurface", 2, "Neumann"), Boundary("ExternalSurface", 4, "Neumann")}; - auto Tboundaries = {Boundary("InterPelletPlane", 0, "Neumann"), - Boundary("MidPelletPlane", 1, "Neumann"), - Boundary("FrontSurface", 3, "Neumann"), - Boundary("ExternalSurface", 4, "Dirichlet", 1073.15), - Boundary("BehindSurface", 2, "Neumann")}; + auto Tboundaries = { + Boundary("InterPelletPlane", 0, "Neumann"), Boundary("MidPelletPlane", 1, "Neumann"), + Boundary("FrontSurface", 3, "Neumann"), Boundary("ExternalSurface", 4, "Dirichlet", 1073.15), + Boundary("BehindSurface", 2, "Neumann")}; auto bcs = BCS(&spatial, boundaries); auto Tbcs = BCS(&spatial, Tboundaries); @@ -206,26 +190,26 @@ int main(int argc, char* argv[]) { // AllenCahn: Coefficients ac_coef(double_well, capillary, mobility, interpolation, grad_energy); std::vector spatials{&spatial}; - AC_OPE oper(spatials, {"AllenCahn", "MeltingTemperature"}, ac_params, TimeScheme::EulerImplicit, - "TimeDerivative"); + TransientOPE oper(spatials, {"AllenCahn", "MeltingTemperature"}, ac_params, + TimeScheme::EulerImplicit, "TimeDerivative"); oper.overload_nl_solver(NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("print_level", 1), Parameter("abs_tol", 1.e-20))); - AC_PB allencahn_pb("AllenCahn", oper, ac_vars, {ac_coef}, pst, heat_vars); + TransientPB allencahn_pb("AllenCahn", oper, ac_vars, {ac_coef}, pst, heat_vars); // Heat: Coefficients heat_coef(density, heat_capacity, conductivity); std::vector > src_term; src_term.emplace_back(AnalyticalFunctions(src_func)); - HEAT_OPE oper_heat(spatials, {"Fourier"}, TimeScheme::EulerImplicit, "HeatTimeDerivative", - src_term); + TransientOPE oper_heat(spatials, {"Fourier"}, TimeScheme::EulerImplicit, "HeatTimeDerivative", + src_term); oper_heat.overload_nl_solver( NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("print_level", 1), Parameter("rel_tol", 1.e-11), Parameter("abs_tol", 1.e-11), Parameter("iter_max", 1000))); - HEAT_PB heat_pb("Heat", oper_heat, heat_vars, {heat_coef}, pst2); + TransientPB heat_pb("Heat", oper_heat, heat_vars, {heat_coef}, pst2); // Coupling 1 auto cc = Coupling("AC-Heat coupling", allencahn_pb, heat_pb); diff --git a/tests/Studies/multigrains/CMakeLists.txt b/tests/Studies/multigrains/CMakeLists.txt index ca943d33..04d2818a 100644 --- a/tests/Studies/multigrains/CMakeLists.txt +++ b/tests/Studies/multigrains/CMakeLists.txt @@ -1,3 +1,4 @@ add_subdirectory(test1) +add_subdirectory(test1_amr) # add_subdirectory(test2) # add_subdirectory(test3) \ No newline at end of file diff --git a/tests/Studies/multigrains/test1/main.cpp b/tests/Studies/multigrains/test1/main.cpp index 90e7d4b2..192ab60f 100644 --- a/tests/Studies/multigrains/test1/main.cpp +++ b/tests/Studies/multigrains/test1/main.cpp @@ -43,15 +43,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - ///////////////////////// - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -211,7 +203,7 @@ int main(int argc, char* argv[]) { &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial}; - OPE ope_ac_grains(spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); + TransientOPE ope_ac_grains(spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); ope_ac_grains.overload_nl_solver( NLSolverType::LBFGS, @@ -225,7 +217,7 @@ int main(int argc, char* argv[]) { coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains}; - PB problem_ac_grains(ope_ac_grains, var_grains, vcoeff, pst); + TransientPB problem_ac_grains(ope_ac_grains, var_grains, vcoeff, pst); // // Coupling 1 auto cc = Coupling("Multigrains ", problem_ac_grains); diff --git a/tests/Studies/multigrains/test1_amr/CMakeLists.txt b/tests/Studies/multigrains/test1_amr/CMakeLists.txt new file mode 100644 index 00000000..0275f2d6 --- /dev/null +++ b/tests/Studies/multigrains/test1_amr/CMakeLists.txt @@ -0,0 +1,7 @@ +execute_process(COMMAND python3 ${BUILD_SCRIPT_DIR}/GenerateCoefficient.py -r -f ${CMAKE_CURRENT_SOURCE_DIR}/coefficients.json + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) +create_test("AMRGrains2Dtest1" "AMRGrains2Dtest1" FALSE "2D EXE AC" 2) +configure_file(${CMAKE_SOURCE_DIR}/tests/Studies/multigrains/test1_amr/initial-grain.txt ${CMAKE_CURRENT_BINARY_DIR}/initial-grain.txt COPYONLY) + + +create_col_comparison("CompareGrainsAMR" "time_specialized.csv" "Saves/GrainsProblem/Default_NonLinear_problem29_time_specialized.csv" -1 relativeEpsilon 1e-12 FALSE "AMRGrains2Dtest1" "2D AC") diff --git a/tests/Studies/multigrains/test1_amr/coefficients.json b/tests/Studies/multigrains/test1_amr/coefficients.json new file mode 100644 index 00000000..cba96bf7 --- /dev/null +++ b/tests/Studies/multigrains/test1_amr/coefficients.json @@ -0,0 +1,26 @@ +[ + { + "expression":"-A*(y*y)/2.0 + B*(y*y*y*y)/4.0 + 2.0*y*y*Sum(x[i]*x[i], (i,1,29))", + "variables":"y", + "auxiliary_variables":"x(1..29)", + "constants":"(A:1.0),(B:1.0)", + "class_name":"ExplicitGrainGw", + "outputfile":"GrainsCoefficients" + }, + { + "expression":"y*y+Sum(x[i]*x[i], (i,1,29))", + "variables":"y", + "auxiliary_variables":"x(1..29)", + "class_name":"SumOfSquares", + "outputfile":"GrainsCoefficients" + }, + { + "expression":"kappa*dot(y,y)+kappa*(sdot(x(1..29)))", + "variables":"y", + "auxiliary_variables":"x(1..29)", + "constants":"(kappa:10.1)", + "class_name":"GrainGradient", + "outputfile":"GrainsCoefficients", + "gradient":true + } +] \ No newline at end of file diff --git a/tests/Studies/multigrains/test1_amr/initial-grain.txt b/tests/Studies/multigrains/test1_amr/initial-grain.txt new file mode 100644 index 00000000..cb930ffb --- /dev/null +++ b/tests/Studies/multigrains/test1_amr/initial-grain.txt @@ -0,0 +1,30 @@ +13.045985 1.771713 11.52 +25.233116 9.193766 3.14 +14.411219 9.725194 27.83 +16.844785 19.961991 8.66 +24.856815 21.959733 19.45 +31.390044 19.226115 6.77 +26.046993 22.676645 30.12 +0.881110 28.936551 14.91 +14.396955 3.805589 1.95 +26.729606 6.471943 22.48 +5.574485 14.372707 17.33 +21.433433 30.636771 9.28 +26.666664 16.265919 25.67 +20.160754 26.721110 13.04 +14.314613 24.393295 28.90 +20.381512 11.593469 4.61 +0.466386 17.343517 21.77 +10.180975 4.639691 2.84 +17.564542 5.999401 15.66 +12.767407 7.681223 31.02 +1.172955 18.193432 18.55 +29.528474 5.729763 7.93 +22.498485 23.040409 26.41 +0.994049 18.650410 10.73 +22.325683 29.115311 29.88 +30.934336 26.743345 12.11 +30.435884 16.202417 5.39 +6.223948 2.228632 23.74 +29.625461 12.522447 16.02 +13.061463 5.468962 0.88 \ No newline at end of file diff --git a/tests/Studies/multigrains/test1_amr/main.cpp b/tests/Studies/multigrains/test1_amr/main.cpp new file mode 100644 index 00000000..5507e59e --- /dev/null +++ b/tests/Studies/multigrains/test1_amr/main.cpp @@ -0,0 +1,275 @@ +/** + * @file main.cpp + * @author ci230846 (clement.introini@cea.fr) + * @brief Multigrains simulations from "Programming Phase-field modeling - Biner 2017" with AMR and + * partioned scheme + * @version 0.1 + * @date 2026-05-08 + * + * @copyright Copyright (c) 2026 + * + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "./GrainsCoefficients.hpp" +#include "Sloth/sloth.hpp" +#include "Sloth/tests.hpp" +#include "voro++.hh" + +using namespace voro; + +double distance(double x1, double y1, double x2, double y2, double L) { + double dx = std::abs(x2 - x1); + double dy = std::abs(y2 - y1); + // periodicity + dx = std::min(dx, L - dx); + dy = std::min(dy, L - dy); + + return std::sqrt(dx * dx + dy * dy); +} + +///////////////////////// + +///--------------- +/// Main program +///--------------- +int main(int argc, char* argv[]) { + using namespace Sloth2D; + setVerbosity(Verbosity::Normal); + //--------------------------------------- + // Initialize MPI + //--------------------------------------- + mfem::Mpi::Init(argc, argv); + mfem::Hypre::Init(); + // + //--------------------------------------- + // Profiling start + Profiling::getInstance().enable(); + //--------------------------------------- + + constexpr int ngrains = 30; + + // ########################################### + // ########################################### + // Polycristaline // + // ########################################### + // ########################################### + const double L = 32.; + const double SUBDIV = 8; + + const std::string& filename = "initial-grain.txt"; + std::ifstream inputFile(filename); + + if (!inputFile) { + std::cerr << "Error while opening " << filename << " for reading." << std::endl; + return 1; + } + + // Vector of tuples to store the data + std::vector> data; + std::vector dmin; + + // Read and parse the file + std::string line; + while (std::getline(inputFile, line)) { + std::istringstream iss(line); + double col1, col2; + if (!(iss >> col1 >> col2)) { + std::cerr << "Error parsing line: " << line << std::endl; + continue; + } + data.emplace_back(col1, col2); + } + + // Close the file + inputFile.close(); + + container con(0., L, // x bounds + 0., L, // y bounds + -0.5, 0.5, // z bounds (set to zero for 2D case) + SUBDIV, SUBDIV, 1, // Number of grid subdivisions + true, true, false, // No periodic boundaries + SUBDIV); + + for (int i = 0; i < data.size(); ++i) { + con.put(i, std::get<0>(data[i]), std::get<1>(data[i]), 0.0); + } + + std::vector> vect_user_func; + for (int id_grain = 0; id_grain < static_cast(data.size()); ++id_grain) { + auto user_func = std::function( + [id_grain, &con, L](const mfem::Vector& x, [[maybe_unused]] double time) { + int closest_particle_id = -1; + double min_distance = std::numeric_limits::max(); + // Loop through all particles to find the one closest to the grid point + c_loop_all vl(con); + double xx, y, z; + if (vl.start()) { + do { + // Get the current particle's position + vl.pos(xx, y, z); + // Calculate the distance from the grid point to the current particle + double dist = distance(x[0], x[1], xx, y, L); + if (dist < min_distance) { + min_distance = dist; + // Get the particle ID (Voronoi cell index) + closest_particle_id = vl.pid(); + } + } while (vl.inc()); + } + const auto func = (closest_particle_id == id_grain) ? 1. : 0.; + return func; + }); + vect_user_func.emplace_back(user_func); + } + + // ########################################### + // ########################################### + // Spatial Discretization // + // ########################################### + // ########################################### + int refinement_level = 0; + int NN = 8; + // Create translation vectors defining the periodicity + mfem::Vector x_translation({L, 0.0}); + mfem::Vector y_translation({0.0, L}); + std::vector translations = {x_translation, y_translation}; + + SPAS spatials = + setPeriodicSpatialDiscretization(30, "InlineSquareWithQuadrangles", 1, refinement_level, + std::make_tuple(NN, NN, L, L), translations, true); + + // ############################## + // Boundary conditions // + // ############################## + auto boundaries = {Boundary("lower", 0, "Periodic"), Boundary("right", 1, "Periodic"), + Boundary("upper", 2, "Periodic"), Boundary("left", 3, "Periodic")}; + auto bcs = setBoundaryConditions(ngrains, spatials, boundaries); + + // ########################################### + // ########################################### + // Variables + // ########################################### + // ########################################### + std::vector vars_grains; + vars_grains.reserve(ngrains); + for (int i = 0; i < ngrains; ++i) { + auto vv = VAR(spatials[i], bcs[i], "phi_" + std::to_string(i), Glossary::PhaseField, 2, + AnalyticalFunctions(vect_user_func[i])); + vv.set_additional_information("phi"); + vars_grains.emplace_back(vv); + } + + // ########################################### + // ########################################### + // Post-processing + // ########################################### + // ########################################### + const std::string& main_folder_path = "Saves"; + const auto& level_of_detail = 1; + const auto& frequency = 2; + const bool enable_save_specialized_at_iter = true; + std::string calculation_path = "GrainsProblem"; + auto p_pst = + Parameters(Parameter("main_folder_path", main_folder_path), + Parameter("calculation_path", calculation_path), Parameter("frequency", frequency), + Parameter("level_of_detail", level_of_detail), + Parameter("enable_save_specialized_at_iter", enable_save_specialized_at_iter)); + auto pst_vec = PST(spatials[0], p_pst); + + // ########################################### + // ########################################### + // Coefficients + // ########################################### + // ########################################### + const double& mob(5.); + const double& lambda(0.1); + Coefficient grad_energy_i(Glossary::GradEnergy, Scheme::Implicit, GrainGradient()); + Coefficient double_well_exp_i(Glossary::FreeEnergy, Scheme::Implicit, ExplicitGrainGw()); + Coefficient capillary_i(Glossary::Capillary, lambda); + Coefficient mobility_i(Glossary::Mobility, mob); + Coefficient squares(Glossary::PhaseField, Scheme::Implicit, SumOfSquares()); + squares.set_name("Squares"); + std::vector coeffs_i{ + Coefficients(double_well_exp_i, capillary_i, mobility_i, grad_energy_i)}; + + // ########################################### + // ########################################### + // Problems + // ########################################### + // ########################################### + int level_amr = 3; // 4; + auto amr_params = + Parameters(Parameter("max_elem_error", 1.e-3), Parameter("amr_max_level", level_amr), + Parameter("nc_limit", 0), Parameter("max_preref_cycles", level_amr)); + auto amr_coef = mfem::ConstantCoefficient(1.0); + + std::vector ac_pbs; + ac_pbs.reserve(ngrains); + + for (int i = 0; i < ngrains; ++i) { + // Operator + TransientOPE ope_i({spatials[i]}, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); + + // Auxiliary variables + std::vector aux_ptrs; + aux_ptrs.reserve(ngrains - 1); + for (int j = 0; j < ngrains; ++j) { + if (j != i) aux_ptrs.push_back(&vars_grains[j]); + } + ac_pbs.emplace_back(ope_i, vars_grains[i], coeffs_i, pst_vec); + ac_pbs.back().set_auxvariables(std::move(aux_ptrs)); + + // AMR + auto* amr_integ_i = new mfem::DiffusionIntegrator(amr_coef); + auto* estimator_i = new SlothErrorEstimators(ErrorEstimatorType::KELLY, amr_integ_i); + auto* amr_i = + new MultiVariableMaxAMR(*spatials[i]->get_mesh(), spatials[i]->is_nc_simplices()); + amr_i->SetCriteria(estimator_i, amr_params); + ac_pbs.back().set_amr(amr_i); + // + } + ac_pbs.back().set_vtk_coefficients({squares}); + + // ########################################### + // ########################################### + // Coupling // + // ########################################### + // ########################################### + auto cc = setCoupling("Multigrains", ac_pbs); + + // ########################################### + // ########################################### + // Time-integration // + // ########################################### + // ########################################### + const double t_initial = 0.0; + const auto& t_final = 0.2; // 50.0; + const auto& dt = 1.e-1; + auto time_params = + Parameters(Parameter("initial_time", t_initial), Parameter("vtk_unified", true), + Parameter("final_time", t_final), Parameter("time_step", dt)); + auto time = TimeDiscretization(time_params, cc); + + time.solve(); + + //--------------------------------------- + // Profiling stop + //--------------------------------------- + Profiling::getInstance().print(); + //--------------------------------------- + // Finalize MPI + //--------------------------------------- + MPI_Finalize(); + + deleteSpatialDiscretization(spatials); + //--------------------------------------- + return 0; +} diff --git a/tests/Studies/multigrains/test1_amr/ref/time_specialized.csv b/tests/Studies/multigrains/test1_amr/ref/time_specialized.csv new file mode 100644 index 00000000..06ccb652 --- /dev/null +++ b/tests/Studies/multigrains/test1_amr/ref/time_specialized.csv @@ -0,0 +1,3 @@ +Iter[-],Dt[s],Time[s],Density[J.m-3],Sigma[J.m-3] +1,0.1,0.1,8012.54,16028.5 +2,0.1,0.2,6340.03,12683.2 diff --git a/tests/Studies/multigrains/test2/main.cpp b/tests/Studies/multigrains/test2/main.cpp index cbbca76a..762c4a16 100644 --- a/tests/Studies/multigrains/test2/main.cpp +++ b/tests/Studies/multigrains/test2/main.cpp @@ -43,15 +43,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 3; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - ///////////////////////// - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth3D; // ########################################### // ########################################### // Spatial Discretization // @@ -212,7 +204,7 @@ int main(int argc, char* argv[]) { &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial}; - OPE ope_ac_grains(spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); + TransientOPE ope_ac_grains(spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); ope_ac_grains.overload_nl_solver( NLSolverType::LBFGS, @@ -226,7 +218,7 @@ int main(int argc, char* argv[]) { coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains}; - PB problem_ac_grains(ope_ac_grains, var_grains, vcoeff, pst); + TransientPB problem_ac_grains(ope_ac_grains, var_grains, vcoeff, pst); // // Coupling 1 auto cc = Coupling("Multigrains ", problem_ac_grains); diff --git a/tests/Studies/multigrains/test3/main.cpp b/tests/Studies/multigrains/test3/main.cpp index 4d9e9b82..551215fe 100644 --- a/tests/Studies/multigrains/test3/main.cpp +++ b/tests/Studies/multigrains/test3/main.cpp @@ -43,15 +43,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - ///////////////////////// - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -243,7 +235,7 @@ int main(int argc, char* argv[]) { &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial}; - OPE ope_ac_grains(spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); + TransientOPE ope_ac_grains(spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); ope_ac_grains.overload_nl_solver( NLSolverType::LBFGS, @@ -272,7 +264,7 @@ int main(int argc, char* argv[]) { coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains, coef_ac_grains}; - PB problem_ac_grains(ope_ac_grains, var_grains, vcoeff, pst); + TransientPB problem_ac_grains(ope_ac_grains, var_grains, vcoeff, pst); // // Coupling 1 auto cc = Coupling("Multigrains ", problem_ac_grains); diff --git a/tests/Studies/nucleation/test1/main.cpp b/tests/Studies/nucleation/test1/main.cpp index 84a72ed3..b5bb891a 100644 --- a/tests/Studies/nucleation/test1/main.cpp +++ b/tests/Studies/nucleation/test1/main.cpp @@ -36,16 +36,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - using BCS = Test::BCS; - ///////////////////////// - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -151,8 +142,8 @@ int main(int argc, char* argv[]) { auto ac_param = Parameters(Parameter("melting_factor", DeltaF)); // Problem 1: std::vector spatials{&spatial}; - OPE oper(spatials, {"AllenCahn", "MeltingConstant"}, ac_param, TimeScheme::EulerImplicit, - "TimeDerivative"); + TransientOPE oper(spatials, {"AllenCahn", "MeltingConstant"}, ac_param, + TimeScheme::EulerImplicit, "TimeDerivative"); oper.overload_nl_solver(NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("print_level", 1), Parameter("rel_tol", 1.e-10), @@ -164,7 +155,7 @@ int main(int argc, char* argv[]) { auto pst = PST(&spatial, p_pst); Coefficients coef_pb1(double_well, capillary, mobility, grad_energy, interpolation); - PB problem1(oper, vars, {coef_pb1}, pst); + TransientPB problem1(oper, vars, {coef_pb1}, pst); // Coupling 1 auto cc = Coupling("AllenCahn Coupling", problem1); diff --git a/tests/Studies/ostwald/test1/main.cpp b/tests/Studies/ostwald/test1/main.cpp index 420291ef..63b660b7 100644 --- a/tests/Studies/ostwald/test1/main.cpp +++ b/tests/Studies/ostwald/test1/main.cpp @@ -79,15 +79,7 @@ int main(int argc, char* argv[]) { common_parameters(args, p); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - ///////////////////////// - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -364,17 +356,18 @@ int main(int argc, char* argv[]) { // CahnHilliard std::vector spatials{&spatial, &spatial}; - OPE ch_oper(spatials, {"CahnHilliard"}, TimeScheme::EulerImplicit, "SplitTimeDerivative"); + TransientOPE ch_oper(spatials, {"CahnHilliard"}, TimeScheme::EulerImplicit, + "SplitTimeDerivative"); ch_oper.overload_nl_solver( NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("print_level", -1), Parameter("rel_tol", 1.e-10), Parameter("abs_tol", 1.e-14))); auto ch_pst = PST(&spatial, ch_p_pst); - PB ch_pb("CahnHilliard", ch_oper, ch_vars, {ch_coef, ch_coef}, ch_pst, ac_vars); + TransientPB ch_pb("CahnHilliard", ch_oper, ch_vars, {ch_coef, ch_coef}, ch_pst, ac_vars); std::vector ac_spatials{&spatial, &spatial, &spatial, &spatial}; - OPE ac_oper(ac_spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); + TransientOPE ac_oper(ac_spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); ac_oper.overload_nl_solver( NLSolverType::NEWTON, Parameters(Parameter("description", "LBFGS solver "), Parameter("print_level", -1), @@ -384,7 +377,8 @@ int main(int argc, char* argv[]) { ac_oper.overload_solver(solver); ac_oper.overload_preconditioner(precond); auto ac_pst = PST(&spatial, ac_p_pst); - PB ac_pb("AllenCahn", ac_oper, ac_vars, {ac_coef, ac_coef, ac_coef, ac_coef}, ac_pst, ch_vars); + TransientPB ac_pb("AllenCahn", ac_oper, ac_vars, {ac_coef, ac_coef, ac_coef, ac_coef}, ac_pst, + ch_vars); // Coupling 1 auto cc = Coupling("CahnHilliard/AllenCahn Coupling", ac_pb, ch_pb); diff --git a/tests/Studies/sintering/test1/main.cpp b/tests/Studies/sintering/test1/main.cpp index 918a5f31..53acf6e2 100644 --- a/tests/Studies/sintering/test1/main.cpp +++ b/tests/Studies/sintering/test1/main.cpp @@ -37,15 +37,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - ///////////////////////// - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -216,7 +208,8 @@ int main(int argc, char* argv[]) { // CahnHilliard std::vector spatials{&spatial, &spatial}; - OPE ch_oper(spatials, {"CahnHilliard"}, TimeScheme::EulerImplicit, "SplitTimeDerivative"); + TransientOPE ch_oper(spatials, {"CahnHilliard"}, TimeScheme::EulerImplicit, + "SplitTimeDerivative"); ch_oper.overload_nl_solver( NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("print_level", 1), @@ -227,12 +220,12 @@ int main(int argc, char* argv[]) { ch_oper.overload_preconditioner(ch_precond); auto ch_pst = PST(&spatial, ch_p_pst); - PB ch_pb("CahnHilliard", ch_oper, ch_vars, {ch_coef, ch_coef}, ch_pst, ac_vars); + TransientPB ch_pb("CahnHilliard", ch_oper, ch_vars, {ch_coef, ch_coef}, ch_pst, ac_vars); // // // std::vector ac_spatials{&spatial, &spatial}; - OPE ac_oper(ac_spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); + TransientOPE ac_oper(ac_spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); ac_oper.overload_nl_solver( NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("print_level", 1), @@ -242,7 +235,7 @@ int main(int argc, char* argv[]) { ac_oper.overload_solver(solver); ac_oper.overload_preconditioner(precond); auto ac_pst = PST(&spatial, ac_p_pst); - PB ac_pb("AllenCahn", ac_oper, ac_vars, {ac_coef, ac_coef}, ac_pst, ch_vars); + TransientPB ac_pb("AllenCahn", ac_oper, ac_vars, {ac_coef, ac_coef}, ac_pst, ch_vars); // Coupling 1 auto cc = Coupling("CahnHilliard/AllenCahn Coupling", ac_pb, ch_pb); diff --git a/tests/Studies/sintering/test1_amr/main.cpp b/tests/Studies/sintering/test1_amr/main.cpp index c54e0323..5623efe9 100644 --- a/tests/Studies/sintering/test1_amr/main.cpp +++ b/tests/Studies/sintering/test1_amr/main.cpp @@ -37,15 +37,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - ///////////////////////// - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -222,7 +214,8 @@ int main(int argc, char* argv[]) { // CahnHilliard std::vector spatials{&spatial_c, &spatial_mu}; - OPE ch_oper(spatials, {"CahnHilliard"}, TimeScheme::EulerImplicit, "SplitTimeDerivative"); + TransientOPE ch_oper(spatials, {"CahnHilliard"}, TimeScheme::EulerImplicit, + "SplitTimeDerivative"); ch_oper.overload_nl_solver( NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("print_level", 1), @@ -233,10 +226,10 @@ int main(int argc, char* argv[]) { ch_oper.overload_preconditioner(ch_precond); auto ch_pst = PST(&spatial_c, ch_p_pst); - PB ch_pb("CahnHilliard", ch_oper, ch_vars, {ch_coef, ch_coef}, ch_pst, ac_vars); + TransientPB ch_pb("CahnHilliard", ch_oper, ch_vars, {ch_coef, ch_coef}, ch_pst, ac_vars); std::vector ac_spatials{&spatial_eta1, &spatial_eta2}; - OPE ac_oper(ac_spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); + TransientOPE ac_oper(ac_spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); ac_oper.overload_nl_solver( NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("print_level", 1), @@ -246,7 +239,7 @@ int main(int argc, char* argv[]) { ac_oper.overload_solver(solver); ac_oper.overload_preconditioner(precond); auto ac_pst = PST(&spatial_eta1, ac_p_pst); - PB ac_pb("AllenCahn", ac_oper, ac_vars, {ac_coef, ac_coef}, ac_pst, ch_vars); + TransientPB ac_pb("AllenCahn", ac_oper, ac_vars, {ac_coef, ac_coef}, ac_pst, ch_vars); // AMR ///////////////////////////////// /// AC diff --git a/tests/Studies/sintering/test2/main.cpp b/tests/Studies/sintering/test2/main.cpp index b02b636e..f241cfb9 100644 --- a/tests/Studies/sintering/test2/main.cpp +++ b/tests/Studies/sintering/test2/main.cpp @@ -37,15 +37,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 2; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - ///////////////////////// - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -593,7 +585,8 @@ int main(int argc, char* argv[]) { // CahnHilliard std::vector spatials{&spatial, &spatial}; - OPE ch_oper(spatials, {"CahnHilliard"}, TimeScheme::EulerImplicit, "SplitTimeDerivative"); + TransientOPE ch_oper(spatials, {"CahnHilliard"}, TimeScheme::EulerImplicit, + "SplitTimeDerivative"); ch_oper.overload_nl_solver( NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("print_level", 1), @@ -604,13 +597,13 @@ int main(int argc, char* argv[]) { ch_oper.overload_preconditioner(ch_precond); auto ch_pst = PST(&spatial, ch_p_pst); - PB ch_pb("CahnHilliard", ch_oper, ch_vars, {ch_coef, ch_coef}, ch_pst, ac_vars); + TransientPB ch_pb("CahnHilliard", ch_oper, ch_vars, {ch_coef, ch_coef}, ch_pst, ac_vars); // // // std::vector ac_spatials{&spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial}; - OPE ac_oper(ac_spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); + TransientOPE ac_oper(ac_spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); ac_oper.overload_nl_solver( NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("print_level", 1), @@ -620,9 +613,10 @@ int main(int argc, char* argv[]) { ac_oper.overload_solver(solver); ac_oper.overload_preconditioner(precond); auto ac_pst = PST(&spatial, ac_p_pst); - PB ac_pb("AllenCahn", ac_oper, ac_vars, - {ac_coef, ac_coef, ac_coef, ac_coef, ac_coef, ac_coef, ac_coef, ac_coef, ac_coef}, - ac_pst, ch_vars); + TransientPB ac_pb( + "AllenCahn", ac_oper, ac_vars, + {ac_coef, ac_coef, ac_coef, ac_coef, ac_coef, ac_coef, ac_coef, ac_coef, ac_coef}, ac_pst, + ch_vars); // Coupling 1 auto cc = Coupling("CahnHilliard/AllenCahn Coupling", ac_pb, ch_pb); diff --git a/tests/Studies/sintering/test3/main.cpp b/tests/Studies/sintering/test3/main.cpp index 0cc049bb..2c8f7952 100644 --- a/tests/Studies/sintering/test3/main.cpp +++ b/tests/Studies/sintering/test3/main.cpp @@ -37,15 +37,7 @@ int main(int argc, char* argv[]) { Profiling::getInstance().enable(); //--------------------------------------- ///////////////////////// - const int DIM = 3; - using FECollection = Test::FECollection; - using VARS = Test::VARS; - using VAR = Test::VAR; - using PST = Test::PST; - using SPA = Test::SPA; - ///////////////////////// - using OPE = TransientOperator; - using PB = Problem; + using namespace Sloth2D; // ########################################### // ########################################### // Spatial Discretization // @@ -625,7 +617,8 @@ int main(int argc, char* argv[]) { // CahnHilliard std::vector spatials{&spatial, &spatial}; - OPE ch_oper(spatials, {"CahnHilliard"}, TimeScheme::EulerImplicit, "SplitTimeDerivative"); + TransientOPE ch_oper(spatials, {"CahnHilliard"}, TimeScheme::EulerImplicit, + "SplitTimeDerivative"); ch_oper.overload_nl_solver( NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("print_level", -1), @@ -636,13 +629,13 @@ int main(int argc, char* argv[]) { ch_oper.overload_preconditioner(ch_precond); auto ch_pst = PST(&spatial, ch_p_pst); - PB ch_pb("CahnHilliard", ch_oper, ch_vars, {ch_coef, ch_coef}, ch_pst, ac_vars); + TransientPB ch_pb("CahnHilliard", ch_oper, ch_vars, {ch_coef, ch_coef}, ch_pst, ac_vars); // // // std::vector ac_spatials{&spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial, &spatial}; - OPE ac_oper(ac_spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); + TransientOPE ac_oper(ac_spatials, {"AllenCahn"}, TimeScheme::EulerImplicit, "TimeDerivative"); ac_oper.overload_nl_solver( NLSolverType::NEWTON, Parameters(Parameter("description", "Newton solver "), Parameter("print_level", -1), @@ -652,9 +645,10 @@ int main(int argc, char* argv[]) { ac_oper.overload_solver(solver); ac_oper.overload_preconditioner(precond); auto ac_pst = PST(&spatial, ac_p_pst); - PB ac_pb("AllenCahn", ac_oper, ac_vars, - {ac_coef, ac_coef, ac_coef, ac_coef, ac_coef, ac_coef, ac_coef, ac_coef, ac_coef}, - ac_pst, ch_vars); + TransientPB ac_pb( + "AllenCahn", ac_oper, ac_vars, + {ac_coef, ac_coef, ac_coef, ac_coef, ac_coef, ac_coef, ac_coef, ac_coef, ac_coef}, ac_pst, + ch_vars); // Coupling 1 auto cc = Coupling("CahnHilliard/AllenCahn Coupling", ac_pb, ch_pb);