Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b40e516
Added a ConstructJacobianSolver method to the ProblemOperator classes…
May 22, 2024
2d7c18a
Removed ConstructJacobianSolver method from problem operator classes;…
May 22, 2024
670fd60
Removes SetJacobianPreconditioner and SetJacobianSolver methods from …
May 22, 2024
a17308e
Removes ConstructTimestepper method from problem builder classes. Add…
May 22, 2024
18a158d
Removes ConstructNonlinearSolver from problem builder classes; adds C…
May 22, 2024
b388476
Removed SetNonlinearSolver setter.
May 22, 2024
9c8a27a
Moves ConstructTimestepper into TimeDomainProblemOperator::Init
May 23, 2024
9ce6f23
Adds SolverOptions structure and SetSolverOptions method.
May 23, 2024
6d30e48
Makes ConstructJacobianSolver protected in derived classes.
May 23, 2024
84df05c
Implements SetSolverOptions for HCurlProblemOperator.
May 23, 2024
798739e
Implements SetSolverOptions for DualOperator.
May 23, 2024
2383fa3
Implements SetSolverOptions for ComplexMaxwellOperator.
May 23, 2024
14eb5d7
Implements SetSolverOptions for StaticsOperator.
May 23, 2024
29d3137
SetSolverOptions argument now passed by value.
May 23, 2024
cc09a40
Updates examples to use new SetSolverOptions.
May 23, 2024
7482759
Updates integration tests to use SetSolverOptions.
May 23, 2024
b9f3ae1
Removes solver input parameters from Problem and SetSolverOptions fro…
May 23, 2024
fe35b42
Adds custom Update implementation for HCurlProblemOperator
May 23, 2024
1b58254
Adds DualOperator update implementation.
May 23, 2024
c801b56
Corrected comments in ProblemOperatorBase.
May 23, 2024
73f9c96
Switched order in ComplexMaxwellOperator::Update to be consistent
May 23, 2024
f574312
Switches order in TimeDomainEquationSystemProblemOperator::Update to …
May 23, 2024
673d1eb
Adds solver options member variable to store parameters; now call Con…
May 23, 2024
3d9071c
Removes jacobian preconditioner template accessor from ProblemOperato…
May 23, 2024
5046623
Removes Jacobian operator handle from EquationSystem.
May 23, 2024
f57eb82
Removes ConstructOperator from problem classes. Implemented directly …
May 23, 2024
e4c038e
Removed TODO comment from EquationSystemProblemOperator.
May 24, 2024
2f97298
Adds DefaultSolverOptions virtual method
May 24, 2024
01a2ceb
Adds ApplySolverOptions; SetSolverOptions no longer virtual and wraps…
May 24, 2024
636cdfd
SolverOptions are now private; adds GetSolverOptions accessor.
May 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions examples/closed_coil/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,13 @@ main(int argc, char * argv[])
hephaestus::Outputs outputs = defineOutputs();
problem_builder->SetOutputs(outputs);

hephaestus::InputParameters solver_options;
solver_options.SetParam("Tolerance", float(1.0e-13));
solver_options.SetParam("AbsTolerance", float(1.0e-16));
solver_options.SetParam("MaxIter", (unsigned int)500);
problem_builder->SetSolverOptions(solver_options);

problem_builder->FinalizeProblem();

auto problem = problem_builder->ReturnProblem();

problem->GetOperator()->SetSolverOptions(
{._tolerance = 1.0e-13, ._abs_tolerance = 1.0e-16, ._max_iteration = 500});

hephaestus::InputParameters exec_params;
exec_params.SetParam("VisualisationSteps", int(1));
exec_params.SetParam("UseGLVis", true);
Expand Down
7 changes: 2 additions & 5 deletions examples/complex_team7/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,12 @@ main(int argc, char * argv[])
linesamplerwriter->SetPriority(5);
problem_builder->AddPostprocessor("LineSamplerWriter", linesamplerwriter);

hephaestus::InputParameters solver_options;
solver_options.SetParam("Tolerance", float(1.0e-16));
solver_options.SetParam("MaxIter", (unsigned int)1000);
problem_builder->SetSolverOptions(solver_options);

