xref: /libCEED/backends/ref/ceed-ref.h (revision 7578c8217078a59840b2b4a3f9726cf4a6bc1827)
1 // Copyright (c) 2017-2018, Lawrence Livermore National Security, LLC.
2 // Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707.
3 // All Rights reserved. See files LICENSE and NOTICE for details.
4 //
5 // This file is part of CEED, a collection of benchmarks, miniapps, software
6 // libraries and APIs for efficient high-order finite element and spectral
7 // element discretizations for exascale applications. For more information and
8 // source code availability see http://github.com/ceed.
9 //
10 // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
11 // a collaborative effort of two U.S. Department of Energy organizations (Office
12 // of Science and the National Nuclear Security Administration) responsible for
13 // the planning and preparation of a capable exascale ecosystem, including
14 // software, applications, hardware, advanced system engineering and early
15 // testbed platforms, in support of the nation's exascale computing imperative.
16 
17 #ifndef _ceed_ref_h
18 #define _ceed_ref_h
19 
20 #include <ceed/ceed.h>
21 #include <ceed/backend.h>
22 #include <stdbool.h>
23 #include <stdint.h>
24 
25 typedef struct {
26   CeedScalar *collo_grad_1d;
27   bool has_collo_interp;
28 } CeedBasis_Ref;
29 
30 typedef struct {
31   CeedScalar *array;
32   CeedScalar *array_borrowed;
33   CeedScalar *array_owned;
34 } CeedVector_Ref;
35 
36 typedef struct {
37   const CeedInt *offsets;
38   CeedInt *offsets_allocated;
39   // Orientation, if it exists, is true when the face must be flipped (multiplies by -1.).
40   const bool *orient;
41   bool *orient_allocated;
42   int (*Apply)(CeedElemRestriction, const CeedInt, const CeedInt,
43                const CeedInt, CeedInt, CeedInt, CeedTransposeMode, CeedVector,
44                CeedVector, CeedRequest *);
45 } CeedElemRestriction_Ref;
46 
47 typedef struct {
48   const CeedScalar **inputs;
49   CeedScalar **outputs;
50 } CeedQFunction_Ref;
51 
52 typedef struct {
53   void *data;
54   void *data_borrowed;
55   void *data_owned;
56 } CeedQFunctionContext_Ref;
57 
58 typedef struct {
59   bool is_identity_qf, is_identity_restr_op;
60   CeedVector *e_vecs_full; /* Full E-vectors, inputs followed by outputs */
61   uint64_t *input_states;  /* State counter of inputs */
62   CeedVector *e_vecs_in;   /* Single element input E-vectors  */
63   CeedVector *e_vecs_out;  /* Single element output E-vectors */
64   CeedVector *q_vecs_in;   /* Single element input Q-vectors  */
65   CeedVector *q_vecs_out;  /* Single element output Q-vectors */
66   CeedInt    num_inputs, num_outputs;
67   CeedInt    num_active_in, num_active_out;
68   CeedVector *qf_active_in;
69 } CeedOperator_Ref;
70 
71 CEED_INTERN int CeedVectorCreate_Ref(CeedInt n, CeedVector vec);
72 
73 CEED_INTERN int CeedElemRestrictionCreate_Ref(CeedMemType mem_type,
74     CeedCopyMode copy_mode, const CeedInt *indices, CeedElemRestriction r);
75 
76 CEED_INTERN int CeedElemRestrictionCreateOriented_Ref(CeedMemType mem_type,
77     CeedCopyMode copy_mode, const CeedInt *indices,
78     const bool *orient, CeedElemRestriction r);
79 
80 CEED_INTERN int CeedBasisCreateTensorH1_Ref(CeedInt dim, CeedInt P_1d,
81     CeedInt Q_1d, const CeedScalar *interp_1d, const CeedScalar *grad_1d,
82     const CeedScalar *q_ref_1d, const CeedScalar *q_weight_1d, CeedBasis basis);
83 
84 CEED_INTERN int CeedBasisCreateH1_Ref(CeedElemTopology topo,
85                                       CeedInt dim, CeedInt num_dof, CeedInt num_qpts,
86                                       const CeedScalar *interp,
87                                       const CeedScalar *grad,
88                                       const CeedScalar *q_ref,
89                                       const CeedScalar *q_weight,
90                                       CeedBasis basis);
91 
92 CEED_INTERN int CeedBasisCreateHdiv_Ref(CeedElemTopology topo,
93                                         CeedInt dim, CeedInt num_dof, CeedInt num_qpts,
94                                         const CeedScalar *interp,
95                                         const CeedScalar *div,
96                                         const CeedScalar *q_ref,
97                                         const CeedScalar *q_weight,
98                                         CeedBasis basis);
99 
100 CEED_INTERN int CeedTensorContractCreate_Ref(CeedBasis basis,
101     CeedTensorContract contract);
102 
103 CEED_INTERN int CeedQFunctionCreate_Ref(CeedQFunction qf);
104 
105 CEED_INTERN int CeedQFunctionContextCreate_Ref(CeedQFunctionContext ctx);
106 
107 CEED_INTERN int CeedOperatorCreate_Ref(CeedOperator op);
108 
109 #endif // _ceed_ref_h
110