MFEM v4.9.0
Finite element discretization library
Loading...
Searching...
No Matches
bilininteg_curlcurl_pa.cpp
Go to the documentation of this file.
1// Copyright (c) 2010-2025, Lawrence Livermore National Security, LLC. Produced
2// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3// LICENSE and NOTICE for details. LLNL-CODE-806117.
4//
5// This file is part of the MFEM library. For more information and source code
6// availability visit https://mfem.org.
7//
8// MFEM is free software; you can redistribute it and/or modify it under the
9// terms of the BSD-3 license. We welcome feedback and contributions, see file
10// CONTRIBUTING.md for details.
11
12#include "../qfunction.hpp"
14
15namespace mfem
16{
17
18CurlCurlIntegrator::CurlCurlIntegrator() : Q(nullptr), DQ(nullptr), MQ(nullptr)
19{
20 static Kernels kernels;
21}
22
24 const IntegrationRule *ir)
25 : BilinearFormIntegrator(ir), Q(&q), DQ(nullptr), MQ(nullptr)
26{
27 static Kernels kernels;
28}
29
31 const IntegrationRule *ir)
32 : BilinearFormIntegrator(ir), Q(nullptr), DQ(&dq), MQ(nullptr)
33{
34 static Kernels kernels;
35}
36
38 const IntegrationRule *ir)
39 : BilinearFormIntegrator(ir), Q(nullptr), DQ(nullptr), MQ(&mq)
40{
41 static Kernels kernels;
42}
43
44/// \cond DO_NOT_DOCUMENT
45
46CurlCurlIntegrator::Kernels::Kernels()
47{
52}
53
55CurlCurlIntegrator::ApplyPAKernels::Fallback(int DIM, int, int)
56{
57 if (DIM == 2) { return internal::PACurlCurlApply2D; }
58 else if (DIM == 3)
59 {
61 {
62 return internal::SmemPACurlCurlApply3D;
63 }
64 else
65 {
66 return internal::PACurlCurlApply3D;
67 }
68 }
69 else { MFEM_ABORT(""); }
70}
71
73CurlCurlIntegrator::DiagonalPAKernels::Fallback(int DIM, int, int)
74{
75 if (DIM == 2)
76 {
77 return internal::PACurlCurlAssembleDiagonal2D;
78 }
79 else if (DIM == 3)
80 {
82 {
83 return internal::SmemPACurlCurlAssembleDiagonal3D;
84 }
85 else
86 {
87 return internal::PACurlCurlAssembleDiagonal3D;
88 }
89 }
90 else
91 {
92 MFEM_ABORT("");
93 }
94}
95
96/// \endcond DO_NOT_DOCUMENT
97
99{
100 // Assumes tensor-product elements
101 Mesh *mesh = fes.GetMesh();
102 const FiniteElement *fel = fes.GetTypicalFE();
103
104 const VectorTensorFiniteElement *el =
105 dynamic_cast<const VectorTensorFiniteElement*>(fel);
106 MFEM_VERIFY(el != NULL, "Only VectorTensorFiniteElement is supported!");
107
108 const IntegrationRule *ir
111
112 const int dims = el->GetDim();
113 MFEM_VERIFY(dims == 2 || dims == 3, "");
114
115 nq = ir->GetNPoints();
116 dim = mesh->Dimension();
117 MFEM_VERIFY(dim == 2 || dim == 3, "");
118
119 ne = fes.GetNE();
123 dofs1D = mapsC->ndof;
124 quad1D = mapsC->nqpt;
125
126 MFEM_VERIFY(dofs1D == mapsO->ndof + 1 && quad1D == mapsO->nqpt, "");
127
128 QuadratureSpace qs(*mesh, *ir);
130 if (Q) { coeff.Project(*Q); }
131 else if (MQ) { coeff.ProjectTranspose(*MQ); }
132 else if (DQ) { coeff.Project(*DQ); }
133 else { coeff.SetConstant(1.0); }
134
135 const int coeff_dim = coeff.GetVDim();
136 symmetric = (coeff_dim != dim*dim);
137 const int sym_dims = (dims * (dims + 1)) / 2; // 1x1: 1, 2x2: 3, 3x3: 6
138 const int ndata = (dim == 2) ? 1 : (symmetric ? sym_dims : dim*dim);
140
142 {
143 MFEM_ABORT("Unknown kernel.");
144 }
145
146 if (dim == 3)
147 {
148 internal::PACurlCurlSetup3D(quad1D, coeff_dim, ne, ir->GetWeights(), geom->J,
149 coeff, pa_data);
150 }
151 else
152 {
153 internal::PACurlCurlSetup2D(quad1D, ne, ir->GetWeights(), geom->J, coeff,
154 pa_data);
155 }
156}
157
159{
160 DiagonalPAKernels::Run(dim, dofs1D, quad1D, dofs1D, quad1D, symmetric, ne,
161 mapsO->B, mapsC->B, mapsO->G, mapsC->G, pa_data,
162 diag);
163}
164
166{
167 ApplyPAKernels::Run(dim, dofs1D, quad1D, dofs1D, quad1D, symmetric, ne,
168 mapsO->B, mapsC->B, mapsO->Bt, mapsC->Bt, mapsC->G,
169 mapsC->Gt, pa_data, x, y, false);
170}
171
173{
174 Vector abs_pa_data(pa_data);
175 abs_pa_data.Abs();
176 auto absO = mapsO->Abs();
177 auto absC = mapsC->Abs();
178
179 ApplyPAKernels::Run(dim, dofs1D, quad1D, dofs1D, quad1D, symmetric, ne,
180 absO.B, absC.B, absO.Bt, absC.Bt, absC.G, absC.Gt,
181 abs_pa_data, x, y, true);
182}
183
184} // namespace mfem
Abstract base class BilinearFormIntegrator.
Class to represent a coefficient evaluated at quadrature points.
void SetConstant(real_t constant)
Set this vector to the given constant.
void Project(Coefficient &coeff)
Evaluate the given Coefficient at the quadrature points defined by qs.
int GetVDim() const
Return the number of values per quadrature point.
void ProjectTranspose(MatrixCoefficient &coeff)
Project the transpose of coeff.
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
const GeometricFactors * geom
Not owned.
void AddAbsMultPA(const Vector &x, Vector &y) const override
static void AddSpecialization()
bool symmetric
False if using a nonsymmetric matrix coefficient.
void(*)(const int, const int, const bool, const int, const Array< real_t > &, const Array< real_t > &, const Array< real_t > &, const Array< real_t > &, const Vector &, Vector &) DiagonalKernelType
arguments: d1d, q1d, symmetric, ne, Bo, Bc, Go, Gc, pa_data, diag
MatrixCoefficient * MQ
void(*)( const int, const int, const bool, const int, const Array< real_t > &, const Array< real_t > &, const Array< real_t > &, const Array< real_t > &, const Array< real_t > &, const Array< real_t > &, const Vector &, const Vector &, Vector &, const bool) ApplyKernelType
const DofToQuad * mapsC
Not owned. DOF-to-quad map, closed.
void AddMultPA(const Vector &x, Vector &y) const override
Method for partially assembled action.
void AssembleDiagonalPA(Vector &diag) override
Assemble diagonal and add it to Vector diag.
const DofToQuad * mapsO
Not owned. DOF-to-quad map, open.
void AssemblePA(const FiniteElementSpace &fes) override
Method defining partial assembly.
DiagonalMatrixCoefficient * DQ
static MemoryType GetMemoryType()
(DEPRECATED) Equivalent to GetDeviceMemoryType().
Definition device.hpp:281
static bool Allows(unsigned long b_mask)
Return true if any of the backends in the backend mask, b_mask, are allowed.
Definition device.hpp:262
Array< real_t > G
Gradients/divergences/curls of basis functions evaluated at quadrature points.
Definition fe_base.hpp:214
@ TENSOR
Tensor product representation using 1D matrices/tensors with dimensions using 1D number of quadrature...
Definition fe_base.hpp:165
Array< real_t > B
Basis functions evaluated at quadrature points.
Definition fe_base.hpp:193
int ndof
Number of degrees of freedom = number of basis functions. When mode is TENSOR, this is the 1D number.
Definition fe_base.hpp:178
Array< real_t > Gt
Transpose of G.
Definition fe_base.hpp:221
int nqpt
Number of quadrature points. When mode is TENSOR, this is the 1D number.
Definition fe_base.hpp:182
Array< real_t > Bt
Transpose of B.
Definition fe_base.hpp:199
DofToQuad Abs() const
Returns absolute value of the maps.
Definition fe_base.cpp:23
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition fespace.hpp:208
int GetNE() const
Returns number of elements in the mesh.
Definition fespace.hpp:869
Mesh * GetMesh() const
Returns the mesh.
Definition fespace.hpp:644
const FiniteElement * GetTypicalFE() const
Return GetFE(0) if the local mesh is not empty; otherwise return a typical FE based on the Geometry t...
Definition fespace.cpp:3860
Abstract class for all finite elements.
Definition fe_base.hpp:247
int GetDerivType() const
Returns the FiniteElement::DerivType of the element describing the spatial derivative method implemen...
Definition fe_base.hpp:368
int GetDim() const
Returns the reference space dimension for the finite element.
Definition fe_base.hpp:324
@ CURL
Implements CalcCurlShape methods.
Definition fe_base.hpp:310
Vector J
Jacobians of the element transformations at all quadrature points.
Definition mesh.hpp:3115
Class for an integration rule - an Array of IntegrationPoint.
Definition intrules.hpp:100
int GetNPoints() const
Returns the number of the points in the integration rule.
Definition intrules.hpp:256
const Array< real_t > & GetWeights() const
Return the quadrature weights in a contiguous array.
Definition intrules.cpp:86
const IntegrationRule * IntRule
static const IntegrationRule & GetRule(const FiniteElement &trial_fe, const FiniteElement &test_fe, const ElementTransformation &Trans)
Base class for Matrix Coefficients that optionally depend on time and space.
Mesh data type.
Definition mesh.hpp:65
int Dimension() const
Dimension of the reference space used within the elements.
Definition mesh.hpp:1306
ElementTransformation * GetTypicalElementTransformation()
If the local mesh is not empty return GetElementTransformation(0); otherwise, return the identity tra...
Definition mesh.cpp:393
const GeometricFactors * GetGeometricFactors(const IntegrationRule &ir, const int flags, MemoryType d_mt=MemoryType::DEFAULT)
Return the mesh geometric factors corresponding to the given integration rule.
Definition mesh.cpp:883
Class representing the storage layout of a QuadratureFunction.
Definition qspace.hpp:164
Base class for vector Coefficients that optionally depend on time and space.
const DofToQuad & GetDofToQuadOpen(const IntegrationRule &ir, DofToQuad::Mode mode) const
Definition fe_base.hpp:1365
const DofToQuad & GetDofToQuad(const IntegrationRule &ir, DofToQuad::Mode mode) const override
Return a DofToQuad structure corresponding to the given IntegrationRule using the given DofToQuad::Mo...
Definition fe_base.hpp:1357
Vector data type.
Definition vector.hpp:82
void Abs()
(*this)(i) = abs((*this)(i))
Definition vector.cpp:392
void SetSize(int s)
Resize the vector to size s.
Definition vector.hpp:584
constexpr int DIM
@ SYMMETRIC
Store the triangular part of symmetric matrices.
@ DEVICE_MASK
Biwise-OR of all device backends.
Definition device.hpp:99