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 1602 : ScaleIntegrator::AssembleElementMatrix2(const mfem::FiniteElement & el1,
36 : const mfem::FiniteElement & el2,
37 : mfem::ElementTransformation & Trans,
38 : mfem::DenseMatrix & elmat)
39 : {
40 1602 : CheckIntegrator();
41 1602 : _integrator->AssembleElementMatrix2(el1, el2, Trans, elmat);
42 1602 : elmat *= _scale;
43 1602 : }
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 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 5 : ScaleIntegrator::AssembleMF(const mfem::FiniteElementSpace & fes)
146 : {
147 5 : CheckIntegrator();
148 5 : _integrator->AssembleMF(fes);
149 5 : }
150 :
151 : void
152 449 : ScaleIntegrator::AddMultMF(const mfem::Vector & x, mfem::Vector & y) const
153 : {
154 : // y += Mx*scale
155 449 : mfem::Vector Mx(y.Size());
156 449 : Mx = 0.0;
157 449 : _integrator->AddMultMF(x, Mx);
158 449 : Mx *= _scale;
159 449 : y += Mx;
160 449 : }
161 :
162 : void
163 4 : ScaleIntegrator::AssembleDiagonalMF(mfem::Vector & diag)
164 : {
165 4 : _integrator->AssembleDiagonalMF(diag);
166 4 : diag *= _scale;
167 4 : }
168 :
169 1658 : ScaleIntegrator::~ScaleIntegrator()
170 : {
171 832 : if (_own_integrator)
172 4 : delete _integrator;
173 1658 : }
174 :
175 : } // namespace Moose::MFEM
176 :
177 : #endif
|