Commits

Nathan Collier committed a9d50c0

switched to IGAWriteVec

Comments (0)

Files changed (5)

demo/CahnHilliard2D.c

 }
 
 #undef __FUNCT__
-#define __FUNCT__ "WriteSolution"
-PetscErrorCode WriteSolution(Vec C, const char pattern[],int number)
+#define __FUNCT__ "OutputMonitor"
+PetscErrorCode OutputMonitor(TS ts,PetscInt it_number,PetscReal c_time,Vec U,void *mctx)
 {
   PetscFunctionBegin;
-  PetscErrorCode  ierr;
-  MPI_Comm        comm;
-  char            filename[256];
-  PetscViewer     viewer;
-
-  PetscFunctionBegin;
-  sprintf(filename,pattern,number);
-  ierr = PetscObjectGetComm((PetscObject)C,&comm);CHKERRQ(ierr);
-  ierr = PetscViewerBinaryOpen(comm,filename,FILE_MODE_WRITE,&viewer);CHKERRQ(ierr);
-  ierr = VecView(C,viewer);CHKERRQ(ierr);
-  ierr = PetscViewerFlush(viewer);CHKERRQ(ierr);
-  ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr);
+  PetscErrorCode ierr;
+  AppCtx *user = (AppCtx *)mctx;
+  char           filename[256];
+  sprintf(filename,"./ch2d%d.dat",it_number);
+  ierr = IGAWriteVec(user->iga,U,filename);CHKERRQ(ierr);
   PetscFunctionReturn(0);
 }
-#undef __FUNCT__
-#define __FUNCT__ "OutputMonitor"
-PetscErrorCode OutputMonitor(TS ts,PetscInt step,PetscReal t,Vec U,void *mctx)
-{
-  PetscErrorCode ierr;
-  PetscFunctionBegin;
-  ierr = WriteSolution(U,"ch%d.dat",step);CHKERRQ(ierr);
-  PetscFunctionReturn(0);
-}
-
 
 #undef __FUNCT__
 #define __FUNCT__ "main"
   ierr = IGACreate(PETSC_COMM_WORLD,&iga);CHKERRQ(ierr);
   ierr = IGASetDim(iga,2);CHKERRQ(ierr);
   ierr = IGASetDof(iga,1);CHKERRQ(ierr);
+  user.iga = iga;
 
   IGAAxis axis0;
   ierr = IGAGetAxis(iga,0,&axis0);CHKERRQ(ierr);
   ierr = TSAlphaSetAdapt(ts,TSAlphaAdaptDefault,NULL);CHKERRQ(ierr); 
 
   if (monitor) {
-    user.iga = iga;
     PetscPrintf(PETSC_COMM_WORLD,"#Time        dt           Free Energy            Second moment          Third moment\n");
     ierr = TSMonitorSet(ts,StatsMonitor,&user,NULL);CHKERRQ(ierr);
   }

demo/CahnHilliard3D.c

 }
 
 #undef __FUNCT__
-#define __FUNCT__ "WriteSolution"
-PetscErrorCode WriteSolution(Vec C, const char pattern[],int number)
+#define __FUNCT__ "OutputMonitor"
+PetscErrorCode OutputMonitor(TS ts,PetscInt it_number,PetscReal c_time,Vec U,void *mctx)
 {
   PetscFunctionBegin;
-  PetscErrorCode  ierr;
-  MPI_Comm        comm;
-  char            filename[256];
-  PetscViewer     viewer;
-
-  PetscFunctionBegin;
-  sprintf(filename,pattern,number);
-  ierr = PetscObjectGetComm((PetscObject)C,&comm);CHKERRQ(ierr);
-  ierr = PetscViewerBinaryOpen(comm,filename,FILE_MODE_WRITE,&viewer);CHKERRQ(ierr);
-  ierr = VecView(C,viewer);CHKERRQ(ierr);
-  ierr = PetscViewerFlush(viewer);CHKERRQ(ierr);
-  ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr);
-  PetscFunctionReturn(0);
-}
-#undef __FUNCT__
-#define __FUNCT__ "OutputMonitor"
-PetscErrorCode OutputMonitor(TS ts,PetscInt step,PetscReal t,Vec U,void *mctx)
-{
   PetscErrorCode ierr;
-  PetscFunctionBegin;
-  ierr = WriteSolution(U,"ch%d.dat",step);CHKERRQ(ierr);
+  AppCtx *user = (AppCtx *)mctx;
+  char           filename[256];
+  sprintf(filename,"./ch3d%d.dat",it_number);
+  ierr = IGAWriteVec(user->iga,U,filename);CHKERRQ(ierr);
   PetscFunctionReturn(0);
 }
 

