forked from aurora-multiphysics/platypus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request aurora-multiphysics#5 from aurora-multiphysics/Edw…
…ardPalmer99/remove-hephaestus-dependency Remove Hephaestus Dependency
- Loading branch information
Showing
29 changed files
with
1,113 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#pragma once | ||
#include "essential_bcs.h" | ||
#include "integrated_bcs.h" | ||
#include "named_fields_map.h" | ||
#include "robin_bcs.h" | ||
|
||
namespace platypus | ||
{ | ||
|
||
class BCMap : public platypus::NamedFieldsMap<platypus::BoundaryCondition> | ||
{ | ||
public: | ||
mfem::Array<int> GetEssentialBdrMarkers(const std::string & name_, mfem::Mesh * mesh_); | ||
|
||
void ApplyEssentialBCs(const std::string & name_, | ||
mfem::Array<int> & ess_tdof_list, | ||
mfem::GridFunction & gridfunc, | ||
mfem::Mesh * mesh_); | ||
|
||
void ApplyEssentialBCs(const std::string & name_, | ||
mfem::Array<int> & ess_tdof_list, | ||
mfem::ParComplexGridFunction & gridfunc, | ||
mfem::Mesh * mesh_); | ||
|
||
void ApplyIntegratedBCs(const std::string & name_, mfem::LinearForm & lf, mfem::Mesh * mesh_); | ||
|
||
void ApplyIntegratedBCs(const std::string & name_, | ||
mfem::ParComplexLinearForm & clf, | ||
mfem::Mesh * mesh_); | ||
|
||
void ApplyIntegratedBCs(const std::string & name_, | ||
mfem::ParSesquilinearForm & clf, | ||
mfem::Mesh * mesh_); | ||
}; | ||
|
||
} // namespace platypus |
141 changes: 141 additions & 0 deletions
141
framework/include/mfem/equation_systems/equation_system.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
#pragma once | ||
#include "../common/pfem_extras.hpp" | ||
#include "inputs.h" | ||
#include "kernel_base.h" | ||
#include "named_fields_map.h" | ||
|
||
namespace platypus | ||
{ | ||
|
||
/* | ||
Class to store weak form components (bilinear and linear forms, and optionally | ||
mixed and nonlinear forms) and build methods | ||
*/ | ||
class EquationSystem : public mfem::Operator | ||
{ | ||
public: | ||
using ParBilinearFormKernel = platypus::Kernel<mfem::ParBilinearForm>; | ||
using ParLinearFormKernel = platypus::Kernel<mfem::ParLinearForm>; | ||
using ParNonlinearFormKernel = platypus::Kernel<mfem::ParNonlinearForm>; | ||
using ParMixedBilinearFormKernel = platypus::Kernel<mfem::ParMixedBilinearForm>; | ||
|
||
EquationSystem() = default; | ||
~EquationSystem() override; | ||
|
||
// Test variables are associated with LinearForms, | ||
// whereas trial variables are associated with gridfunctions. | ||
|
||
// Names of all variables corresponding to gridfunctions. This may differ | ||
// from test_var_names when time derivatives are present. | ||
std::vector<std::string> _trial_var_names; | ||
// Names of all test variables corresponding to linear forms in this equation | ||
// system | ||
std::vector<std::string> _test_var_names; | ||
std::vector<mfem::ParFiniteElementSpace *> _test_pfespaces; | ||
|
||
// Components of weak form. // Named according to test variable | ||
platypus::NamedFieldsMap<mfem::ParBilinearForm> _blfs; | ||
platypus::NamedFieldsMap<mfem::ParLinearForm> _lfs; | ||
platypus::NamedFieldsMap<mfem::ParNonlinearForm> _nlfs; | ||
platypus::NamedFieldsMap<platypus::NamedFieldsMap<mfem::ParMixedBilinearForm>> | ||
_mblfs; // named according to trial variable | ||
|
||
// add test variable to EquationSystem; | ||
virtual void AddTestVariableNameIfMissing(const std::string & test_var_name); | ||
virtual void AddTrialVariableNameIfMissing(const std::string & trial_var_name); | ||
|
||
// Add kernels. | ||
void AddKernel(const std::string & test_var_name, | ||
std::shared_ptr<ParBilinearFormKernel> blf_kernel); | ||
|
||
void AddKernel(const std::string & test_var_name, std::shared_ptr<ParLinearFormKernel> lf_kernel); | ||
|
||
void AddKernel(const std::string & test_var_name, | ||
std::shared_ptr<ParNonlinearFormKernel> nlf_kernel); | ||
|
||
void AddKernel(const std::string & trial_var_name, | ||
const std::string & test_var_name, | ||
std::shared_ptr<ParMixedBilinearFormKernel> mblf_kernel); | ||
|
||
virtual void ApplyBoundaryConditions(platypus::BCMap & bc_map); | ||
|
||
// override to add kernels | ||
virtual void AddKernels() {} | ||
|
||
// Build forms | ||
virtual void Init(platypus::GridFunctions & gridfunctions, | ||
const platypus::FESpaces & fespaces, | ||
platypus::BCMap & bc_map, | ||
platypus::Coefficients & coefficients); | ||
virtual void BuildLinearForms(platypus::BCMap & bc_map); | ||
virtual void BuildBilinearForms(); | ||
virtual void BuildMixedBilinearForms(); | ||
virtual void BuildEquationSystem(platypus::BCMap & bc_map); | ||
|
||
// Form linear system, with essential boundary conditions accounted for | ||
virtual void FormLinearSystem(mfem::OperatorHandle & op, | ||
mfem::BlockVector & trueX, | ||
mfem::BlockVector & trueRHS); | ||
|
||
// Build linear system, with essential boundary conditions accounted for | ||
virtual void BuildJacobian(mfem::BlockVector & trueX, mfem::BlockVector & trueRHS); | ||
|
||
/// Compute residual y = Mu | ||
void Mult(const mfem::Vector & u, mfem::Vector & residual) const override; | ||
|
||
/// Compute J = M + grad_H(u) | ||
mfem::Operator & GetGradient(const mfem::Vector & u) const override; | ||
|
||
// Update variable from solution vector after solve | ||
virtual void RecoverFEMSolution(mfem::BlockVector & trueX, | ||
platypus::GridFunctions & gridfunctions); | ||
|
||
std::vector<mfem::Array<int>> _ess_tdof_lists; | ||
|
||
protected: | ||
bool VectorContainsName(const std::vector<std::string> & the_vector, | ||
const std::string & name) const; | ||
|
||
// gridfunctions for setting Dirichlet BCs | ||
std::vector<std::unique_ptr<mfem::ParGridFunction>> _xs; | ||
|
||
mfem::Array2D<mfem::HypreParMatrix *> _h_blocks; | ||
|
||
// Arrays to store kernels to act on each component of weak form. Named | ||
// according to test variable | ||
platypus::NamedFieldsMap<std::vector<std::shared_ptr<ParBilinearFormKernel>>> _blf_kernels_map; | ||
|
||
platypus::NamedFieldsMap<std::vector<std::shared_ptr<ParLinearFormKernel>>> _lf_kernels_map; | ||
|
||
platypus::NamedFieldsMap<std::vector<std::shared_ptr<ParNonlinearFormKernel>>> _nlf_kernels_map; | ||
|
||
platypus::NamedFieldsMap< | ||
platypus::NamedFieldsMap<std::vector<std::shared_ptr<ParMixedBilinearFormKernel>>>> | ||
_mblf_kernels_map_map; | ||
|
||
mutable mfem::OperatorHandle _jacobian; | ||
}; | ||
|
||
/* | ||
Class to store weak form components for time dependent PDEs | ||
*/ | ||
class TimeDependentEquationSystem : public EquationSystem | ||
{ | ||
public: | ||
TimeDependentEquationSystem(); | ||
~TimeDependentEquationSystem() override = default; | ||
|
||
static std::string GetTimeDerivativeName(std::string name) | ||
{ | ||
return std::string("d") + name + std::string("_dt"); | ||
} | ||
|
||
void AddTrialVariableNameIfMissing(const std::string & trial_var_name) override; | ||
|
||
virtual void SetTimeStep(double dt); | ||
virtual void UpdateEquationSystem(platypus::BCMap & bc_map); | ||
mfem::ConstantCoefficient _dt_coef; // Coefficient for timestep scaling | ||
std::vector<std::string> _trial_var_time_derivative_names; | ||
}; | ||
|
||
} // namespace platypus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
framework/include/mfem/problem_operators/equation_system_problem_operator.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
#include "problem_operator.h" | ||
#include "problem_operator_interface.h" | ||
#include "equation_system_interface.h" | ||
|
||
namespace platypus | ||
{ | ||
/// Steady-state problem operator with an equation system. | ||
class EquationSystemProblemOperator : public ProblemOperator, public EquationSystemInterface | ||
{ | ||
public: | ||
EquationSystemProblemOperator(platypus::Problem &) = delete; | ||
|
||
EquationSystemProblemOperator(platypus::Problem & problem, | ||
std::unique_ptr<platypus::EquationSystem> equation_system) | ||
: ProblemOperator(problem), _equation_system(std::move(equation_system)) | ||
{ | ||
} | ||
|
||
void SetGridFunctions() override; | ||
void Init(mfem::Vector & X) override; | ||
|
||
~EquationSystemProblemOperator() override = default; | ||
|
||
[[nodiscard]] platypus::EquationSystem * GetEquationSystem() const override | ||
{ | ||
if (!_equation_system) | ||
{ | ||
MFEM_ABORT("No equation system has been added to ProblemOperator."); | ||
} | ||
|
||
return _equation_system.get(); | ||
} | ||
|
||
private: | ||
std::unique_ptr<platypus::EquationSystem> _equation_system{nullptr}; | ||
}; | ||
|
||
} // namespace platypus |
Oops, something went wrong.