@@ -59,6 +59,22 @@ int main(int argc,char **argv)
59
59
PetscLogStageRegister ("Setup" , & setup );
60
60
PetscLogStageRegister ("GPU copy stage - triggered by a prelim KSPSolve" , & gpu_copy );
61
61
62
+ // Dimensions of box, L_y x L_x - default to [0, 1]^2
63
+ L_x = 1.0 ;
64
+ L_y = 1.0 ;
65
+ PetscOptionsGetReal (NULL , NULL , "-L_x" , & L_x_test , & option_found_u );
66
+ PetscOptionsGetReal (NULL , NULL , "-L_y" , & L_y_test , & option_found_v );
67
+
68
+ if (option_found_u ) PetscCheck (L_x_test >= 0.0 , PETSC_COMM_WORLD , PETSC_ERR_ARG_WRONGSTATE , "L_x must be positive" );
69
+ if (option_found_v ) PetscCheck (L_y_test >= 0.0 , PETSC_COMM_WORLD , PETSC_ERR_ARG_WRONGSTATE , "L_y must be positive" );
70
+
71
+ if (option_found_u ) {
72
+ L_x = L_x_test ;
73
+ }
74
+ if (option_found_v ) {
75
+ L_y = L_y_test ;
76
+ }
77
+
62
78
ierr = KSPCreate (PETSC_COMM_WORLD ,& ksp );CHKERRQ (ierr );
63
79
ierr = DMDACreate2d (PETSC_COMM_WORLD , DM_BOUNDARY_NONE , DM_BOUNDARY_NONE ,DMDA_STENCIL_STAR ,11 ,11 ,PETSC_DECIDE ,PETSC_DECIDE ,1 ,1 ,NULL ,NULL ,& da );CHKERRQ (ierr );
64
80
ierr = DMSetFromOptions (da );CHKERRQ (ierr );
@@ -67,6 +83,7 @@ int main(int argc,char **argv)
67
83
// We do this instead of calling MatFilter as there is no Kokkos implementation so its very slow
68
84
ierr = DMSetMatrixPreallocateOnly (da ,PETSC_TRUE );CHKERRQ (ierr );
69
85
ierr = DMSetUp (da );CHKERRQ (ierr );
86
+ ierr = DMDASetUniformCoordinates (da , 0.0 , L_x , 0.0 , L_y , 0.0 , 0.0 );CHKERRQ (ierr );
70
87
ierr = KSPSetDM (ksp ,(DM )da );CHKERRQ (ierr );
71
88
// We generate the matrix ourselves
72
89
ierr = KSPSetDMActive (ksp , PETSC_FALSE );CHKERRQ (ierr );
@@ -111,22 +128,6 @@ int main(int argc,char **argv)
111
128
v = v_test ;
112
129
}
113
130
114
- // Dimensions of box, L_y x L_x - default to [0, 1]^2
115
- L_x = 1.0 ;
116
- L_y = 1.0 ;
117
- PetscOptionsGetReal (NULL , NULL , "-L_x" , & L_x_test , & option_found_u );
118
- PetscOptionsGetReal (NULL , NULL , "-L_y" , & L_y_test , & option_found_v );
119
-
120
- if (option_found_u ) PetscCheck (L_x_test >= 0.0 , PETSC_COMM_WORLD , PETSC_ERR_ARG_WRONGSTATE , "L_x must be positive" );
121
- if (option_found_v ) PetscCheck (L_y_test >= 0.0 , PETSC_COMM_WORLD , PETSC_ERR_ARG_WRONGSTATE , "L_y must be positive" );
122
-
123
- if (option_found_u ) {
124
- L_x = L_x_test ;
125
- }
126
- if (option_found_v ) {
127
- L_y = L_y_test ;
128
- }
129
-
130
131
// Diffusion coefficient
131
132
// Default alpha is 0 - pure advection
132
133
alpha = 0.0 ;
0 commit comments