forked from CEED/Laghos
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlaghost_assembly.hpp
249 lines (215 loc) · 8.39 KB
/
laghost_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
// 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_LAGHOST_ASSEMBLY
#define MFEM_LAGHOST_ASSEMBLY
#include "mfem.hpp"
#include "general/forall.hpp"
#include "linalg/dtensor.hpp"
namespace mfem
{
namespace geodynamics
{
// Container for all data needed at quadrature points.
struct QuadratureData
{
// 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 stressJinvT;
// 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;
// Quadrature data used for full/partial assembly of the stress rate operator.
DenseTensor tauJinvT;
// Quadrature data used for full/partial assembly of the body force operator.
DenseTensor buoyJinvT; // We store it (vector) as a tensor form.
// Quadrature data used for full/partial assembly of the plastic strain operator.
// DenseTensor epsJinvT;
// Quadrature data used for full/partial assembly of the plastic strain operator.
// DenseTensor plsJinvT;
// 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;
double h_est;
// mass_scale
double mscale;
double vbc_max_val;
// gravity
double gravity;
QuadratureData(int dim, int NE, int quads_per_el)
: Jac0inv(dim, dim, NE * quads_per_el),
stressJinvT(NE * quads_per_el, dim, dim),
tauJinvT(NE * quads_per_el, dim, dim),
buoyJinvT(NE * quads_per_el, dim, dim),
// epsJinvT(NE * quads_per_el, dim, dim),
// plsJinvT(NE * quads_per_el, dim, dim),
rho0DetJ0w(NE * quads_per_el) { }
void Resize(int dim, int NE, int quads_per_el)
{
Jac0inv.SetSize(dim, dim, NE * quads_per_el);
stressJinvT.SetSize(NE * quads_per_el, dim, dim);
tauJinvT.SetSize(NE * quads_per_el, dim, dim);
buoyJinvT.SetSize(NE * quads_per_el, dim, dim);
rho0DetJ0w.SetSize(NE * quads_per_el);
}
};
// This class is used only for visualization. It assembles (rho, phi) in each
// zone, which is used by LagrangianGeoOperator::ComputeDensity to do an L2
// projection of the density.
class DensityIntegrator : public LinearFormIntegrator
{
using LinearFormIntegrator::AssembleRHSElementVect;
private:
const QuadratureData &qdata;
public:
DensityIntegrator(QuadratureData &qdata) : qdata(qdata) { }
virtual void AssembleRHSElementVect(const FiniteElement &fe,
ElementTransformation &Tr,
Vector &elvect);
};
class SigmaIntegrator : public LinearFormIntegrator
{
using LinearFormIntegrator::AssembleRHSElementVect;
private:
const QuadratureData &qdata;
public:
SigmaIntegrator(QuadratureData &qdata) : qdata(qdata) { }
virtual void AssembleRHSElementVect(const FiniteElement &fe,
ElementTransformation &Tr,
Vector &elvect);
};
/*
class PlasticIntegrator : public LinearFormIntegrator
{
using LinearFormIntegrator::AssembleRHSElementVect;
private:
const QuadratureData &qdata;
public:
PlasticIntegrator(QuadratureData &qdata) : qdata(qdata) { }
virtual void AssembleRHSElementVect(const FiniteElement &fe,
ElementTransformation &Tr,
Vector &elvect);
};
*/
/*
class SigmaIntegrator : public BilinearFormIntegrator
{
private:
const QuadratureData &qdata;
public:
SigmaIntegrator(QuadratureData &qdata) : qdata(qdata) { }
virtual void AssembleElementMatrix2(const FiniteElement &trial_fe,
const FiniteElement &test_fe,
ElementTransformation &Tr,
DenseMatrix &elmat);
};
*/
// Performs full assembly for the force operator.
class ForceIntegrator : public BilinearFormIntegrator
{
private:
const QuadratureData &qdata;
public:
ForceIntegrator(QuadratureData &qdata) : qdata(qdata) { }
virtual void AssembleElementMatrix2(const FiniteElement &trial_fe,
const FiniteElement &test_fe,
ElementTransformation &Tr,
DenseMatrix &elmat);
};
class BodyForceIntegrator : public LinearFormIntegrator
{
using LinearFormIntegrator::AssembleRHSElementVect;
private:
const QuadratureData &qdata;
public:
BodyForceIntegrator(QuadratureData &qdata) : qdata(qdata) { }
virtual void AssembleRHSElementVect(const FiniteElement &fe,
ElementTransformation &Tr,
Vector &elvect);
};
// Perform patiall assembly for the stress rate operator
// This is the same as ForcePAOperator, but with different integrator
class StressPAOperator : public Operator
{
private:
const int dim, NE;
const QuadratureData &qdata;
const ParFiniteElementSpace &H1, &L2;
const Operator *H1R, *L2R;
const IntegrationRule &ir1D;
const int D1D, Q1D, L1D, H1sz, L2sz;
const DofToQuad *L2D2Q, *H1D2Q;
mutable Vector X, Y;
public:
StressPAOperator(const QuadratureData&,
ParFiniteElementSpace&,
ParFiniteElementSpace&,
const IntegrationRule&);
virtual void Mult(const Vector&, Vector&) const;
virtual void MultTranspose(const Vector&, Vector&) const;
virtual void MultTranspose(const Vector&, Vector&, const int&) const;
};
// Performs partial assembly for the force operator.
class ForcePAOperator : public Operator
{
private:
const int dim, NE;
const QuadratureData &qdata;
const ParFiniteElementSpace &H1, &L2;
const Operator *H1R, *L2R;
const IntegrationRule &ir1D;
const int D1D, Q1D, L1D, H1sz, L2sz;
const DofToQuad *L2D2Q, *H1D2Q;
mutable Vector X, Y;
public:
ForcePAOperator(const QuadratureData&,
ParFiniteElementSpace&,
ParFiniteElementSpace&,
const IntegrationRule&);
virtual void Mult(const Vector&, Vector&) const;
virtual void MultTranspose(const Vector&, Vector&) const;
};
// Performs partial assembly for the velocity mass matrix.
class MassPAOperator : public Operator
{
private:
const MPI_Comm comm;
const int dim, NE, vsize;
ParBilinearForm pabf;
int ess_tdofs_count;
Array<int> ess_tdofs;
OperatorPtr mass;
public:
MassPAOperator(ParFiniteElementSpace&, const IntegrationRule&, Coefficient&);
virtual void Mult(const Vector&, Vector&) const;
void MultFull(const Vector &x, Vector &y) const { mass->Mult(x, y); }
virtual void SetEssentialTrueDofs(Array<int>&);
virtual void EliminateRHS(Vector&) const;
const ParBilinearForm &GetBF() const { return pabf; }
};
} // namespace geodynamics
} // namespace mfem
#endif // MFEM_LAGHOST_ASSEMBLY