LCOV - code coverage report
Current view: top level - src/mfem/auxkernels - MFEMGradAux.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 18 19 94.7 %
Date: 2025-07-17 01:28:37 Functions: 3 3 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 MFEM_ENABLED
      11             : 
      12             : #include "MFEMGradAux.h"
      13             : #include "MFEMProblem.h"
      14             : 
      15             : registerMooseObject("MooseApp", MFEMGradAux);
      16             : 
      17             : /*
      18             : Class to set an H(curl) auxvariable to be the gradient of a H1 scalar variable.
      19             : */
      20             : InputParameters
      21        8678 : MFEMGradAux::validParams()
      22             : {
      23        8678 :   InputParameters params = MFEMAuxKernel::validParams();
      24        8678 :   params.addClassDescription(
      25             :       "Calculates the gradient of an H1 conforming source variable and stores the result"
      26             :       " on an H(curl) conforming ND result auxvariable");
      27        8678 :   params.addRequiredParam<VariableName>("source",
      28             :                                         "Scalar H1 MFEMVariable to take the gradient of.");
      29        8678 :   params.addParam<mfem::real_t>("scale_factor", 1.0, "Factor to scale result auxvariable by.");
      30        8678 :   return params;
      31           0 : }
      32             : 
      33          24 : MFEMGradAux::MFEMGradAux(const InputParameters & parameters)
      34             :   : MFEMAuxKernel(parameters),
      35          24 :     _source_var_name(getParam<VariableName>("source")),
      36          24 :     _source_var(*getMFEMProblem().getProblemData().gridfunctions.Get(_source_var_name)),
      37          24 :     _scale_factor(getParam<mfem::real_t>("scale_factor")),
      38          48 :     _grad(_source_var.ParFESpace(), _result_var.ParFESpace())
      39             : {
      40          24 :   _grad.Assemble();
      41          24 :   _grad.Finalize();
      42          24 : }
      43             : 
      44             : // Computes the auxvariable.
      45             : void
      46          24 : MFEMGradAux::execute()
      47             : {
      48          24 :   _result_var = 0.0;
      49          24 :   _grad.AddMult(_source_var, _result_var, _scale_factor);
      50          24 : }
      51             : 
      52             : #endif

Generated by: LCOV version 1.14