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 MFEM_ENABLED 11 : 12 : #include "TimeDomainEquationSystemProblemOperator.h" 13 : 14 : namespace Moose::MFEM 15 : { 16 : 17 : void 18 24 : TimeDomainEquationSystemProblemOperator::SetGridFunctions() 19 : { 20 24 : _test_var_names = GetEquationSystem()->TestVarNames(); 21 24 : _trial_var_names = GetEquationSystem()->TrialVarNames(); 22 : _trial_variable_time_derivatives = 23 24 : _problem.gridfunctions.Get(GetEquationSystem()->TrialVarTimeDerivativeNames()); 24 : 25 24 : TimeDomainProblemOperator::SetGridFunctions(); 26 24 : } 27 : 28 : void 29 24 : TimeDomainEquationSystemProblemOperator::Init(mfem::BlockVector & X) 30 : { 31 24 : TimeDomainProblemOperator::Init(X); 32 24 : GetEquationSystem()->BuildEquationSystem(); 33 24 : } 34 : 35 : void 36 68 : TimeDomainEquationSystemProblemOperator::ImplicitSolve(const double dt, 37 : const mfem::Vector & /*X*/, 38 : mfem::Vector & dX_dt) 39 : { 40 68 : dX_dt = 0.0; 41 68 : SetTestVariablesFromTrueVectors(); 42 136 : for (unsigned int ind = 0; ind < _trial_variables.size(); ++ind) 43 : { 44 136 : _trial_variables.at(ind)->MakeTRef( 45 68 : _trial_variables.at(ind)->ParFESpace(), dX_dt, _block_true_offsets[ind]); 46 : } 47 68 : _problem.coefficients.setTime(GetTime()); 48 68 : BuildEquationSystemOperator(dt); 49 : 50 68 : if (_problem.jacobian_solver->isLOR() && _equation_system->_test_var_names.size() > 1) 51 0 : mooseError("LOR solve is only supported for single-variable systems"); 52 : 53 68 : _problem.jacobian_solver->updateSolver( 54 68 : *_equation_system->_blfs.Get(_equation_system->_test_var_names.at(0)), 55 68 : _equation_system->_ess_tdof_lists.at(0)); 56 : 57 68 : _problem.nonlinear_solver->SetSolver(_problem.jacobian_solver->getSolver()); 58 68 : _problem.nonlinear_solver->SetOperator(*GetEquationSystem()); 59 68 : _problem.nonlinear_solver->Mult(_true_rhs, dX_dt); 60 68 : SetTrialVariablesFromTrueVectors(); 61 68 : } 62 : 63 : void 64 68 : TimeDomainEquationSystemProblemOperator::BuildEquationSystemOperator(double dt) 65 : { 66 68 : GetEquationSystem()->SetTimeStep(dt); 67 68 : GetEquationSystem()->UpdateEquationSystem(); 68 68 : GetEquationSystem()->BuildJacobian(_true_x, _true_rhs); 69 68 : } 70 : 71 : } // namespace Moose::MFEM 72 : 73 : #endif