problem_builder->FinalizeProblem();

auto problem = problem_builder->ReturnProblem();

problem->GetOperator()->SetSolverOptions({._tolerance = 1.0e-16, ._max_iteration = 1000});

hephaestus::InputParameters exec_params;
exec_params.SetParam("Problem", static_cast<hephaestus::SteadyStateProblem *>(problem.get()));

Expand Down
8 changes: 3 additions & 5 deletions examples/magnetostatic/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,12 @@ main(int argc, char * argv[])
hephaestus::Outputs outputs = defineOutputs();
problem_builder->SetOutputs(outputs);

hephaestus::InputParameters solver_options;
solver_options.SetParam("Tolerance", float(1.0e-16));
solver_options.SetParam("MaxIter", (unsigned int)1000);
problem_builder->SetSolverOptions(solver_options);

problem_builder->FinalizeProblem();

auto problem = problem_builder->ReturnProblem();

problem->GetOperator()->SetSolverOptions({._tolerance = 1.0e-16, ._max_iteration = 1000});

hephaestus::InputParameters exec_params;
exec_params.SetParam("VisualisationSteps", int(1));
exec_params.SetParam("UseGLVis", true);
Expand Down
10 changes: 4 additions & 6 deletions examples/open_coil/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,13 @@ main(int argc, char * argv[])
hephaestus::Outputs outputs = defineOutputs();
problem_builder->SetOutputs(outputs);

hephaestus::InputParameters solver_options;
solver_options.SetParam("Tolerance", float(1.0e-10));
solver_options.SetParam("AbsTolerance", float(1.0e-10));
solver_options.SetParam("MaxIter", (unsigned int)1000);
problem_builder->SetSolverOptions(solver_options);

problem_builder->FinalizeProblem();

auto problem = problem_builder->ReturnProblem();

problem->GetOperator()->SetSolverOptions(
{._tolerance = 1.0e-10, ._abs_tolerance = 1.0e-10, ._max_iteration = 1000});

hephaestus::InputParameters exec_params;
exec_params.SetParam("VisualisationSteps", int(1));
exec_params.SetParam("UseGLVis", true);
Expand Down
10 changes: 4 additions & 6 deletions examples/team4/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,13 @@ main(int argc, char * argv[])
fluxmonitor->SetPriority(2);
problem_builder->AddPostprocessor("FluxMonitor", fluxmonitor);

hephaestus::InputParameters solver_options;
solver_options.SetParam("AbsTolerance", float(1.0e-20));
solver_options.SetParam("Tolerance", float(1.0e-20));
solver_options.SetParam("MaxIter", (unsigned int)500);
problem_builder->SetSolverOptions(solver_options);

problem_builder->FinalizeProblem();

auto problem = problem_builder->ReturnProblem();

problem->GetOperator()->SetSolverOptions(
{._tolerance = 1.0e-20, ._abs_tolerance = 1.0e-20, ._max_iteration = 500});

hephaestus::InputParameters exec_params;
exec_params.SetParam("TimeStep", float(0.001));
exec_params.SetParam("StartTime", float(0.00));
Expand Down
8 changes: 3 additions & 5 deletions examples/team7/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,12 @@ main(int argc, char * argv[])
linesamplerwriter->SetPriority(5);
problem_builder->AddPostprocessor("LineSamplerWriter", linesamplerwriter);

hephaestus::InputParameters solver_options;
solver_options.SetParam("Tolerance", float(1.0e-16));
solver_options.SetParam("MaxIter", (unsigned int)1000);
problem_builder->SetSolverOptions(solver_options);

problem_builder->FinalizeProblem();

auto problem = problem_builder->ReturnProblem();

problem->GetOperator()->SetSolverOptions({._tolerance = 1.0e-16, ._max_iteration = 1000});

hephaestus::InputParameters exec_params;
exec_params.SetParam("TimeStep", float(0.001));
exec_params.SetParam("StartTime", float(0.00));
Expand Down
3 changes: 0 additions & 3 deletions src/equation_systems/equation_system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ class EquationSystem : public mfem::Operator
virtual void RecoverFEMSolution(mfem::BlockVector & trueX,
hephaestus::GridFunctions & gridfunctions);

