@@ -56,11 +56,11 @@ int main(int argc, char **argv) {
56
56
problemData * problem = NULL ;
57
57
StabilizationType stab ;
58
58
PetscBool implicit ;
59
- PetscInt degree , qextra , outputfreq , steps , contsteps ;
59
+ PetscInt degree , qextra , outputfreq , steps , contsteps , nedgenodes = 0 ;
60
60
PetscMPIInt rank ;
61
61
PetscScalar ftime ;
62
- Vec Q , Qloc , Xloc ;
63
- const CeedInt ncompx = 3 ;
62
+ Vec Q , Qloc , Xloc , Xpanelsloc ;
63
+ const PetscInt ncompx = 3 ;
64
64
PetscInt viz_refine = 0 ;
65
65
PetscBool read_mesh , simplex , test ;
66
66
PetscInt topodim = 2 , ncompq = 3 , lnodes ;
@@ -196,7 +196,7 @@ int main(int argc, char **argv) {
196
196
g *= mpersquareds ;
197
197
198
198
// Set up the libCEED context
199
- PhysicsContext_s phys_ctx = {
199
+ PhysicsContext_s physCtxData = {
200
200
.u0 = 0. ,
201
201
.v0 = 0. ,
202
202
.h0 = .1 ,
@@ -208,27 +208,27 @@ int main(int argc, char **argv) {
208
208
.time = 0.
209
209
};
210
210
211
- ProblemContext_s probl_ctx = {
211
+ ProblemContext_s problCtxData = {
212
212
.g = g ,
213
213
.H0 = H0 ,
214
214
.CtauS = CtauS ,
215
215
.strong_form = strong_form ,
216
216
.stabilization = stab
217
217
};
218
218
219
- // Setup DM
219
+ // Create DM
220
220
if (read_mesh ) {
221
221
ierr = DMPlexCreateFromFile (PETSC_COMM_WORLD , filename , PETSC_TRUE , & dm );
222
222
CHKERRQ (ierr );
223
223
} else {
224
224
// Create the mesh as a 0-refined sphere. This will create a cubic surface, not a box.
225
225
PetscBool simplex = PETSC_FALSE ;
226
226
ierr = DMPlexCreateSphereMesh (PETSC_COMM_WORLD , topodim , simplex ,
227
- phys_ctx .R , & dm );
227
+ physCtxData .R , & dm );
228
228
CHKERRQ (ierr );
229
229
// Set the object name
230
230
ierr = PetscObjectSetName ((PetscObject )dm , "Sphere" ); CHKERRQ (ierr );
231
- // Define cube panels (charts)
231
+ // Define cube panels
232
232
DMLabel label ;
233
233
PetscInt c , cStart , cEnd , npanel , permidx [6 ] = {5 , 1 , 4 , 0 , 3 , 2 };
234
234
ierr = DMCreateLabel (dm , "panel" );
@@ -238,6 +238,7 @@ int main(int argc, char **argv) {
238
238
for (c = cStart , npanel = 0 ; c < cEnd ; c ++ ) {
239
239
ierr = DMLabelSetValue (label , c , permidx [npanel ++ ]); CHKERRQ (ierr );
240
240
}
241
+ ierr = DMPlexLabelComplete (dm , label ); CHKERRQ (ierr );
241
242
// Distribute mesh over processes
242
243
{
243
244
DM dmDist = NULL ;
@@ -259,11 +260,8 @@ int main(int argc, char **argv) {
259
260
ierr = DMViewFromOptions (dm , NULL , "-dm_view" ); CHKERRQ (ierr );
260
261
}
261
262
262
- // Create DM
263
- ierr = DMLocalizeCoordinates (dm ); CHKERRQ (ierr );
264
- ierr = DMSetFromOptions (dm ); CHKERRQ (ierr );
265
- ierr = SetupDM (dm , degree , ncompq , topodim );
266
- CHKERRQ (ierr );
263
+ // Setup DM
264
+ ierr = SetupDMByDegree (dm , degree , ncompq , topodim ); CHKERRQ (ierr );
267
265
268
266
// Refine DM for high-order viz
269
267
dmviz = NULL ;
@@ -283,7 +281,8 @@ int main(int argc, char **argv) {
283
281
ierr = DMSetCoarseDM (dmhierarchy [i + 1 ], dmhierarchy [i ]); CHKERRQ (ierr );
284
282
d = (d + 1 ) / 2 ;
285
283
if (i + 1 == viz_refine ) d = 1 ;
286
- ierr = SetupDM (dmhierarchy [i + 1 ], degree , ncompq , topodim ); CHKERRQ (ierr );
284
+ ierr = SetupDMByDegree (dmhierarchy [i + 1 ], degree , ncompq , topodim );
285
+ CHKERRQ (ierr );
287
286
ierr = DMCreateInterpolation (dmhierarchy [i ], dmhierarchy [i + 1 ],
288
287
& interp_next , NULL ); CHKERRQ (ierr );
289
288
if (!i ) interpviz = interp_next ;
@@ -296,7 +295,7 @@ int main(int argc, char **argv) {
296
295
interpviz = C ;
297
296
}
298
297
}
299
- for (PetscInt i = 1 ; i < viz_refine ; i ++ ) {
298
+ for (PetscInt i = 1 ; i < viz_refine ; i ++ ) {
300
299
ierr = DMDestroy (& dmhierarchy [i ]); CHKERRQ (ierr );
301
300
}
302
301
dmviz = dmhierarchy [viz_refine ];
@@ -372,14 +371,30 @@ int main(int argc, char **argv) {
372
371
// Set up global mass vector
373
372
ierr = VecDuplicate (Q , & user -> M ); CHKERRQ (ierr );
374
373
375
- // Setup global lat-long vector for different panels (charts) of the cube
374
+ // Setup transformation matrix different panels of the cube
376
375
Mat T ;
377
- ierr = FindPanelEdgeNodes (dm , & phys_ctx , ncompq , & T ); CHKERRQ (ierr );
376
+ EdgeNode edgenodes ;
377
+ ierr = FindPanelEdgeNodes (dm , & physCtxData , ncompq , & nedgenodes , & edgenodes ,
378
+ & T );
379
+ CHKERRQ (ierr );
380
+
381
+ // Pass transformation matrix to context for setup operator
382
+ problCtxData .T = T ;
383
+
384
+ ierr = DMGetCoordinatesLocal (dm , & Xloc ); CHKERRQ (ierr );
385
+ ierr = VecDuplicate (Xloc , & Xpanelsloc ); CHKERRQ (ierr );
386
+ // Transform coordinate according to their panel systems
387
+ ierr = TransformCoords (dm , Xloc , ncompx , edgenodes , nedgenodes , & physCtxData ,
388
+ & Xpanelsloc ); CHKERRQ (ierr );
389
+
390
+ // Free edgenodes structure array
391
+ ierr = PetscFree (edgenodes ); CHKERRQ (ierr );
378
392
379
393
// Setup libCEED's objects
380
394
ierr = PetscMalloc1 (1 , & ceeddata ); CHKERRQ (ierr );
381
- ierr = SetupLibceed (dm , ceed , degree , qextra , ncompx , ncompq , user , ceeddata ,
382
- problem , & phys_ctx , & probl_ctx ); CHKERRQ (ierr );
395
+ ierr = SetupLibceed (dm , ceed , degree , qextra , ncompx , ncompq , user ,
396
+ Xpanelsloc , ceeddata , problem , & physCtxData , & problCtxData );
397
+ CHKERRQ (ierr );
383
398
384
399
// Set up PETSc context
385
400
// Set up units structure
@@ -402,9 +417,11 @@ int main(int argc, char **argv) {
402
417
ierr = VecZeroEntries (Q ); CHKERRQ (ierr );
403
418
ierr = VectorPlacePetscVec (user -> q0ceed , Qloc ); CHKERRQ (ierr );
404
419
420
+ // Set up contex for QFunctions
421
+ CeedQFunctionSetContext (ceeddata -> qf_setup , ceeddata -> physCtx );
422
+
405
423
// Apply Setup Ceed Operators
406
- ierr = DMGetCoordinatesLocal (dm , & Xloc ); CHKERRQ (ierr );
407
- ierr = VectorPlacePetscVec (ceeddata -> xcorners , Xloc ); CHKERRQ (ierr );
424
+ ierr = VectorPlacePetscVec (ceeddata -> xcorners , Xpanelsloc ); CHKERRQ (ierr );
408
425
CeedOperatorApply (ceeddata -> op_setup , ceeddata -> xcorners , ceeddata -> qdata ,
409
426
CEED_REQUEST_IMMEDIATE );
410
427
ierr = ComputeLumpedMassMatrix (ceed , dm , ceeddata -> Erestrictq ,
@@ -414,7 +431,7 @@ int main(int argc, char **argv) {
414
431
// Apply IC operator and fix multiplicity of initial state vector
415
432
ierr = ICs_FixMultiplicity (ceeddata -> op_ics , ceeddata -> xcorners , user -> q0ceed ,
416
433
dm , Qloc , Q , ceeddata -> Erestrictq ,
417
- & phys_ctx , 0.0 ); CHKERRQ (ierr );
434
+ & physCtxData , 0.0 ); CHKERRQ (ierr );
418
435
419
436
MPI_Comm_rank (comm , & rank );
420
437
if (!rank ) {
@@ -524,6 +541,8 @@ int main(int argc, char **argv) {
524
541
CeedQFunctionDestroy (& ceeddata -> qf_explicit );
525
542
CeedQFunctionDestroy (& ceeddata -> qf_implicit );
526
543
CeedQFunctionDestroy (& ceeddata -> qf_jacobian );
544
+ CeedQFunctionContextDestroy (& ceeddata -> physCtx );
545
+ CeedQFunctionContextDestroy (& ceeddata -> problCtx );
527
546
CeedOperatorDestroy (& ceeddata -> op_setup );
528
547
CeedOperatorDestroy (& ceeddata -> op_ics );
529
548
CeedOperatorDestroy (& ceeddata -> op_explicit );
0 commit comments