MFEM v4.10.0
Finite element discretization library
Loading...
Searching...
No Matches
bilininteg_vectorfemass_kernels.hpp
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#ifndef MFEM_BILININTEG_VECTORFEMASS_KERNELS_HPP
13#define MFEM_BILININTEG_VECTORFEMASS_KERNELS_HPP
14
16#include "../bilininteg.hpp"
17
22
23namespace mfem
24{
25/// \cond DO_NOT_DOCUMENT
26namespace internal
27{
28namespace hcurlmass
29{
30constexpr int NBZ3D(int d1d, int q1d)
31{
32 if (d1d <= 1 || q1d <= 0)
33 {
34 return 1;
35 }
36 // assume q1d >= d1d
37 // z dimension is capped at 64 on nvidia and amd gpus
38 int tmp = std::min((128 + q1d * q1d * q1d - 1) / (q1d * q1d * q1d), 64);
39 int smem_req =
40 sizeof(mfem::real_t) *
41 (3 * ((d1d - 1) * d1d * d1d + 2 * q1d * q1d * q1d) * tmp +
42 q1d * (d1d - 1) + q1d * d1d);
43 // assume GPU has at least 48k shared memory
44 return std::max(std::min(tmp, (48 * 1024 + smem_req - 1) / smem_req), 1);
45}
46} // namespace hcurlmass
47} // namespace internal
48
49template <FiniteElement::DerivType TrialType, FiniteElement::DerivType TestType,
50 int DIM, int TrialD1D, int TestD1D, int Q1D>
52VectorFEMassIntegrator::ApplyPAKernels::Kernel()
53{
54 constexpr bool trial_curl = (TrialType == mfem::FiniteElement::CURL);
55 constexpr bool trial_div = (TrialType == mfem::FiniteElement::DIV);
56 constexpr bool test_curl = (TestType == mfem::FiniteElement::CURL);
57 constexpr bool test_div = (TestType == mfem::FiniteElement::DIV);
58
59 if constexpr (DIM == 3)
60 {
61 if constexpr (trial_curl && test_curl)
62 {
64 {
65 // assume TrialD1D == TestD1D
66 return internal::SmemPAHcurlMassApply3D<
67 TrialD1D, Q1D, internal::hcurlmass::NBZ3D(TrialD1D, Q1D)>;
68 }
69 else
70 {
71 return internal::PAHcurlMassApply3D;
72 }
73 }
74 else if constexpr (trial_div && test_div)
75 {
76 // assumes TrialD1D == TestD1D
77 return internal::SmemPAHdivMassApply3D<TrialD1D, Q1D>;
78 }
79 else if constexpr (trial_curl && test_div)
80 {
81 return internal::PAHdivHcurlMassApply3D;
82 }
83 else if constexpr (trial_div && test_curl)
84 {
85 return internal::PAHcurlHdivMassApply3D;
86 }
87 }
88 else if constexpr (DIM == 2) // 2D
89 {
90 if constexpr (trial_curl && test_curl)
91 {
92 return internal::PAHcurlMassApply2D;
93 }
94 else if constexpr (trial_div && test_div)
95 {
96 // assumes TrialD1D == TestD1D
97 return internal::SmemPAHdivMassApply2D<TrialD1D, Q1D>;
98 }
99 else if constexpr (trial_curl && test_div)
100 {
101 return internal::PAHdivHcurlMassApply2D;
102 }
103 else if constexpr (trial_div && test_curl)
104 {
105 return internal::PAHcurlHdivMassApply2D;
106 }
107 }
108 MFEM_ABORT("Unknown kernel.");
109}
110/// \endcond DO_NOT_DOCUMENT
111}
112
113#endif
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:271
DerivType
Enumeration for DerivType: defines which derivative method is implemented.
Definition fe_base.hpp:363
@ DIV
Implements CalcDivShape methods.
Definition fe_base.hpp:366
@ CURL
Implements CalcCurlShape methods.
Definition fe_base.hpp:367
void(*)(const int NE, bool symmetric, const bool scalar_coeff, const Array< real_t > &trialBO, const Array< real_t > &trialBC, const Array< real_t > &testBOt, const Array< real_t > &testBCt, const Vector &pa_data, const Vector &x, Vector &y, const int triald1d, const int testd1d, const int q1d) ApplyKernelType
constexpr int DIM
float real_t
Definition config.hpp:46
@ DEVICE_MASK
Biwise-OR of all device backends.
Definition device.hpp:104