LCOV - code coverage report
Current view: top level - src/mfem/functions - MFEMScalarQuadratureFunctionCoefficient.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #33416 (b10b36) with base 9fbd27 Lines: 30 35 85.7 %
Date: 2026-07-23 16:15:30 Functions: 4 5 80.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 "MFEMScalarQuadratureFunctionCoefficient.h"
      13             : #include "libmesh/int_range.h"
      14             : 
      15          21 : MFEMScalarQuadratureFunctionCoefficient::MFEMScalarQuadratureFunctionCoefficient(
      16             :     mfem::Coefficient & source,
      17             :     mfem::QuadratureFunction & qf,
      18             :     UpdatePolicy update_policy,
      19          21 :     const std::string & name)
      20             :   : mfem::QuadratureFunctionCoefficient(qf),
      21             :     MFEMQuadratureFunctionCoefficientBase(update_policy, name),
      22          21 :     _source(source),
      23          21 :     _qf(qf)
      24             : {
      25          21 : }
      26             : 
      27             : void
      28         300 : MFEMScalarQuadratureFunctionCoefficient::SetTime(mfem::real_t t)
      29             : {
      30         300 :   mfem::Coefficient::SetTime(t);
      31         300 :   MarkTimeChanged();
      32         300 : }
      33             : 
      34             : mfem::real_t
      35      444242 : MFEMScalarQuadratureFunctionCoefficient::Eval(mfem::ElementTransformation & T,
      36             :                                               const mfem::IntegrationPoint & ip)
      37             : {
      38      444242 :   if (_dirty)
      39         621 :     Refresh();
      40      444242 :   CheckIntegrationRule(_qf, T, ip);
      41      444240 :   return mfem::QuadratureFunctionCoefficient::Eval(T, ip);
      42             : }
      43             : 
      44             : void
      45           0 : MFEMScalarQuadratureFunctionCoefficient::Project(mfem::QuadratureFunction & qf)
      46             : {
      47           0 :   if (_dirty)
      48           0 :     Refresh();
      49           0 :   mfem::QuadratureFunctionCoefficient::Project(qf);
      50           0 : }
      51             : 
      52             : void
      53         621 : MFEMScalarQuadratureFunctionCoefficient::Refresh()
      54             : {
      55             :   // Equivalent to _source.Project(_qf), except performed with a caller-owned element
      56             :   // transformation: the mesh-owned shared transformation used by mfem::Coefficient::Project
      57             :   // may belong to an in-flight assembly loop that is evaluating this coefficient, and
      58             :   // projecting through it would corrupt that loop's state.
      59         621 :   const mfem::QuadratureSpaceBase & qspace = *_qf.GetSpace();
      60         621 :   const mfem::Mesh & mesh = *qspace.GetMesh();
      61         621 :   mfem::IsoparametricTransformation T;
      62         621 :   mfem::Vector values;
      63         621 :   _qf.HostWrite();
      64       46460 :   for (const auto iel : libMesh::make_range(qspace.GetNE()))
      65             :   {
      66       45839 :     _qf.GetValues(iel, values);
      67       45839 :     const mfem::IntegrationRule & ir = qspace.GetIntRule(iel);
      68       45839 :     mesh.GetElementTransformation(iel, &T);
      69      420291 :     for (const auto iq : libMesh::make_range(ir.Size()))
      70             :     {
      71      374452 :       const mfem::IntegrationPoint & ip = ir[iq];
      72      374452 :       T.SetIntPoint(&ip);
      73      374452 :       values[iq] = _source.Eval(T, ip);
      74             :     }
      75             :   }
      76         621 :   _dirty = false;
      77         621 : }
      78             : 
      79             : #endif

Generated by: LCOV version 1.14