xref: /libCEED/rust/libceed-sys/c-src/backends/ref/ceed-ref.h (revision fc0567d9dd43c4a8f0744c44d73ac6beb4777ae6)
121617c04Sjeremylt // Copyright (c) 2017-2018, Lawrence Livermore National Security, LLC.
221617c04Sjeremylt // Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707.
321617c04Sjeremylt // All Rights reserved. See files LICENSE and NOTICE for details.
421617c04Sjeremylt //
521617c04Sjeremylt // This file is part of CEED, a collection of benchmarks, miniapps, software
621617c04Sjeremylt // libraries and APIs for efficient high-order finite element and spectral
721617c04Sjeremylt // element discretizations for exascale applications. For more information and
821617c04Sjeremylt // source code availability see http://github.com/ceed.
921617c04Sjeremylt //
1021617c04Sjeremylt // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
1121617c04Sjeremylt // a collaborative effort of two U.S. Department of Energy organizations (Office
1221617c04Sjeremylt // of Science and the National Nuclear Security Administration) responsible for
1321617c04Sjeremylt // the planning and preparation of a capable exascale ecosystem, including
1421617c04Sjeremylt // software, applications, hardware, advanced system engineering and early
1521617c04Sjeremylt // testbed platforms, in support of the nation's exascale computing imperative.
1621617c04Sjeremylt 
173d576824SJeremy L Thompson #ifndef _ceed_ref_h
183d576824SJeremy L Thompson #define _ceed_ref_h
193d576824SJeremy L Thompson 
20ec3da8bcSJed Brown #include <ceed/ceed.h>
21ec3da8bcSJed Brown #include <ceed/backend.h>
223d576824SJeremy L Thompson #include <stdbool.h>
233d576824SJeremy L Thompson #include <stdint.h>
2421617c04Sjeremylt 
2521617c04Sjeremylt typedef struct {
268c1105f8SJeremy L Thompson   CeedScalar *collo_grad_1d;
278c1105f8SJeremy L Thompson   bool has_collo_interp;
2884a01de5SJeremy L Thompson } CeedBasis_Ref;
2984a01de5SJeremy L Thompson 
3084a01de5SJeremy L Thompson typedef struct {
3121617c04Sjeremylt   CeedScalar *array;
329c774eddSJeremy L Thompson   CeedScalar *array_borrowed;
339c774eddSJeremy L Thompson   CeedScalar *array_owned;
3421617c04Sjeremylt } CeedVector_Ref;
3521617c04Sjeremylt 
3621617c04Sjeremylt typedef struct {
37d979a051Sjeremylt   const CeedInt *offsets;
38d979a051Sjeremylt   CeedInt *offsets_allocated;
39*fc0567d9Srezgarshakeri   // Orientation, if it exists, is true when the face must be flipped (multiplies by -1.).
40*fc0567d9Srezgarshakeri   const bool *orient;
41*fc0567d9Srezgarshakeri   bool *orient_allocated;
42d979a051Sjeremylt   int (*Apply)(CeedElemRestriction, const CeedInt, const CeedInt,
43d979a051Sjeremylt                const CeedInt, CeedInt, CeedInt, CeedTransposeMode, CeedVector,
44d979a051Sjeremylt                CeedVector, CeedRequest *);
4521617c04Sjeremylt } CeedElemRestriction_Ref;
4621617c04Sjeremylt 
4721617c04Sjeremylt typedef struct {
48aedaa0e5Sjeremylt   const CeedScalar **inputs;
49aedaa0e5Sjeremylt   CeedScalar **outputs;
50aedaa0e5Sjeremylt } CeedQFunction_Ref;
51aedaa0e5Sjeremylt 
52aedaa0e5Sjeremylt typedef struct {
53777ff853SJeremy L Thompson   void *data;
549c774eddSJeremy L Thompson   void *data_borrowed;
559c774eddSJeremy L Thompson   void *data_owned;
56777ff853SJeremy L Thompson } CeedQFunctionContext_Ref;
57777ff853SJeremy L Thompson 
58777ff853SJeremy L Thompson typedef struct {
590b454692Sjeremylt   bool is_identity_qf, is_identity_restr_op;
604fc1f125SJeremy L Thompson   CeedVector *e_vecs_full; /* Full E-vectors, inputs followed by outputs */
614fc1f125SJeremy L Thompson   uint64_t *input_states;  /* State counter of inputs */
624fc1f125SJeremy L Thompson   CeedVector *e_vecs_in;   /* Single element input E-vectors  */
634fc1f125SJeremy L Thompson   CeedVector *e_vecs_out;  /* Single element output E-vectors */
644fc1f125SJeremy L Thompson   CeedVector *q_vecs_in;   /* Single element input Q-vectors  */
654fc1f125SJeremy L Thompson   CeedVector *q_vecs_out;  /* Single element output Q-vectors */
664fc1f125SJeremy L Thompson   CeedInt    num_inputs, num_outputs;
674fc1f125SJeremy L Thompson   CeedInt    num_active_in, num_active_out;
68bb219a0fSJeremy L Thompson   CeedVector *qf_active_in;
6921617c04Sjeremylt } CeedOperator_Ref;
7021617c04Sjeremylt 
71667bc5fcSjeremylt CEED_INTERN int CeedVectorCreate_Ref(CeedInt n, CeedVector vec);
7221617c04Sjeremylt 
73d1d35e2fSjeremylt CEED_INTERN int CeedElemRestrictionCreate_Ref(CeedMemType mem_type,
74d1d35e2fSjeremylt     CeedCopyMode copy_mode, const CeedInt *indices, CeedElemRestriction r);
7521617c04Sjeremylt 
76*fc0567d9Srezgarshakeri CEED_INTERN int CeedElemRestrictionCreateOriented_Ref(CeedMemType mem_type,
77*fc0567d9Srezgarshakeri     CeedCopyMode copy_mode, const CeedInt *indices,
78*fc0567d9Srezgarshakeri     const bool *orient, CeedElemRestriction r);
79*fc0567d9Srezgarshakeri 
80d1d35e2fSjeremylt CEED_INTERN int CeedBasisCreateTensorH1_Ref(CeedInt dim, CeedInt P_1d,
81d1d35e2fSjeremylt     CeedInt Q_1d, const CeedScalar *interp_1d, const CeedScalar *grad_1d,
82d1d35e2fSjeremylt     const CeedScalar *q_ref_1d, const CeedScalar *q_weight_1d, CeedBasis basis);
8321617c04Sjeremylt 
84667bc5fcSjeremylt CEED_INTERN int CeedBasisCreateH1_Ref(CeedElemTopology topo,
85d1d35e2fSjeremylt                                       CeedInt dim, CeedInt num_dof, CeedInt num_qpts,
86a8de75f0Sjeremylt                                       const CeedScalar *interp,
87a8de75f0Sjeremylt                                       const CeedScalar *grad,
88d1d35e2fSjeremylt                                       const CeedScalar *q_ref,
89d1d35e2fSjeremylt                                       const CeedScalar *q_weight,
90a8de75f0Sjeremylt                                       CeedBasis basis);
91a8de75f0Sjeremylt 
9250c301a5SRezgar Shakeri CEED_INTERN int CeedBasisCreateHdiv_Ref(CeedElemTopology topo,
9350c301a5SRezgar Shakeri                                         CeedInt dim, CeedInt num_dof, CeedInt num_qpts,
9450c301a5SRezgar Shakeri                                         const CeedScalar *interp,
9550c301a5SRezgar Shakeri                                         const CeedScalar *div,
9650c301a5SRezgar Shakeri                                         const CeedScalar *q_ref,
9750c301a5SRezgar Shakeri                                         const CeedScalar *q_weight,
9850c301a5SRezgar Shakeri                                         CeedBasis basis);
9950c301a5SRezgar Shakeri 
100c71e1dcdSjeremylt CEED_INTERN int CeedTensorContractCreate_Ref(CeedBasis basis,
101c71e1dcdSjeremylt     CeedTensorContract contract);
1022f86a920SJeremy L Thompson 
10321617c04Sjeremylt CEED_INTERN int CeedQFunctionCreate_Ref(CeedQFunction qf);
10421617c04Sjeremylt 
105777ff853SJeremy L Thompson CEED_INTERN int CeedQFunctionContextCreate_Ref(CeedQFunctionContext ctx);
106777ff853SJeremy L Thompson 
10721617c04Sjeremylt CEED_INTERN int CeedOperatorCreate_Ref(CeedOperator op);
108c04a41a7SJeremy L Thompson 
1093d576824SJeremy L Thompson #endif // _ceed_ref_h
110