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/hcurlhdiv_qf.h"
14 : #include "fem/qfunctions/hdiv_qf.h"
15 :
16 : PalacePragmaDiagnosticPop
17 :
18 : namespace palace
19 : {
20 :
21 : using namespace ceed;
22 :
23 774 : void MixedVectorCurlIntegrator::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 774 : info.assemble_q_data = assemble_q_data;
32 :
33 : // Set up QFunctions.
34 : CeedInt dim, space_dim, trial_num_comp, test_num_comp;
35 774 : PalaceCeedCall(ceed, CeedBasisGetDimension(trial_basis, &dim));
36 774 : PalaceCeedCall(ceed, CeedGeometryDataGetSpaceDimension(geom_data_restr, dim, &space_dim));
37 774 : MFEM_VERIFY(dim == 3 && space_dim == 3,
38 : "MixedVectorCurlIntegrator is only available in 3D!");
39 774 : PalaceCeedCall(ceed, CeedBasisGetNumComponents(trial_basis, &trial_num_comp));
40 774 : PalaceCeedCall(ceed, CeedBasisGetNumComponents(test_basis, &test_num_comp));
41 774 : MFEM_VERIFY(
42 : trial_num_comp == test_num_comp && trial_num_comp == 1,
43 : "MixedVectorCurlIntegrator requires test and trial spaces with a single component!");
44 774 : if (test_map_type == mfem::FiniteElement::H_DIV)
45 : {
46 387 : info.apply_qf = assemble_q_data ? f_build_hdiv_33 : f_apply_hdiv_33;
47 387 : info.apply_qf_path = PalaceQFunctionRelativePath(assemble_q_data ? f_build_hdiv_33_loc
48 : : f_apply_hdiv_33_loc);
49 : }
50 387 : else if (test_map_type == mfem::FiniteElement::H_CURL)
51 : {
52 387 : info.apply_qf = assemble_q_data ? f_build_hdivhcurl_33 : f_apply_hdivhcurl_33;
53 387 : info.apply_qf_path = PalaceQFunctionRelativePath(
54 : assemble_q_data ? f_build_hdivhcurl_33_loc : f_apply_hdivhcurl_33_loc);
55 : }
56 : else
57 : {
58 0 : MFEM_ABORT("Invalid trial/test element map type for MixedVectorCurlIntegrator!");
59 : }
60 774 : info.trial_ops = EvalMode::Curl;
61 774 : info.test_ops = EvalMode::Interp;
62 :
63 : // Set up the coefficient and assemble.
64 774 : auto ctx = PopulateCoefficientContext(space_dim, Q, transpose);
65 774 : AssembleCeedOperator(info, (void *)ctx.data(), ctx.size() * sizeof(CeedIntScalar), ceed,
66 : trial_restr, test_restr, trial_basis, test_basis, geom_data,
67 : geom_data_restr, op);
68 774 : }
69 :
70 774 : void MixedVectorWeakCurlIntegrator::Assemble(Ceed ceed, CeedElemRestriction trial_restr,
71 : CeedElemRestriction test_restr,
72 : CeedBasis trial_basis, CeedBasis test_basis,
73 : CeedVector geom_data,
74 : CeedElemRestriction geom_data_restr,
75 : CeedOperator *op) const
76 : {
77 : CeedQFunctionInfo info;
78 774 : info.assemble_q_data = assemble_q_data;
79 :
80 : // Set up QFunctions.
81 : CeedInt dim, space_dim, trial_num_comp, test_num_comp;
82 774 : PalaceCeedCall(ceed, CeedBasisGetDimension(trial_basis, &dim));
83 774 : PalaceCeedCall(ceed, CeedGeometryDataGetSpaceDimension(geom_data_restr, dim, &space_dim));
84 774 : MFEM_VERIFY(dim == 3 && space_dim == 3,
85 : "MixedVectorWeakCurlIntegrator is only available in 3D!");
86 774 : PalaceCeedCall(ceed, CeedBasisGetNumComponents(trial_basis, &trial_num_comp));
87 774 : PalaceCeedCall(ceed, CeedBasisGetNumComponents(test_basis, &test_num_comp));
88 774 : MFEM_VERIFY(trial_num_comp == test_num_comp && trial_num_comp == 1,
89 : "MixedVectorWeakCurlIntegrator requires test and trial spaces with a single "
90 : "component!");
91 774 : if (trial_map_type == mfem::FiniteElement::H_DIV)
92 : {
93 387 : info.apply_qf = assemble_q_data ? f_build_hdiv_33 : f_apply_hdiv_33;
94 387 : info.apply_qf_path = PalaceQFunctionRelativePath(assemble_q_data ? f_build_hdiv_33_loc
95 : : f_apply_hdiv_33_loc);
96 : }
97 387 : else if (trial_map_type == mfem::FiniteElement::H_CURL)
98 : {
99 387 : info.apply_qf = assemble_q_data ? f_build_hcurlhdiv_33 : f_apply_hcurlhdiv_33;
100 387 : info.apply_qf_path = PalaceQFunctionRelativePath(
101 : assemble_q_data ? f_build_hcurlhdiv_33_loc : f_apply_hcurlhdiv_33_loc);
102 : }
103 : else
104 : {
105 0 : MFEM_ABORT("Invalid trial/test element map type for MixedVectorWeakCurlIntegrator!");
106 : }
107 774 : info.trial_ops = EvalMode::Interp;
108 774 : info.test_ops = EvalMode::Curl;
109 :
110 : // Set up the coefficient and assemble.
111 774 : auto ctx = PopulateCoefficientContext(space_dim, Q, transpose, -1.0);
112 774 : AssembleCeedOperator(info, (void *)ctx.data(), ctx.size() * sizeof(CeedIntScalar), ceed,
113 : trial_restr, test_restr, trial_basis, test_basis, geom_data,
114 : geom_data_restr, op);
115 774 : }
116 :
117 : } // namespace palace
|