Line data Source code
1 : // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 : // SPDX-License-Identifier: Apache-2.0
3 :
4 : #include "fem/integrator.hpp"
5 :
6 : #include "fem/libceed/coefficient.hpp"
7 : #include "fem/libceed/integrator.hpp"
8 : #include "utils/diagnostic.hpp"
9 :
10 : PalacePragmaDiagnosticPush
11 : PalacePragmaDiagnosticDisableUnused
12 :
13 : #include "fem/qfunctions/hcurl_qf.h"
14 : #include "fem/qfunctions/hcurlhdiv_qf.h"
15 :
16 : PalacePragmaDiagnosticPop
17 :
18 : namespace palace
19 : {
20 :
21 : using namespace ceed;
22 :
23 2067 : void MixedVectorGradientIntegrator::Assemble(Ceed ceed, CeedElemRestriction trial_restr,
24 : CeedElemRestriction test_restr,
25 : CeedBasis trial_basis, CeedBasis test_basis,
26 : CeedVector geom_data,
27 : CeedElemRestriction geom_data_restr,
28 : CeedOperator *op) const
29 : {
30 : CeedQFunctionInfo info;
31 2067 : info.assemble_q_data = assemble_q_data;
32 :
33 : // Set up QFunctions.
34 : CeedInt dim, space_dim, trial_num_comp, test_num_comp;
35 2067 : PalaceCeedCall(ceed, CeedBasisGetDimension(trial_basis, &dim));
36 2067 : PalaceCeedCall(ceed, CeedGeometryDataGetSpaceDimension(geom_data_restr, dim, &space_dim));
37 2067 : PalaceCeedCall(ceed, CeedBasisGetNumComponents(trial_basis, &trial_num_comp));
38 2067 : PalaceCeedCall(ceed, CeedBasisGetNumComponents(test_basis, &test_num_comp));
39 2067 : MFEM_VERIFY(trial_num_comp == test_num_comp && trial_num_comp == 1,
40 : "MixedVectorGradientIntegrator requires test and trial spaces with a single "
41 : "component!");
42 2067 : switch (10 * space_dim + dim)
43 : {
44 864 : case 22:
45 864 : if (test_map_type == mfem::FiniteElement::H_CURL)
46 : {
47 432 : info.apply_qf = assemble_q_data ? f_build_hcurl_22 : f_apply_hcurl_22;
48 432 : info.apply_qf_path = PalaceQFunctionRelativePath(
49 : assemble_q_data ? f_build_hcurl_22_loc : f_apply_hcurl_22_loc);
50 : }
51 432 : else if (test_map_type == mfem::FiniteElement::H_DIV)
52 : {
53 432 : info.apply_qf = assemble_q_data ? f_build_hcurlhdiv_22 : f_apply_hcurlhdiv_22;
54 432 : info.apply_qf_path = PalaceQFunctionRelativePath(
55 : assemble_q_data ? f_build_hcurlhdiv_22_loc : f_apply_hcurlhdiv_22_loc);
56 : }
57 : else
58 : {
59 0 : MFEM_ABORT("Invalid test map type for MixedVectorGradientIntegrator!");
60 : }
61 : break;
62 774 : case 33:
63 774 : if (test_map_type == mfem::FiniteElement::H_CURL)
64 : {
65 387 : info.apply_qf = assemble_q_data ? f_build_hcurl_33 : f_apply_hcurl_33;
66 387 : info.apply_qf_path = PalaceQFunctionRelativePath(
67 : assemble_q_data ? f_build_hcurl_33_loc : f_apply_hcurl_33_loc);
68 : }
69 387 : else if (test_map_type == mfem::FiniteElement::H_DIV)
70 : {
71 387 : info.apply_qf = assemble_q_data ? f_build_hcurlhdiv_33 : f_apply_hcurlhdiv_33;
72 387 : info.apply_qf_path = PalaceQFunctionRelativePath(
73 : assemble_q_data ? f_build_hcurlhdiv_33_loc : f_apply_hcurlhdiv_33_loc);
74 : }
75 : else
76 : {
77 0 : MFEM_ABORT("Invalid test map type for MixedVectorGradientIntegrator!");
78 : }
79 : break;
80 0 : case 21:
81 0 : if (test_map_type == mfem::FiniteElement::H_CURL)
82 : {
83 0 : info.apply_qf = assemble_q_data ? f_build_hcurl_21 : f_apply_hcurl_21;
84 0 : info.apply_qf_path = PalaceQFunctionRelativePath(
85 : assemble_q_data ? f_build_hcurl_21_loc : f_apply_hcurl_21_loc);
86 : }
87 0 : else if (test_map_type == mfem::FiniteElement::H_DIV)
88 : {
89 0 : info.apply_qf = assemble_q_data ? f_build_hcurlhdiv_21 : f_apply_hcurlhdiv_21;
90 0 : info.apply_qf_path = PalaceQFunctionRelativePath(
91 : assemble_q_data ? f_build_hcurlhdiv_21_loc : f_apply_hcurlhdiv_21_loc);
92 : }
93 : else
94 : {
95 0 : MFEM_ABORT("Invalid test map type for MixedVectorGradientIntegrator!");
96 : }
97 : break;
98 429 : case 32:
99 429 : if (test_map_type == mfem::FiniteElement::H_CURL)
100 : {
101 429 : info.apply_qf = assemble_q_data ? f_build_hcurl_32 : f_apply_hcurl_32;
102 429 : info.apply_qf_path = PalaceQFunctionRelativePath(
103 : assemble_q_data ? f_build_hcurl_32_loc : f_apply_hcurl_32_loc);
104 : }
105 0 : else if (test_map_type == mfem::FiniteElement::H_DIV)
106 : {
107 0 : info.apply_qf = assemble_q_data ? f_build_hcurlhdiv_32 : f_apply_hcurlhdiv_32;
108 0 : info.apply_qf_path = PalaceQFunctionRelativePath(
109 : assemble_q_data ? f_build_hcurlhdiv_32_loc : f_apply_hcurlhdiv_32_loc);
110 : }
111 : else
112 : {
113 0 : MFEM_ABORT("Invalid test map type for MixedVectorGradientIntegrator!");
114 : }
115 : break;
116 0 : default:
117 0 : MFEM_ABORT("Invalid value of (dim, space_dim) = ("
118 : << dim << ", " << space_dim << ") for MixedVectorGradientIntegrator!");
119 : }
120 2067 : info.trial_ops = EvalMode::Grad;
121 2067 : info.test_ops = EvalMode::Interp;
122 :
123 : // Set up the coefficient and assemble.
124 2067 : auto ctx = PopulateCoefficientContext(space_dim, Q, transpose);
125 2067 : AssembleCeedOperator(info, (void *)ctx.data(), ctx.size() * sizeof(CeedIntScalar), ceed,
126 : trial_restr, test_restr, trial_basis, test_basis, geom_data,
127 : geom_data_restr, op);
128 2067 : }
129 :
130 1247 : void MixedVectorWeakDivergenceIntegrator::Assemble(
131 : Ceed ceed, CeedElemRestriction trial_restr, CeedElemRestriction test_restr,
132 : CeedBasis trial_basis, CeedBasis test_basis, CeedVector geom_data,
133 : CeedElemRestriction geom_data_restr, CeedOperator *op) const
134 : {
135 : CeedQFunctionInfo info;
136 1247 : info.assemble_q_data = assemble_q_data;
137 :
138 : // Set up QFunctions.
139 : CeedInt dim, space_dim, trial_num_comp, test_num_comp;
140 1247 : PalaceCeedCall(ceed, CeedBasisGetDimension(trial_basis, &dim));
141 1247 : PalaceCeedCall(ceed, CeedGeometryDataGetSpaceDimension(geom_data_restr, dim, &space_dim));
142 1247 : PalaceCeedCall(ceed, CeedBasisGetNumComponents(trial_basis, &trial_num_comp));
143 1247 : PalaceCeedCall(ceed, CeedBasisGetNumComponents(test_basis, &test_num_comp));
144 1247 : MFEM_VERIFY(
145 : trial_num_comp == test_num_comp && trial_num_comp == 1,
146 : "MixedVectorWeakDivergenceIntegrator requires test and trial spaces with a single "
147 : "component!");
148 1247 : switch (10 * space_dim + dim)
149 : {
150 432 : case 22:
151 432 : info.apply_qf = assemble_q_data ? f_build_hcurl_22 : f_apply_hcurl_22;
152 432 : info.apply_qf_path = PalaceQFunctionRelativePath(
153 : assemble_q_data ? f_build_hcurl_22_loc : f_apply_hcurl_22_loc);
154 : break;
155 387 : case 33:
156 387 : info.apply_qf = assemble_q_data ? f_build_hcurl_33 : f_apply_hcurl_33;
157 387 : info.apply_qf_path = PalaceQFunctionRelativePath(
158 : assemble_q_data ? f_build_hcurl_33_loc : f_apply_hcurl_33_loc);
159 : break;
160 0 : case 21:
161 0 : info.apply_qf = assemble_q_data ? f_build_hcurl_21 : f_apply_hcurl_21;
162 0 : info.apply_qf_path = PalaceQFunctionRelativePath(
163 : assemble_q_data ? f_build_hcurl_21_loc : f_apply_hcurl_21_loc);
164 : break;
165 428 : case 32:
166 428 : info.apply_qf = assemble_q_data ? f_build_hcurl_32 : f_apply_hcurl_32;
167 428 : info.apply_qf_path = PalaceQFunctionRelativePath(
168 : assemble_q_data ? f_build_hcurl_32_loc : f_apply_hcurl_32_loc);
169 : break;
170 0 : default:
171 0 : MFEM_ABORT("Invalid value of (dim, space_dim) = ("
172 : << dim << ", " << space_dim
173 : << ") for MixedVectorWeakDivergenceIntegrator!");
174 : }
175 1247 : info.trial_ops = EvalMode::Interp;
176 1247 : info.test_ops = EvalMode::Grad;
177 :
178 : // Set up the coefficient and assemble.
179 1247 : auto ctx = PopulateCoefficientContext(space_dim, Q, transpose, -1.0);
180 1247 : AssembleCeedOperator(info, (void *)ctx.data(), ctx.size() * sizeof(CeedIntScalar), ceed,
181 : trial_restr, test_restr, trial_basis, test_basis, geom_data,
182 : geom_data_restr, op);
183 1247 : }
184 :
185 : } // namespace palace
|