-
Notifications
You must be signed in to change notification settings - Fork 7
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 #26 from aurora-multiphysics/alexanderianblair/MFE…
…MSolversAndPreconditioners Enable user specification of solvers and preconditioners
- Loading branch information
Showing
31 changed files
with
4,205 additions
and
3,725 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
|
||
#include "MooseObjectAction.h" | ||
|
||
/** | ||
* This class allows us to have a section of the input file like the following | ||
* specifying the solver to use and the solve options. | ||
* | ||
* [Preconditioner] | ||
* [] | ||
*/ | ||
class AddMFEMPreconditionerAction : public MooseObjectAction | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
AddMFEMPreconditionerAction(const InputParameters & parameters); | ||
|
||
void act() override; | ||
}; |
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,20 @@ | ||
#pragma once | ||
|
||
#include "MooseObjectAction.h" | ||
|
||
/** | ||
* This class allows us to have a section of the input file like the following | ||
* specifying the solver to use and the solve options. | ||
* | ||
* [Solver] | ||
* [] | ||
*/ | ||
class AddMFEMSolverAction : public MooseObjectAction | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
AddMFEMSolverAction(const InputParameters & parameters); | ||
|
||
void act() override; | ||
}; |
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,24 @@ | ||
#pragma once | ||
#include "MFEMSolverBase.h" | ||
#include "MFEMFESpace.h" | ||
|
||
/** | ||
* Wrapper for mfem::HypreAMS solver. | ||
*/ | ||
class MFEMHypreAMS : public MFEMSolverBase | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
MFEMHypreAMS(const InputParameters &); | ||
|
||
/// Returns a shared pointer to the instance of the Solver derived-class. | ||
std::shared_ptr<mfem::Solver> getSolver() const override { return _preconditioner; } | ||
|
||
protected: | ||
void constructSolver(const InputParameters & parameters) override; | ||
|
||
private: | ||
const MFEMFESpace & _mfem_fespace; | ||
std::shared_ptr<mfem::HypreAMS> _preconditioner{nullptr}; | ||
}; |
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,24 @@ | ||
#pragma once | ||
#include "MFEMSolverBase.h" | ||
#include "mfem.hpp" | ||
#include <memory> | ||
|
||
/** | ||
* Wrapper for mfem::HypreBoomerAMG solver. | ||
*/ | ||
class MFEMHypreBoomerAMG : public MFEMSolverBase | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
MFEMHypreBoomerAMG(const InputParameters &); | ||
|
||
/// Returns a shared pointer to the instance of the Solver derived-class. | ||
std::shared_ptr<mfem::Solver> getSolver() const override { return _solver; } | ||
|
||
protected: | ||
void constructSolver(const InputParameters & parameters) override; | ||
|
||
private: | ||
std::shared_ptr<mfem::HypreBoomerAMG> _solver{nullptr}; | ||
}; |
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,24 @@ | ||
#pragma once | ||
#include "MFEMSolverBase.h" | ||
#include "mfem.hpp" | ||
#include <memory> | ||
|
||
/** | ||
* Wrapper for mfem::HypreFGMRES solver. | ||
*/ | ||
class MFEMHypreFGMRES : public MFEMSolverBase | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
MFEMHypreFGMRES(const InputParameters & parameters); | ||
|
||
std::shared_ptr<mfem::Solver> getSolver() const override { return _solver; } | ||
|
||
protected: | ||
void constructSolver(const InputParameters & parameters) override; | ||
|
||
private: | ||
std::shared_ptr<mfem::Solver> _preconditioner{nullptr}; | ||
std::shared_ptr<mfem::HypreFGMRES> _solver{nullptr}; | ||
}; |
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,26 @@ | ||
#pragma once | ||
#include "MFEMSolverBase.h" | ||
#include "MFEMHypreBoomerAMG.h" | ||
#include "mfem.hpp" | ||
#include <memory> | ||
|
||
/** | ||
* Wrapper for mfem::HypreGMRES solver. | ||
*/ | ||
class MFEMHypreGMRES : public MFEMSolverBase | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
MFEMHypreGMRES(const InputParameters &); | ||
|
||
/// Returns a shared pointer to the instance of the Solver derived-class. | ||
std::shared_ptr<mfem::Solver> getSolver() const override { return _solver; } | ||
|
||
protected: | ||
void constructSolver(const InputParameters & parameters) override; | ||
|
||
private: | ||
std::shared_ptr<mfem::Solver> _preconditioner{nullptr}; | ||
std::shared_ptr<mfem::HypreGMRES> _solver{nullptr}; | ||
}; |
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,25 @@ | ||
#pragma once | ||
#include "MFEMSolverBase.h" | ||
#include "mfem.hpp" | ||
#include <memory> | ||
|
||
/** | ||
* Wrapper for mfem::HyprePCG solver. | ||
*/ | ||
class MFEMHyprePCG : public MFEMSolverBase | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
MFEMHyprePCG(const InputParameters & parameters); | ||
|
||
/// Returns a shared pointer to the instance of the Solver derived-class. | ||
std::shared_ptr<mfem::Solver> getSolver() const override { return _solver; } | ||
|
||
protected: | ||
void constructSolver(const InputParameters & parameters) override; | ||
|
||
private: | ||
std::shared_ptr<mfem::Solver> _preconditioner{nullptr}; | ||
std::shared_ptr<mfem::HyprePCG> _solver{nullptr}; | ||
}; |
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,22 @@ | ||
#pragma once | ||
#include "MFEMGeneralUserObject.h" | ||
#include "mfem.hpp" | ||
#include <memory> | ||
|
||
/** | ||
* Base class for wrapping mfem::Solver-derived classes. | ||
*/ | ||
class MFEMSolverBase : public MFEMGeneralUserObject | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
MFEMSolverBase(const InputParameters & parameters); | ||
|
||
/// Returns a shared pointer to the instance of the Solver derived-class. | ||
virtual std::shared_ptr<mfem::Solver> getSolver() const = 0; | ||
|
||
protected: | ||
/// Override in derived classes to construct and set the solver options. | ||
virtual void constructSolver(const InputParameters & parameters) = 0; | ||
}; |
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,46 @@ | ||
#pragma once | ||
#include "MFEMSolverBase.h" | ||
#include "mfem.hpp" | ||
#include <memory> | ||
|
||
namespace platypus | ||
{ | ||
|
||
/** | ||
* Wrapper for mfem::SuperLU solver that creates a SuperLURowLocMatrix from the operator | ||
* when set. | ||
*/ | ||
class SuperLUSolver : public mfem::SuperLUSolver | ||
{ | ||
public: | ||
SuperLUSolver(MPI_Comm comm, int npdep = 1) : mfem::SuperLUSolver(comm, npdep){}; | ||
void SetOperator(const mfem::Operator & op) override | ||
{ | ||
_a_superlu = std::make_unique<mfem::SuperLURowLocMatrix>(op); | ||
mfem::SuperLUSolver::SetOperator(*_a_superlu.get()); | ||
} | ||
|
||
private: | ||
std::unique_ptr<mfem::SuperLURowLocMatrix> _a_superlu{nullptr}; | ||
}; | ||
} // namespace platypus | ||
|
||
/** | ||
* Wrapper for mfem::HyprePCG solver. | ||
*/ | ||
class MFEMSuperLU : public MFEMSolverBase | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
MFEMSuperLU(const InputParameters & parameters); | ||
|
||
/// Returns a shared pointer to the instance of the Solver derived-class. | ||
std::shared_ptr<mfem::Solver> getSolver() const override { return _solver; } | ||
|
||
protected: | ||
void constructSolver(const InputParameters & parameters) override; | ||
|
||
private: | ||
std::shared_ptr<platypus::SuperLUSolver> _solver{nullptr}; | ||
}; |
Oops, something went wrong.