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 "MFEMDataCollection.h" 13 : 14 : InputParameters 15 26378 : MFEMDataCollection::validParams() 16 : { 17 26378 : InputParameters params = FileOutput::validParams(); 18 26378 : params.addClassDescription("Output for controlling MFEMDataCollection inherited data."); 19 26378 : params.addParam<std::string>("submesh", 20 : "Submesh to output variables on. Leave blank to use base mesh."); 21 26378 : return params; 22 0 : } 23 : 24 244 : MFEMDataCollection::MFEMDataCollection(const InputParameters & parameters) 25 : : FileOutput(parameters), 26 488 : _problem_data(static_cast<MFEMProblem *>(_problem_ptr)->getProblemData()), 27 488 : _pmesh(parameters.isParamValid("submesh") 28 472 : ? _problem_data.submeshes.GetRef(getParam<std::string>("submesh")) 29 472 : : const_cast<mfem::ParMesh &>(*_problem_data.pmesh.get())) 30 : { 31 244 : } 32 : 33 : void 34 244 : MFEMDataCollection::registerFields() 35 : { 36 244 : mfem::DataCollection & dc(getDataCollection()); 37 735 : for (auto const & [gf_name, gf_ptr] : _problem_data.gridfunctions) 38 : { 39 491 : if (dc.GetMesh() == gf_ptr->FESpace()->GetMesh()) 40 483 : dc.RegisterField(gf_name, gf_ptr.get()); 41 : else 42 8 : mooseInfo("The variable ", 43 : gf_name, 44 : " is not defined on the same mesh as the output DataCollection."); 45 : } 46 244 : } 47 : 48 : void 49 579 : MFEMDataCollection::output() 50 : { 51 579 : mfem::DataCollection & dc(getDataCollection()); 52 : // Write fields to disk 53 579 : dc.SetCycle(getFileNumber()); 54 579 : dc.SetTime(time()); 55 579 : if (gridFunctionsNeedHostRead()) 56 48 : for (auto & [_, gf_ptr] : _problem_data.gridfunctions) 57 32 : gf_ptr->HostRead(); 58 579 : dc.Save(); 59 579 : _file_num++; 60 579 : } 61 : 62 : #endif