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 "MFEMParaViewDataCollection.h" 13 : 14 : registerMooseObject("MooseApp", MFEMParaViewDataCollection); 15 : 16 : InputParameters 17 3332 : MFEMParaViewDataCollection::validParams() 18 : { 19 3332 : InputParameters params = MFEMDataCollection::validParams(); 20 6664 : params.addClassDescription("Output for controlling export to an mfem::ParaViewDataCollection."); 21 9996 : params.addParam<unsigned int>("refinements", 22 6664 : 0, 23 : "Number of uniform refinements for oversampling " 24 : "(refinement levels beyond any uniform " 25 : "refinements)"); 26 9996 : params.addParam<bool>("high_order_output", 27 6664 : false, 28 : "Sets whether or not to output the data as " 29 : "high-order elements (false by default)." 30 : "Reading high-order data requires ParaView" 31 : "5.5 or later."); 32 13328 : params.addParam<std::vector<MFEMScalarCoefficientName>>( 33 : "scalar_coefficients", 34 : {}, 35 : "Optional set of scalar coefficient names to evaluate and include in output."); 36 13328 : params.addParam<std::vector<MFEMVectorCoefficientName>>( 37 : "vector_coefficients", 38 : {}, 39 : "Optional set of vector coefficient names to evaluate and include in output."); 40 : 41 13328 : MooseEnum vtk_format("ASCII BINARY BINARY32", "BINARY", true); 42 9996 : params.addParam<MooseEnum>( 43 : "vtk_format", 44 : vtk_format, 45 : "Select VTK data format to use, choosing between BINARY, BINARY32, and ASCII."); 46 6664 : return params; 47 3332 : } 48 : 49 617 : MFEMParaViewDataCollection::MFEMParaViewDataCollection(const InputParameters & parameters) 50 : : MFEMDataCollection(parameters), 51 1851 : _pv_dc((_file_base + std::string("/Run") + std::to_string(getFileNumber())).c_str(), &_pmesh), 52 1234 : _scalar_coefficient_names( 53 : getParam<std::vector<MFEMScalarCoefficientName>>("scalar_coefficients")), 54 1234 : _vector_coefficient_names( 55 : getParam<std::vector<MFEMVectorCoefficientName>>("vector_coefficients")), 56 1234 : _high_order_output(getParam<bool>("high_order_output")), 57 1234 : _refinements(getParam<unsigned int>("refinements")), 58 1234 : _vtk_format(parameters.get<MooseEnum>("vtk_format").getEnum<mfem::VTKFormat>()) 59 : { 60 617 : _pv_dc.SetPrecision(9); 61 617 : _pv_dc.SetHighOrderOutput(_high_order_output); 62 617 : _pv_dc.SetLevelsOfDetail(_refinements + 1); 63 617 : _pv_dc.SetDataFormat(_vtk_format); 64 617 : registerFields(); 65 617 : registerScalarCoefficients(_scalar_coefficient_names); 66 617 : registerVectorCoefficients(_vector_coefficient_names); 67 617 : } 68 : 69 : void 70 617 : MFEMParaViewDataCollection::registerScalarCoefficients( 71 : std::vector<MFEMScalarCoefficientName> & scalar_coefficient_names) 72 : { 73 652 : for (const auto & scalar_coefficient_name : scalar_coefficient_names) 74 : { 75 35 : std::string coef_name(scalar_coefficient_name + "_coef"); 76 70 : _pv_dc.RegisterCoeffField( 77 35 : coef_name, &_problem_data.coefficients.getScalarCoefficient(scalar_coefficient_name)); 78 35 : } 79 617 : } 80 : 81 : void 82 617 : MFEMParaViewDataCollection::registerVectorCoefficients( 83 : std::vector<MFEMVectorCoefficientName> & vector_coefficient_names) 84 : { 85 631 : for (const auto & vector_coefficient_name : vector_coefficient_names) 86 : { 87 14 : std::string vec_coef_name(vector_coefficient_name + "_coef"); 88 28 : _pv_dc.RegisterVCoeffField( 89 14 : vec_coef_name, &_problem_data.coefficients.getVectorCoefficient(vector_coefficient_name)); 90 14 : } 91 617 : } 92 : 93 : #endif