Skip to content

Commit

Permalink
added regression tests and function descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
leorosie committed Aug 12, 2021
1 parent 4da18e0 commit a9078df
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 4 deletions.
Binary file added demo/richards/initial.h5
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- PRESSURE: Liquid Pressure --
Max: 9.9000539440768e+04
Min: 9.9000489163783e+04
Mean: 9.9000513212237e+04
0: 9.9000489163783e+04
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- PRESSURE: Liquid Pressure --
Max: 9.9000582419508e+04
Min: 9.9000529724118e+04
Mean: 9.9000555854316e+04
0: 9.9000529724118e+04
7 changes: 7 additions & 0 deletions demo/richards/richards.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[suites]
standard=
richards-driver-snes-prob1
richards-driver-snes-initial-cond-isotropic-k
richards-driver-snes-initial-cond-anisotropic-k
#richards-driver-ts-prob1

standard_parallel=
Expand All @@ -25,3 +27,8 @@ np=4
timeout=300.
input_arguments=-dim 3 -Nx 3 -Ny 3 -Nz 3 -tdy_water_density exponential -tdy_regression_test -tdy_regression_test_num_cells_per_process 1 -tdy_regression_test_filename richards-driver-ts-prob1-np4 -tdy_final_time 3.1536e3 -tdy_dt_max 600. -tdy_dt_growth_factor 1.5 -tdy_timers -tdy_init_with_random_field -tdy_time_integration_method TS

[richards-driver-snes-initial-cond-isotropic-k]
input_arguments=-dim 3 -Nx 5 -Ny 4 -Nz 3 -tdy_water_density exponential -tdy_regression_test -tdy_regression_test_num_cells_per_process 1 -tdy_regression_test_filename richards-driver-snes-initial-cond-isotropic-k -tdy_final_time 3.1536e3 -tdy_dt_max 600. -tdy_dt_growth_factor 1.5 -tdy_time_integration_method SNES -init_permeability_file initial.h5 -ic_file initial.h5

[richards-driver-snes-initial-cond-anisotropic-k]
input_arguments=-dim 3 -Nx 5 -Ny 4 -Nz 3 -tdy_water_density exponential -tdy_regression_test -tdy_regression_test_num_cells_per_process 1 -tdy_regression_test_filename richards-driver-snes-initial-cond-anisotropic-k -tdy_final_time 3.1536e3 -tdy_dt_max 600. -tdy_dt_growth_factor 1.5 -tdy_time_integration_method SNES -init_porosity_file initial.h5 -init_permeability_file initial.h5 -anisotropic_perm -ic_file initial.h5 -ic_dataset fields/IC
32 changes: 28 additions & 4 deletions src/tdyio.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ PetscErrorCode TDyIOSetPrintIntermediate(TDyIO io, PetscBool flag){
PetscFunctionReturn(0);
}

/* -------------------------------------------------------------------------- */
/// Reads in and sets initial permeability for the TDy solver
///
/// @param [inout] tdy A TDy struct
/// @returns 0 on success, or a non-zero error code on failure
PetscErrorCode TDyIOReadPermeability(TDy tdy){
PetscFunctionBegin;
PetscInt cStart,cEnd,ncell,c,n,BlockSize;
Expand Down Expand Up @@ -162,6 +167,11 @@ PetscErrorCode TDyIOReadPermeability(TDy tdy){
PetscFunctionReturn(0);
}

/* -------------------------------------------------------------------------- */
/// Reads in and sets initial porosity for the TDy solver
///
/// @param [inout] tdy A TDy struct
/// @returns 0 on success, or a non-zero error code on failure
PetscErrorCode TDyIOReadPorosity(TDy tdy){
PetscFunctionBegin;
PetscInt cStart,cEnd,ncell,c;
Expand Down Expand Up @@ -192,6 +202,11 @@ PetscErrorCode TDyIOReadPorosity(TDy tdy){
PetscFunctionReturn(0);
}

/* -------------------------------------------------------------------------- */
/// Reads in and sets initial condition for the TDy solver
///
/// @param [inout] tdy A TDy struct
/// @returns 0 on success, or a non-zero error code on failure
PetscErrorCode TDyIOReadIC(TDy tdy){
PetscFunctionBegin;
PetscInt cStart,cEnd,ncell,c;
Expand All @@ -209,20 +224,28 @@ PetscErrorCode TDyIOReadIC(TDy tdy){
strcpy(VariableName, tdy->io->ic_dataset);
}

ierr = DMPlexGetHeightStratum(tdy->dm,0,&cStart,&cEnd);CHKERRQ(ierr);
ncell = (cEnd-cStart);
ierr = VecCreate(PETSC_COMM_WORLD,&u);
ierr = VecSetSizes(u,ncell,PETSC_DECIDE);

ierr = PetscObjectSetName((PetscObject) u, VariableName);

ierr = PetscViewerHDF5Open(PETSC_COMM_WORLD,tdy->io->ic_filename,FILE_MODE_READ,&viewer);CHKERRQ(ierr);
ierr = VecLoad(u,viewer);CHKERRQ(ierr);

ierr = TDyNaturaltoLocal(tdy->dm,u,&u_local);CHKERRQ(ierr);

ierr = TDySetInitialCondition(tdy,u_local);CHKERRQ(ierr);
PetscFunctionReturn(0);
}

/* -------------------------------------------------------------------------- */
/// Reads in and sets initial permeability for the TDy solver
///
/// @param [inout] tdy A TDy struct
/// @param [in] VariableName A char that is set as the variable name for the
/// PETSc vector read in from the HDF5 file
/// @param [in] filename A char that is the filename of the HDF5 file
/// @param [inout] variable A pointer to the values read in from HDF5 file
/// @returns 0 on success, or a non-zero error code on failure
PetscErrorCode TDyIOReadVariable(TDy tdy, char *VariableName, char *filename, PetscReal **variable){
PetscFunctionBegin;
PetscErrorCode ierr;
Expand All @@ -237,8 +260,9 @@ PetscErrorCode TDyIOReadVariable(TDy tdy, char *VariableName, char *filename, Pe

ierr = PetscViewerHDF5Open(PETSC_COMM_WORLD,filename,FILE_MODE_READ,&viewer);CHKERRQ(ierr);
ierr = VecLoad(u,viewer);CHKERRQ(ierr);

ierr = TDyNaturaltoLocal(tdy->dm,u,&u_local);CHKERRQ(ierr);

ierr = VecGetArray(u_local,&ptr);CHKERRQ(ierr);
ierr = VecGetSize(u_local,&n);CHKERRQ(ierr);

Expand Down

0 comments on commit a9078df

Please sign in to comment.