xref: /libCEED/rust/libceed-sys/c-src/backends/ref/ceed-ref.h (revision fcbe8c069ccd22d836386af4823e4c7d84ee0a69)
13d8e8822SJeremy L Thompson // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors.
23d8e8822SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
321617c04Sjeremylt //
43d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause
521617c04Sjeremylt //
63d8e8822SJeremy L Thompson // This file is part of CEED:  http://github.com/ceed
721617c04Sjeremylt 
83d576824SJeremy L Thompson #ifndef _ceed_ref_h
93d576824SJeremy L Thompson #define _ceed_ref_h
103d576824SJeremy L Thompson 
1149aac155SJeremy L Thompson #include <ceed.h>
12ec3da8bcSJed Brown #include <ceed/backend.h>
133d576824SJeremy L Thompson #include <stdbool.h>
143d576824SJeremy L Thompson #include <stdint.h>
1521617c04Sjeremylt 
1621617c04Sjeremylt typedef struct {
178c1105f8SJeremy L Thompson   CeedScalar *collo_grad_1d;
188c1105f8SJeremy L Thompson   bool        has_collo_interp;
1984a01de5SJeremy L Thompson } CeedBasis_Ref;
2084a01de5SJeremy L Thompson 
2184a01de5SJeremy L Thompson typedef struct {
2221617c04Sjeremylt   CeedScalar *array;
239c774eddSJeremy L Thompson   CeedScalar *array_borrowed;
249c774eddSJeremy L Thompson   CeedScalar *array_owned;
2521617c04Sjeremylt } CeedVector_Ref;
2621617c04Sjeremylt 
2721617c04Sjeremylt typedef struct {
28d979a051Sjeremylt   const CeedInt *offsets;
29d979a051Sjeremylt   CeedInt       *offsets_allocated;
3077d1c127SSebastian Grimberg   const bool    *orients; /* Orientation, if it exists, is true when the dof must be flipped */
3177d1c127SSebastian Grimberg   bool          *orients_allocated;
3277d1c127SSebastian Grimberg   const CeedInt *curl_orients; /* Tridiagonal matrix (row-major) for a general transformation during restriction */
3377d1c127SSebastian Grimberg   CeedInt       *curl_orients_allocated;
34f30b1135SSebastian Grimberg   int (*Apply)(CeedElemRestriction, CeedInt, CeedInt, CeedInt, CeedInt, CeedInt, bool, CeedTransposeMode, CeedVector, CeedVector, CeedRequest *);
3521617c04Sjeremylt } CeedElemRestriction_Ref;
3621617c04Sjeremylt 
3721617c04Sjeremylt typedef struct {
38aedaa0e5Sjeremylt   const CeedScalar **inputs;
39aedaa0e5Sjeremylt   CeedScalar       **outputs;
40aedaa0e5Sjeremylt } CeedQFunction_Ref;
41aedaa0e5Sjeremylt 
42aedaa0e5Sjeremylt typedef struct {
43777ff853SJeremy L Thompson   void *data;
449c774eddSJeremy L Thompson   void *data_borrowed;
459c774eddSJeremy L Thompson   void *data_owned;
46777ff853SJeremy L Thompson } CeedQFunctionContext_Ref;
47777ff853SJeremy L Thompson 
48777ff853SJeremy L Thompson typedef struct {
490b454692Sjeremylt   bool        is_identity_qf, is_identity_restr_op;
504fc1f125SJeremy L Thompson   CeedVector *e_vecs_full;  /* Full E-vectors, inputs followed by outputs */
514fc1f125SJeremy L Thompson   uint64_t   *input_states; /* State counter of inputs */
524fc1f125SJeremy L Thompson   CeedVector *e_vecs_in;    /* Single element input E-vectors  */
534fc1f125SJeremy L Thompson   CeedVector *e_vecs_out;   /* Single element output E-vectors */
544fc1f125SJeremy L Thompson   CeedVector *q_vecs_in;    /* Single element input Q-vectors  */
554fc1f125SJeremy L Thompson   CeedVector *q_vecs_out;   /* Single element output Q-vectors */
564fc1f125SJeremy L Thompson   CeedInt     num_inputs, num_outputs;
574fc1f125SJeremy L Thompson   CeedInt     num_active_in, num_active_out;
58bb219a0fSJeremy L Thompson   CeedVector *qf_active_in;
5921617c04Sjeremylt } CeedOperator_Ref;
6021617c04Sjeremylt 
611f9221feSJeremy L Thompson CEED_INTERN int CeedVectorCreate_Ref(CeedSize n, CeedVector vec);
6221617c04Sjeremylt 
63*fcbe8c06SSebastian Grimberg CEED_INTERN int CeedElemRestrictionCreate_Ref(CeedMemType mem_type, CeedCopyMode copy_mode, const CeedInt *offsets, const bool *orients,
6477d1c127SSebastian Grimberg                                               const CeedInt *curl_orients, CeedElemRestriction r);
6521617c04Sjeremylt 
662b730f8bSJeremy L Thompson CEED_INTERN int CeedBasisCreateTensorH1_Ref(CeedInt dim, CeedInt P_1d, CeedInt Q_1d, const CeedScalar *interp_1d, const CeedScalar *grad_1d,
67d1d35e2fSjeremylt                                             const CeedScalar *q_ref_1d, const CeedScalar *q_weight_1d, CeedBasis basis);
682b730f8bSJeremy L Thompson CEED_INTERN int CeedBasisCreateH1_Ref(CeedElemTopology topo, CeedInt dim, CeedInt num_nodes, CeedInt num_qpts, const CeedScalar *interp,
692b730f8bSJeremy L Thompson                                       const CeedScalar *grad, const CeedScalar *q_ref, const CeedScalar *q_weight, CeedBasis basis);
702b730f8bSJeremy L Thompson CEED_INTERN int CeedBasisCreateHdiv_Ref(CeedElemTopology topo, CeedInt dim, CeedInt num_nodes, CeedInt num_qpts, const CeedScalar *interp,
712b730f8bSJeremy L Thompson                                         const CeedScalar *div, const CeedScalar *q_ref, const CeedScalar *q_weight, CeedBasis basis);
72c4e3f59bSSebastian Grimberg CEED_INTERN int CeedBasisCreateHcurl_Ref(CeedElemTopology topo, CeedInt dim, CeedInt num_nodes, CeedInt num_qpts, const CeedScalar *interp,
73c4e3f59bSSebastian Grimberg                                          const CeedScalar *curl, const CeedScalar *q_ref, const CeedScalar *q_weight, CeedBasis basis);
7421617c04Sjeremylt 
752b730f8bSJeremy L Thompson CEED_INTERN int CeedTensorContractCreate_Ref(CeedBasis basis, CeedTensorContract contract);
762f86a920SJeremy L Thompson 
7721617c04Sjeremylt CEED_INTERN int CeedQFunctionCreate_Ref(CeedQFunction qf);
7821617c04Sjeremylt 
79777ff853SJeremy L Thompson CEED_INTERN int CeedQFunctionContextCreate_Ref(CeedQFunctionContext ctx);
80777ff853SJeremy L Thompson 
8121617c04Sjeremylt CEED_INTERN int CeedOperatorCreate_Ref(CeedOperator op);
82c04a41a7SJeremy L Thompson 
833d576824SJeremy L Thompson #endif  // _ceed_ref_h
84