LCOV - code coverage report
Current view: top level - src/mfem/outputs - MFEMDataCollection.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #31405 (292dce) with base fef103 Lines: 25 26 96.2 %
Date: 2025-09-04 07:52:05 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.14