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 :
9 : #include "fem/qfunctions/hcurl_qf.h"
10 : #include "fem/qfunctions/hcurlhdiv_qf.h"
11 : #include "fem/qfunctions/hdiv_qf.h"
12 :
13 : namespace palace
14 : {
15 :
16 : using namespace ceed;
17 :
18 4127 : void VectorFEMassIntegrator::Assemble(Ceed ceed, CeedElemRestriction trial_restr,
19 : CeedElemRestriction test_restr, CeedBasis trial_basis,
20 : CeedBasis test_basis, CeedVector geom_data,
21 : CeedElemRestriction geom_data_restr,
22 : CeedOperator *op) const
23 : {
24 : CeedQFunctionInfo info;
25 4127 : info.assemble_q_data = assemble_q_data;
26 :
27 : // Set up QFunctions.
28 : CeedInt dim, space_dim, trial_num_comp, test_num_comp;
29 4127 : PalaceCeedCall(ceed, CeedBasisGetDimension(trial_basis, &dim));
30 4127 : PalaceCeedCall(ceed, CeedGeometryDataGetSpaceDimension(geom_data_restr, dim, &space_dim));
31 4127 : PalaceCeedCall(ceed, CeedBasisGetNumComponents(trial_basis, &trial_num_comp));
32 4127 : PalaceCeedCall(ceed, CeedBasisGetNumComponents(test_basis, &test_num_comp));
33 4127 : MFEM_VERIFY(
34 : trial_num_comp == test_num_comp && trial_num_comp == 1,
35 : "VectorFEMassIntegrator requires test and trial spaces with a single component!");
36 4127 : switch (10 * space_dim + dim)
37 : {
38 1726 : case 22:
39 1726 : if (trial_map_type == mfem::FiniteElement::H_CURL &&
40 863 : test_map_type == mfem::FiniteElement::H_CURL)
41 : {
42 431 : info.apply_qf = assemble_q_data ? f_build_hcurl_22 : f_apply_hcurl_22;
43 431 : info.apply_qf_path = PalaceQFunctionRelativePath(
44 : assemble_q_data ? f_build_hcurl_22_loc : f_apply_hcurl_22_loc);
45 : }
46 1295 : else if (trial_map_type == mfem::FiniteElement::H_DIV &&
47 863 : test_map_type == mfem::FiniteElement::H_DIV)
48 : {
49 431 : info.apply_qf = assemble_q_data ? f_build_hdiv_22 : f_apply_hdiv_22;
50 431 : info.apply_qf_path = PalaceQFunctionRelativePath(
51 : assemble_q_data ? f_build_hdiv_22_loc : f_apply_hdiv_22_loc);
52 : }
53 864 : else if (trial_map_type == mfem::FiniteElement::H_CURL &&
54 432 : test_map_type == mfem::FiniteElement::H_DIV)
55 : {
56 432 : info.apply_qf = assemble_q_data ? f_build_hcurlhdiv_22 : f_apply_hcurlhdiv_22;
57 432 : info.apply_qf_path = PalaceQFunctionRelativePath(
58 : assemble_q_data ? f_build_hcurlhdiv_22_loc : f_apply_hcurlhdiv_22_loc);
59 : }
60 432 : else if (trial_map_type == mfem::FiniteElement::H_DIV &&
61 432 : test_map_type == mfem::FiniteElement::H_CURL)
62 : {
63 432 : info.apply_qf = assemble_q_data ? f_build_hdivhcurl_22 : f_apply_hdivhcurl_22;
64 432 : info.apply_qf_path = PalaceQFunctionRelativePath(
65 : assemble_q_data ? f_build_hdivhcurl_22_loc : f_apply_hdivhcurl_22_loc);
66 : }
67 : else
68 : {
69 0 : MFEM_ABORT("Invalid trial/test element map type for VectorFEMassIntegrator!");
70 : }
71 : break;
72 1623 : case 33:
73 1623 : if (trial_map_type == mfem::FiniteElement::H_CURL &&
74 819 : test_map_type == mfem::FiniteElement::H_CURL)
75 : {
76 432 : info.apply_qf = assemble_q_data ? f_build_hcurl_33 : f_apply_hcurl_33;
77 432 : info.apply_qf_path = PalaceQFunctionRelativePath(
78 : assemble_q_data ? f_build_hcurl_33_loc : f_apply_hcurl_33_loc);
79 : }
80 1191 : else if (trial_map_type == mfem::FiniteElement::H_DIV &&
81 804 : test_map_type == mfem::FiniteElement::H_DIV)
82 : {
83 417 : info.apply_qf = assemble_q_data ? f_build_hdiv_33 : f_apply_hdiv_33;
84 417 : info.apply_qf_path = PalaceQFunctionRelativePath(
85 : assemble_q_data ? f_build_hdiv_33_loc : f_apply_hdiv_33_loc);
86 : }
87 774 : else if (trial_map_type == mfem::FiniteElement::H_CURL &&
88 387 : test_map_type == mfem::FiniteElement::H_DIV)
89 : {
90 387 : info.apply_qf = assemble_q_data ? f_build_hcurlhdiv_33 : f_apply_hcurlhdiv_33;
91 387 : info.apply_qf_path = PalaceQFunctionRelativePath(
92 : assemble_q_data ? f_build_hcurlhdiv_33_loc : f_apply_hcurlhdiv_33_loc);
93 : }
94 387 : else if (trial_map_type == mfem::FiniteElement::H_DIV &&
95 387 : test_map_type == mfem::FiniteElement::H_CURL)
96 : {
97 387 : info.apply_qf = assemble_q_data ? f_build_hdivhcurl_33 : f_apply_hdivhcurl_33;
98 387 : info.apply_qf_path = PalaceQFunctionRelativePath(
99 : assemble_q_data ? f_build_hdivhcurl_33_loc : f_apply_hdivhcurl_33_loc);
100 : }
101 : else
102 : {
103 0 : MFEM_ABORT("Invalid trial/test element map type for VectorFEMassIntegrator!");
104 : }
105 : break;
106 324 : case 21:
107 324 : if (trial_map_type == mfem::FiniteElement::H_CURL &&
108 324 : test_map_type == mfem::FiniteElement::H_CURL)
109 : {
110 324 : info.apply_qf = assemble_q_data ? f_build_hcurl_21 : f_apply_hcurl_21;
111 324 : info.apply_qf_path = PalaceQFunctionRelativePath(
112 : assemble_q_data ? f_build_hcurl_21_loc : f_apply_hcurl_21_loc);
113 : }
114 0 : else if (trial_map_type == mfem::FiniteElement::H_DIV &&
115 0 : test_map_type == mfem::FiniteElement::H_DIV)
116 : {
117 0 : info.apply_qf = assemble_q_data ? f_build_hdiv_21 : f_apply_hdiv_21;
118 0 : info.apply_qf_path = PalaceQFunctionRelativePath(
119 : assemble_q_data ? f_build_hdiv_21_loc : f_apply_hdiv_21_loc);
120 : }
121 0 : else if (trial_map_type == mfem::FiniteElement::H_CURL &&
122 0 : test_map_type == mfem::FiniteElement::H_DIV)
123 : {
124 0 : info.apply_qf = assemble_q_data ? f_build_hcurlhdiv_21 : f_apply_hcurlhdiv_21;
125 0 : info.apply_qf_path = PalaceQFunctionRelativePath(
126 : assemble_q_data ? f_build_hcurlhdiv_21_loc : f_apply_hcurlhdiv_21_loc);
127 : }
128 0 : else if (trial_map_type == mfem::FiniteElement::H_DIV &&
129 0 : test_map_type == mfem::FiniteElement::H_CURL)
130 : {
131 0 : info.apply_qf = assemble_q_data ? f_build_hdivhcurl_21 : f_apply_hdivhcurl_21;
132 0 : info.apply_qf_path = PalaceQFunctionRelativePath(
133 : assemble_q_data ? f_build_hdivhcurl_21_loc : f_apply_hdivhcurl_21_loc);
134 : }
135 : else
136 : {
137 0 : MFEM_ABORT("Invalid trial/test element map type for VectorFEMassIntegrator!");
138 : }
139 : break;
140 454 : case 32:
141 454 : if (trial_map_type == mfem::FiniteElement::H_CURL &&
142 454 : test_map_type == mfem::FiniteElement::H_CURL)
143 : {
144 454 : info.apply_qf = assemble_q_data ? f_build_hcurl_32 : f_apply_hcurl_32;
145 454 : info.apply_qf_path = PalaceQFunctionRelativePath(
146 : assemble_q_data ? f_build_hcurl_32_loc : f_apply_hcurl_32_loc);
147 : }
148 0 : else if (trial_map_type == mfem::FiniteElement::H_DIV &&
149 0 : test_map_type == mfem::FiniteElement::H_DIV)
150 : {
151 0 : info.apply_qf = assemble_q_data ? f_build_hdiv_32 : f_apply_hdiv_32;
152 0 : info.apply_qf_path = PalaceQFunctionRelativePath(
153 : assemble_q_data ? f_build_hdiv_32_loc : f_apply_hdiv_32_loc);
154 : }
155 0 : else if (trial_map_type == mfem::FiniteElement::H_CURL &&
156 0 : test_map_type == mfem::FiniteElement::H_DIV)
157 : {
158 0 : info.apply_qf = assemble_q_data ? f_build_hcurlhdiv_32 : f_apply_hcurlhdiv_32;
159 0 : info.apply_qf_path = PalaceQFunctionRelativePath(
160 : assemble_q_data ? f_build_hcurlhdiv_32_loc : f_apply_hcurlhdiv_32_loc);
161 : }
162 0 : else if (trial_map_type == mfem::FiniteElement::H_DIV &&
163 0 : test_map_type == mfem::FiniteElement::H_CURL)
164 : {
165 0 : info.apply_qf = assemble_q_data ? f_build_hdivhcurl_32 : f_apply_hdivhcurl_32;
166 0 : info.apply_qf_path = PalaceQFunctionRelativePath(
167 : assemble_q_data ? f_build_hdivhcurl_32_loc : f_apply_hdivhcurl_32_loc);
168 : }
169 : else
170 : {
171 0 : MFEM_ABORT("Invalid trial/test element map type for VectorFEMassIntegrator!");
172 : }
173 : break;
174 0 : default:
175 0 : MFEM_ABORT("Invalid value of (dim, space_dim) = ("
176 : << dim << ", " << space_dim << ") for VectorFEMassIntegrator!");
177 : }
178 4127 : info.trial_ops = EvalMode::Interp;
179 4127 : info.test_ops = EvalMode::Interp;
180 :
181 : // Set up the coefficient and assemble.
182 4127 : auto ctx = PopulateCoefficientContext(space_dim, Q, transpose);
183 4127 : AssembleCeedOperator(info, (void *)ctx.data(), ctx.size() * sizeof(CeedIntScalar), ceed,
184 : trial_restr, test_restr, trial_basis, test_basis, geom_data,
185 : geom_data_restr, op);
186 4127 : }
187 :
188 : } // namespace palace
|