xref: /libCEED/rust/libceed-sys/c-src/backends/ref/ceed-ref.h (revision f8a0df597ca176fee6b07766b6124704acaa0050)
15aed82e4SJeremy L Thompson // Copyright (c) 2017-2024, 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
7509d4af6SJeremy L Thompson #pragma once
83d576824SJeremy L Thompson 
949aac155SJeremy L Thompson #include <ceed.h>
10ec3da8bcSJed Brown #include <ceed/backend.h>
113d576824SJeremy L Thompson #include <stdbool.h>
123d576824SJeremy L Thompson #include <stdint.h>
1321617c04Sjeremylt 
1421617c04Sjeremylt typedef struct {
1521617c04Sjeremylt   CeedScalar *array;
169c774eddSJeremy L Thompson   CeedScalar *array_borrowed;
179c774eddSJeremy L Thompson   CeedScalar *array_owned;
1821617c04Sjeremylt } CeedVector_Ref;
1921617c04Sjeremylt 
2021617c04Sjeremylt typedef struct {
21d979a051Sjeremylt   const CeedInt  *offsets;
22a267acd1SJeremy L Thompson   const CeedInt  *offsets_borrowed;
23f5d1e504SJeremy L Thompson   const CeedInt  *offsets_owned;
2477d1c127SSebastian Grimberg   const bool     *orients; /* Orientation, if it exists, is true when the dof must be flipped */
25a267acd1SJeremy L Thompson   const bool     *orients_borrowed;
26f5d1e504SJeremy L Thompson   const bool     *orients_owned;
270c73c039SSebastian Grimberg   const CeedInt8 *curl_orients; /* Tridiagonal matrix (row-major) for a general transformation during restriction */
28a267acd1SJeremy L Thompson   const CeedInt8 *curl_orients_borrowed;
29f5d1e504SJeremy L Thompson   const CeedInt8 *curl_orients_owned;
307c1dbaffSSebastian Grimberg   int (*Apply)(CeedElemRestriction, CeedInt, CeedInt, CeedInt, CeedInt, CeedInt, CeedTransposeMode, bool, bool, CeedVector, CeedVector,
317c1dbaffSSebastian Grimberg                CeedRequest *);
3221617c04Sjeremylt } CeedElemRestriction_Ref;
3321617c04Sjeremylt 
3421617c04Sjeremylt typedef struct {
35c7b67790SJeremy L Thompson   CeedScalar *collo_grad_1d;
36c7b67790SJeremy L Thompson   bool        has_collo_interp;
37c7b67790SJeremy L Thompson } CeedBasis_Ref;
38c7b67790SJeremy L Thompson 
39c7b67790SJeremy L Thompson typedef struct {
40aedaa0e5Sjeremylt   const CeedScalar **inputs;
41aedaa0e5Sjeremylt   CeedScalar       **outputs;
42aedaa0e5Sjeremylt } CeedQFunction_Ref;
43aedaa0e5Sjeremylt 
44aedaa0e5Sjeremylt typedef struct {
45777ff853SJeremy L Thompson   void *data;
469c774eddSJeremy L Thompson   void *data_borrowed;
479c774eddSJeremy L Thompson   void *data_owned;
48777ff853SJeremy L Thompson } CeedQFunctionContext_Ref;
49777ff853SJeremy L Thompson 
50777ff853SJeremy L Thompson typedef struct {
51edb2538eSJeremy L Thompson   bool        is_identity_qf, is_identity_rstr_op;
52*f8a0df59SJeremy L Thompson   bool       *skip_rstr_in, *skip_rstr_out, *apply_add_basis_out;
53*f8a0df59SJeremy L Thompson   CeedInt    *e_data_out_indices;
544fc1f125SJeremy L Thompson   uint64_t   *input_states; /* State counter of inputs */
553aab95c0SJeremy L Thompson   CeedVector *e_vecs_full;  /* Full E-vectors, inputs followed by outputs */
564fc1f125SJeremy L Thompson   CeedVector *e_vecs_in;    /* Single element input E-vectors  */
574fc1f125SJeremy L Thompson   CeedVector *e_vecs_out;   /* Single element output E-vectors */
584fc1f125SJeremy L Thompson   CeedVector *q_vecs_in;    /* Single element input Q-vectors  */
594fc1f125SJeremy L Thompson   CeedVector *q_vecs_out;   /* Single element output Q-vectors */
604fc1f125SJeremy L Thompson   CeedInt     num_inputs, num_outputs;
61ff8551c5SJeremy L Thompson   CeedInt     qf_size_in, qf_size_out;
62c7b67790SJeremy L Thompson   CeedVector  point_coords_elem;
6321617c04Sjeremylt } CeedOperator_Ref;
6421617c04Sjeremylt 
651f9221feSJeremy L Thompson CEED_INTERN int CeedVectorCreate_Ref(CeedSize n, CeedVector vec);
6621617c04Sjeremylt 
67fcbe8c06SSebastian Grimberg CEED_INTERN int CeedElemRestrictionCreate_Ref(CeedMemType mem_type, CeedCopyMode copy_mode, const CeedInt *offsets, const bool *orients,
680c73c039SSebastian Grimberg                                               const CeedInt8 *curl_orients, CeedElemRestriction r);
6921617c04Sjeremylt 
702b730f8bSJeremy L Thompson CEED_INTERN int CeedBasisCreateTensorH1_Ref(CeedInt dim, CeedInt P_1d, CeedInt Q_1d, const CeedScalar *interp_1d, const CeedScalar *grad_1d,
71d1d35e2fSjeremylt                                             const CeedScalar *q_ref_1d, const CeedScalar *q_weight_1d, CeedBasis basis);
722b730f8bSJeremy L Thompson CEED_INTERN int CeedBasisCreateH1_Ref(CeedElemTopology topo, CeedInt dim, CeedInt num_nodes, CeedInt num_qpts, const CeedScalar *interp,
732b730f8bSJeremy L Thompson                                       const CeedScalar *grad, const CeedScalar *q_ref, const CeedScalar *q_weight, CeedBasis basis);
742b730f8bSJeremy L Thompson CEED_INTERN int CeedBasisCreateHdiv_Ref(CeedElemTopology topo, CeedInt dim, CeedInt num_nodes, CeedInt num_qpts, const CeedScalar *interp,
752b730f8bSJeremy L Thompson                                         const CeedScalar *div, const CeedScalar *q_ref, const CeedScalar *q_weight, CeedBasis basis);
76c4e3f59bSSebastian Grimberg CEED_INTERN int CeedBasisCreateHcurl_Ref(CeedElemTopology topo, CeedInt dim, CeedInt num_nodes, CeedInt num_qpts, const CeedScalar *interp,
77c4e3f59bSSebastian Grimberg                                          const CeedScalar *curl, const CeedScalar *q_ref, const CeedScalar *q_weight, CeedBasis basis);
7821617c04Sjeremylt 
79a71faab1SSebastian Grimberg CEED_INTERN int CeedTensorContractCreate_Ref(CeedTensorContract contract);
802f86a920SJeremy L Thompson 
8121617c04Sjeremylt CEED_INTERN int CeedQFunctionCreate_Ref(CeedQFunction qf);
8221617c04Sjeremylt 
83777ff853SJeremy L Thompson CEED_INTERN int CeedQFunctionContextCreate_Ref(CeedQFunctionContext ctx);
84777ff853SJeremy L Thompson 
8521617c04Sjeremylt CEED_INTERN int CeedOperatorCreate_Ref(CeedOperator op);
8648acf710SJeremy L Thompson CEED_INTERN int CeedOperatorCreateAtPoints_Ref(CeedOperator op);
87