Line data Source code
1 : // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 : // SPDX-License-Identifier: Apache-2.0
3 :
4 : #ifndef PALACE_LIBCEED_INTEGRATOR_HPP
5 : #define PALACE_LIBCEED_INTEGRATOR_HPP
6 :
7 : #include <string>
8 : #include <vector>
9 : #include "fem/libceed/ceed.hpp"
10 :
11 : namespace palace::ceed
12 : {
13 :
14 : // Evaluation modes for CeedOperator fields for various integrators.
15 : enum EvalMode : unsigned int
16 : {
17 : Weight = 1 << 0,
18 : None = 1 << 1,
19 : Interp = 1 << 2,
20 : Grad = 1 << 3,
21 : Div = 1 << 4,
22 : Curl = 1 << 5
23 : };
24 :
25 : // Data structure for CeedOperator construction for various integrators.
26 : struct CeedQFunctionInfo
27 : {
28 : // QFunctions for operator construction and application.
29 : CeedQFunctionUser apply_qf;
30 :
31 : // Path and name of the QFunctions for operator construction and application.
32 : std::string apply_qf_path;
33 :
34 : // Evaluation modes for the test and trial basis.
35 : unsigned int trial_ops, test_ops;
36 :
37 : // Control whether or not to pre-assemble the quadrature data or compute it during
38 : // operator application in true matrix-free fashion.
39 : bool assemble_q_data;
40 :
41 : CeedQFunctionInfo()
42 15407 : : apply_qf(nullptr), apply_qf_path(""), trial_ops(0), test_ops(0),
43 : assemble_q_data(false)
44 : {
45 : }
46 : };
47 :
48 : // Helper function to get the geometry space dimension.
49 : int CeedGeometryDataGetSpaceDimension(CeedElemRestriction geom_data_restr, CeedInt dim,
50 : CeedInt *space_dim);
51 :
52 : // Assemble libCEED mesh geometry factor quadrature data for use in a partially assembled
53 : // libCEED operator.
54 : void AssembleCeedGeometryData(Ceed ceed, CeedElemRestriction mesh_restr,
55 : CeedBasis mesh_basis, CeedVector mesh_nodes,
56 : CeedElemRestriction attr_restr, CeedBasis attr_basis,
57 : CeedVector elem_attr, CeedVector geom_data,
58 : CeedElemRestriction geom_data_restr);
59 :
60 : // Construct libCEED operator using the given quadrature data, element restriction, and
61 : // basis objects.
62 : void AssembleCeedOperator(const CeedQFunctionInfo &info, void *ctx, std::size_t ctx_size,
63 : Ceed ceed, CeedElemRestriction trial_restr,
64 : CeedElemRestriction test_restr, CeedBasis trial_basis,
65 : CeedBasis test_basis, CeedVector geom_data,
66 : CeedElemRestriction geom_data_restr, CeedOperator *op);
67 :
68 : // Construct libCEED operators for interpolation operations and their transpose between
69 : // the two spaces. Note that contributions for shared degrees of freedom are added, so the
70 : // output of the operator application must be scaled by the inverse multiplicity.
71 : void AssembleCeedInterpolator(Ceed ceed, CeedElemRestriction trial_restr,
72 : CeedElemRestriction test_restr, CeedBasis interp_basis,
73 : CeedOperator *op, CeedOperator *op_t);
74 :
75 : // Construct a libCEED operator which integrates the squared difference between two
76 : // functions over every element.
77 : void AssembleCeedElementErrorIntegrator(
78 : const CeedQFunctionInfo &info, void *ctx, std::size_t ctx_size, Ceed ceed,
79 : CeedVector input1, CeedVector input2, CeedElemRestriction input1_restr,
80 : CeedElemRestriction input2_restr, CeedBasis input1_basis, CeedBasis input2_basis,
81 : CeedElemRestriction mesh_elem_restr, CeedVector geom_data,
82 : CeedElemRestriction geom_data_restr, CeedOperator *op);
83 :
84 : } // namespace palace::ceed
85 :
86 : #endif // PALACE_LIBCEED_INTEGRATOR_HPP
|