LCOV - code coverage report
Current view: top level - src/mfem/auxkernels - MFEMDotProductAux.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: d8769b Lines: 27 30 90.0 %
Date: 2025-11-07 20:01:30 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 MOOSE_MFEM_ENABLED
      11             : 
      12             : #include "MFEMDotProductAux.h"
      13             : #include "MFEMProblem.h"
      14             : 
      15             : registerMooseObject("MooseApp", MFEMDotProductAux);
      16             : 
      17             : InputParameters
      18        9366 : MFEMDotProductAux::validParams()
      19             : {
      20        9366 :   InputParameters params = MFEMAuxKernel::validParams();
      21       18732 :   params.addClassDescription("Project s(x) * (U . V) onto a scalar MFEM auxvariable.");
      22       37464 :   params.addRequiredParam<VariableName>("first_source_vec", "Vector MFEMVariable U");
      23       37464 :   params.addRequiredParam<VariableName>("second_source_vec", "Vector MFEMVariable V");
      24       18732 :   params.addParam<mfem::real_t>(
      25       18732 :       "scale_factor", 1.0, "Constant multiplier applied to the dot product");
      26        9366 :   return params;
      27           0 : }
      28             : 
      29           7 : MFEMDotProductAux::MFEMDotProductAux(const InputParameters & parameters)
      30             :   : MFEMAuxKernel(parameters),
      31           7 :     _u_var_name(getParam<VariableName>("first_source_vec")),
      32          14 :     _v_var_name(getParam<VariableName>("second_source_vec")),
      33           7 :     _u_var(*getMFEMProblem().getProblemData().gridfunctions.Get(_u_var_name)),
      34           7 :     _v_var(*getMFEMProblem().getProblemData().gridfunctions.Get(_v_var_name)),
      35          14 :     _scale_factor(getParam<mfem::real_t>("scale_factor")),
      36           7 :     _u_coef(&_u_var),
      37           7 :     _v_coef(&_v_var),
      38           7 :     _dot_uv(_u_coef, _v_coef),
      39           7 :     _scale_c(_scale_factor),
      40          14 :     _final_coef(_scale_c, _dot_uv)
      41             : {
      42             :   // Must be L2
      43           7 :   mfem::ParFiniteElementSpace * fes = _result_var.ParFESpace();
      44           7 :   if (!dynamic_cast<const mfem::L2_FECollection *>(fes->FEColl()))
      45           0 :     paramError("variable", "The target variable must use L2_FECollection.");
      46             : 
      47             :   // Must have no shared/constrained DOFs
      48           7 :   if (fes->GetTrueVSize() != fes->GetVSize())
      49           0 :     mooseError("MFEMDotProductAux currently supports only L2 spaces with interior DOFs (no "
      50             :                "shared/constrained DOFs).");
      51           7 : }
      52             : 
      53             : void
      54           7 : MFEMDotProductAux::execute()
      55             : {
      56             :   // Project into the scalar aux result variable per element projection for L2
      57           7 :   _result_var = 0.0;
      58           7 :   _result_var.ProjectCoefficient(_final_coef);
      59           7 : }
      60             : 
      61             : #endif // MOOSE_MFEM_ENABLED

Generated by: LCOV version 1.14