/// Returns a reference to the jacobian operator handle.
[[nodiscard]] mfem::OperatorHandle & JacobianOperatorHandle() { return _jacobian; }

std::vector<mfem::Array<int>> _ess_tdof_lists;

protected:
Expand Down
14 changes: 7 additions & 7 deletions src/formulations/ComplexMaxwell/complex_maxwell_formulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ ComplexMaxwellFormulation::ComplexMaxwellFormulation(std::string alpha_coef_name
{
}

void
ComplexMaxwellFormulation::ConstructJacobianSolver()
{
ConstructJacobianSolverWithOptions(SolverType::SUPER_LU);
}

void
ComplexMaxwellFormulation::ConstructOperator()
{
Expand Down Expand Up @@ -168,8 +162,8 @@ ComplexMaxwellOperator::Init()
void
ComplexMaxwellOperator::Update()
{
_u->Update();
ProblemOperator::Update();
_u->Update();
}

void
Expand Down Expand Up @@ -226,4 +220,10 @@ ComplexMaxwellOperator::Solve(mfem::Vector & X)
_problem._gridfunctions.GetRef(_trial_var_names.at(1)) = _u->imag();
}

void
ComplexMaxwellOperator::ConstructJacobianSolver()
{
_jacobian_solver = std::make_unique<hephaestus::SuperLUSolver>(_problem._comm);
}

} // namespace hephaestus
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ class ComplexMaxwellFormulation : public hephaestus::FrequencyDomainEMFormulatio

~ComplexMaxwellFormulation() override = default;

void ConstructJacobianSolver() override;

void ConstructOperator() override;

void RegisterGridFunctions() override;
Expand Down Expand Up @@ -88,6 +86,11 @@ class ComplexMaxwellOperator : public ProblemOperator
mfem::Coefficient * _loss_coef{nullptr}; // omega sigma

mfem::Array<int> _ess_bdr_tdofs;

protected:
void ApplySolverOptions() override {}

