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