Richards
Solving The Richards equation with temporally periodic surface boundary conditions
main.cc
Go to the documentation of this file.
1 
3 #include <string>
4 #include <vector>
5 #include <iostream>
6 
7 #include "io.h"
8 #include "grid.h"
9 #include "settings.h"
10 #include "richards.h"
11 
13 int main (int argc, char **argv) {
14 
15  if ( argc != 3 )
16  print_exit("richards must be given two command line arguments\n 1. path to settings file\n 2. path to output directory");
17 
18  printf(" starting richards integration from initial condition\n");
19 
20  //output directory
21  std::string dirout = argv[2];
22 
23  //read settings
24  Settings stg = parse_settings(read_values(argv[1]));
25 
26  //create grid
27  Grid grid(stg.depth, stg.delz0, stg.delzfrac, stg.delzmax);
28  long n = grid.get_n();
29  printf(" %g meter grid created with %li cells\n", grid.get_dep(), grid.get_n());
30  printf(" surface cell depth: %g cm\n", grid.get_delze()[n-1]*100);
31  printf(" bottom cell depth: %g cm\n", grid.get_delze()[0]*100);
32  if ( stg.save_grid )
33  grid.save(dirout);
34 
35  //create system
36  Richards rich(grid, stg);
37 
38  //integrate
39  double tint = stg.tint*stg.tunit;
40  rich.solve_adaptive(tint, tint/1e9, stg.nsnap, dirout.c_str());
41  printf(" done\n");
42 
43  return(0);
44 }
read_values
std::vector< std::vector< std::string > > read_values(const char *fn)
reads a settings file into a vector of vectors of strings
Definition: io.cc:72
print_exit
void print_exit(const char *msg)
prints a message before quitting the program
Definition: io.cc:5
settings.h
Grid::get_delze
const std::vector< double > get_delze() const
gets arrayvector of cell widths used for stability calculations (m)
Definition: grid.h:40
Settings
container struct for all the settings variables needed for a BousThermModel run
Definition: settings.h:13
Grid::get_dep
double get_dep()
gets length/depth of the domain (m)
Definition: grid.h:32
Grid
class for constructing and containing grid information
Definition: grid.h:17
Grid::save
void save(std::string dirout)
writes grid arrays into a directory as binary files
Definition: grid.cc:41
grid.h
Settings::tint
double tint
duration of solve
Definition: settings.h:33
Settings::delz0
double delz0
surface cell width (m)
Definition: settings.h:21
Grid::get_n
long get_n()
gets number of cells
Definition: grid.h:30
main
int main(int argc, char **argv)
driver function compiled into richards.exe
Definition: main.cc:13
Settings::tunit
double tunit
time unit to use (number of seconds)
Definition: settings.h:35
Richards
the main model class
Definition: richards.h:54
Settings::delzmax
double delzmax
maximum cell width (m)
Definition: settings.h:25
parse_settings
Settings parse_settings(std::vector< std::vector< std::string > > sv)
parses a settings file and returns it in a Settings structure
Definition: settings.cc:20
io.h
richards.h
Settings::depth
double depth
domain depth (m)
Definition: settings.h:19
Settings::nsnap
long nsnap
number of snaps to take
Definition: settings.h:37
Settings::save_grid
bool save_grid
whether to write grid files
Definition: settings.h:27
Settings::delzfrac
double delzfrac
fraction increase for deeper neighbor cell
Definition: settings.h:23