-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathc7_assembly.hpp
369 lines (302 loc) · 12 KB
/
c7_assembly.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
// Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at
// the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights
// reserved. See files LICENSE and NOTICE for details.
//
// This file is part of CEED, a collection of benchmarks, miniapps, software
// libraries and APIs for efficient high-order finite element and spectral
// element discretizations for exascale applications. For more information and
// source code availability see http://github.com/ceed.
//
// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
// a collaborative effort of two U.S. Department of Energy organizations (Office
// of Science and the National Nuclear Security Administration) responsible for
// the planning and preparation of a capable exascale ecosystem, including
// software, applications, hardware, advanced system engineering and early
// testbed platforms, in support of the nation's exascale computing imperative.
#ifndef MFEM_NTH_C7_ASSEMBLY
#define MFEM_NTH_C7_ASSEMBLY
#include "mfem.hpp"
#ifdef MFEM_USE_MPI
#include <memory>
#include <iostream>
namespace mfem
{
namespace nth
{
// Container for all data needed at quadrature points.
struct QuadratureData
{
// TODO: use QuadratureFunctions?
// Reference to physical Jacobian for the initial mesh. These are computed
// only at time zero and stored here.
DenseTensor Jac0inv;
// Quadrature data used for full/partial assembly of the force operator. At
// each quadrature point, it combines the stress, inverse Jacobian,
// determinant of the Jacobian and the integration weight. It must be
// recomputed in every time step.
DenseTensor stress1JinvT, stress0JinvT;
// Quadrature data used for full/partial assembly of the mass matrices. At
// time zero, we compute and store (rho0 * det(J0) * qp_weight) at each
// quadrature point. Note the at any other time, we can compute
// rho = rho0 * det(J0) / det(J), representing the notion of pointwise mass
// conservation.
Vector rho0DetJ0w;
// Mass integrators.
Vector nuinvrho, nutinvrho;
// The pointwise equality rho * detJ = rho0 * detJ0 is used by integrators.
// Electric and magnetic fields.
DenseMatrix Einvrho, AEinvrho, AIEinvrho, Binvrho;
// Explicit zero moment "mass" integrator.
Vector Ef1invvf0rho;
// Initial length scale. This represents a notion of local mesh size. We
// assume that all initial zones have similar size.
double h0;
// Estimate of the minimum time step over all quadrature points. This is
// recomputed at every time step to achieve adaptive time stepping.
double dt_est;
QuadratureData(int dim, int nzones, int quads_per_zone)
: Jac0inv(dim, dim, nzones * quads_per_zone),
stress1JinvT(nzones * quads_per_zone, dim, dim),
stress0JinvT(nzones * quads_per_zone, dim, dim),
rho0DetJ0w(nzones * quads_per_zone),
nuinvrho(nzones * quads_per_zone),
nutinvrho(nzones * quads_per_zone),
Einvrho(nzones * quads_per_zone, dim),
AEinvrho(nzones * quads_per_zone, dim),
AIEinvrho(nzones * quads_per_zone, dim),
Binvrho(nzones * quads_per_zone, dim),
Ef1invvf0rho(nzones * quads_per_zone) { }
};
// This class is used only for visualization. It assembles (rho, phi) in each
// zone, which is used by LagrangianHydroOperator::ComputeDensity to do an L2
// projection of the density.
class DensityIntegrator : public LinearFormIntegrator
{
private:
const QuadratureData &quad_data;
public:
DensityIntegrator(QuadratureData &quad_data_) : quad_data(quad_data_) { }
virtual void AssembleRHSElementVect(const FiniteElement &fe,
ElementTransformation &Tr,
Vector &elvect);
};
// Assembles element contributions to the global velocity force matrix.
// This class is used for the full assembly case; it's not used with partial
// assembly.
class Mass0Integrator : public BilinearFormIntegrator
{
protected:
const QuadratureData &quad_data;
public:
Mass0Integrator(QuadratureData &quad_data_) : quad_data(quad_data_) { }
virtual void AssembleElementMatrix(const FiniteElement &fe,
ElementTransformation &Trans,
DenseMatrix &elmat)
{ AssembleElementMatrix2(fe, fe, Trans, elmat); }
virtual void AssembleElementMatrix2(const FiniteElement &trial_fe,
const FiniteElement &test_fe,
ElementTransformation &Trans,
DenseMatrix &elmat);
virtual double GetIntegrator(int i) = 0;
};
// Assembles element contributions to the global velocity force matrix.
// This class is used for the full assembly case; it's not used with partial
// assembly.
class Mass1Integrator : public BilinearFormIntegrator
{
protected:
const QuadratureData &quad_data;
public:
Mass1Integrator(QuadratureData &quad_data_) : quad_data(quad_data_) { }
virtual void AssembleElementMatrix(const FiniteElement &fe,
ElementTransformation &Trans,
DenseMatrix &elmat)
{ AssembleElementMatrix2(fe, fe, Trans, elmat); }
virtual void AssembleElementMatrix2(const FiniteElement &trial_fe,
const FiniteElement &test_fe,
ElementTransformation &Trans,
DenseMatrix &elmat);
virtual double GetIntegrator(int i) = 0;
};
// Assembles element contributions to the global velocity force matrix.
// This class is used for the full assembly case; it's not used with partial
// assembly.
class DivIntegrator : public BilinearFormIntegrator
{
protected:
const QuadratureData &quad_data;
public:
DivIntegrator(QuadratureData &quad_data_) : quad_data(quad_data_) { }
virtual void AssembleElementMatrix2(const FiniteElement &trial_fe,
const FiniteElement &test_fe,
ElementTransformation &Trans,
DenseMatrix &elmat);
virtual double GetIntegrator(int q, int vd, int gd) = 0;
};
// Assembles element contributions to the global velocity force matrix.
// This class is used for the full assembly case; it's not used with partial
// assembly.
class VdotIntegrator : public BilinearFormIntegrator
{
protected:
const QuadratureData &quad_data;
public:
VdotIntegrator(QuadratureData &quad_data_) : quad_data(quad_data_) { }
virtual void AssembleElementMatrix2(const FiniteElement &trial_fe,
const FiniteElement &test_fe,
ElementTransformation &Trans,
DenseMatrix &elmat);
virtual double GetIntegrator(int q, int vd) = 0;
};
// Assembles element contributions to the global velocity force matrix.
// This class is used for the full assembly case; it's not used with partial
// assembly.
class VcrossIntegrator : public BilinearFormIntegrator
{
protected:
const QuadratureData &quad_data;
public:
VcrossIntegrator(QuadratureData &quad_data_) : quad_data(quad_data_) { }
virtual void AssembleElementMatrix(const FiniteElement &fe,
ElementTransformation &Trans,
DenseMatrix &elmat)
{ AssembleElementMatrix2(fe, fe, Trans, elmat); }
virtual void AssembleElementMatrix2(const FiniteElement &trial_fe,
const FiniteElement &test_fe,
ElementTransformation &Trans,
DenseMatrix &elmat);
virtual double GetIntegrator(int q, int vd) = 0;
};
// Assembles element contributions to the global velocity force matrix.
// This class is used for the full assembly case; it's not used with partial
// assembly.
class Mass0cIntegrator : public Mass0Integrator
{
private:
public:
Mass0cIntegrator(QuadratureData &quad_data_) :
Mass0Integrator(quad_data_) { }
double GetIntegrator(int i);
};
// Assembles element contributions to the global velocity force matrix.
// This class is used for the full assembly case; it's not used with partial
// assembly.
class Mass0NuIntegrator : public Mass0Integrator
{
private:
public:
Mass0NuIntegrator(QuadratureData &quad_data_) :
Mass0Integrator(quad_data_) { }
double GetIntegrator(int i);
};
// Assembles element contributions to the global velocity force matrix.
// This class is used for the full assembly case; it's not used with partial
// assembly.
class ExplMass0Integrator : public Mass0Integrator
{
private:
public:
ExplMass0Integrator(QuadratureData &quad_data_) :
Mass0Integrator(quad_data_) { }
double GetIntegrator(int i);
};
// Assembles element contributions to the global velocity force matrix.
// This class is used for the full assembly case; it's not used with partial
// assembly.
class Mass1cIntegrator : public Mass1Integrator
{
private:
public:
Mass1cIntegrator(QuadratureData &quad_data_) :
Mass1Integrator(quad_data_) { }
double GetIntegrator(int i);
};
// Assembles element contributions to the global velocity force matrix.
// This class is used for the full assembly case; it's not used with partial
// assembly.
class Mass1NuIntegrator : public Mass1Integrator
{
private:
public:
Mass1NuIntegrator(QuadratureData &quad_data_) :
Mass1Integrator(quad_data_) { }
double GetIntegrator(int i);
};
// Assembles element contributions to the global velocity force matrix.
// This class is used for the full assembly case; it's not used with partial
// assembly.
class Mass1NutIntegrator : public Mass1Integrator
{
private:
public:
Mass1NutIntegrator(QuadratureData &quad_data_) :
Mass1Integrator(quad_data_) { }
double GetIntegrator(int i);
};
// Assembles element contributions to the global temperature force matrix.
// This class is used for the full assembly case; it's not used with partial
// assembly.
class Divf0Integrator : public DivIntegrator
{
private:
public:
Divf0Integrator(QuadratureData &quad_data_) : DivIntegrator(quad_data_) { }
double GetIntegrator(int q, int vd, int gd);
};
// Assembles element contributions to the global velocity force matrix.
// This class is used for the full assembly case; it's not used with partial
// assembly.
class Divf1Integrator : public DivIntegrator
{
private:
public:
Divf1Integrator(QuadratureData &quad_data_) : DivIntegrator(quad_data_) { }
double GetIntegrator(int q, int vd, int gd);
};
// Assembles element contributions to the global temperature force matrix.
// This class is used for the full assembly case; it's not used with partial
// assembly.
class EfieldIntegrator : public VdotIntegrator
{
private:
public:
EfieldIntegrator(QuadratureData &quad_data_) : VdotIntegrator(quad_data_) { }
double GetIntegrator(int q, int vd);
};
// Assembles element contributions to the global temperature force matrix.
// This class is used for the full assembly case; it's not used with partial
// assembly.
class AEfieldIntegrator : public VdotIntegrator
{
private:
public:
AEfieldIntegrator(QuadratureData &quad_data_) :
VdotIntegrator(quad_data_) { }
double GetIntegrator(int q, int vd);
};
// Assembles element contributions to the global temperature force matrix.
// This class is used for the full assembly case; it's not used with partial
// assembly.
class AIEfieldIntegrator : public VdotIntegrator
{
private:
public:
AIEfieldIntegrator(QuadratureData &quad_data_) :
VdotIntegrator(quad_data_) { }
double GetIntegrator(int q, int vd);
};
// Assembles element contributions to the global temperature force matrix.
// This class is used for the full assembly case; it's not used with partial
// assembly.
class BfieldIntegrator : public VcrossIntegrator
{
private:
public:
BfieldIntegrator(QuadratureData &quad_data_) :
VcrossIntegrator(quad_data_) { }
double GetIntegrator(int q, int vd);
};
} // namespace nth
} // namespace mfem
#endif // MFEM_USE_MPI
#endif // MFEM_NTH_C7_ASSEMBLY