void ConstructJacobianSolver() override;
};

} // namespace hephaestus
41 changes: 27 additions & 14 deletions src/formulations/Dual/dual_formulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,6 @@ DualFormulation::DualFormulation(std::string alpha_coef_name,
{
}

void
DualFormulation::ConstructJacobianSolver()
{
auto precond =
std::make_unique<mfem::HypreAMS>(GetProblem()->GetEquationSystem()->_test_pfespaces.at(0));

precond->SetSingularProblem();
precond->SetPrintLevel(-1);

GetProblem()->GetOperator()->SetJacobianPreconditioner(std::move(precond));

ConstructJacobianSolverWithOptions(SolverType::HYPRE_PCG, {._max_iteration = 1000});
}

void
DualFormulation::ConstructOperator()
{
Expand Down Expand Up @@ -213,12 +199,39 @@ DualOperator::Init()
void
DualOperator::Update()
{
// 0. Call superclass' update method.
TimeDomainEquationSystemProblemOperator::Update();

_curl->Update();
_curl->Assemble();
}

void
DualOperator::ConstructJacobianSolver()
{
auto precond = std::make_unique<mfem::HypreAMS>(GetEquationSystem()->_test_pfespaces.at(0));

precond->SetSingularProblem();
precond->SetPrintLevel(-1);

auto solver = std::make_unique<mfem::HyprePCG>(_problem._comm);
solver->SetPreconditioner(*precond);

_jacobian_preconditioner = std::move(precond);
_jacobian_solver = std::move(solver);
}

void
DualOperator::ApplySolverOptions()
{
auto & solver = static_cast<mfem::HyprePCG &>(*_jacobian_solver);

solver.SetTol(GetSolverOptions()._tolerance);
solver.SetAbsTol(GetSolverOptions()._abs_tolerance);
solver.SetMaxIter(GetSolverOptions()._max_iteration);
solver.SetPrintLevel(GetSolverOptions()._print_level);
}

void
DualOperator::ImplicitSolve(const double dt, const mfem::Vector & X, mfem::Vector & dX_dt)
{
Expand Down
6 changes: 4 additions & 2 deletions src/formulations/Dual/dual_formulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ class DualFormulation : public TimeDomainEMFormulation

~DualFormulation() override = default;

void ConstructJacobianSolver() override;

void ConstructOperator() override;

void RegisterGridFunctions() override;
Expand Down Expand Up @@ -72,6 +70,10 @@ class DualOperator : public TimeDomainEquationSystemProblemOperator
mfem::ParGridFunction * _dv{nullptr}; // HDiv vector field

protected:
void ConstructJacobianSolver() override;

void ApplySolverOptions() override;

int GetSolutionVectorSize() const override;

std::unique_ptr<mfem::ParDiscreteLinearOperator> _curl;
Expand Down
42 changes: 27 additions & 15 deletions src/formulations/HCurl/hcurl_formulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,10 @@ HCurlFormulation::ConstructOperator()

auto equation_system = std::make_unique<hephaestus::CurlCurlEquationSystem>(weak_form_params);

GetProblem()->SetOperator(std::make_unique<hephaestus::TimeDomainEquationSystemProblemOperator>(
GetProblem()->SetOperator(std::make_unique<hephaestus::HCurlProblemOperator>(
*GetProblem(), std::move(equation_system)));
}

void
HCurlFormulation::ConstructJacobianSolver()
{
auto precond =
std::make_unique<mfem::HypreAMS>(GetProblem()->GetEquationSystem()->_test_pfespaces.at(0));

precond->SetSingularProblem();
precond->SetPrintLevel(-1);

GetProblem()->GetOperator()->SetJacobianPreconditioner(std::move(precond));

ConstructJacobianSolverWithOptions(SolverType::HYPRE_PCG);
}

void
HCurlFormulation::RegisterGridFunctions()
{
Expand All @@ -102,6 +88,32 @@ HCurlFormulation::RegisterGridFunctions()
TimeDomainEquationSystemProblemBuilder::RegisterGridFunctions();
};

void
HCurlProblemOperator::ApplySolverOptions()
{
auto & solver = static_cast<mfem::HyprePCG &>(*_jacobian_solver);

solver.SetTol(GetSolverOptions()._tolerance);
solver.SetAbsTol(GetSolverOptions()._abs_tolerance);
solver.SetMaxIter(GetSolverOptions()._max_iteration);
solver.SetPrintLevel(GetSolverOptions()._print_level);
}

void
HCurlProblemOperator::ConstructJacobianSolver()
{
auto precond = std::make_unique<mfem::HypreAMS>(GetEquationSystem()->_test_pfespaces.at(0));

precond->SetSingularProblem();
precond->SetPrintLevel(-1);

auto solver = std::make_unique<mfem::HyprePCG>(_problem._comm);
solver->SetPreconditioner(*precond);

_jacobian_preconditioner = std::move(precond);
_jacobian_solver = std::move(solver);
}

CurlCurlEquationSystem::CurlCurlEquationSystem(const hephaestus::InputParameters & params)
: _h_curl_var_name(params.GetParam<std::string>("HCurlVarName")),
_alpha_coef_name(params.GetParam<std::string>("AlphaCoefName")),
Expand Down
17 changes: 15 additions & 2 deletions src/formulations/HCurl/hcurl_formulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ class HCurlFormulation : public TimeDomainEMFormulation

void ConstructOperator() override;

void ConstructJacobianSolver() override;

void RegisterGridFunctions() override;

void RegisterCoefficients() override;
Expand All @@ -30,6 +28,21 @@ class HCurlFormulation : public TimeDomainEMFormulation
const std::string _h_curl_var_name;
};

class HCurlProblemOperator : public TimeDomainEquationSystemProblemOperator
{
public:
HCurlProblemOperator(hephaestus::Problem & problem,
std::unique_ptr<hephaestus::TimeDependentEquationSystem> equation_system)
: TimeDomainEquationSystemProblemOperator(problem, std::move(equation_system))
{
}

protected:
void ApplySolverOptions() override;

void ConstructJacobianSolver() override;
};

class CurlCurlEquationSystem : public TimeDependentEquationSystem
{
public:
Expand Down
Loading