LCOV - code coverage report
Current view: top level - src/mfem/outputs - MFEMDataCollection.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 909fe5 Lines: 25 26 96.2 %
Date: 2025-08-29 20:01:24 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       26500 : MFEMDataCollection::validParams()
      16             : {
      17       26500 :   InputParameters params = FileOutput::validParams();
      18       53000 :   params.addClassDescription("Output for controlling MFEMDataCollection inherited data.");
      19       79500 :   params.addParam<std::string>("submesh",
      20             :                                "Submesh to output variables on. Leave blank to use base mesh.");
      21       26500 :   return params;
      22           0 : }
      23             : 
      24         305 : MFEMDataCollection::MFEMDataCollection(const InputParameters & parameters)
      25             :   : FileOutput(parameters),
      26         305 :     _problem_data(static_cast<MFEMProblem *>(_problem_ptr)->getProblemData()),
      27         305 :     _pmesh(parameters.isParamValid("submesh")
      28         631 :                ? _problem_data.submeshes.GetRef(getParam<std::string>("submesh"))
      29         589 :                : const_cast<mfem::ParMesh &>(*_problem_data.pmesh.get()))
      30             : {
      31         305 : }
      32             : 
      33             : void
      34         305 : MFEMDataCollection::registerFields()
      35             : {
      36         305 :   mfem::DataCollection & dc(getDataCollection());
      37         917 :   for (auto const & [gf_name, gf_ptr] : _problem_data.gridfunctions)
      38             :   {
      39         612 :     if (dc.GetMesh() == gf_ptr->FESpace()->GetMesh())
      40         599 :       dc.RegisterField(gf_name, gf_ptr.get());
      41             :     else
      42          13 :       mooseInfo("The variable ",
      43             :                 gf_name,
      44             :                 " is not defined on the same mesh as the output DataCollection.");
      45             :   }
      46         305 : }
      47             : 
      48             : void
      49         872 : MFEMDataCollection::output()
      50             : {
      51         872 :   mfem::DataCollection & dc(getDataCollection());
      52             :   // Write fields to disk
      53         872 :   dc.SetCycle(getFileNumber());
      54         872 :   dc.SetTime(time());
      55         872 :   dc.Save();
      56         872 :   _file_num++;
      57         872 : }
      58             : 
      59             : #endif

Generated by: LCOV version 1.14