xref: /libCEED/backends/ref/ceed-ref.h (revision ce18bed930e8f3bfebcf709a18844aba97fe4630)
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/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   CeedInt *offsets_allocated;
30   // Orientation, if it exists, is true when the face must be flipped (multiplies by -1.).
31   const bool *orient;
32   bool *orient_allocated;
33   int (*Apply)(CeedElemRestriction, const CeedInt, const CeedInt,
34                const CeedInt, CeedInt, CeedInt, CeedTransposeMode, CeedVector,
35                CeedVector, CeedRequest *);
36 } CeedElemRestriction_Ref;
37 
38 typedef struct {
39   const CeedScalar **inputs;
40   CeedScalar **outputs;
41 } CeedQFunction_Ref;
42 
43 typedef struct {
44   void *data;
45   void *data_borrowed;
46   void *data_owned;
47 } CeedQFunctionContext_Ref;
48 
49 typedef struct {
50   bool is_identity_qf, is_identity_restr_op;
51   CeedVector *e_vecs_full; /* Full E-vectors, inputs followed by outputs */
52   uint64_t *input_states;  /* State counter of inputs */
53   CeedVector *e_vecs_in;   /* Single element input E-vectors  */
54   CeedVector *e_vecs_out;  /* Single element output E-vectors */
55   CeedVector *q_vecs_in;   /* Single element input Q-vectors  */
56   CeedVector *q_vecs_out;  /* Single element output Q-vectors */
57   CeedInt    num_inputs, num_outputs;
58   CeedInt    num_active_in, num_active_out;
59   CeedVector *qf_active_in;
60 } CeedOperator_Ref;
61 
62 CEED_INTERN int CeedVectorCreate_Ref(CeedSize n, CeedVector vec);
63 
64 CEED_INTERN int CeedElemRestrictionCreate_Ref(CeedMemType mem_type,
65     CeedCopyMode copy_mode, const CeedInt *indices, CeedElemRestriction r);
66 
67 CEED_INTERN int CeedElemRestrictionCreateOriented_Ref(CeedMemType mem_type,
68     CeedCopyMode copy_mode, const CeedInt *indices,
69     const bool *orient, CeedElemRestriction r);
70 
71 CEED_INTERN int CeedBasisCreateTensorH1_Ref(CeedInt dim, CeedInt P_1d,
72     CeedInt Q_1d, const CeedScalar *interp_1d, const CeedScalar *grad_1d,
73     const CeedScalar *q_ref_1d, const CeedScalar *q_weight_1d, CeedBasis basis);
74 
75 CEED_INTERN int CeedBasisCreateH1_Ref(CeedElemTopology topo,
76                                       CeedInt dim, CeedInt num_dof, CeedInt num_qpts,
77                                       const CeedScalar *interp,
78                                       const CeedScalar *grad,
79                                       const CeedScalar *q_ref,
80                                       const CeedScalar *q_weight,
81                                       CeedBasis basis);
82 
83 CEED_INTERN int CeedBasisCreateHdiv_Ref(CeedElemTopology topo,
84                                         CeedInt dim, CeedInt num_dof, CeedInt num_qpts,
85                                         const CeedScalar *interp,
86                                         const CeedScalar *div,
87                                         const CeedScalar *q_ref,
88                                         const CeedScalar *q_weight,
89                                         CeedBasis basis);
90 
91 CEED_INTERN int CeedTensorContractCreate_Ref(CeedBasis basis,
92     CeedTensorContract contract);
93 
94 CEED_INTERN int CeedQFunctionCreate_Ref(CeedQFunction qf);
95 
96 CEED_INTERN int CeedQFunctionContextCreate_Ref(CeedQFunctionContext ctx);
97 
98 CEED_INTERN int CeedOperatorCreate_Ref(CeedOperator op);
99 
100 #endif // _ceed_ref_h
101