demo/Elasticity3D.c

   ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr);
   
   // Dump solution vector
-  MPI_Comm        comm;
-  PetscViewer     viewer;
-  ierr = PetscObjectGetComm((PetscObject)x,&comm);CHKERRQ(ierr);
-  ierr = PetscViewerBinaryOpen(comm,"solution.dat",FILE_MODE_WRITE,&viewer);CHKERRQ(ierr);
-  ierr = VecView(x,viewer);CHKERRQ(ierr);
-  ierr = PetscViewerFlush(viewer);CHKERRQ(ierr);
-  ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr);
+  ierr = IGAWriteVec(iga,x,"solution.dat");CHKERRQ(ierr);
 
   // Cleanup
   ierr = KSPDestroy(&ksp);CHKERRQ(ierr);

demo/HyperElasticity.c

     }
 
     // Dump solution vector
-    ierr = WriteSolution(Utotal,"disp%d.dat",step);CHKERRQ(ierr);
+    char filename[256];
+    sprintf(filename,"disp%d.dat",step);
+    ierr = IGAWriteVec(iga,Utotal,filename);CHKERRQ(ierr);
+
   }
 
   ierr = PetscFinalize();CHKERRQ(ierr);

demo/PhaseFieldCrystal2D.c

 }
 
 #undef __FUNCT__
-#define __FUNCT__ "WriteSolution"
-PetscErrorCode WriteSolution(Vec C, const char pattern[],int number)
+#define __FUNCT__ "OutputMonitor"
+PetscErrorCode OutputMonitor(TS ts,PetscInt it_number,PetscReal c_time,Vec U,void *mctx)
 {
   PetscFunctionBegin;
-  PetscErrorCode  ierr;
-  MPI_Comm        comm;
-  char            filename[256];
-  PetscViewer     viewer;
-
-  PetscFunctionBegin;
-  sprintf(filename,pattern,number);
-  ierr = PetscObjectGetComm((PetscObject)C,&comm);CHKERRQ(ierr);
-  ierr = PetscViewerBinaryOpen(comm,filename,FILE_MODE_WRITE,&viewer);CHKERRQ(ierr);
-  ierr = VecView(C,viewer);CHKERRQ(ierr);
-  ierr = PetscViewerFlush(viewer);CHKERRQ(ierr);
-  ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr);
+  PetscErrorCode ierr;
+  AppCtx *user = (AppCtx *)mctx;
+  char           filename[256];
+  sprintf(filename,"./pfc2d%d.dat",it_number);
+  ierr = IGAWriteVec(user->iga,U,filename);CHKERRQ(ierr);
   PetscFunctionReturn(0);
 }
-#undef __FUNCT__
-#define __FUNCT__ "OutputMonitor"
-PetscErrorCode OutputMonitor(TS ts,PetscInt step,PetscReal t,Vec U,void *mctx)
-{
-  PetscErrorCode ierr;
-  PetscFunctionBegin;
-  ierr = WriteSolution(U,"pfc%d.dat",step);CHKERRQ(ierr);
-  PetscFunctionReturn(0);
-}
-
 
 #undef __FUNCT__
 #define __FUNCT__ "main"
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.