MFEM v4.10.0
Finite element discretization library
Loading...
Searching...
No Matches
bilininteg_vectorfediv_pa.cpp
Go to the documentation of this file.
1// Copyright (c) 2010-2026, 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 "../bilininteg.hpp"
13#include "../gridfunc.hpp"
14#include "../qfunction.hpp"
16
17namespace mfem
18{
19
20void
22 const FiniteElementSpace &test_fes)
23{
24 // Assumes tensor-product elements, with a vector test space and
25 // scalar trial space.
26 Mesh *mesh = trial_fes.GetMesh();
27 const FiniteElement *trial_fel = trial_fes.GetTypicalFE();
28 const FiniteElement *test_fel = test_fes.GetTypicalFE();
29
30 const VectorTensorFiniteElement *trial_el =
31 dynamic_cast<const VectorTensorFiniteElement*>(trial_fel);
32 MFEM_VERIFY(trial_el != NULL, "Only VectorTensorFiniteElement is supported!");
33
34 const NodalTensorFiniteElement *test_el =
35 dynamic_cast<const NodalTensorFiniteElement*>(test_fel);
36 MFEM_VERIFY(test_el != NULL, "Only NodalTensorFiniteElement is supported!");
37
39 *trial_el, *trial_el,
41
42 const int dims = trial_el->GetDim();
43 MFEM_VERIFY(dims == 2 || dims == 3, "");
44
45 const int nq = ir->GetNPoints();
46 dim = mesh->Dimension();
47 MFEM_VERIFY(dim == 2 || dim == 3, "");
48
49 MFEM_VERIFY(trial_el->GetOrder() == test_el->GetOrder() + 1, "");
50
51 ne = trial_fes.GetNE();
52 mapsC = &trial_el->GetDofToQuad(*ir, DofToQuad::TENSOR);
53 mapsO = &trial_el->GetDofToQuadOpen(*ir, DofToQuad::TENSOR);
54 dofs1D = mapsC->ndof;
55 quad1D = mapsC->nqpt;
56
57 L2mapsO = &test_el->GetDofToQuad(*ir, DofToQuad::TENSOR);
58 L2dofs1D = L2mapsO->ndof;
59
60 MFEM_VERIFY(dofs1D == mapsO->ndof + 1 && quad1D == mapsO->nqpt, "");
61 if (dim == 2)
62 {
63 MFEM_VERIFY(nq == quad1D * quad1D, "");
64 }
65 else
66 {
67 MFEM_VERIFY(nq == quad1D * quad1D * quad1D, "");
68 }
69
70 pa_data.SetSize(nq * ne, Device::GetMemoryType());
71
72 QuadratureSpace qs(*mesh, *ir);
74
75 const GeometricFactors *geom = nullptr;
76 if (test_el->GetMapType() == FiniteElement::INTEGRAL)
77 {
79 }
80
81 if (trial_el->GetDerivType() == mfem::FiniteElement::DIV && dim == 3)
82 {
83 internal::PAHdivL2Setup3D(quad1D, ne, ir->GetWeights(), coeff, pa_data,
84 geom);
85 }
86 else if (trial_el->GetDerivType() == mfem::FiniteElement::DIV && dim == 2)
87 {
88 internal::PAHdivL2Setup2D(quad1D, ne, ir->GetWeights(), coeff, pa_data,
89 geom);
90 }
91 else
92 {
93 MFEM_ABORT("Unknown kernel.");
94 }
95}
96
98 Vector &diag)
99{
100 if (dim == 3)
101 {
102 internal::PAHdivL2AssembleDiagonal_ADAt_3D(dofs1D, quad1D, L2dofs1D, ne,
103 L2mapsO->B,
104 mapsC->Gt, mapsO->Bt, pa_data, D, diag);
105 }
106 else if (dim == 2)
107 {
108 internal::PAHdivL2AssembleDiagonal_ADAt_2D(dofs1D, quad1D, L2dofs1D, ne,
109 L2mapsO->B,
110 mapsC->Gt, mapsO->Bt, pa_data, D, diag);
111 }
112 else
113 {
114 MFEM_ABORT("Unsupported dimension!");
115 }
116}
117
119{
120 if (dim == 3)
121 {
122 internal::PAHdivL2Apply3D(dofs1D, quad1D, L2dofs1D, ne, mapsO->B, mapsC->G,
123 L2mapsO->Bt, pa_data, x, y);
124 }
125 else if (dim == 2)
126 {
127 internal::PAHdivL2Apply2D(dofs1D, quad1D, L2dofs1D, ne, mapsO->B, mapsC->G,
128 L2mapsO->Bt, pa_data, x, y);
129 }
130 else
131 {
132 MFEM_ABORT("Unsupported dimension!");
133 }
134}
135
137 Vector &y) const
138{
139 if (dim == 3)
140 {
141 internal::PAHdivL2ApplyTranspose3D(dofs1D, quad1D, L2dofs1D, ne, L2mapsO->B,
142 mapsC->Gt, mapsO->Bt, pa_data, x, y);
143 }
144 else if (dim == 2)
145 {
146 internal::PAHdivL2ApplyTranspose2D(dofs1D, quad1D, L2dofs1D, ne, L2mapsO->B,
147 mapsC->Gt, mapsO->Bt, pa_data, x, y);
148 }
149 else
150 {
151 MFEM_ABORT("Unsupported dimension!");
152 }
153}
154
155} // namespace mfem
Class to represent a coefficient evaluated at quadrature points.
static MemoryType GetMemoryType()
(DEPRECATED) Equivalent to GetDeviceMemoryType().
Definition device.hpp:302
Array< real_t > G
Gradients/divergences/curls of basis functions evaluated at quadrature points.
Definition fe_base.hpp:222
@ 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:201
int ndof
Number of degrees of freedom = number of basis functions. When mode is TENSOR, this is the 1D number.
Definition fe_base.hpp:186
Array< real_t > Gt
Transpose of G.
Definition fe_base.hpp:229
int nqpt
Number of quadrature points. When mode is TENSOR, this is the 1D number.
Definition fe_base.hpp:190
Array< real_t > Bt
Transpose of B.
Definition fe_base.hpp:207
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition fespace.hpp:210
int GetNE() const
Returns number of elements in the mesh.
Definition fespace.hpp:867
Mesh * GetMesh() const
Returns the mesh.
Definition fespace.hpp:639
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:3896
Abstract class for all finite elements.
Definition fe_base.hpp:294
int GetOrder() const
Returns the order of the finite element. In the case of anisotropic orders, returns the maximum order...
Definition fe_base.hpp:414
int GetDerivType() const
Returns the FiniteElement::DerivType of the element describing the spatial derivative method implemen...
Definition fe_base.hpp:441
int GetDim() const
Returns the reference space dimension for the finite element.
Definition fe_base.hpp:381
int GetMapType() const
Returns the FiniteElement::MapType of the element describing how reference functions are mapped to ph...
Definition fe_base.hpp:436
@ DIV
Implements CalcDivShape methods.
Definition fe_base.hpp:366
Structure for storing mesh geometric factors: coordinates, Jacobians, and determinants of the Jacobia...
Definition mesh.hpp:3119
Class for an integration rule - an Array of IntegrationPoint.
Definition intrules.hpp:96
int GetNPoints() const
Returns the number of the points in the integration rule.
Definition intrules.hpp:255
const Array< real_t > & GetWeights() const
Return the quadrature weights in a contiguous array.
Definition intrules.cpp:98
const IntegrationRule * IntRule
static const IntegrationRule & GetRule(const FiniteElement &trial_fe, const FiniteElement &test_fe, const ElementTransformation &Trans, const bool stroud=false)
Mesh data type.
Definition mesh.hpp:67
int Dimension() const
Dimension of the reference space used within the elements.
Definition mesh.hpp:1314
ElementTransformation * GetTypicalElementTransformation()
If the local mesh is not empty return GetElementTransformation(0); otherwise, return the identity tra...
Definition mesh.cpp:394
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:958
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.cpp:2766
Class representing the storage layout of a QuadratureFunction.
Definition qspace.hpp:164
void AddMultPA(const Vector &, Vector &) const override
Method for partially assembled action.
void AddMultTransposePA(const Vector &, Vector &) const override
Method for partially assembled transposed action.
void AssemblePA(const FiniteElementSpace &trial_fes, const FiniteElementSpace &test_fes) override
void AssembleDiagonalPA_ADAt(const Vector &D, Vector &diag) override
Assemble diagonal of ( is this integrator) and add it to diag.
const DofToQuad & GetDofToQuadOpen(const IntegrationRule &ir, DofToQuad::Mode mode) const
Definition fe_base.hpp:1442
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:1434
Vector data type.
Definition vector.hpp:82
void SetSize(int s)
Resize the vector to size s.
Definition vector.hpp:633
@ FULL
Store the coefficient as a full QuadratureFunction.