LCOV - code coverage report
Current view: top level - src/mfem/outputs - MFEMDataCollection.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #31653 (1b668c) with base bb0a08 Lines: 25 26 96.2 %
Date: 2025-11-03 17:02:13 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       28782 : MFEMDataCollection::validParams()
      16             : {
      17       28782 :   InputParameters params = FileOutput::validParams();
      18       57564 :   params.addClassDescription("Output for controlling MFEMDataCollection inherited data.");
      19       86346 :   params.addParam<std::string>("submesh",
      20             :                                "Submesh to output variables on. Leave blank to use base mesh.");
      21       28782 :   return params;
      22           0 : }
      23             : 
      24         363 : MFEMDataCollection::MFEMDataCollection(const InputParameters & parameters)
      25             :   : FileOutput(parameters),
      26         363 :     _problem_data(static_cast<MFEMProblem *>(_problem_ptr)->getProblemData()),
      27         363 :     _pmesh(parameters.isParamValid("submesh")
      28         778 :                ? _problem_data.submeshes.GetRef(getParam<std::string>("submesh"))
      29         674 :                : const_cast<mfem::ParMesh &>(*_problem_data.pmesh.get()))
      30             : {
      31         363 : }
      32             : 
      33             : void
      34         363 : MFEMDataCollection::registerFields()
      35             : {
      36         363 :   mfem::DataCollection & dc(getDataCollection());
      37        1362 :   for (auto const & [gf_name, gf_ptr] : _problem_data.gridfunctions)
      38             :   {
      39         999 :     if (dc.GetMesh() == gf_ptr->FESpace()->GetMesh())
      40         792 :       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         363 : }
      47             : 
      48             : void
      49        1017 : MFEMDataCollection::output()
      50             : {
      51        1017 :   mfem::DataCollection & dc(getDataCollection());
      52             :   // Write fields to disk
      53        1017 :   dc.SetCycle(getFileNumber());
      54        1017 :   dc.SetTime(time());
      55        1017 :   dc.Save();
      56        1017 :   _file_num++;
      57        1017 : }
      58             : 
      59             : #endif

Generated by: LCOV version 1.14