xref: /libCEED/backends/ref/ceed-ref.h (revision edb2538e3dd6743c029967fc4e89c6fcafedb8c2)
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   CeedInt        *offsets_allocated;
30   const bool     *orients; /* Orientation, if it exists, is true when the dof must be flipped */
31   bool           *orients_allocated;
32   const CeedInt8 *curl_orients; /* Tridiagonal matrix (row-major) for a general transformation during restriction */
33   CeedInt8       *curl_orients_allocated;
34   int (*Apply)(CeedElemRestriction, CeedInt, CeedInt, CeedInt, CeedInt, CeedInt, CeedTransposeMode, bool, bool, CeedVector, CeedVector,
35                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_rstr_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, CeedCopyMode copy_mode, const CeedInt *offsets, const bool *orients,
65                                               const CeedInt8 *curl_orients, CeedElemRestriction r);
66 
67 CEED_INTERN int CeedBasisCreateTensorH1_Ref(CeedInt dim, CeedInt P_1d, CeedInt Q_1d, const CeedScalar *interp_1d, const CeedScalar *grad_1d,
68                                             const CeedScalar *q_ref_1d, const CeedScalar *q_weight_1d, CeedBasis basis);
69 CEED_INTERN int CeedBasisCreateH1_Ref(CeedElemTopology topo, CeedInt dim, CeedInt num_nodes, CeedInt num_qpts, const CeedScalar *interp,
70                                       const CeedScalar *grad, const CeedScalar *q_ref, const CeedScalar *q_weight, CeedBasis basis);
71 CEED_INTERN int CeedBasisCreateHdiv_Ref(CeedElemTopology topo, CeedInt dim, CeedInt num_nodes, CeedInt num_qpts, const CeedScalar *interp,
72                                         const CeedScalar *div, const CeedScalar *q_ref, const CeedScalar *q_weight, CeedBasis basis);
73 CEED_INTERN int CeedBasisCreateHcurl_Ref(CeedElemTopology topo, CeedInt dim, CeedInt num_nodes, CeedInt num_qpts, const CeedScalar *interp,
74                                          const CeedScalar *curl, const CeedScalar *q_ref, const CeedScalar *q_weight, CeedBasis basis);
75 
76 CEED_INTERN int CeedTensorContractCreate_Ref(CeedBasis basis, CeedTensorContract contract);
77 
78 CEED_INTERN int CeedQFunctionCreate_Ref(CeedQFunction qf);
79 
80 CEED_INTERN int CeedQFunctionContextCreate_Ref(CeedQFunctionContext ctx);
81 
82 CEED_INTERN int CeedOperatorCreate_Ref(CeedOperator op);
83 
84 #endif  // CEED_REF_H
85