3.1.1.5.1.13. thyrsis.simulation.openfoam module¶
OPENFOAM specific functions
-
class
thyrsis.simulation.openfoam.
OpenFoam
(database)¶ Bases :
object
OpenFoam process class
-
static
boundaryField
(fil, wall='zeroGradient')¶ builds the boundary section for OPENFOAM file
- Paramètres
fil (BufferedIOBase) – buffered file
wall (string) – wall value if fixed
-
compute
(compute_dir, total_time, MPI=None)¶ computes saturated or unsaturated
- Paramètres
compute_dir (string) – path of compute folder
total_time (float) – simulation time duration in second
-
compute_hynverse
(compute_dir)¶ computes saturated for inversion
- Paramètres
compute_dir (string) – path of compute folder
-
compute_probes
(compute_dir)¶ computes results at probes
- Paramètres
compute_dir (string) – path of compute folder
-
convert_infiltration_transitoire
(compute_dir)¶ Copy transient infiltration file to compute_dir
- Paramètres
compute_dir (string) – path of compute folder
-
create_debit_sat
(sat_dir, flux)¶ builds the input file for OPENFOAM in case of no unsaturated calculation
- Paramètres
sat_dir (string) – path of saturated folder
flux – flux value list
-
create_hydrostationary_files
(sat_dir, with_permeabilies=True)¶ builds the input files for OPENFOAM saturated inversion
- Paramètres
sat_dir (string) – path of saturated folder
-
create_infiltration_sat
(sat_dir, cur)¶ builds the infiltration saturated OPENFOAM file
- Paramètres
sat_dir (string) – path of saturated folder
cur (sqlite3.Cursor) – cursor
-
create_insat_files
(insat_dir, simulation_data, injection_data, param, settings, znodes)¶ builds the input files for OPENFOAM unsaturated
- Paramètres
insat_dir (string) – path of insaturated folder
simulation_data (dict) – dictionnary of simulation data
injections_data (list) – list, containing a dictionnary for each injection
param (dict) – parameters dictionnary
settings (Settings) – Thyrsis settings
znodes (list) – znodes (list of z coordinate)
-
create_maillage_insat
(mesh_dir, znodes)¶ creates the OPENFOAM mesh files for unsaturated computations
- Paramètres
insat_dir (string) – path of insaturated folder
znodes (list) – znodes (list of z coordinate)
-
create_maillage_sat
(sat_dir, cur, hynverse=False)¶ builds the mesh saturated OPENFOAM files
- Paramètres
sat_dir (string) – path of saturated folder
cur (sqlite3.Cursor) – cursor
hynverse (bool) – hynverse flag
-
create_mnt_sat
(sat_dir, cur)¶ builds the mnt saturated OPENFOAM file
- Paramètres
sat_dir (string) – path of saturated folder
cur (sqlite3.Cursor) – cursor
-
create_mur_sat
(sat_dir, cur)¶ builds the bedrock saturated OPENFOAM file
- Paramètres
sat_dir (string) – path of saturated folder
cur (sqlite3.Cursor) – cursor
-
create_permeabilities_sat
(sat_dir, cur=None, liste_pm=None)¶ builds the permeabilities saturated OPENFOAM file
- Paramètres
sat_dir (string) – path of saturated folder
cur (sqlite3.Cursor) – cursor
liste_pm (list) – permeabilities data per mesh element
-
create_probes_sat
(sat_dir, cur, field='C')¶ builds the probes file for OPENFOAM
- Paramètres
sat_dir (string) – path of saturated folder
cur (sqlite3.Cursor) – cursor
-
create_sat_files
(sat_dir, simulation_data, param, settings)¶ builds the input files for OPENFOAM saturated
- Paramètres
sat_dir (string) – path of saturated folder
simulation_data (dict) – dictionnary of simulation data
param (dict) – parameters dictionnary
settings (Settings) – Thyrsis settings
-
static
create_tree
(compute_dir, foam_name)¶ builds the directory tree for openfoam computation
- Paramètres
compute_dir (string) – path of compute folder
foam_name (string) – foam mode [saturated/unsaturated/stationaryGroundwaterFoam/stationaryGroundwater2DFoam
-
create_velocities_sat
(sat_dir, cur=None, liste_vm=None, init=False)¶ builds the velocities saturated OPENFOAM file
- Paramètres
sat_dir (string) – path of saturated folder
cur (sqlite3.Cursor) – cursor
liste_vm (list) – velocities data per mesh element
init (boolean) – boolean, True if only initialisation to (0 0 0)
-
static
entete
(name_dir, name_file, classe, location, note=None)¶ builds the leading section of OPENFOAM files
- Paramètres
name_dir (string) – path of folder
classe (string) – classe name
location (string) – path to location
note (string) – optional note
-
file_exists
(result_file)¶ returns True if the result file exists, with the name connections of variables_dictionary
- Renvoie
path of result file
- Type renvoyé
string
-
get_hynverse_options
()¶ specific options for inversion with OPENFOAM
- Renvoie
OpenFoam options
- Type renvoyé
dict
-
get_mailles
()¶ Return nodes
- Renvoie
list of mesh element ids and coords
- Type renvoyé
list
-
static
get_meshid
(compute_dir)¶ returns the list of cells renumbered by renumberMesh
- Paramètres
compute_dir (string) – path of compute folder
- Renvoie
list of cells
- Type renvoyé
list
-
static
get_ncells
(compute_dir)¶ returns the number of cells
- Paramètres
compute_dir (string) – path of compute folder
- Renvoie
number of cells
- Type renvoyé
int
-
get_nodes
()¶ Return nodes
- Renvoie
list of node ids
- Type renvoyé
list
-
get_number_mailles_per_node
()¶ Return number of mesh connected to each node
- Renvoie
dict giving the number of mesh connected to each node
- Type renvoyé
dict
-
get_options
()¶ specific options for OPENFOAM
- Renvoie
OpenFoam options
- Type renvoyé
dict
-
get_solver
(simulation_data, mode='saturated')¶ Returns the OPENFOAM solver name, depending of the computation type
- Paramètres
simulation_data (dict) – dictionnary of simulation data
mode (string) – foam mode
- Renvoie
solver_saturated
- Type renvoyé
string
-
modif_data
(rep, tini=0.0)¶ modifies the OPENFOAM data file and corrects the initial time, yet not used for OPENFOAM
- Paramètres
rep (string) – file path
tini (float) – initial time
-
nok
(log_file)¶ returns False if the OPENFOAM computation is OK, by testing the End string in the log file
- Paramètres
log_file (string) – log file path
- Renvoie
success state
- Type renvoyé
bool
-
read_debit
(result_file, dates)¶ reads saturated CmassBalance.csv file
- Paramètres
result_file (string) – path of the result file
dates (list) – list of dates
- Renvoie
results
- Type renvoyé
numpy.ndarray
-
read_file
(result_file, dates, convert=False)¶ reads an OPENFOAM results file
- Paramètres
result_file (string) – path of the result file
dates (list) – list of dates
convert (bool) – convert flag to get ZNS columns data
- Renvoie
result
- Type renvoyé
numpy.ndarray
-
read_file_formate
(result_file, dates, convert=False)¶ reads an OPENFOAM results file from time directories and adds values in case of missing dates
- Paramètres
result_file (string) – path of the result file
dates (list) – list of dates
convert (bool) – convert flag to get ZNS columns data
- Renvoie
results
- Type renvoyé
numpy.ndarray
-
read_insat_flux
(insat_dir, name='debit')¶ reads the outgoing flux from a ZNS column
- Paramètres
insat_dir (string) – path of insaturated folder
name (string) – flux name
- Return ldates
dates list
- Rtype ldates
list
- Return lflux
outgoing flux value list
- Rtype lflux »
list
-
read_mesh_insat
(insat_dir)¶ reads the OPENFOAM points file and returns the nodes number and the nodes surfaces
- Paramètres
insat_dir (string) – path of insaturated folder
- Return nnodes
nodes number
- Rtype nnodes
list
- Return surfaces
nodes surfaces
- Rtype surfaces
list
-
static
read_openfoam_file
(file_name, norm=True, nbVal=None)¶ reads an OPENFOAM file and returns list of values
- Paramètres
file_name (string) – path of openfoam file
norm (bool) – norm flag
nbVal (integer) – number of values
- Renvoie
number of cells
- Type renvoyé
int
-
read_potential_at_nodes
(sat_dir, dates)¶ Reads the potential at node for each dates
- Paramètres
sat_dir (string) – path of insaturated folder
dates (list) – list of dates
- Renvoie
result
- Type renvoyé
numpy.ndarray
-
static
renumberMesh
(sat_dir)¶ renumber the mesh to fit OPENFOAM constraints
- Paramètres
sat_dir (string) – path of insaturated folder
-
settings_to_dict
(settings)¶ save settings in dictionnary, yet not used for OPENFOAM
- Paramètres
settings (Settings) – Thyrsis settings
-
static
times_dir_names
(compute_dir)¶ returns a sorted list of the times directories
- Paramètres
compute_dir (string) – path of compute folder
-
update_database
(conn, compute_dir)¶ update database after inversion
- Paramètres
conn (sqlite3.Connection) – conn on a sqlite database
compute_dir (string) – path of compute folder
-
write_sat_flux
(sat_dir, name, dates, nodes, ldates, lnodes, lflux)¶ creates the file giving the incoming flux into the groundwater
- Paramètres
sat_dir (string) – path of saturated folder
name (string) – flux name
dates (list) – list of dates
nodes (list) – nodes
ldates (list) – dates list
lnodes (list) – outgoing nodes list
lflux – outgoing flux value list
-
static