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 1 : ScaleIntegrator::SetIntRule(const mfem::IntegrationRule * ir) 19 : { 20 1 : IntRule = ir; 21 1 : _integrator->SetIntRule(ir); 22 1 : } 23 : 24 : void 25 323393 : ScaleIntegrator::AssembleElementMatrix(const mfem::FiniteElement & el, 26 : mfem::ElementTransformation & Trans, 27 : mfem::DenseMatrix & elmat) 28 : { 29 323393 : CheckIntegrator(); 30 323393 : _integrator->AssembleElementMatrix(el, Trans, elmat); 31 323393 : elmat *= _scale; 32 323393 : } 33 : 34 : void 35 1 : ScaleIntegrator::AssembleElementMatrix2(const mfem::FiniteElement & el1, 36 : const mfem::FiniteElement & el2, 37 : mfem::ElementTransformation & Trans, 38 : mfem::DenseMatrix & elmat) 39 : { 40 1 : CheckIntegrator(); 41 1 : _integrator->AssembleElementMatrix2(el1, el2, Trans, elmat); 42 1 : elmat *= _scale; 43 1 : } 44 : 45 : void 46 11 : ScaleIntegrator::AssembleFaceMatrix(const mfem::FiniteElement & el1, 47 : const mfem::FiniteElement & el2, 48 : mfem::FaceElementTransformations & Trans, 49 : mfem::DenseMatrix & elmat) 50 : { 51 11 : CheckIntegrator(); 52 11 : _integrator->AssembleFaceMatrix(el1, el2, Trans, elmat); 53 11 : elmat *= _scale; 54 11 : } 55 : 56 : void 57 1 : ScaleIntegrator::AssemblePA(const mfem::FiniteElementSpace & fes) 58 : { 59 1 : CheckIntegrator(); 60 1 : _integrator->AssemblePA(fes); 61 1 : } 62 : 63 : void 64 33 : ScaleIntegrator::AssembleDiagonalPA(mfem::Vector & diag) 65 : { 66 33 : _integrator->AssembleDiagonalPA(diag); 67 33 : diag *= _scale; 68 33 : } 69 : 70 : void 71 1 : ScaleIntegrator::AssemblePAInteriorFaces(const mfem::FiniteElementSpace & fes) 72 : { 73 1 : _integrator->AssemblePAInteriorFaces(fes); 74 1 : } 75 : 76 : void 77 1 : ScaleIntegrator::AssemblePABoundaryFaces(const mfem::FiniteElementSpace & fes) 78 : { 79 1 : _integrator->AssemblePABoundaryFaces(fes); 80 1 : } 81 : 82 : void 83 1 : ScaleIntegrator::AddMultPA(const mfem::Vector & x, mfem::Vector & y) const 84 : { 85 : // y += Mx*scale 86 1 : mfem::Vector Mx(y.Size()); 87 1 : Mx = 0.0; 88 1 : _integrator->AddMultPA(x, Mx); 89 1 : Mx *= _scale; 90 1 : y += Mx; 91 1 : } 92 : 93 : void 94 1 : ScaleIntegrator::AddMultTransposePA(const mfem::Vector & x, mfem::Vector & y) const 95 : { 96 : // y += M^T x*scale 97 1 : mfem::Vector MTx(y.Size()); 98 1 : MTx = 0.0; 99 1 : _integrator->AddMultTransposePA(x, MTx); 100 1 : MTx *= _scale; 101 1 : y += MTx; 102 1 : } 103 : 104 : void 105 40 : ScaleIntegrator::AssembleEA(const mfem::FiniteElementSpace & fes, 106 : mfem::Vector & emat, 107 : const bool add) 108 : { 109 40 : CheckIntegrator(); 110 40 : if (add) 111 : { 112 40 : mfem::Vector emat_scale(emat.Size()); 113 40 : _integrator->AssembleEA(fes, emat_scale, false); 114 40 : emat_scale *= _scale; 115 40 : emat += emat_scale; 116 40 : } 117 : else 118 : { 119 0 : _integrator->AssembleEA(fes, emat, add); 120 0 : emat *= _scale; 121 : } 122 40 : } 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 445 : ScaleIntegrator::~ScaleIntegrator() 150 : { 151 224 : if (_own_integrator) 152 191 : delete _integrator; 153 445 : } 154 : 155 : } // namespace Moose::MFEM 156 : 157 : #endif