xref: /libCEED/include/ceed-impl.h (revision bff6a1231d662da27b929cc95dd28e45f562ae48)
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.
36ea7c6c1SJed Brown //
43d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause
56ea7c6c1SJed Brown //
63d8e8822SJeremy L Thompson // This file is part of CEED:  http://github.com/ceed
76ea7c6c1SJed Brown 
85d6bafb2Sjeremylt /// @file
95d6bafb2Sjeremylt /// Private header for frontend components of libCEED
106ea7c6c1SJed Brown #ifndef _ceed_impl_h
116ea7c6c1SJed Brown #define _ceed_impl_h
126ea7c6c1SJed Brown 
13ec3da8bcSJed Brown #include <ceed/ceed.h>
14ec3da8bcSJed Brown #include <ceed/backend.h>
15ff8ca64bSJed Brown #include <stdbool.h>
166ea7c6c1SJed Brown 
17032e71eaSJeremy L Thompson CEED_INTERN const char CeedJitSourceRootDefault[];
18032e71eaSJeremy L Thompson 
197a982d89SJeremy L. Thompson /** @defgroup CeedUser Public API for Ceed
207a982d89SJeremy L. Thompson     @ingroup Ceed
217a982d89SJeremy L. Thompson */
227a982d89SJeremy L. Thompson /** @defgroup CeedBackend Backend API for Ceed
237a982d89SJeremy L. Thompson     @ingroup Ceed
247a982d89SJeremy L. Thompson */
257a982d89SJeremy L. Thompson /** @defgroup CeedDeveloper Internal library functions for Ceed
267a982d89SJeremy L. Thompson     @ingroup Ceed
277a982d89SJeremy L. Thompson */
287a982d89SJeremy L. Thompson /** @defgroup CeedVectorUser Public API for CeedVector
297a982d89SJeremy L. Thompson     @ingroup CeedVector
307a982d89SJeremy L. Thompson */
317a982d89SJeremy L. Thompson /** @defgroup CeedVectorBackend Backend API for CeedVector
327a982d89SJeremy L. Thompson     @ingroup CeedVector
337a982d89SJeremy L. Thompson */
347a982d89SJeremy L. Thompson /** @defgroup CeedVectorDeveloper Internal library functions for CeedVector
357a982d89SJeremy L. Thompson     @ingroup CeedVector
367a982d89SJeremy L. Thompson */
377a982d89SJeremy L. Thompson /** @defgroup CeedElemRestrictionUser Public API for CeedElemRestriction
387a982d89SJeremy L. Thompson     @ingroup CeedElemRestriction
397a982d89SJeremy L. Thompson */
407a982d89SJeremy L. Thompson /** @defgroup CeedElemRestrictionBackend Backend API for CeedElemRestriction
417a982d89SJeremy L. Thompson     @ingroup CeedElemRestriction
427a982d89SJeremy L. Thompson */
437a982d89SJeremy L. Thompson /** @defgroup CeedElemRestrictionDeveloper Internal library functions for CeedElemRestriction
447a982d89SJeremy L. Thompson     @ingroup CeedElemRestriction
457a982d89SJeremy L. Thompson */
467a982d89SJeremy L. Thompson /** @defgroup CeedBasisUser Public API for CeedBasis
477a982d89SJeremy L. Thompson     @ingroup CeedBasis
487a982d89SJeremy L. Thompson */
497a982d89SJeremy L. Thompson /** @defgroup CeedBasisBackend Backend API for CeedBasis
507a982d89SJeremy L. Thompson     @ingroup CeedBasis
517a982d89SJeremy L. Thompson */
527a982d89SJeremy L. Thompson /** @defgroup CeedBasisDeveloper Internal library functions for CeedBasis
537a982d89SJeremy L. Thompson     @ingroup CeedBasis
547a982d89SJeremy L. Thompson */
557a982d89SJeremy L. Thompson /** @defgroup CeedQFunctionUser Public API for CeedQFunction
567a982d89SJeremy L. Thompson     @ingroup CeedQFunction
577a982d89SJeremy L. Thompson */
587a982d89SJeremy L. Thompson /** @defgroup CeedQFunctionBackend Backend API for CeedQFunction
597a982d89SJeremy L. Thompson     @ingroup CeedQFunction
607a982d89SJeremy L. Thompson */
617a982d89SJeremy L. Thompson /** @defgroup CeedQFunctionDeveloper Internal library functions for CeedQFunction
627a982d89SJeremy L. Thompson     @ingroup CeedQFunction
637a982d89SJeremy L. Thompson */
647a982d89SJeremy L. Thompson /** @defgroup CeedOperatorUser Public API for CeedOperator
657a982d89SJeremy L. Thompson     @ingroup CeedOperator
667a982d89SJeremy L. Thompson */
677a982d89SJeremy L. Thompson /** @defgroup CeedOperatorBackend Backend API for CeedOperator
687a982d89SJeremy L. Thompson     @ingroup CeedOperator
697a982d89SJeremy L. Thompson */
707a982d89SJeremy L. Thompson /** @defgroup CeedOperatorDeveloper Internal library functions for CeedOperator
717a982d89SJeremy L. Thompson     @ingroup CeedOperator
727a982d89SJeremy L. Thompson */
737a982d89SJeremy L. Thompson 
74fe2413ffSjeremylt // Lookup table field for backend functions
75fe2413ffSjeremylt typedef struct {
76d1d35e2fSjeremylt   const char *func_name;
77fe2413ffSjeremylt   size_t offset;
78d1d35e2fSjeremylt } FOffset;
79fe2413ffSjeremylt 
80aefd8378Sjeremylt // Lookup table field for object delegates
81aefd8378Sjeremylt typedef struct {
82d1d35e2fSjeremylt   char *obj_name;
83aefd8378Sjeremylt   Ceed delegate;
84d1d35e2fSjeremylt } ObjDelegate;
85aefd8378Sjeremylt 
866ea7c6c1SJed Brown struct Ceed_private {
87e07206deSjeremylt   const char *resource;
885fe0d4faSjeremylt   Ceed delegate;
892f86a920SJeremy L Thompson   Ceed parent;
90d1d35e2fSjeremylt   ObjDelegate *obj_delegates;
91d1d35e2fSjeremylt   int obj_delegate_count;
92d1d35e2fSjeremylt   Ceed op_fallback_ceed, op_fallback_parent;
93d1d35e2fSjeremylt   const char *op_fallback_resource;
94ee5a26f2SJeremy L Thompson   char **jit_source_roots;
95032e71eaSJeremy L Thompson   CeedInt num_jit_source_roots;
962f86a920SJeremy L Thompson   int (*Error)(Ceed, const char *, int, const char *, int, const char *,
97f9982c62SWill Pazner                va_list *);
98c907536fSjeremylt   int (*GetPreferredMemType)(CeedMemType *);
996ea7c6c1SJed Brown   int (*Destroy)(Ceed);
1001f9221feSJeremy L Thompson   int (*VectorCreate)(CeedSize, CeedVector);
101667bc5fcSjeremylt   int (*ElemRestrictionCreate)(CeedMemType, CeedCopyMode,
102667bc5fcSjeremylt                                const CeedInt *, CeedElemRestriction);
103fc0567d9Srezgarshakeri   int (*ElemRestrictionCreateOriented)(CeedMemType, CeedCopyMode,
104fc0567d9Srezgarshakeri                                        const CeedInt *, const bool *,
105fc0567d9Srezgarshakeri                                        CeedElemRestriction);
106667bc5fcSjeremylt   int (*ElemRestrictionCreateBlocked)(CeedMemType, CeedCopyMode,
107667bc5fcSjeremylt                                       const CeedInt *, CeedElemRestriction);
108667bc5fcSjeremylt   int (*BasisCreateTensorH1)(CeedInt, CeedInt, CeedInt, const CeedScalar *,
1092f86a920SJeremy L Thompson                              const CeedScalar *, const CeedScalar *,
1102f86a920SJeremy L Thompson                              const CeedScalar *, CeedBasis);
111667bc5fcSjeremylt   int (*BasisCreateH1)(CeedElemTopology, CeedInt, CeedInt, CeedInt,
112a8de75f0Sjeremylt                        const CeedScalar *,
1132f86a920SJeremy L Thompson                        const CeedScalar *, const CeedScalar *,
1142f86a920SJeremy L Thompson                        const CeedScalar *, CeedBasis);
11550c301a5SRezgar Shakeri   int (*BasisCreateHdiv)(CeedElemTopology, CeedInt, CeedInt, CeedInt,
11650c301a5SRezgar Shakeri                          const CeedScalar *,
11750c301a5SRezgar Shakeri                          const CeedScalar *, const CeedScalar *,
11850c301a5SRezgar Shakeri                          const CeedScalar *, CeedBasis);
119c71e1dcdSjeremylt   int (*TensorContractCreate)(CeedBasis, CeedTensorContract);
1206ea7c6c1SJed Brown   int (*QFunctionCreate)(CeedQFunction);
121777ff853SJeremy L Thompson   int (*QFunctionContextCreate)(CeedQFunctionContext);
1226ea7c6c1SJed Brown   int (*OperatorCreate)(CeedOperator);
12352d6035fSJeremy L Thompson   int (*CompositeOperatorCreate)(CeedOperator);
124d1d35e2fSjeremylt   int ref_count;
1256ea7c6c1SJed Brown   void *data;
1263f21f6b1SJeremy L Thompson   bool is_debug;
127d04bbc78SJeremy L Thompson   bool has_valid_op_fallback_resource;
1283f21f6b1SJeremy L Thompson   bool is_deterministic;
129d1d35e2fSjeremylt   char err_msg[CEED_MAX_RESOURCE_LEN];
130d1d35e2fSjeremylt   FOffset *f_offsets;
1316ea7c6c1SJed Brown };
1326ea7c6c1SJed Brown 
1336ea7c6c1SJed Brown struct CeedVector_private {
1346ea7c6c1SJed Brown   Ceed ceed;
1359c774eddSJeremy L Thompson   int (*HasValidArray)(CeedVector, bool *);
1369c774eddSJeremy L Thompson   int (*HasBorrowedArrayOfType)(CeedVector, CeedMemType, bool *);
1376ea7c6c1SJed Brown   int (*SetArray)(CeedVector, CeedMemType, CeedCopyMode, CeedScalar *);
1382a1ab385Sjeremylt   int (*SetValue)(CeedVector, CeedScalar);
13954540941SJeremy L Thompson   int (*SyncArray)(CeedVector, CeedMemType);
1406a6c615bSJeremy L Thompson   int (*TakeArray)(CeedVector, CeedMemType, CeedScalar **);
1416ea7c6c1SJed Brown   int (*GetArray)(CeedVector, CeedMemType, CeedScalar **);
1426ea7c6c1SJed Brown   int (*GetArrayRead)(CeedVector, CeedMemType, const CeedScalar **);
1439c774eddSJeremy L Thompson   int (*GetArrayWrite)(CeedVector, CeedMemType, CeedScalar **);
144f05116b9SJeremy L Thompson   int (*RestoreArray)(CeedVector);
145f05116b9SJeremy L Thompson   int (*RestoreArrayRead)(CeedVector);
146547d9b97Sjeremylt   int (*Norm)(CeedVector, CeedNormType, CeedScalar *);
147e0dd3b27Sjeremylt   int (*Scale)(CeedVector, CeedScalar);
1480f7fd0f8Sjeremylt   int (*AXPY)(CeedVector, CeedScalar, CeedVector);
1490f7fd0f8Sjeremylt   int (*PointwiseMult)(CeedVector, CeedVector, CeedVector);
150d99fa3c5SJeremy L Thompson   int (*Reciprocal)(CeedVector);
1516ea7c6c1SJed Brown   int (*Destroy)(CeedVector);
152d1d35e2fSjeremylt   int ref_count;
153d2643443SJeremy L Thompson   CeedSize length;
15436ac90ebSjeremylt   uint64_t state;
155d1d35e2fSjeremylt   uint64_t num_readers;
1566ea7c6c1SJed Brown   void *data;
1576ea7c6c1SJed Brown };
1586ea7c6c1SJed Brown 
1596ea7c6c1SJed Brown struct CeedElemRestriction_private {
1606ea7c6c1SJed Brown   Ceed ceed;
161074cb416Sjeremylt   int (*Apply)(CeedElemRestriction, CeedTransposeMode, CeedVector, CeedVector,
162074cb416Sjeremylt                CeedRequest *);
163074cb416Sjeremylt   int (*ApplyBlock)(CeedElemRestriction, CeedInt, CeedTransposeMode, CeedVector,
164074cb416Sjeremylt                     CeedVector, CeedRequest *);
165bd33150aSjeremylt   int (*GetOffsets)(CeedElemRestriction, CeedMemType, const CeedInt **);
1666ea7c6c1SJed Brown   int (*Destroy)(CeedElemRestriction);
167d1d35e2fSjeremylt   int ref_count;
168d1d35e2fSjeremylt   CeedInt num_elem;      /* number of elements */
169d1d35e2fSjeremylt   CeedInt elem_size;     /* number of nodes per element */
170d1d35e2fSjeremylt   CeedInt num_comp;      /* number of components */
171d1d35e2fSjeremylt   CeedInt comp_stride;   /* Component stride for L-vector ordering */
172e79b91d9SJeremy L Thompson   CeedSize l_size;       /* size of the L-vector, can be used for checking
173d979a051Sjeremylt                               for correct vector sizes */
174d1d35e2fSjeremylt   CeedInt blk_size;      /* number of elements in a batch */
175d1d35e2fSjeremylt   CeedInt num_blk;       /* number of blocks of elements */
1767509a596Sjeremylt   CeedInt *strides;      /* strides between [nodes, components, elements] */
17749fd234cSJeremy L Thompson   CeedInt layout[3];     /* E-vector layout [nodes, components, elements] */
178d1d35e2fSjeremylt   uint64_t num_readers;  /* number of instances of offset read only access */
179b435c5a6Srezgarshakeri   bool is_oriented;       /* flag for oriented restriction */
1806ea7c6c1SJed Brown   void *data;            /* place for the backend to store any data */
1816ea7c6c1SJed Brown };
1826ea7c6c1SJed Brown 
1836ea7c6c1SJed Brown struct CeedBasis_private {
1846ea7c6c1SJed Brown   Ceed ceed;
1854b8bea3bSJed Brown   int (*Apply)(CeedBasis, CeedInt, CeedTransposeMode, CeedEvalMode,
186aedaa0e5Sjeremylt                CeedVector, CeedVector);
1876ea7c6c1SJed Brown   int (*Destroy)(CeedBasis);
188d1d35e2fSjeremylt   int ref_count;
189d1d35e2fSjeremylt   bool tensor_basis;       /* flag for tensor basis */
1900f5de9e9Sjeremylt   CeedInt dim;             /* topological dimension */
191d99fa3c5SJeremy L Thompson   CeedElemTopology topo;   /* element topology */
192d1d35e2fSjeremylt   CeedInt num_comp;        /* number of field components (1 for scalar fields) */
19350c301a5SRezgar Shakeri   CeedInt Q_comp;        /* number of Q-vector components (1 for H^1, dim for H(div)) */
194d1d35e2fSjeremylt   CeedInt P_1d;            /* number of nodes in one dimension */
195d1d35e2fSjeremylt   CeedInt Q_1d;            /* number of quadrature points in one dimension */
196a8de75f0Sjeremylt   CeedInt P;               /* total number of nodes */
197a8de75f0Sjeremylt   CeedInt Q;               /* total number of quadrature points */
198d1d35e2fSjeremylt   CeedScalar *q_ref_1d;    /* Array of length Q1d holding the locations of
199a8d32208Sjeremylt                                 quadrature points on the 1D reference
200a8d32208Sjeremylt                                 element [-1, 1] */
201d1d35e2fSjeremylt   CeedScalar
202d1d35e2fSjeremylt   *q_weight_1d; /* array of length Q1d holding the quadrature weights on
2030f5de9e9Sjeremylt                                the reference element */
2044b8bea3bSJed Brown   CeedScalar
20550c301a5SRezgar Shakeri   *interp;    /* row-major matrix of shape [Q_comp*Q, P] expressing the values of
20600f91b2bSjeremylt                    nodal basis functions at quadrature points */
20700f91b2bSjeremylt   CeedScalar
208d1d35e2fSjeremylt   *interp_1d; /* row-major matrix of shape [Q1d, P1d] expressing the values of
2090f5de9e9Sjeremylt                    nodal basis functions at quadrature points */
2104b8bea3bSJed Brown   CeedScalar
21150c301a5SRezgar Shakeri   *grad;      /* row-major matrix of shape [dim*Q_comp*Q, P] matrix expressing
212a8d32208Sjeremylt                    derivatives of nodal basis functions at quadrature points */
21300f91b2bSjeremylt   CeedScalar
214d1d35e2fSjeremylt   *grad_1d;   /* row-major matrix of shape [Q1d, P1d] matrix expressing
215a8d32208Sjeremylt                    derivatives of nodal basis functions at quadrature points */
2162f86a920SJeremy L Thompson   CeedTensorContract contract; /* tensor contraction object */
217*bff6a123SJeremy L Thompson   CeedFESpace basis_space;  /* Initialize in basis constructor
21850c301a5SRezgar Shakeri                                  with 1,2 for H^1, H(div) FE space */
21950c301a5SRezgar Shakeri   CeedScalar *div;  /* row-major matrix of shape [Q, P] expressing
22050c301a5SRezgar Shakeri                         the divergence of nodal basis functions
22150c301a5SRezgar Shakeri                         at quadrature points for H(div) discretizations */
222c01dd730Scamierjs   void *data;                  /* place for the backend to store any data */
2236ea7c6c1SJed Brown };
2246ea7c6c1SJed Brown 
2252f86a920SJeremy L Thompson struct CeedTensorContract_private {
2262f86a920SJeremy L Thompson   Ceed ceed;
2272f86a920SJeremy L Thompson   int (*Apply)(CeedTensorContract, CeedInt, CeedInt, CeedInt, CeedInt,
2282f86a920SJeremy L Thompson                const CeedScalar *restrict, CeedTransposeMode, const CeedInt,
2292f86a920SJeremy L Thompson                const CeedScalar *restrict, CeedScalar *restrict);
2302f86a920SJeremy L Thompson   int (*Destroy)(CeedTensorContract);
231d1d35e2fSjeremylt   int ref_count;
2322f86a920SJeremy L Thompson   void *data;
2332f86a920SJeremy L Thompson };
2342f86a920SJeremy L Thompson 
235d1bcdac9Sjeremylt struct CeedQFunctionField_private {
236d1d35e2fSjeremylt   const char *field_name;
2374d537eeaSYohann   CeedInt size;
238d1d35e2fSjeremylt   CeedEvalMode eval_mode;
239ff8ca64bSJed Brown };
240ff8ca64bSJed Brown 
2416ea7c6c1SJed Brown struct CeedQFunction_private {
2426ea7c6c1SJed Brown   Ceed ceed;
2432f86a920SJeremy L Thompson   int (*Apply)(CeedQFunction, CeedInt, CeedVector *, CeedVector *);
2448c84ac63Sjeremylt   int (*SetCUDAUserFunction)(CeedQFunction, void *);
2458c84ac63Sjeremylt   int (*SetHIPUserFunction)(CeedQFunction, void *);
2466ea7c6c1SJed Brown   int (*Destroy)(CeedQFunction);
247d1d35e2fSjeremylt   int ref_count;
248d1d35e2fSjeremylt   CeedInt vec_length; /* Number of quadrature points must be padded to a
249d1d35e2fSjeremylt                            multiple of vec_length */
250d1d35e2fSjeremylt   CeedQFunctionField *input_fields;
251d1d35e2fSjeremylt   CeedQFunctionField *output_fields;
252d1d35e2fSjeremylt   CeedInt num_input_fields, num_output_fields;
2539f0427d9SYohann   CeedQFunctionUser function;
2546e15d496SJeremy L Thompson   CeedInt user_flop_estimate;
255ca5eadf8SJeremy L Thompson   const char *user_source;
256d1d35e2fSjeremylt   const char *source_path;
25743e1b16fSJeremy L Thompson   const char *kernel_name;
25843e1b16fSJeremy L Thompson   const char *gallery_name;
25943e1b16fSJeremy L Thompson   bool is_gallery;
260f04ea552SJeremy L Thompson   bool is_identity;
261f04ea552SJeremy L Thompson   bool is_fortran;
262f04ea552SJeremy L Thompson   bool is_immutable;
263441428dfSJeremy L Thompson   bool is_context_writable;
264777ff853SJeremy L Thompson   CeedQFunctionContext ctx; /* user context for function */
265a8d32208Sjeremylt   void *data;          /* place for the backend to store any data */
2666ea7c6c1SJed Brown };
2676ea7c6c1SJed Brown 
268777ff853SJeremy L Thompson struct CeedQFunctionContext_private {
269777ff853SJeremy L Thompson   Ceed ceed;
270d1d35e2fSjeremylt   int ref_count;
2719c774eddSJeremy L Thompson   int (*HasValidData)(CeedQFunctionContext, bool *);
2729c774eddSJeremy L Thompson   int (*HasBorrowedDataOfType)(CeedQFunctionContext, CeedMemType, bool *);
273777ff853SJeremy L Thompson   int (*SetData)(CeedQFunctionContext, CeedMemType, CeedCopyMode, void *);
274891038deSjeremylt   int (*TakeData)(CeedQFunctionContext, CeedMemType, void *);
275777ff853SJeremy L Thompson   int (*GetData)(CeedQFunctionContext, CeedMemType, void *);
27628bfd0b7SJeremy L Thompson   int (*GetDataRead)(CeedQFunctionContext, CeedMemType, void *);
277777ff853SJeremy L Thompson   int (*RestoreData)(CeedQFunctionContext);
27828bfd0b7SJeremy L Thompson   int (*RestoreDataRead)(CeedQFunctionContext);
2792e64a2b9SJeremy L Thompson   int (*DataDestroy)(CeedQFunctionContext);
280777ff853SJeremy L Thompson   int (*Destroy)(CeedQFunctionContext);
2812790b72bSJeremy L Thompson   CeedQFunctionContextDataDestroyUser data_destroy_function;
2822790b72bSJeremy L Thompson   CeedMemType data_destroy_mem_type;
283cdf32b93SJeremy L Thompson   CeedInt num_fields;
284cdf32b93SJeremy L Thompson   CeedInt max_fields;
2853668ca4bSJeremy L Thompson   CeedContextFieldLabel *field_labels;
286777ff853SJeremy L Thompson   uint64_t state;
28728bfd0b7SJeremy L Thompson   uint64_t num_readers;
288d1d35e2fSjeremylt   size_t ctx_size;
289777ff853SJeremy L Thompson   void *data;
290777ff853SJeremy L Thompson };
291777ff853SJeremy L Thompson 
2921e35832bSjeremylt /// Struct to handle the context data to use the Fortran QFunction stub
2931e35832bSjeremylt /// @ingroup CeedQFunction
294777ff853SJeremy L Thompson struct CeedFortranContext_private {
2958cb0412aSJeremy L Thompson   CeedQFunctionContext inner_ctx;
296069aeabaSjeremylt   void (*f)(void *ctx, int *nq,
297069aeabaSjeremylt             const CeedScalar *u,const CeedScalar *u1,
298069aeabaSjeremylt             const CeedScalar *u2,const CeedScalar *u3,
299069aeabaSjeremylt             const CeedScalar *u4,const CeedScalar *u5,
300069aeabaSjeremylt             const CeedScalar *u6,const CeedScalar *u7,
301069aeabaSjeremylt             const CeedScalar *u8,const CeedScalar *u9,
302069aeabaSjeremylt             const CeedScalar *u10,const CeedScalar *u11,
303069aeabaSjeremylt             const CeedScalar *u12,const CeedScalar *u13,
304069aeabaSjeremylt             const CeedScalar *u14,const CeedScalar *u15,
305069aeabaSjeremylt             CeedScalar *v,CeedScalar *v1,CeedScalar *v2,
306069aeabaSjeremylt             CeedScalar *v3,CeedScalar *v4,CeedScalar *v5,
307069aeabaSjeremylt             CeedScalar *v6,CeedScalar *v7,CeedScalar *v8,
308069aeabaSjeremylt             CeedScalar *v9, CeedScalar *v10,CeedScalar *v11,
309069aeabaSjeremylt             CeedScalar *v12,CeedScalar *v13,CeedScalar *v14,
310069aeabaSjeremylt             CeedScalar *v15, int *err);
311777ff853SJeremy L Thompson };
312777ff853SJeremy L Thompson typedef struct CeedFortranContext_private *CeedFortranContext;
313069aeabaSjeremylt 
3143668ca4bSJeremy L Thompson struct CeedContextFieldLabel_private {
3153668ca4bSJeremy L Thompson   const char *name;
3163668ca4bSJeremy L Thompson   const char *description;
3173668ca4bSJeremy L Thompson   CeedContextFieldType type;
3183668ca4bSJeremy L Thompson   size_t size;
3197bfe0f0eSJeremy L Thompson   size_t num_values;
3203668ca4bSJeremy L Thompson   size_t offset;
3213668ca4bSJeremy L Thompson   CeedInt num_sub_labels;
3223668ca4bSJeremy L Thompson   CeedContextFieldLabel *sub_labels;
3233668ca4bSJeremy L Thompson };
3243668ca4bSJeremy L Thompson 
325d1bcdac9Sjeremylt struct CeedOperatorField_private {
326d1d35e2fSjeremylt   CeedElemRestriction elem_restr; /* Restriction from L-vector */
327a8d32208Sjeremylt   CeedBasis basis;                /* Basis or CEED_BASIS_COLLOCATED for
328a8d32208Sjeremylt                                        collocated fields */
329a8d32208Sjeremylt   CeedVector vec;                 /* State vector for passive fields or
330a8d32208Sjeremylt                                        CEED_VECTOR_NONE for no vector */
331d1d35e2fSjeremylt   const char *field_name;          /* matching QFunction field name */
332ff8ca64bSJed Brown };
333ff8ca64bSJed Brown 
334480fae85SJeremy L Thompson struct CeedQFunctionAssemblyData_private {
335480fae85SJeremy L Thompson   Ceed ceed;
336480fae85SJeremy L Thompson   int ref_count;
337480fae85SJeremy L Thompson   bool is_setup;
338beecbf24SJeremy L Thompson   bool reuse_data;
339beecbf24SJeremy L Thompson   bool needs_data_update;
340480fae85SJeremy L Thompson   CeedVector vec;
341480fae85SJeremy L Thompson   CeedElemRestriction rstr;
342480fae85SJeremy L Thompson };
343480fae85SJeremy L Thompson 
344ed9e99e6SJeremy L Thompson struct CeedOperatorAssemblyData_private {
345ed9e99e6SJeremy L Thompson   Ceed ceed;
346ed9e99e6SJeremy L Thompson   CeedInt num_eval_mode_in, num_eval_mode_out;
347ed9e99e6SJeremy L Thompson   CeedEvalMode *eval_mode_in, *eval_mode_out;
348ed9e99e6SJeremy L Thompson   CeedScalar *B_in, *B_out;
349ed9e99e6SJeremy L Thompson   CeedBasis basis_in, basis_out;
350ed9e99e6SJeremy L Thompson };
351ed9e99e6SJeremy L Thompson 
3526ea7c6c1SJed Brown struct CeedOperator_private {
3536ea7c6c1SJed Brown   Ceed ceed;
354d1d35e2fSjeremylt   CeedOperator op_fallback;
355d1d35e2fSjeremylt   int ref_count;
35680ac2e43SJeremy L Thompson   int (*LinearAssembleQFunction)(CeedOperator, CeedVector *,
3571d102b48SJeremy L Thompson                                  CeedElemRestriction *, CeedRequest *);
35870a7ffb3SJeremy L Thompson   int (*LinearAssembleQFunctionUpdate)(CeedOperator, CeedVector,
35970a7ffb3SJeremy L Thompson                                        CeedElemRestriction, CeedRequest *);
3602bba3ffaSJeremy L Thompson   int (*LinearAssembleDiagonal)(CeedOperator, CeedVector, CeedRequest *);
3619e9210b8SJeremy L Thompson   int (*LinearAssembleAddDiagonal)(CeedOperator, CeedVector, CeedRequest *);
3622bba3ffaSJeremy L Thompson   int (*LinearAssemblePointBlockDiagonal)(CeedOperator, CeedVector,
363d965c7a7SJeremy L Thompson                                           CeedRequest *);
3649e9210b8SJeremy L Thompson   int (*LinearAssembleAddPointBlockDiagonal)(CeedOperator, CeedVector,
3659e9210b8SJeremy L Thompson       CeedRequest *);
366c30b7fbdSJeremy L Thompson   int (*LinearAssembleSymbolic)(CeedOperator, CeedSize *, CeedInt **,
3673047f789SJeremy L Thompson                                 CeedInt **);
368e2f04181SAndrew T. Barker   int (*LinearAssemble)(CeedOperator, CeedVector);
369cefa2673SJeremy L Thompson   int (*LinearAssembleSingle)(CeedOperator, CeedInt, CeedVector);
370713f43c3Sjeremylt   int (*CreateFDMElementInverse)(CeedOperator, CeedOperator *, CeedRequest *);
371ff8ca64bSJed Brown   int (*Apply)(CeedOperator, CeedVector, CeedVector, CeedRequest *);
372250756a7Sjeremylt   int (*ApplyComposite)(CeedOperator, CeedVector, CeedVector, CeedRequest *);
373cae8b89aSjeremylt   int (*ApplyAdd)(CeedOperator, CeedVector, CeedVector, CeedRequest *);
374250756a7Sjeremylt   int (*ApplyAddComposite)(CeedOperator, CeedVector, CeedVector, CeedRequest *);
3756ea7c6c1SJed Brown   int (*ApplyJacobian)(CeedOperator, CeedVector, CeedVector, CeedVector,
3766ea7c6c1SJed Brown                        CeedVector, CeedRequest *);
3776ea7c6c1SJed Brown   int (*Destroy)(CeedOperator);
378d1d35e2fSjeremylt   CeedOperatorField *input_fields;
379d1d35e2fSjeremylt   CeedOperatorField *output_fields;
3802b104005SJeremy L Thompson   CeedSize input_size, output_size;
381d1d35e2fSjeremylt   CeedInt num_elem;   /* Number of elements */
382d1d35e2fSjeremylt   CeedInt num_qpts;   /* Number of quadrature points over all elements */
383d1d35e2fSjeremylt   CeedInt num_fields; /* Number of fields that have been set */
3846ea7c6c1SJed Brown   CeedQFunction qf;
3856ea7c6c1SJed Brown   CeedQFunction dqf;
3866ea7c6c1SJed Brown   CeedQFunction dqfT;
387ea6b5821SJeremy L Thompson   const char *name;
388f04ea552SJeremy L Thompson   bool is_immutable;
389f04ea552SJeremy L Thompson   bool is_interface_setup;
390f04ea552SJeremy L Thompson   bool is_backend_setup;
391f04ea552SJeremy L Thompson   bool is_composite;
392d1d35e2fSjeremylt   bool has_restriction;
393480fae85SJeremy L Thompson   CeedQFunctionAssemblyData qf_assembled;
394ed9e99e6SJeremy L Thompson   CeedOperatorAssemblyData op_assembled;
395d1d35e2fSjeremylt   CeedOperator *sub_operators;
396d1d35e2fSjeremylt   CeedInt num_suboperators;
3976ea7c6c1SJed Brown   void *data;
3983668ca4bSJeremy L Thompson   CeedInt num_context_labels;
3993668ca4bSJeremy L Thompson   CeedInt max_context_labels;
4003668ca4bSJeremy L Thompson   CeedContextFieldLabel *context_labels;
4016ea7c6c1SJed Brown };
4026ea7c6c1SJed Brown 
403d04bbc78SJeremy L Thompson CEED_INTERN int CeedOperatorGetFallback(CeedOperator op,
404d04bbc78SJeremy L Thompson                                         CeedOperator *op_fallback);
405d04bbc78SJeremy L Thompson 
4066ea7c6c1SJed Brown #endif
407