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 50 : ScaleIntegrator::SetIntRule(const mfem::IntegrationRule * ir)
19 : {
20 50 : IntRule = ir;
21 50 : _integrator->SetIntRule(ir);
22 50 : }
23 :
24 : void
25 1553610 : ScaleIntegrator::AssembleElementMatrix(const mfem::FiniteElement & el,
26 : mfem::ElementTransformation & Trans,
27 : mfem::DenseMatrix & elmat)
28 : {
29 1553610 : CheckIntegrator();
30 1553610 : _integrator->AssembleElementMatrix(el, Trans, elmat);
31 1553610 : elmat *= _scale;
32 1553610 : }
33 :
34 : void
35 1802 : ScaleIntegrator::AssembleElementMatrix2(const mfem::FiniteElement & el1,
36 : const mfem::FiniteElement & el2,
37 : mfem::ElementTransformation & Trans,
38 : mfem::DenseMatrix & elmat)
39 : {
40 1802 : CheckIntegrator();
41 1802 : _integrator->AssembleElementMatrix2(el1, el2, Trans, elmat);
42 1802 : elmat *= _scale;
43 1802 : }
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 26 : ScaleIntegrator::AssembleDiagonalPA(mfem::Vector & diag)
65 : {
66 26 : _integrator->AssembleDiagonalPA(diag);
67 26 : diag *= _scale;
68 26 : }
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 24 : ScaleIntegrator::AssembleEA(const mfem::FiniteElementSpace & fes,
106 : mfem::Vector & emat,
107 : const bool add)
108 : {
109 24 : CheckIntegrator();
110 24 : if (add)
111 : {
112 0 : mfem::Vector emat_scale(emat.Size());
113 0 : _integrator->AssembleEA(fes, emat_scale, false);
114 0 : emat_scale *= _scale;
115 0 : emat += emat_scale;
116 0 : }
117 : else
118 : {
119 24 : _integrator->AssembleEA(fes, emat, add);
120 24 : emat *= _scale;
121 : }
122 24 : }
123 :
124 : void
125 0 : ScaleIntegrator::AssembleEABoundary(const mfem::FiniteElementSpace & fes,
126 : mfem::Vector & emat,
127 : const bool add)
128 : {
129 0 : CheckIntegrator();
130 0 : if (add)
131 : {
132 0 : mfem::Vector emat_scale(emat.Size());
133 0 : _integrator->AssembleEABoundary(fes, emat_scale, false);
134 0 : emat_scale *= _scale;
135 0 : emat += emat_scale;
136 0 : }
137 : else
138 : {
139 0 : _integrator->AssembleEABoundary(fes, emat, add);
140 0 : emat *= _scale;
141 : }
142 0 : }
143 :
144 : void
145 4 : ScaleIntegrator::AssembleMF(const mfem::FiniteElementSpace & fes)
146 : {
147 4 : CheckIntegrator();
148 4 : _integrator->AssembleMF(fes);
149 4 : }
150 :
151 : void
152 453 : ScaleIntegrator::AddMultMF(const mfem::Vector & x, mfem::Vector & y) const
153 : {
154 : // y += Mx*scale
155 453 : mfem::Vector Mx(y.Size());
156 453 : Mx = 0.0;
157 453 : _integrator->AddMultMF(x, Mx);
158 453 : Mx *= _scale;
159 453 : y += Mx;
160 453 : }
161 :
162 : void
163 4 : ScaleIntegrator::AssembleDiagonalMF(mfem::Vector & diag)
164 : {
165 4 : _integrator->AssembleDiagonalMF(diag);
166 4 : diag *= _scale;
167 4 : }
168 :
169 2174 : ScaleIntegrator::~ScaleIntegrator()
170 : {
171 1090 : if (_own_integrator)
172 1088 : delete _integrator;
173 2174 : }
174 :
175 : } // namespace Moose::MFEM
176 :
177 : #endif
|