Line data Source code
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 : #pragma once 13 : 14 : #include "MFEMProblem.h" 15 : #include <functional> 16 : 17 : namespace Moose::MFEM 18 : { 19 : class EquationSystem; 20 : 21 : /// Interface inherited by ProblemOperator and TimeDependentProblemOperator. Removes duplicated code in both classes. 22 : class ProblemOperatorBase 23 : { 24 : public: 25 : ProblemOperatorBase(MFEMProblem & problem); 26 1440 : virtual ~ProblemOperatorBase() = default; 27 : 28 : virtual void SetGridFunctions(); 29 : virtual void SetTrialVariablesFromTrueVectors(); 30 : virtual void Init(mfem::BlockVector & X); 31 : virtual void Solve() = 0; 32 : 33 : mfem::Array<int> _block_true_offsets_test; 34 : mfem::Array<int> _block_true_offsets_trial; 35 : 36 : mfem::BlockVector _true_x, _true_rhs; 37 : 38 : protected: 39 : /// Solve the current equation system/operator using the configured nonlinear solver or linear 40 : /// solver for a purely linear problem 41 : void 42 : SolveWithOperator(EquationSystem & equation_system, const mfem::Vector & rhs, mfem::Vector & x); 43 : 44 : /// Reference to the current problem. 45 : MFEMProblem & _problem; 46 : MFEMProblemData & _problem_data; 47 : 48 : /// Vector of names of state gridfunctions used in formulation, ordered by appearance in block 49 : /// vector during solve. 50 : std::vector<std::string> _trial_var_names; 51 : std::vector<std::string> _test_var_names; 52 : std::vector<mfem::ParGridFunction *> _trial_variables; 53 : std::vector<mfem::ParGridFunction *> _test_variables; 54 : mfem::Vector * _trial_true_vector = nullptr; 55 : }; 56 : } 57 : 58 : #endif