19
19
static int CeedBasisApply_Ref (CeedBasis basis , CeedInt num_elem , CeedTransposeMode t_mode , CeedEvalMode eval_mode , CeedVector U , CeedVector V ) {
20
20
Ceed ceed ;
21
21
CeedCallBackend (CeedBasisGetCeed (basis , & ceed ));
22
- CeedInt dim , num_comp , num_nodes , num_qpts , Q_comp ;
22
+ CeedInt dim , num_comp , q_comp , num_nodes , num_qpts ;
23
23
CeedCallBackend (CeedBasisGetDimension (basis , & dim ));
24
24
CeedCallBackend (CeedBasisGetNumComponents (basis , & num_comp ));
25
+ CeedCallBackend (CeedBasisGetNumQuadratureComponents (basis , eval_mode , & q_comp ));
25
26
CeedCallBackend (CeedBasisGetNumNodes (basis , & num_nodes ));
26
27
CeedCallBackend (CeedBasisGetNumQuadraturePoints (basis , & num_qpts ));
27
- CeedCallBackend (CeedBasisGetNumQuadratureComponents (basis , & Q_comp ));
28
28
CeedTensorContract contract ;
29
29
CeedCallBackend (CeedBasisGetTensorContract (basis , & contract ));
30
30
const CeedInt add = (t_mode == CEED_TRANSPOSE );
@@ -46,8 +46,8 @@ static int CeedBasisApply_Ref(CeedBasis basis, CeedInt num_elem, CeedTransposeMo
46
46
}
47
47
bool tensor_basis ;
48
48
CeedCallBackend (CeedBasisIsTensor (basis , & tensor_basis ));
49
- // Tensor basis
50
49
if (tensor_basis ) {
50
+ // Tensor basis
51
51
CeedInt P_1d , Q_1d ;
52
52
CeedCallBackend (CeedBasisGetNumNodes1D (basis , & P_1d ));
53
53
CeedCallBackend (CeedBasisGetNumQuadraturePoints1D (basis , & Q_1d ));
@@ -191,36 +191,31 @@ static int CeedBasisApply_Ref(CeedBasis basis, CeedInt num_elem, CeedTransposeMo
191
191
}
192
192
} else {
193
193
// Non-tensor basis
194
+ CeedInt P = num_nodes , Q = num_qpts ;
194
195
switch (eval_mode ) {
195
196
// Interpolate to/from quadrature points
196
197
case CEED_EVAL_INTERP : {
197
- CeedInt P = num_nodes , Q = Q_comp * num_qpts ;
198
198
const CeedScalar * interp ;
199
199
CeedCallBackend (CeedBasisGetInterp (basis , & interp ));
200
- if (t_mode == CEED_TRANSPOSE ) {
201
- P = Q_comp * num_qpts ;
202
- Q = num_nodes ;
203
- }
204
- CeedCallBackend (CeedTensorContractApply (contract , num_comp , P , num_elem , Q , interp , t_mode , add , u , v ));
200
+ CeedCallBackend (CeedTensorContractStridedApply (contract , num_comp , P , num_elem , q_comp , Q , interp , t_mode , add , u , v ));
205
201
} break ;
206
202
// Evaluate the gradient to/from quadrature points
207
203
case CEED_EVAL_GRAD : {
208
- CeedInt P = num_nodes , Q = num_qpts ;
209
- CeedInt dim_stride = num_qpts * num_comp * num_elem ;
210
- CeedInt grad_stride = num_qpts * num_nodes ;
211
204
const CeedScalar * grad ;
212
205
CeedCallBackend (CeedBasisGetGrad (basis , & grad ));
213
- if (t_mode == CEED_TRANSPOSE ) {
214
- P = num_qpts ;
215
- Q = num_nodes ;
216
- for (CeedInt d = 0 ; d < dim ; d ++ ) {
217
- CeedCallBackend (CeedTensorContractApply (contract , num_comp , P , num_elem , Q , grad + d * grad_stride , t_mode , add , u + d * dim_stride , v ));
218
- }
219
- } else {
220
- for (CeedInt d = 0 ; d < dim ; d ++ ) {
221
- CeedCallBackend (CeedTensorContractApply (contract , num_comp , P , num_elem , Q , grad + d * grad_stride , t_mode , add , u , v + d * dim_stride ));
222
- }
223
- }
206
+ CeedCallBackend (CeedTensorContractStridedApply (contract , num_comp , P , num_elem , q_comp , Q , grad , t_mode , add , u , v ));
207
+ } break ;
208
+ // Evaluate the divergence to/from the quadrature points
209
+ case CEED_EVAL_DIV : {
210
+ const CeedScalar * div ;
211
+ CeedCallBackend (CeedBasisGetDiv (basis , & div ));
212
+ CeedCallBackend (CeedTensorContractStridedApply (contract , num_comp , P , num_elem , q_comp , Q , div , t_mode , add , u , v ));
213
+ } break ;
214
+ // Evaluate the curl to/from the quadrature points
215
+ case CEED_EVAL_CURL : {
216
+ const CeedScalar * curl ;
217
+ CeedCallBackend (CeedBasisGetCurl (basis , & curl ));
218
+ CeedCallBackend (CeedTensorContractStridedApply (contract , num_comp , P , num_elem , q_comp , Q , curl , t_mode , add , u , v ));
224
219
} break ;
225
220
// Retrieve interpolation weights
226
221
case CEED_EVAL_WEIGHT : {
@@ -235,21 +230,7 @@ static int CeedBasisApply_Ref(CeedBasis basis, CeedInt num_elem, CeedTransposeMo
235
230
for (CeedInt e = 0 ; e < num_elem ; e ++ ) v [i * num_elem + e ] = q_weight [i ];
236
231
}
237
232
} break ;
238
- // Evaluate the divergence to/from the quadrature points
239
- case CEED_EVAL_DIV : {
240
- CeedInt P = num_nodes , Q = num_qpts ;
241
- const CeedScalar * div ;
242
- CeedCallBackend (CeedBasisGetDiv (basis , & div ));
243
- if (t_mode == CEED_TRANSPOSE ) {
244
- P = num_qpts ;
245
- Q = num_nodes ;
246
- }
247
- CeedCallBackend (CeedTensorContractApply (contract , num_comp , P , num_elem , Q , div , t_mode , add , u , v ));
248
- } break ;
249
233
// LCOV_EXCL_START
250
- // Evaluate the curl to/from the quadrature points
251
- case CEED_EVAL_CURL :
252
- return CeedError (ceed , CEED_ERROR_BACKEND , "CEED_EVAL_CURL not supported" );
253
234
// Take no action, BasisApply should not have been called
254
235
case CEED_EVAL_NONE :
255
236
return CeedError (ceed , CEED_ERROR_BACKEND , "CEED_EVAL_NONE does not make sense in this context" );
@@ -301,6 +282,25 @@ int CeedBasisCreateHdiv_Ref(CeedElemTopology topo, CeedInt dim, CeedInt num_node
301
282
return CEED_ERROR_SUCCESS ;
302
283
}
303
284
285
+ //------------------------------------------------------------------------------
286
+ // Basis Create Non-Tensor H(curl)
287
+ //------------------------------------------------------------------------------
288
+ int CeedBasisCreateHcurl_Ref (CeedElemTopology topo , CeedInt dim , CeedInt num_nodes , CeedInt num_qpts , const CeedScalar * interp ,
289
+ const CeedScalar * curl , const CeedScalar * q_ref , const CeedScalar * q_weight , CeedBasis basis ) {
290
+ Ceed ceed ;
291
+ CeedCallBackend (CeedBasisGetCeed (basis , & ceed ));
292
+
293
+ Ceed parent ;
294
+ CeedCallBackend (CeedGetParent (ceed , & parent ));
295
+ CeedTensorContract contract ;
296
+ CeedCallBackend (CeedTensorContractCreate (parent , basis , & contract ));
297
+ CeedCallBackend (CeedBasisSetTensorContract (basis , contract ));
298
+
299
+ CeedCallBackend (CeedSetBackendFunction (ceed , "Basis" , basis , "Apply" , CeedBasisApply_Ref ));
300
+
301
+ return CEED_ERROR_SUCCESS ;
302
+ }
303
+
304
304
//------------------------------------------------------------------------------
305
305
// Basis Destroy Tensor
306
306
//------------------------------------------------------------------------------
0 commit comments