6.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
- Parameters
fil (BufferedIOBase) – buffered file
wall (string) – wall value if fixed
- compute(compute_dir, total_time, MPI=None)¶
computes saturated or unsaturated
- Parameters
compute_dir (string) – path of compute folder
total_time (float) – simulation time duration in second
- compute_hynverse(compute_dir)¶
computes saturated for inversion
- Parameters
compute_dir (string) – path of compute folder
- compute_probes(compute_dir)¶
computes results at probes
- Parameters
compute_dir (string) – path of compute folder
- convert_infiltration_transitoire_insature(compute_dir)¶
Copy transient infiltration file to compute_dir
- Parameters
compute_dir (string) – path of compute folder
- convert_infiltration_transitoire_sature(compute_dir)¶
Copy transient infiltration file to compute_dir
- Parameters
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
- Parameters
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
- Parameters
sat_dir (string) – path of saturated folder
- create_infiltration_sat(sat_dir, cur)¶
builds the infiltration saturated OPENFOAM file
- Parameters
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
- Parameters
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
- Parameters
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
- Parameters
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
- Parameters
sat_dir (string) – path of saturated folder
cur (sqlite3.Cursor) – cursor
- create_mur_sat(sat_dir, cur)¶
builds the bedrock saturated OPENFOAM file
- Parameters
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
- Parameters
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
- Parameters
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
- Parameters
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
- Parameters
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
- Parameters
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
- Parameters
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
- Returns
path of result file
- Return type
string
- get_hynverse_options()¶
specific options for inversion with OPENFOAM
- Returns
OpenFoam options
- Return type
dict
- get_mailles()¶
Return nodes
- Returns
list of mesh element ids and coords
- Return type
list
- static get_meshid(compute_dir)¶
returns the list of cells renumbered by renumberMesh
- Parameters
compute_dir (string) – path of compute folder
- Returns
list of cells
- Return type
list
- static get_ncells(compute_dir)¶
returns the number of cells
- Parameters
compute_dir (string) – path of compute folder
- Returns
number of cells
- Return type
int
- get_nodes()¶
Return nodes
- Returns
list of node ids
- Return type
list
- get_number_mailles_per_node()¶
Return number of mesh connected to each node
- Returns
dict giving the number of mesh connected to each node
- Return type
dict
- get_options()¶
specific options for OPENFOAM
- Returns
OpenFoam options
- Return type
dict
- get_solver(simulation_data, mode='saturated')¶
Returns the OPENFOAM solver name, depending of the computation type
- Parameters
simulation_data (dict) – dictionnary of simulation data
mode (string) – foam mode
- Returns
solver_saturated
- Return type
string
- modif_data(rep, tini=0.0)¶
- modifies the OPENFOAM data file and corrects the initial time
and modifies the dates_simulation.txt file in order to keep only dates greater than tini and concerts dates to integers.
- Parameters
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
- Parameters
log_file (string) – log file path
- Returns
success state
- Return type
bool
- read_debit(result_file, dates)¶
reads saturated CmassBalance.csv file
- Parameters
result_file (string) – path of the result file
dates (list) – list of dates
- Returns
results
- Return type
numpy.ndarray
- read_file(result_file, dates, convert=False)¶
reads an OPENFOAM results file
- Parameters
result_file (string) – path of the result file
dates (list) – list of dates
convert (bool) – convert flag to get ZNS columns data
- Returns
result
- Return type
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
- Parameters
result_file (string) – path of the result file
dates (list) – list of dates
convert (bool) – convert flag to get ZNS columns data
- Returns
results
- Return type
numpy.ndarray
- read_insat_flux(insat_dir, name='debit')¶
reads the outgoing flux from a ZNS column
- Parameters
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
- Parameters
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
- Parameters
file_name (string) – path of openfoam file
norm (bool) – norm flag
nbVal (integer) – number of values
- Returns
number of cells
- Return type
int
- read_potential_at_nodes(sat_dir, dates)¶
Reads the potential at node for each dates
- Parameters
sat_dir (string) – path of insaturated folder
dates (list) – list of dates
- Returns
result
- Return type
numpy.ndarray
- static renumberMesh(sat_dir)¶
renumber the mesh to fit OPENFOAM constraints
- Parameters
sat_dir (string) – path of insaturated folder
- settings_to_dict(settings)¶
save settings in dictionnary, yet not used for OPENFOAM
- Parameters
settings (Settings) – Thyrsis settings
- static times_dir_names(compute_dir)¶
returns a sorted list of the times directories
- Parameters
compute_dir (string) – path of compute folder
- update_database(conn, compute_dir)¶
update database after inversion
- Parameters
conn (sqlite3.Connection) – conn on a sqlite database
compute_dir (string) – path of compute folder
- write_sat_flux(sat_dir, name, dates, nodes, meshes, ldates, lnodes, lmeshes, lflux)¶
creates the file giving the incoming flux into the groundwater
- Parameters
sat_dir (string) – path of saturated folder
name (string) – flux name
dates (list) – list of dates
nodes (list) – total injection nodes list
meshes (list) – total injection meshes list
ldates (list) – dates list
lnodes (list) – list of injection nodes lists per injection
lmeshes (list) – list of (injection meshes, area ratio) lists per injection
lflux – list of time-dependant flux lists per injection