1. petsc
  2. PETSc
  3. petsc

Commits

Matt Knepley  committed 5260739

DMPlex: FVM geometry tests now work for triangles

  • Participants
  • Parent commits ee6bbdb
  • Branches master

Comments (0)

Files changed (1)

File src/dm/impls/plex/examples/tests/ex8.c

View file
  • Ignore whitespace
       PetscReal   JEx[4]          = {1.0, 0.0, 0.0, 1.0}, R[4], rot[2], rotM[4];
       PetscReal   invJEx[4]       = {1.0, 0.0, 0.0, 1.0};
       PetscReal   detJEx          = 1.0, scale, phi;
+      PetscReal   centroidEx[2]   = {-0.333333333333, -0.333333333333};
+      PetscReal   normalEx[2]     = {0.0, 0.0};
+      PetscReal   volEx           = 2.0;
       PetscInt    d, e, f, p;
 
       ierr = PetscRandomGetValueReal(r, &scale);CHKERRQ(ierr);
         for (d = 0; d < dim; ++d) vertexCoords[p*dim+d] = rot[d];
       }
       for (d = 0; d < dim; ++d) {
+        for (e = 0, rot[d] = 0.0; e < dim; ++e) {
+          rot[d] += R[d*dim+e] * centroidEx[e];
+        }
+      }
+      for (d = 0; d < dim; ++d) centroidEx[d] = rot[d];
+      for (d = 0; d < dim; ++d) {
         for (e = 0; e < dim; ++e) {
           for (f = 0, rotM[d*dim+e] = 0.0; f < dim; ++f) {
             rotM[d*dim+e] += R[d*dim+f] * JEx[f*dim+e];
           invJEx[d*dim+e] /= scale;
         }
         detJEx *= scale;
+        centroidEx[d] *= scale;
+        centroidEx[d] += trans[d];
+        volEx *= scale;
       }
       ierr = ChangeCoordinates(dm, dim, vertexCoords);CHKERRQ(ierr);
       ierr = CheckFEMGeometry(dm, 0, dim, v0Ex, JEx, invJEx, detJEx);CHKERRQ(ierr);
+      if (interpolate) {ierr = CheckFVMGeometry(dm, 0, dim, centroidEx, normalEx, volEx);CHKERRQ(ierr);}
     }
     ierr = PetscRandomDestroy(&r);CHKERRQ(ierr);
     ierr = PetscRandomDestroy(&ang);CHKERRQ(ierr);
       PetscReal   JEx[9]          = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0}, R[9], rot[3], rotM[9];
       PetscReal   invJEx[9]       = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0};
       PetscReal   detJEx          = 1.0, scale, phi, theta, psi = 0.0;
+      PetscReal   centroidEx[3]   = {-0.333333333333, -0.333333333333, 0.0};
+      PetscReal   normalEx[3]     = {0.0, 0.0, 1.0};
+      PetscReal   volEx           = 2.0;
       PetscInt    d, e, f, p;
 
       ierr = PetscRandomGetValueReal(r, &scale);CHKERRQ(ierr);
           vertexCoords[p*dim+d] *= scale;
           vertexCoords[p*dim+d] += trans[d];
         }
+        centroidEx[d] *= scale;
+        centroidEx[d] += trans[d];
         for (e = 0; e < dim-1; ++e) {
           JEx[d*dim+e]    *= scale;
           invJEx[d*dim+e] /= scale;
         }
-        if (d < dim-1) detJEx *= scale;
+        if (d < dim-1) {
+          detJEx *= scale;
+          volEx  *= scale;
+        }
       }
       R[0] = cos(theta)*cos(psi); R[1] = sin(phi)*sin(theta)*cos(psi) - cos(phi)*sin(psi); R[2] = sin(phi)*sin(psi) + cos(phi)*sin(theta)*cos(psi);
       R[3] = cos(theta)*sin(psi); R[4] = cos(phi)*cos(psi) + sin(phi)*sin(theta)*sin(psi); R[5] = cos(phi)*sin(theta)*sin(psi) - sin(phi)*cos(psi);
         for (d = 0; d < dim; ++d) vertexCoords[p*dim+d] = rot[d];
       }
       for (d = 0; d < dim; ++d) {
+        for (e = 0, rot[d] = 0.0; e < dim; ++e) {
+          rot[d] += R[d*dim+e] * centroidEx[e];
+        }
+      }
+      for (d = 0; d < dim; ++d) centroidEx[d] = rot[d];
+      for (d = 0; d < dim; ++d) {
+        for (e = 0, rot[d] = 0.0; e < dim; ++e) {
+          rot[d] += R[d*dim+e] * normalEx[e];
+        }
+      }
+      for (d = 0; d < dim; ++d) normalEx[d] = rot[d];
+      for (d = 0; d < dim; ++d) {
         v0Ex[d] = vertexCoords[d];
         for (e = 0; e < dim; ++e) {
           for (f = 0, rotM[d*dim+e] = 0.0; f < dim; ++f) {
       }
       ierr = ChangeCoordinates(dm, dim, vertexCoords);CHKERRQ(ierr);
       ierr = CheckFEMGeometry(dm, 0, dim, v0Ex, JEx, invJEx, detJEx);CHKERRQ(ierr);
+      if (interpolate) {ierr = CheckFVMGeometry(dm, 0, dim, centroidEx, normalEx, volEx);CHKERRQ(ierr);}
     }
     ierr = PetscRandomDestroy(&r);CHKERRQ(ierr);
     ierr = PetscRandomDestroy(&ang);CHKERRQ(ierr);