xref: /libCEED/backends/ref/ceed-ref.h (revision ad75ff5827444f41d1c36185c0dbd657b62817df)
1 // Copyright (c) 2017-2022, 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 
8 #ifndef CEED_REF_H
9 #define CEED_REF_H
10 
11 #include <ceed.h>
12 #include <ceed/backend.h>
13 #include <stdbool.h>
14 #include <stdint.h>
15 
16 typedef struct {
17   CeedScalar *collo_grad_1d;
18   bool        has_collo_interp;
19 } CeedBasis_Ref;
20 
21 typedef struct {
22   CeedScalar *array;
23   CeedScalar *array_borrowed;
24   CeedScalar *array_owned;
25 } CeedVector_Ref;
26 
27 typedef struct {
28   const CeedInt  *offsets;
29   const CeedInt  *offsets_borrowed;
30   const CeedInt  *offsets_owned;
31   const bool     *orients; /* Orientation, if it exists, is true when the dof must be flipped */
32   const bool     *orients_borrowed;
33   const bool     *orients_owned;
34   const CeedInt8 *curl_orients; /* Tridiagonal matrix (row-major) for a general transformation during restriction */
35   const CeedInt8 *curl_orients_borrowed;
36   const CeedInt8 *curl_orients_owned;
37   int (*Apply)(CeedElemRestriction, CeedInt, CeedInt, CeedInt, CeedInt, CeedInt, CeedTransposeMode, bool, bool, CeedVector, CeedVector,
38                CeedRequest *);
39 } CeedElemRestriction_Ref;
40 
41 typedef struct {
42   const CeedScalar **inputs;
43   CeedScalar       **outputs;
44 } CeedQFunction_Ref;
45 
46 typedef struct {
47   void *data;
48   void *data_borrowed;
49   void *data_owned;
50 } CeedQFunctionContext_Ref;
51 
52 typedef struct {
53   bool        is_identity_qf, is_identity_rstr_op;
54   CeedVector *e_vecs_full;  /* Full E-vectors, inputs followed by outputs */
55   uint64_t   *input_states; /* State counter of inputs */
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     num_active_in, num_active_out;
62   CeedVector *qf_active_in, 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 
88 #endif  // CEED_REF_H
89