xref: /libCEED/include/ceed-impl.h (revision 77d1c127eaba12da4c1761ef74a16ca3fc16e493)
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 
1349aac155SJeremy L Thompson #include <ceed.h>
14ec3da8bcSJed Brown #include <ceed/backend.h>
15ff8ca64bSJed Brown #include <stdbool.h>
166ea7c6c1SJed Brown 
172b730f8bSJeremy 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;
962b730f8bSJeremy L Thompson   int (*Error)(Ceed, const char *, int, const char *, int, const char *, va_list *);
975ae360d4SJeremy L Thompson   int (*SetStream)(Ceed, void *);
98c907536fSjeremylt   int (*GetPreferredMemType)(CeedMemType *);
996ea7c6c1SJed Brown   int (*Destroy)(Ceed);
1001f9221feSJeremy L Thompson   int (*VectorCreate)(CeedSize, CeedVector);
1012b730f8bSJeremy L Thompson   int (*ElemRestrictionCreate)(CeedMemType, CeedCopyMode, const CeedInt *, CeedElemRestriction);
1022b730f8bSJeremy L Thompson   int (*ElemRestrictionCreateOriented)(CeedMemType, CeedCopyMode, const CeedInt *, const bool *, CeedElemRestriction);
103*77d1c127SSebastian Grimberg   int (*ElemRestrictionCreateCurlOriented)(CeedMemType, CeedCopyMode, const CeedInt *, const CeedInt *, CeedElemRestriction);
1042b730f8bSJeremy L Thompson   int (*ElemRestrictionCreateBlocked)(CeedMemType, CeedCopyMode, const CeedInt *, CeedElemRestriction);
105*77d1c127SSebastian Grimberg   int (*ElemRestrictionCreateBlockedOriented)(CeedMemType, CeedCopyMode, const CeedInt *, const bool *, CeedElemRestriction);
106*77d1c127SSebastian Grimberg   int (*ElemRestrictionCreateBlockedCurlOriented)(CeedMemType, CeedCopyMode, const CeedInt *, const CeedInt *, CeedElemRestriction);
1072b730f8bSJeremy L Thompson   int (*BasisCreateTensorH1)(CeedInt, CeedInt, CeedInt, const CeedScalar *, const CeedScalar *, const CeedScalar *, const CeedScalar *, CeedBasis);
1082b730f8bSJeremy L Thompson   int (*BasisCreateH1)(CeedElemTopology, CeedInt, CeedInt, CeedInt, const CeedScalar *, const CeedScalar *, const CeedScalar *, const CeedScalar *,
1092b730f8bSJeremy L Thompson                        CeedBasis);
1102b730f8bSJeremy L Thompson   int (*BasisCreateHdiv)(CeedElemTopology, CeedInt, CeedInt, CeedInt, const CeedScalar *, const CeedScalar *, const CeedScalar *, const CeedScalar *,
1112b730f8bSJeremy L Thompson                          CeedBasis);
112c4e3f59bSSebastian Grimberg   int (*BasisCreateHcurl)(CeedElemTopology, CeedInt, CeedInt, CeedInt, const CeedScalar *, const CeedScalar *, const CeedScalar *, const CeedScalar *,
113c4e3f59bSSebastian Grimberg                           CeedBasis);
114c71e1dcdSjeremylt   int (*TensorContractCreate)(CeedBasis, CeedTensorContract);
1156ea7c6c1SJed Brown   int (*QFunctionCreate)(CeedQFunction);
116777ff853SJeremy L Thompson   int (*QFunctionContextCreate)(CeedQFunctionContext);
1176ea7c6c1SJed Brown   int (*OperatorCreate)(CeedOperator);
11852d6035fSJeremy L Thompson   int (*CompositeOperatorCreate)(CeedOperator);
119d1d35e2fSjeremylt   int      ref_count;
1206ea7c6c1SJed Brown   void    *data;
1213f21f6b1SJeremy L Thompson   bool     is_debug;
122d04bbc78SJeremy L Thompson   bool     has_valid_op_fallback_resource;
1233f21f6b1SJeremy L Thompson   bool     is_deterministic;
124d1d35e2fSjeremylt   char     err_msg[CEED_MAX_RESOURCE_LEN];
125d1d35e2fSjeremylt   FOffset *f_offsets;
1266ea7c6c1SJed Brown };
1276ea7c6c1SJed Brown 
1286ea7c6c1SJed Brown struct CeedVector_private {
1296ea7c6c1SJed Brown   Ceed ceed;
1309c774eddSJeremy L Thompson   int (*HasValidArray)(CeedVector, bool *);
1319c774eddSJeremy L Thompson   int (*HasBorrowedArrayOfType)(CeedVector, CeedMemType, bool *);
1326ea7c6c1SJed Brown   int (*SetArray)(CeedVector, CeedMemType, CeedCopyMode, CeedScalar *);
1332a1ab385Sjeremylt   int (*SetValue)(CeedVector, CeedScalar);
13454540941SJeremy L Thompson   int (*SyncArray)(CeedVector, CeedMemType);
1356a6c615bSJeremy L Thompson   int (*TakeArray)(CeedVector, CeedMemType, CeedScalar **);
1366ea7c6c1SJed Brown   int (*GetArray)(CeedVector, CeedMemType, CeedScalar **);
1376ea7c6c1SJed Brown   int (*GetArrayRead)(CeedVector, CeedMemType, const CeedScalar **);
1389c774eddSJeremy L Thompson   int (*GetArrayWrite)(CeedVector, CeedMemType, CeedScalar **);
139f05116b9SJeremy L Thompson   int (*RestoreArray)(CeedVector);
140f05116b9SJeremy L Thompson   int (*RestoreArrayRead)(CeedVector);
141547d9b97Sjeremylt   int (*Norm)(CeedVector, CeedNormType, CeedScalar *);
142e0dd3b27Sjeremylt   int (*Scale)(CeedVector, CeedScalar);
1430f7fd0f8Sjeremylt   int (*AXPY)(CeedVector, CeedScalar, CeedVector);
1445fb68f37SKaren (Ren) Stengel   int (*AXPBY)(CeedVector, CeedScalar, CeedScalar, CeedVector);
1450f7fd0f8Sjeremylt   int (*PointwiseMult)(CeedVector, CeedVector, CeedVector);
146d99fa3c5SJeremy L Thompson   int (*Reciprocal)(CeedVector);
1476ea7c6c1SJed Brown   int (*Destroy)(CeedVector);
148d1d35e2fSjeremylt   int      ref_count;
149d2643443SJeremy L Thompson   CeedSize length;
15036ac90ebSjeremylt   uint64_t state;
151d1d35e2fSjeremylt   uint64_t num_readers;
1526ea7c6c1SJed Brown   void    *data;
1536ea7c6c1SJed Brown };
1546ea7c6c1SJed Brown 
1556ea7c6c1SJed Brown struct CeedElemRestriction_private {
1566ea7c6c1SJed Brown   Ceed                ceed;
157c17ec2beSJeremy L Thompson   CeedElemRestriction rstr_signed;
1582b730f8bSJeremy L Thompson   int (*Apply)(CeedElemRestriction, CeedTransposeMode, CeedVector, CeedVector, CeedRequest *);
159f30b1135SSebastian Grimberg   int (*ApplyUnsigned)(CeedElemRestriction, CeedTransposeMode, CeedVector, CeedVector, CeedRequest *);
1602b730f8bSJeremy L Thompson   int (*ApplyBlock)(CeedElemRestriction, CeedInt, CeedTransposeMode, CeedVector, CeedVector, CeedRequest *);
161bd33150aSjeremylt   int (*GetOffsets)(CeedElemRestriction, CeedMemType, const CeedInt **);
162*77d1c127SSebastian Grimberg   int (*GetOrientations)(CeedElemRestriction, CeedMemType, const bool **);
163*77d1c127SSebastian Grimberg   int (*GetCurlOrientations)(CeedElemRestriction, CeedMemType, const CeedInt **);
1646ea7c6c1SJed Brown   int (*Destroy)(CeedElemRestriction);
165d1d35e2fSjeremylt   int      ref_count;
166d1d35e2fSjeremylt   CeedInt  num_elem;    /* number of elements */
167d1d35e2fSjeremylt   CeedInt  elem_size;   /* number of nodes per element */
168d1d35e2fSjeremylt   CeedInt  num_comp;    /* number of components */
169d1d35e2fSjeremylt   CeedInt  comp_stride; /* Component stride for L-vector ordering */
170ea61e9acSJeremy L Thompson   CeedSize l_size;      /* size of the L-vector, can be used for checking for correct vector sizes */
171d1d35e2fSjeremylt   CeedInt  blk_size;    /* number of elements in a batch */
172d1d35e2fSjeremylt   CeedInt  num_blk;     /* number of blocks of elements */
1737509a596Sjeremylt   CeedInt *strides;     /* strides between [nodes, components, elements] */
17449fd234cSJeremy L Thompson   CeedInt  layout[3];   /* E-vector layout [nodes, components, elements] */
175d1d35e2fSjeremylt   uint64_t num_readers; /* number of instances of offset read only access */
1766ea7c6c1SJed Brown   void    *data;        /* place for the backend to store any data */
1776ea7c6c1SJed Brown };
1786ea7c6c1SJed Brown 
1796ea7c6c1SJed Brown struct CeedBasis_private {
1806ea7c6c1SJed Brown   Ceed ceed;
1812b730f8bSJeremy L Thompson   int (*Apply)(CeedBasis, CeedInt, CeedTransposeMode, CeedEvalMode, CeedVector, CeedVector);
182c8c3fa7dSJeremy L Thompson   int (*ApplyAtPoints)(CeedBasis, CeedInt, CeedTransposeMode, CeedEvalMode, CeedVector, CeedVector, CeedVector);
1836ea7c6c1SJed Brown   int (*Destroy)(CeedBasis);
184d1d35e2fSjeremylt   int                ref_count;
1856402da51SJeremy L Thompson   bool               is_tensor_basis; /* flag for tensor basis */
1860f5de9e9Sjeremylt   CeedInt            dim;             /* topological dimension */
187d99fa3c5SJeremy L Thompson   CeedElemTopology   topo;            /* element topology */
188d1d35e2fSjeremylt   CeedInt            num_comp;        /* number of field components (1 for scalar fields) */
189d1d35e2fSjeremylt   CeedInt            P_1d;            /* number of nodes in one dimension */
190d1d35e2fSjeremylt   CeedInt            Q_1d;            /* number of quadrature points in one dimension */
191a8de75f0Sjeremylt   CeedInt            P;               /* total number of nodes */
192a8de75f0Sjeremylt   CeedInt            Q;               /* total number of quadrature points */
193c4e3f59bSSebastian Grimberg   CeedFESpace        fe_space;        /* initialized in basis constructor with 1, 2, 3 for H^1, H(div), and H(curl) FE space */
1942f86a920SJeremy L Thompson   CeedTensorContract contract;        /* tensor contraction object */
195c4e3f59bSSebastian Grimberg   CeedScalar        *q_ref_1d;        /* array of length Q1d holding the locations of quadrature points on the 1D reference element [-1, 1] */
196c4e3f59bSSebastian Grimberg   CeedScalar        *q_weight_1d;     /* array of length Q1d holding the quadrature weights on the reference element */
197c4e3f59bSSebastian Grimberg   CeedScalar *interp; /* row-major matrix of shape [Q, P] or [dim * Q, P] expressing the values of nodal basis functions or vector basis functions at
198c4e3f59bSSebastian Grimberg                          quadrature points */
199c4e3f59bSSebastian Grimberg   CeedScalar *interp_1d; /* row-major matrix of shape [Q1d, P1d] expressing the values of nodal basis functions at quadrature points */
200c4e3f59bSSebastian Grimberg   CeedScalar *grad;      /* row-major matrix of shape [dim * Q, P] matrix expressing derivatives of nodal basis functions at quadrature points */
201c4e3f59bSSebastian Grimberg   CeedScalar *grad_1d;   /* row-major matrix of shape [Q1d, P1d] matrix expressing derivatives of nodal basis functions at quadrature points */
202c4e3f59bSSebastian Grimberg   CeedScalar *div; /* row-major matrix of shape [Q, P] expressing the divergence of basis functions at quadrature points for H(div) discretizations */
203c4e3f59bSSebastian Grimberg   CeedScalar *curl; /* row-major matrix of shape [curl_dim * Q, P], curl_dim = 1 if dim < 3 else dim, expressing the curl of basis functions at
204c4e3f59bSSebastian Grimberg                        quadrature points for H(curl) discretizations */
205c8c3fa7dSJeremy L Thompson   CeedVector vec_chebyshev;
206c8c3fa7dSJeremy L Thompson   CeedBasis  basis_chebyshev; /* basis interpolating from nodes to Chebyshev polynomial coefficients */
207c01dd730Scamierjs   void      *data;            /* place for the backend to store any data */
2086ea7c6c1SJed Brown };
2096ea7c6c1SJed Brown 
2102f86a920SJeremy L Thompson struct CeedTensorContract_private {
2112f86a920SJeremy L Thompson   Ceed ceed;
2122b730f8bSJeremy L Thompson   int (*Apply)(CeedTensorContract, CeedInt, CeedInt, CeedInt, CeedInt, const CeedScalar *restrict, CeedTransposeMode, const CeedInt,
2132f86a920SJeremy L Thompson                const CeedScalar *restrict, CeedScalar *restrict);
2142f86a920SJeremy L Thompson   int (*Destroy)(CeedTensorContract);
215d1d35e2fSjeremylt   int   ref_count;
2162f86a920SJeremy L Thompson   void *data;
2172f86a920SJeremy L Thompson };
2182f86a920SJeremy L Thompson 
219d1bcdac9Sjeremylt struct CeedQFunctionField_private {
220d1d35e2fSjeremylt   const char  *field_name;
2214d537eeaSYohann   CeedInt      size;
222d1d35e2fSjeremylt   CeedEvalMode eval_mode;
223ff8ca64bSJed Brown };
224ff8ca64bSJed Brown 
2256ea7c6c1SJed Brown struct CeedQFunction_private {
2266ea7c6c1SJed Brown   Ceed ceed;
2272f86a920SJeremy L Thompson   int (*Apply)(CeedQFunction, CeedInt, CeedVector *, CeedVector *);
2288c84ac63Sjeremylt   int (*SetCUDAUserFunction)(CeedQFunction, void *);
2298c84ac63Sjeremylt   int (*SetHIPUserFunction)(CeedQFunction, void *);
2306ea7c6c1SJed Brown   int (*Destroy)(CeedQFunction);
231d1d35e2fSjeremylt   int                  ref_count;
232ea61e9acSJeremy L Thompson   CeedInt              vec_length; /* Number of quadrature points must be padded to a multiple of vec_length */
233d1d35e2fSjeremylt   CeedQFunctionField  *input_fields;
234d1d35e2fSjeremylt   CeedQFunctionField  *output_fields;
235d1d35e2fSjeremylt   CeedInt              num_input_fields, num_output_fields;
2369f0427d9SYohann   CeedQFunctionUser    function;
2376e15d496SJeremy L Thompson   CeedInt              user_flop_estimate;
238ca5eadf8SJeremy L Thompson   const char          *user_source;
239d1d35e2fSjeremylt   const char          *source_path;
24043e1b16fSJeremy L Thompson   const char          *kernel_name;
24143e1b16fSJeremy L Thompson   const char          *gallery_name;
24243e1b16fSJeremy L Thompson   bool                 is_gallery;
243f04ea552SJeremy L Thompson   bool                 is_identity;
244f04ea552SJeremy L Thompson   bool                 is_fortran;
245f04ea552SJeremy L Thompson   bool                 is_immutable;
246441428dfSJeremy L Thompson   bool                 is_context_writable;
247777ff853SJeremy L Thompson   CeedQFunctionContext ctx;  /* user context for function */
248a8d32208Sjeremylt   void                *data; /* place for the backend to store any data */
2496ea7c6c1SJed Brown };
2506ea7c6c1SJed Brown 
251777ff853SJeremy L Thompson struct CeedQFunctionContext_private {
252777ff853SJeremy L Thompson   Ceed ceed;
253d1d35e2fSjeremylt   int  ref_count;
2549c774eddSJeremy L Thompson   int (*HasValidData)(CeedQFunctionContext, bool *);
2559c774eddSJeremy L Thompson   int (*HasBorrowedDataOfType)(CeedQFunctionContext, CeedMemType, bool *);
256777ff853SJeremy L Thompson   int (*SetData)(CeedQFunctionContext, CeedMemType, CeedCopyMode, void *);
257891038deSjeremylt   int (*TakeData)(CeedQFunctionContext, CeedMemType, void *);
258777ff853SJeremy L Thompson   int (*GetData)(CeedQFunctionContext, CeedMemType, void *);
25928bfd0b7SJeremy L Thompson   int (*GetDataRead)(CeedQFunctionContext, CeedMemType, void *);
260777ff853SJeremy L Thompson   int (*RestoreData)(CeedQFunctionContext);
26128bfd0b7SJeremy L Thompson   int (*RestoreDataRead)(CeedQFunctionContext);
2622e64a2b9SJeremy L Thompson   int (*DataDestroy)(CeedQFunctionContext);
263777ff853SJeremy L Thompson   int (*Destroy)(CeedQFunctionContext);
2642790b72bSJeremy L Thompson   CeedQFunctionContextDataDestroyUser data_destroy_function;
2652790b72bSJeremy L Thompson   CeedMemType                         data_destroy_mem_type;
266cdf32b93SJeremy L Thompson   CeedInt                             num_fields;
267cdf32b93SJeremy L Thompson   CeedInt                             max_fields;
2683668ca4bSJeremy L Thompson   CeedContextFieldLabel              *field_labels;
269777ff853SJeremy L Thompson   uint64_t                            state;
27028bfd0b7SJeremy L Thompson   uint64_t                            num_readers;
271d1d35e2fSjeremylt   size_t                              ctx_size;
272777ff853SJeremy L Thompson   void                               *data;
273777ff853SJeremy L Thompson };
274777ff853SJeremy L Thompson 
2751e35832bSjeremylt /// Struct to handle the context data to use the Fortran QFunction stub
2761e35832bSjeremylt /// @ingroup CeedQFunction
277777ff853SJeremy L Thompson struct CeedFortranContext_private {
2788cb0412aSJeremy L Thompson   CeedQFunctionContext inner_ctx;
2792b730f8bSJeremy L Thompson   void (*f)(void *ctx, int *nq, const CeedScalar *u, const CeedScalar *u1, const CeedScalar *u2, const CeedScalar *u3, const CeedScalar *u4,
2802b730f8bSJeremy L Thompson             const CeedScalar *u5, const CeedScalar *u6, const CeedScalar *u7, const CeedScalar *u8, const CeedScalar *u9, const CeedScalar *u10,
2812b730f8bSJeremy L Thompson             const CeedScalar *u11, const CeedScalar *u12, const CeedScalar *u13, const CeedScalar *u14, const CeedScalar *u15, CeedScalar *v,
2822b730f8bSJeremy L Thompson             CeedScalar *v1, CeedScalar *v2, CeedScalar *v3, CeedScalar *v4, CeedScalar *v5, CeedScalar *v6, CeedScalar *v7, CeedScalar *v8,
2832b730f8bSJeremy L Thompson             CeedScalar *v9, CeedScalar *v10, CeedScalar *v11, CeedScalar *v12, CeedScalar *v13, CeedScalar *v14, CeedScalar *v15, int *err);
284777ff853SJeremy L Thompson };
285777ff853SJeremy L Thompson typedef struct CeedFortranContext_private *CeedFortranContext;
286069aeabaSjeremylt 
2873668ca4bSJeremy L Thompson struct CeedContextFieldLabel_private {
2883668ca4bSJeremy L Thompson   const char            *name;
2893668ca4bSJeremy L Thompson   const char            *description;
2903668ca4bSJeremy L Thompson   CeedContextFieldType   type;
2913668ca4bSJeremy L Thompson   size_t                 size;
2927bfe0f0eSJeremy L Thompson   size_t                 num_values;
2933668ca4bSJeremy L Thompson   size_t                 offset;
2943668ca4bSJeremy L Thompson   CeedInt                num_sub_labels;
2953668ca4bSJeremy L Thompson   CeedContextFieldLabel *sub_labels;
2965ac9af79SJeremy L Thompson   bool                   from_op;
2973668ca4bSJeremy L Thompson };
2983668ca4bSJeremy L Thompson 
299d1bcdac9Sjeremylt struct CeedOperatorField_private {
300437c7c90SJeremy L Thompson   CeedElemRestriction elem_rstr;  /* Restriction from L-vector */
301ea61e9acSJeremy L Thompson   CeedBasis           basis;      /* Basis or CEED_BASIS_COLLOCATED for collocated fields */
302ea61e9acSJeremy L Thompson   CeedVector          vec;        /* State vector for passive fields or CEED_VECTOR_NONE for no vector */
303d1d35e2fSjeremylt   const char         *field_name; /* matching QFunction field name */
304ff8ca64bSJed Brown };
305ff8ca64bSJed Brown 
306480fae85SJeremy L Thompson struct CeedQFunctionAssemblyData_private {
307480fae85SJeremy L Thompson   Ceed                ceed;
308480fae85SJeremy L Thompson   int                 ref_count;
309480fae85SJeremy L Thompson   bool                is_setup;
310beecbf24SJeremy L Thompson   bool                reuse_data;
311beecbf24SJeremy L Thompson   bool                needs_data_update;
312480fae85SJeremy L Thompson   CeedVector          vec;
313480fae85SJeremy L Thompson   CeedElemRestriction rstr;
314480fae85SJeremy L Thompson };
315480fae85SJeremy L Thompson 
316ed9e99e6SJeremy L Thompson struct CeedOperatorAssemblyData_private {
317ed9e99e6SJeremy L Thompson   Ceed                 ceed;
318437c7c90SJeremy L Thompson   CeedInt              num_active_bases;
319437c7c90SJeremy L Thompson   CeedBasis           *active_bases;
320437c7c90SJeremy L Thompson   CeedElemRestriction *active_elem_rstrs;
321437c7c90SJeremy L Thompson   CeedInt             *num_eval_modes_in, *num_eval_modes_out;
322437c7c90SJeremy L Thompson   CeedEvalMode       **eval_modes_in, **eval_modes_out;
323437c7c90SJeremy L Thompson   CeedScalar         **assembled_bases_in, **assembled_bases_out;
324437c7c90SJeremy L Thompson   CeedSize           **eval_mode_offsets_in, **eval_mode_offsets_out, num_output_components;
325ed9e99e6SJeremy L Thompson };
326ed9e99e6SJeremy L Thompson 
3276ea7c6c1SJed Brown struct CeedOperator_private {
3286ea7c6c1SJed Brown   Ceed         ceed;
329b05f7e9fSJeremy L Thompson   CeedOperator op_fallback, op_fallback_parent;
330d1d35e2fSjeremylt   int          ref_count;
3312b730f8bSJeremy L Thompson   int (*LinearAssembleQFunction)(CeedOperator, CeedVector *, CeedElemRestriction *, CeedRequest *);
3322b730f8bSJeremy L Thompson   int (*LinearAssembleQFunctionUpdate)(CeedOperator, CeedVector, CeedElemRestriction, CeedRequest *);
3332bba3ffaSJeremy L Thompson   int (*LinearAssembleDiagonal)(CeedOperator, CeedVector, CeedRequest *);
3349e9210b8SJeremy L Thompson   int (*LinearAssembleAddDiagonal)(CeedOperator, CeedVector, CeedRequest *);
3352b730f8bSJeremy L Thompson   int (*LinearAssemblePointBlockDiagonal)(CeedOperator, CeedVector, CeedRequest *);
3362b730f8bSJeremy L Thompson   int (*LinearAssembleAddPointBlockDiagonal)(CeedOperator, CeedVector, CeedRequest *);
3372b730f8bSJeremy L Thompson   int (*LinearAssembleSymbolic)(CeedOperator, CeedSize *, CeedInt **, CeedInt **);
338e2f04181SAndrew T. Barker   int (*LinearAssemble)(CeedOperator, CeedVector);
339cefa2673SJeremy L Thompson   int (*LinearAssembleSingle)(CeedOperator, CeedInt, CeedVector);
340713f43c3Sjeremylt   int (*CreateFDMElementInverse)(CeedOperator, CeedOperator *, CeedRequest *);
341ff8ca64bSJed Brown   int (*Apply)(CeedOperator, CeedVector, CeedVector, CeedRequest *);
342250756a7Sjeremylt   int (*ApplyComposite)(CeedOperator, CeedVector, CeedVector, CeedRequest *);
343cae8b89aSjeremylt   int (*ApplyAdd)(CeedOperator, CeedVector, CeedVector, CeedRequest *);
344250756a7Sjeremylt   int (*ApplyAddComposite)(CeedOperator, CeedVector, CeedVector, CeedRequest *);
3452b730f8bSJeremy L Thompson   int (*ApplyJacobian)(CeedOperator, CeedVector, CeedVector, CeedVector, CeedVector, CeedRequest *);
3466ea7c6c1SJed Brown   int (*Destroy)(CeedOperator);
347d1d35e2fSjeremylt   CeedOperatorField        *input_fields;
348d1d35e2fSjeremylt   CeedOperatorField        *output_fields;
3492b104005SJeremy L Thompson   CeedSize                  input_size, output_size;
350d1d35e2fSjeremylt   CeedInt                   num_elem;   /* Number of elements */
351d1d35e2fSjeremylt   CeedInt                   num_qpts;   /* Number of quadrature points over all elements */
352d1d35e2fSjeremylt   CeedInt                   num_fields; /* Number of fields that have been set */
3536ea7c6c1SJed Brown   CeedQFunction             qf;
3546ea7c6c1SJed Brown   CeedQFunction             dqf;
3556ea7c6c1SJed Brown   CeedQFunction             dqfT;
356ea6b5821SJeremy L Thompson   const char               *name;
357f04ea552SJeremy L Thompson   bool                      is_immutable;
358f04ea552SJeremy L Thompson   bool                      is_interface_setup;
359f04ea552SJeremy L Thompson   bool                      is_backend_setup;
360f04ea552SJeremy L Thompson   bool                      is_composite;
361d1d35e2fSjeremylt   bool                      has_restriction;
362480fae85SJeremy L Thompson   CeedQFunctionAssemblyData qf_assembled;
363ed9e99e6SJeremy L Thompson   CeedOperatorAssemblyData  op_assembled;
364d1d35e2fSjeremylt   CeedOperator             *sub_operators;
365d1d35e2fSjeremylt   CeedInt                   num_suboperators;
3666ea7c6c1SJed Brown   void                     *data;
3673668ca4bSJeremy L Thompson   CeedInt                   num_context_labels;
3683668ca4bSJeremy L Thompson   CeedInt                   max_context_labels;
3693668ca4bSJeremy L Thompson   CeedContextFieldLabel    *context_labels;
3706ea7c6c1SJed Brown };
3716ea7c6c1SJed Brown 
3722b730f8bSJeremy L Thompson CEED_INTERN int CeedOperatorGetFallback(CeedOperator op, CeedOperator *op_fallback);
373d04bbc78SJeremy L Thompson 
3746ea7c6c1SJed Brown #endif
375