@@ -56,11 +56,11 @@ int main(int argc, char **argv) {
5656 problemData * problem = NULL ;
5757 StabilizationType stab ;
5858 PetscBool implicit ;
59- PetscInt degree , qextra , outputfreq , steps , contsteps ;
59+ PetscInt degree , qextra , outputfreq , steps , contsteps , nedgenodes = 0 ;
6060 PetscMPIInt rank ;
6161 PetscScalar ftime ;
62- Vec Q , Qloc , Xloc ;
63- const CeedInt ncompx = 3 ;
62+ Vec Q , Qloc , Xloc , Xpanelsloc ;
63+ const PetscInt ncompx = 3 ;
6464 PetscInt viz_refine = 0 ;
6565 PetscBool read_mesh , simplex , test ;
6666 PetscInt topodim = 2 , ncompq = 3 , lnodes ;
@@ -196,7 +196,7 @@ int main(int argc, char **argv) {
196196 g *= mpersquareds ;
197197
198198 // Set up the libCEED context
199- PhysicsContext_s phys_ctx = {
199+ PhysicsContext_s physCtxData = {
200200 .u0 = 0. ,
201201 .v0 = 0. ,
202202 .h0 = .1 ,
@@ -208,27 +208,27 @@ int main(int argc, char **argv) {
208208 .time = 0.
209209 };
210210
211- ProblemContext_s probl_ctx = {
211+ ProblemContext_s problCtxData = {
212212 .g = g ,
213213 .H0 = H0 ,
214214 .CtauS = CtauS ,
215215 .strong_form = strong_form ,
216216 .stabilization = stab
217217 };
218218
219- // Setup DM
219+ // Create DM
220220 if (read_mesh ) {
221221 ierr = DMPlexCreateFromFile (PETSC_COMM_WORLD , filename , PETSC_TRUE , & dm );
222222 CHKERRQ (ierr );
223223 } else {
224224 // Create the mesh as a 0-refined sphere. This will create a cubic surface, not a box.
225225 PetscBool simplex = PETSC_FALSE ;
226226 ierr = DMPlexCreateSphereMesh (PETSC_COMM_WORLD , topodim , simplex ,
227- phys_ctx .R , & dm );
227+ physCtxData .R , & dm );
228228 CHKERRQ (ierr );
229229 // Set the object name
230230 ierr = PetscObjectSetName ((PetscObject )dm , "Sphere" ); CHKERRQ (ierr );
231- // Define cube panels (charts)
231+ // Define cube panels
232232 DMLabel label ;
233233 PetscInt c , cStart , cEnd , npanel , permidx [6 ] = {5 , 1 , 4 , 0 , 3 , 2 };
234234 ierr = DMCreateLabel (dm , "panel" );
@@ -238,6 +238,7 @@ int main(int argc, char **argv) {
238238 for (c = cStart , npanel = 0 ; c < cEnd ; c ++ ) {
239239 ierr = DMLabelSetValue (label , c , permidx [npanel ++ ]); CHKERRQ (ierr );
240240 }
241+ ierr = DMPlexLabelComplete (dm , label ); CHKERRQ (ierr );
241242 // Distribute mesh over processes
242243 {
243244 DM dmDist = NULL ;
@@ -259,11 +260,8 @@ int main(int argc, char **argv) {
259260 ierr = DMViewFromOptions (dm , NULL , "-dm_view" ); CHKERRQ (ierr );
260261 }
261262
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 );
267265
268266 // Refine DM for high-order viz
269267 dmviz = NULL ;
@@ -283,7 +281,8 @@ int main(int argc, char **argv) {
283281 ierr = DMSetCoarseDM (dmhierarchy [i + 1 ], dmhierarchy [i ]); CHKERRQ (ierr );
284282 d = (d + 1 ) / 2 ;
285283 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 );
287286 ierr = DMCreateInterpolation (dmhierarchy [i ], dmhierarchy [i + 1 ],
288287 & interp_next , NULL ); CHKERRQ (ierr );
289288 if (!i ) interpviz = interp_next ;
@@ -296,7 +295,7 @@ int main(int argc, char **argv) {
296295 interpviz = C ;
297296 }
298297 }
299- for (PetscInt i = 1 ; i < viz_refine ; i ++ ) {
298+ for (PetscInt i = 1 ; i < viz_refine ; i ++ ) {
300299 ierr = DMDestroy (& dmhierarchy [i ]); CHKERRQ (ierr );
301300 }
302301 dmviz = dmhierarchy [viz_refine ];
@@ -372,14 +371,30 @@ int main(int argc, char **argv) {
372371 // Set up global mass vector
373372 ierr = VecDuplicate (Q , & user -> M ); CHKERRQ (ierr );
374373
375- // Setup global lat-long vector for different panels (charts) of the cube
374+ // Setup transformation matrix different panels of the cube
376375 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 );
378392
379393 // Setup libCEED's objects
380394 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 );
383398
384399 // Set up PETSc context
385400 // Set up units structure
@@ -402,9 +417,11 @@ int main(int argc, char **argv) {
402417 ierr = VecZeroEntries (Q ); CHKERRQ (ierr );
403418 ierr = VectorPlacePetscVec (user -> q0ceed , Qloc ); CHKERRQ (ierr );
404419
420+ // Set up contex for QFunctions
421+ CeedQFunctionSetContext (ceeddata -> qf_setup , ceeddata -> physCtx );
422+
405423 // 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 );
408425 CeedOperatorApply (ceeddata -> op_setup , ceeddata -> xcorners , ceeddata -> qdata ,
409426 CEED_REQUEST_IMMEDIATE );
410427 ierr = ComputeLumpedMassMatrix (ceed , dm , ceeddata -> Erestrictq ,
@@ -414,7 +431,7 @@ int main(int argc, char **argv) {
414431 // Apply IC operator and fix multiplicity of initial state vector
415432 ierr = ICs_FixMultiplicity (ceeddata -> op_ics , ceeddata -> xcorners , user -> q0ceed ,
416433 dm , Qloc , Q , ceeddata -> Erestrictq ,
417- & phys_ctx , 0.0 ); CHKERRQ (ierr );
434+ & physCtxData , 0.0 ); CHKERRQ (ierr );
418435
419436 MPI_Comm_rank (comm , & rank );
420437 if (!rank ) {
@@ -524,6 +541,8 @@ int main(int argc, char **argv) {
524541 CeedQFunctionDestroy (& ceeddata -> qf_explicit );
525542 CeedQFunctionDestroy (& ceeddata -> qf_implicit );
526543 CeedQFunctionDestroy (& ceeddata -> qf_jacobian );
544+ CeedQFunctionContextDestroy (& ceeddata -> physCtx );
545+ CeedQFunctionContextDestroy (& ceeddata -> problCtx );
527546 CeedOperatorDestroy (& ceeddata -> op_setup );
528547 CeedOperatorDestroy (& ceeddata -> op_ics );
529548 CeedOperatorDestroy (& ceeddata -> op_explicit );
0 commit comments