Skip to content

Commit

Permalink
SWE: Assign DM label 'panel' for different faces of initial cube
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriabarra committed Jul 16, 2020
1 parent 01fa172 commit 236dcbd
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions examples/fluids/shallow-water/shallowwater.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ int main(int argc, char **argv) {
PetscScalar R_e = 6.37122e6; // Earth radius (m)
PetscScalar g = 9.81; // gravitational acceleration (m/s^2)
PetscScalar H0 = 0; // constant mean height (m)
PetscScalar gamma = 0; // angle between axis of rotation and polar axis
PetscScalar gamma = 0; // angle between axis of rotation and polar axis
PetscScalar mpersquareds;
// Check PETSc CUDA support
PetscBool petschavecuda, setmemtyperequest = PETSC_FALSE;
Expand Down Expand Up @@ -209,7 +209,7 @@ int main(int argc, char **argv) {
.gamma = gamma,
.time = 0.
};

ProblemContext_s probl_ctx = {
.g = g,
.H0 = H0,
Expand All @@ -229,6 +229,16 @@ int main(int argc, char **argv) {
CHKERRQ(ierr);
// Set the object name
ierr = PetscObjectSetName((PetscObject)dm, "Sphere"); CHKERRQ(ierr);
// Define cube panels (charts)
DMLabel label;
PetscInt c, cStart, cEnd, npanel;
ierr = DMCreateLabel(dm, "panel");
ierr = DMGetLabel(dm, "panel", &label);
// Assign different panel (chart) values to the six faces of the cube
ierr = DMPlexGetHeightStratum(dm, 0, &cStart, &cEnd); CHKERRQ(ierr);
for (c = cStart, npanel = 0; c < cEnd; c++) {
ierr = DMLabelSetValue(label, c, npanel++); CHKERRQ(ierr);
}
// Distribute mesh over processes
{
DM dmDist = NULL;
Expand Down Expand Up @@ -366,7 +376,7 @@ int main(int argc, char **argv) {

// Setup libCEED's objects
ierr = PetscMalloc1(1, &ceeddata); CHKERRQ(ierr);
ierr = SetupLibceed(dm, ceed, degree, qextra, ncompx, ncompq, user, ceeddata,
ierr = SetupLibceed(dm, ceed, degree, qextra, ncompx, ncompq, user, ceeddata,
problem, &phys_ctx, &probl_ctx); CHKERRQ(ierr);

// Set up PETSc context
Expand Down Expand Up @@ -403,7 +413,7 @@ int main(int argc, char **argv) {
ierr = ICs_FixMultiplicity(ceeddata->op_ics, ceeddata->xcorners, user->q0ceed,
dm, Qloc, Q, ceeddata->Erestrictq,
&phys_ctx, 0.0); CHKERRQ(ierr);

MPI_Comm_rank(comm, &rank);
if (!rank) {
ierr = PetscMkdir(user->outputfolder); CHKERRQ(ierr);
Expand All @@ -425,8 +435,8 @@ int main(int argc, char **argv) {
ierr = DMRestoreLocalVector(dm, &Qloc); CHKERRQ(ierr);

// Set up the MatShell for the associated Jacobian operator
ierr = MatCreateShell(PETSC_COMM_SELF, ncompq*odofs, ncompq*odofs,
PETSC_DETERMINE, PETSC_DETERMINE, user, &J);
ierr = MatCreateShell(PETSC_COMM_SELF, ncompq*odofs, ncompq*odofs,
PETSC_DETERMINE, PETSC_DETERMINE, user, &J);
CHKERRQ(ierr);
// Set the MatShell operation needed for the Jacobian
ierr = MatShellSetOperation(J, MATOP_MULT,
Expand Down

0 comments on commit 236dcbd

Please sign in to comment.