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 : #include "ProblemOperatorBase.h" 13 : 14 : class MFEMProblem; 15 : 16 : namespace Moose::MFEM 17 : { 18 : 19 1361 : ProblemOperatorBase::ProblemOperatorBase(MFEMProblem & problem) 20 1361 : : _problem(problem), _problem_data(problem.getProblemData()) 21 : { 22 1361 : } 23 : 24 : void 25 1325 : ProblemOperatorBase::SetGridFunctions() 26 : { 27 1325 : _trial_variables = _problem_data.gridfunctions.Get(_trial_var_names); 28 1325 : _test_variables = _problem_data.gridfunctions.Get(_test_var_names); 29 : 30 : // Set operator size and block structure for trial spaces 31 1325 : _block_true_offsets_trial.SetSize(_trial_variables.size() + 1); 32 1325 : _block_true_offsets_trial[0] = 0; 33 2247 : for (const auto ind : index_range(_trial_variables)) 34 922 : _block_true_offsets_trial[ind + 1] = _trial_variables.at(ind)->ParFESpace()->TrueVSize(); 35 1325 : _block_true_offsets_trial.PartialSum(); 36 : 37 : // Set operator size and block structure for test spaces 38 1325 : _block_true_offsets_test.SetSize(_test_variables.size() + 1); 39 1325 : _block_true_offsets_test[0] = 0; 40 2247 : for (const auto ind : index_range(_test_variables)) 41 922 : _block_true_offsets_test[ind + 1] = _test_variables.at(ind)->ParFESpace()->TrueVSize(); 42 1325 : _block_true_offsets_test.PartialSum(); 43 : 44 1325 : _true_x.Update(_block_true_offsets_trial); 45 1325 : _true_rhs.Update(_block_true_offsets_test); 46 1325 : } 47 : 48 : void 49 1361 : ProblemOperatorBase::Init(mfem::BlockVector & X) 50 : { 51 1361 : X.Update(_block_true_offsets_trial); 52 2257 : for (const auto i : index_range(_trial_variables)) 53 896 : X.GetBlock(i) = _trial_variables[i]->GetTrueVector(); 54 : // Sync the flags from the global vector with the sub-vectors (copies to global vector location) 55 1361 : X.SyncFromBlocks(); 56 : 57 : // After initial assignment of X from the grid function, which may contain initial conditions, 58 : // we alias the grid function to X 59 2257 : for (const auto i : index_range(_trial_variables)) 60 1792 : _trial_variables[i]->MakeTRef( 61 896 : _trial_variables[i]->ParFESpace(), X, _block_true_offsets_trial[i]); 62 1361 : _trial_true_vector = &X; 63 1361 : } 64 : 65 : void 66 1048 : ProblemOperatorBase::SetTrialVariablesFromTrueVectors() 67 : { 68 : mooseAssert(_trial_true_vector, "The true vector should already have been set"); 69 2114 : for (const auto trial_var : _trial_variables) 70 : { 71 : // Sync the memory flags from the global true vector to the gridfunction aliases 72 1066 : trial_var->GetTrueVector().SyncMemory(*_trial_true_vector); 73 1066 : trial_var->SetFromTrueVector(); 74 : } 75 1048 : } 76 : } 77 : 78 : #endif