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 "MFEMVectorQuadratureFunctionCoefficient.h" 13 : #include "libmesh/int_range.h" 14 : 15 13 : MFEMVectorQuadratureFunctionCoefficient::MFEMVectorQuadratureFunctionCoefficient( 16 : mfem::VectorCoefficient & source, 17 : mfem::QuadratureFunction & qf, 18 : UpdatePolicy update_policy, 19 13 : const std::string & name) 20 : : mfem::VectorQuadratureFunctionCoefficient(qf), 21 : MFEMQuadratureFunctionCoefficientBase(update_policy, name), 22 13 : _source(source), 23 13 : _qf(qf) 24 : { 25 13 : } 26 : 27 : void 28 0 : MFEMVectorQuadratureFunctionCoefficient::SetTime(mfem::real_t t) 29 : { 30 0 : mfem::VectorCoefficient::SetTime(t); 31 0 : MarkTimeChanged(); 32 0 : } 33 : 34 : void 35 110592 : MFEMVectorQuadratureFunctionCoefficient::Eval(mfem::Vector & V, 36 : mfem::ElementTransformation & T, 37 : const mfem::IntegrationPoint & ip) 38 : { 39 110592 : if (_dirty) 40 13 : Refresh(); 41 110592 : CheckIntegrationRule(_qf, T, ip); 42 110592 : mfem::VectorQuadratureFunctionCoefficient::Eval(V, T, ip); 43 110592 : } 44 : 45 : void 46 0 : MFEMVectorQuadratureFunctionCoefficient::Project(mfem::QuadratureFunction & qf) 47 : { 48 0 : if (_dirty) 49 0 : Refresh(); 50 0 : mfem::VectorQuadratureFunctionCoefficient::Project(qf); 51 0 : } 52 : 53 : void 54 13 : MFEMVectorQuadratureFunctionCoefficient::Refresh() 55 : { 56 : // Equivalent to _source.Project(_qf), except performed with a caller-owned element 57 : // transformation: the mesh-owned shared transformation used by mfem::VectorCoefficient::Project 58 : // may belong to an in-flight assembly loop that is evaluating this coefficient, and 59 : // projecting through it would corrupt that loop's state. 60 13 : const mfem::QuadratureSpaceBase & qspace = *_qf.GetSpace(); 61 13 : const mfem::Mesh & mesh = *qspace.GetMesh(); 62 13 : mfem::IsoparametricTransformation T; 63 13 : mfem::DenseMatrix values; 64 13 : mfem::Vector col; 65 13 : _qf.HostWrite(); 66 27661 : for (const auto iel : libMesh::make_range(qspace.GetNE())) 67 : { 68 27648 : _qf.GetValues(iel, values); 69 27648 : const mfem::IntegrationRule & ir = qspace.GetIntRule(iel); 70 27648 : mesh.GetElementTransformation(iel, &T); 71 138240 : for (const auto iq : libMesh::make_range(ir.Size())) 72 : { 73 110592 : const mfem::IntegrationPoint & ip = ir[iq]; 74 110592 : T.SetIntPoint(&ip); 75 110592 : values.GetColumnReference(iq, col); 76 110592 : _source.Eval(col, T, ip); 77 : } 78 : } 79 13 : _dirty = false; 80 13 : } 81 : 82 : #endif