https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MFEMProblemSolve.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#ifdef MOOSE_MFEM_ENABLED
11
12#include "Executioner.h"
13#include "MFEMProblemSolve.h"
14#include "MFEMProblem.h"
15
18{
20 params.addClassDescription("Solve object for MFEM problems.");
21 params.addParam<std::string>("device", "", "Run app on the chosen device.");
22 params.addParam<bool>("gpu_aware_mpi", false, "Use GPU-aware MPI.");
23 MooseEnum assembly_levels("legacy full element partial none", "legacy");
24 params.addParam<MooseEnum>("assembly_level", assembly_levels, "Matrix assembly level.");
25 return params;
26}
27
29 Executioner & ex,
30 std::vector<std::shared_ptr<Moose::MFEM::ProblemOperatorBase>> & problem_operators)
31 : SolveObject(ex),
32 _mfem_problem(dynamic_cast<MFEMProblem &>(_problem)),
33 _problem_operators(problem_operators)
34{
35 _app.setMFEMDevice(getParam<std::string>("device"), getParam<bool>("gpu_aware_mpi"));
36}
37
38bool
40{
42 {
43 for (const auto & problem_operator : _problem_operators)
44 problem_operator->Solve();
45
46 // Short-circuit evaluation guarantees we only do one of p- or h-refinement between solves
48 {
49 // Reset linear solver and its preconditioner now the problem size has changed
50 if (auto & solver = _mfem_problem.getProblemData().jacobian_solver)
51 {
52 if (auto * prec = solver->GetPreconditioner())
53 prec->ConstructSolver();
54 solver->ConstructSolver();
55 }
56
57 // Reset gridfunctions
58 for (const auto & problem_operator : _problem_operators)
59 problem_operator->SetGridFunctions();
60
61 // Solve again
62 for (const auto & problem_operator : _problem_operators)
63 problem_operator->Solve();
64 }
65 }
66
68
69 return true;
70}
71
72#endif
InputParameters emptyInputParameters()
Executioners are objects that do the actual work of solving your problem.
Definition Executioner.h:37
bool shouldSolve() const
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
virtual bool solve() override
Solve routine provided by this object.
MFEMProblem & _mfem_problem
static InputParameters validParams()
MFEMProblemSolve(Executioner &ex, std::vector< std::shared_ptr< Moose::MFEM::ProblemOperatorBase > > &problem_operators)
std::vector< std::shared_ptr< Moose::MFEM::ProblemOperatorBase > > & _problem_operators
bool hRefine()
If AMR is enabled, request (and perform if needed) h-refinement.
MFEMProblemData & getProblemData()
Method to get the current MFEMProblemData object storing the current data specifying the FE problem.
bool pRefine()
If AMR is enabled, request (and perform if needed) p-refinement.
void displaceMesh()
Displace the mesh, if mesh displacement is enabled.
void setMFEMDevice(const std::string &executioner_device, const bool &gpu_aware_mpi)
Create/configure the MFEM device.
Definition MooseApp.C:3634
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
MooseApp & _app
The MOOSE application this is associated with.
Definition MooseBase.h:375
std::shared_ptr< Moose::MFEM::LinearSolverBase > jacobian_solver