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 "ScaleIntegrator.h" 13 : 14 : namespace Moose::MFEM 15 : { 16 : 17 : void 18 2 : ScaleIntegrator::SetIntRule(const mfem::IntegrationRule * ir) 19 : { 20 2 : IntRule = ir; 21 2 : _integrator->SetIntRule(ir); 22 2 : } 23 : 24 : void 25 1020251 : ScaleIntegrator::AssembleElementMatrix(const mfem::FiniteElement & el, 26 : mfem::ElementTransformation & Trans, 27 : mfem::DenseMatrix & elmat) 28 : { 29 1020251 : CheckIntegrator(); 30 1020251 : _integrator->AssembleElementMatrix(el, Trans, elmat); 31 1020251 : elmat *= _scale; 32 1020251 : } 33 : 34 : void 35 2 : ScaleIntegrator::AssembleElementMatrix2(const mfem::FiniteElement & el1, 36 : const mfem::FiniteElement & el2, 37 : mfem::ElementTransformation & Trans, 38 : mfem::DenseMatrix & elmat) 39 : { 40 2 : CheckIntegrator(); 41 2 : _integrator->AssembleElementMatrix2(el1, el2, Trans, elmat); 42 2 : elmat *= _scale; 43 2 : } 44 : 45 : void 46 22 : ScaleIntegrator::AssembleFaceMatrix(const mfem::FiniteElement & el1, 47 : const mfem::FiniteElement & el2, 48 : mfem::FaceElementTransformations & Trans, 49 : mfem::DenseMatrix & elmat) 50 : { 51 22 : CheckIntegrator(); 52 22 : _integrator->AssembleFaceMatrix(el1, el2, Trans, elmat); 53 22 : elmat *= _scale; 54 22 : } 55 : 56 : void 57 2 : ScaleIntegrator::AssemblePA(const mfem::FiniteElementSpace & fes) 58 : { 59 2 : CheckIntegrator(); 60 2 : _integrator->AssemblePA(fes); 61 2 : } 62 : 63 : void 64 30 : ScaleIntegrator::AssembleDiagonalPA(mfem::Vector & diag) 65 : { 66 30 : _integrator->AssembleDiagonalPA(diag); 67 30 : diag *= _scale; 68 30 : } 69 : 70 : void 71 2 : ScaleIntegrator::AssemblePAInteriorFaces(const mfem::FiniteElementSpace & fes) 72 : { 73 2 : _integrator->AssemblePAInteriorFaces(fes); 74 2 : } 75 : 76 : void 77 2 : ScaleIntegrator::AssemblePABoundaryFaces(const mfem::FiniteElementSpace & fes) 78 : { 79 2 : _integrator->AssemblePABoundaryFaces(fes); 80 2 : } 81 : 82 : void 83 2 : ScaleIntegrator::AddMultPA(const mfem::Vector & x, mfem::Vector & y) const 84 : { 85 : // y += Mx*scale 86 2 : mfem::Vector Mx(y.Size()); 87 2 : Mx = 0.0; 88 2 : _integrator->AddMultPA(x, Mx); 89 2 : Mx *= _scale; 90 2 : y += Mx; 91 2 : } 92 : 93 : void 94 2 : ScaleIntegrator::AddMultTransposePA(const mfem::Vector & x, mfem::Vector & y) const 95 : { 96 : // y += M^T x*scale 97 2 : mfem::Vector MTx(y.Size()); 98 2 : MTx = 0.0; 99 2 : _integrator->AddMultTransposePA(x, MTx); 100 2 : MTx *= _scale; 101 2 : y += MTx; 102 2 : } 103 : 104 : void 105 35 : ScaleIntegrator::AssembleEA(const mfem::FiniteElementSpace & fes, 106 : mfem::Vector & emat, 107 : const bool add) 108 : { 109 35 : CheckIntegrator(); 110 35 : if (add) 111 : { 112 35 : mfem::Vector emat_scale(emat.Size()); 113 35 : _integrator->AssembleEA(fes, emat_scale, false); 114 35 : emat_scale *= _scale; 115 35 : emat += emat_scale; 116 35 : } 117 : else 118 : { 119 0 : _integrator->AssembleEA(fes, emat, add); 120 0 : emat *= _scale; 121 : } 122 35 : } 123 : 124 : void 125 5 : ScaleIntegrator::AssembleMF(const mfem::FiniteElementSpace & fes) 126 : { 127 5 : CheckIntegrator(); 128 5 : _integrator->AssembleMF(fes); 129 5 : } 130 : 131 : void 132 449 : ScaleIntegrator::AddMultMF(const mfem::Vector & x, mfem::Vector & y) const 133 : { 134 : // y += Mx*scale 135 449 : mfem::Vector Mx(y.Size()); 136 449 : Mx = 0.0; 137 449 : _integrator->AddMultMF(x, Mx); 138 449 : Mx *= _scale; 139 449 : y += Mx; 140 449 : } 141 : 142 : void 143 4 : ScaleIntegrator::AssembleDiagonalMF(mfem::Vector & diag) 144 : { 145 4 : _integrator->AssembleDiagonalMF(diag); 146 4 : diag *= _scale; 147 4 : } 148 : 149 1626 : ScaleIntegrator::~ScaleIntegrator() 150 : { 151 816 : if (_own_integrator) 152 758 : delete _integrator; 153 1626 : } 154 : 155 : } // namespace Moose::MFEM 156 : 157 : #endif