xref: /libCEED/backends/ref/ceed-ref.h (revision 02219a082eb38cf2d3edc97fbfe55fa395a4dc99)
1 // Copyright (c) 2017-2025, Lawrence Livermore National Security, LLC and other CEED contributors.
2 // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
3 //
4 // SPDX-License-Identifier: BSD-2-Clause
5 //
6 // This file is part of CEED:  http://github.com/ceed
7 #pragma once
8 
9 #include <ceed.h>
10 #include <ceed/backend.h>
11 #include <stdbool.h>
12 #include <stdint.h>
13 
14 typedef struct {
15   CeedScalar *array;
16   CeedScalar *array_borrowed;
17   CeedScalar *array_owned;
18 } CeedVector_Ref;
19 
20 typedef struct {
21   const CeedInt  *offsets;
22   const CeedInt  *offsets_borrowed;
23   const CeedInt  *offsets_owned;
24   const bool     *orients; /* Orientation, if it exists, is true when the dof must be flipped */
25   const bool     *orients_borrowed;
26   const bool     *orients_owned;
27   const CeedInt8 *curl_orients; /* Tridiagonal matrix (row-major) for a general transformation during restriction */
28   const CeedInt8 *curl_orients_borrowed;
29   const CeedInt8 *curl_orients_owned;
30   int (*Apply)(CeedElemRestriction, CeedInt, CeedInt, CeedInt, CeedInt, CeedInt, CeedTransposeMode, bool, bool, CeedVector, CeedVector,
31                CeedRequest *);
32 } CeedElemRestriction_Ref;
33 
34 typedef struct {
35   CeedScalar *collo_grad_1d;
36   bool        is_collocated;
37 } CeedBasis_Ref;
38 
39 typedef struct {
40   const CeedScalar **inputs;
41   CeedScalar       **outputs;
42 } CeedQFunction_Ref;
43 
44 typedef struct {
45   void *data;
46   void *data_borrowed;
47   void *data_owned;
48 } CeedQFunctionContext_Ref;
49 
50 typedef struct {
51   bool        is_identity_qf, is_identity_rstr_op;
52   bool       *skip_rstr_in, *skip_rstr_out, *apply_add_basis_out;
53   CeedInt    *e_data_out_indices;
54   uint64_t   *input_states; /* State counter of inputs */
55   CeedVector *e_vecs_full;  /* Full E-vectors, inputs followed by outputs */
56   CeedVector *e_vecs_in;    /* Single element input E-vectors  */
57   CeedVector *e_vecs_out;   /* Single element output E-vectors */
58   CeedVector *q_vecs_in;    /* Single element input Q-vectors  */
59   CeedVector *q_vecs_out;   /* Single element output Q-vectors */
60   CeedInt     num_inputs, num_outputs;
61   CeedInt     qf_size_in, qf_size_out;
62   CeedVector  point_coords_elem;
63 } CeedOperator_Ref;
64 
65 CEED_INTERN int CeedVectorCreate_Ref(CeedSize n, CeedVector vec);
66 
67 CEED_INTERN int CeedElemRestrictionCreate_Ref(CeedMemType mem_type, CeedCopyMode copy_mode, const CeedInt *offsets, const bool *orients,
68                                               const CeedInt8 *curl_orients, CeedElemRestriction r);
69 
70 CEED_INTERN int CeedBasisCreateTensorH1_Ref(CeedInt dim, CeedInt P_1d, CeedInt Q_1d, const CeedScalar *interp_1d, const CeedScalar *grad_1d,
71                                             const CeedScalar *q_ref_1d, const CeedScalar *q_weight_1d, CeedBasis basis);
72 CEED_INTERN int CeedBasisCreateH1_Ref(CeedElemTopology topo, CeedInt dim, CeedInt num_nodes, CeedInt num_qpts, const CeedScalar *interp,
73                                       const CeedScalar *grad, const CeedScalar *q_ref, const CeedScalar *q_weight, CeedBasis basis);
74 CEED_INTERN int CeedBasisCreateHdiv_Ref(CeedElemTopology topo, CeedInt dim, CeedInt num_nodes, CeedInt num_qpts, const CeedScalar *interp,
75                                         const CeedScalar *div, const CeedScalar *q_ref, const CeedScalar *q_weight, CeedBasis basis);
76 CEED_INTERN int CeedBasisCreateHcurl_Ref(CeedElemTopology topo, CeedInt dim, CeedInt num_nodes, CeedInt num_qpts, const CeedScalar *interp,
77                                          const CeedScalar *curl, const CeedScalar *q_ref, const CeedScalar *q_weight, CeedBasis basis);
78 
79 CEED_INTERN int CeedTensorContractCreate_Ref(CeedTensorContract contract);
80 
81 CEED_INTERN int CeedQFunctionCreate_Ref(CeedQFunction qf);
82 
83 CEED_INTERN int CeedQFunctionContextCreate_Ref(CeedQFunctionContext ctx);
84 
85 CEED_INTERN int CeedOperatorCreate_Ref(CeedOperator op);
86 CEED_INTERN int CeedOperatorCreateAtPoints_Ref(CeedOperator op);
87