The path to a clean OGS - pure python API
Example 1: BHE_mesh
from ogstools import examples
import ogstools as ogs
bhe_mesh = ogs.examples.bhe.mesh(params...) # includes information about subdomains (boundaries)
bhe_prj = ogs.examples.bhe.prj() # loads from OGS benchmarks (ogs6py-object)
# customize...
model = ogs.Model(bhe_mesh, bhe_prj, optional_execution_model (e.g. cores=5))
# alternatively:
model = ogs.examples.bhe.model()
results: MeshSeries, LogParser: log = model.run()
results.plot.contourf()
log.timesteps(.plot)
Example 2: feflow
from ogstools import examples
import ogstools as ogs
ms = ogs.MeshSeries.read_feflow_dac(feflow_file.dac)
# Implementation of Model.read_feflow:
ogsmesh = ogs.OGSMesh(mesh, boundary_meshes) # .__init__(self)
# Implementation of feflowModel
feflowModel = feflowModel(feflow_file)
boundary_meshes = feflowModel.get_boundaries() # dict['name_of_boundary_mesh']=boudnary_mesh:
bulk_mesh = feflowModel.get_bulk_mesh() # pv.UnstructuredGrid
prj = feflowModel.get_prj() #ogs6py.OGS()
ogsmesh = ogs.OGSMesh(mesh, boundary_meshes) # .__init__(self)
ogsmesh = ogs.OGSMesh.read_feflow(file.fem) # optional
ogsModel = ogs.Model(ogsmesh,prj)
ogsModel = ogs.Model.read_feflow(file.fem) #optional
# customize...
model.prj.parameters.density *= 2
results: MeshSeries, LogParser: log = model.run()
results.plot.contourf()
log.timesteps(.plot)
Example 3: custom gmsh mesh with existing benchmark prj as template
from ogstools import examples
import ogstools as ogs
mesh = ogs.Mesh.from_msh("path_to.msh") # basically msh2vtu
prj = ogs.examples.THM.2D_consoliation.prj() # loads from OGS benchmarks (ogs6py-object)
# customize...
model = ogs.Model(mesh, prj) # map new meshes to prj??
...
Example 4: custom gmsh mesh with custom prj:
from ogstools import examples
import ogstools as ogs
mesh = ogs.Mesh.from_msh("path_to.msh") # basically msh2vtu
prj = ogs.Project(input_file=ogs.examples.THM.2D_consoliation.prj())
# customize...
prj.add_timestep(...) # ...
prj.save("filename.prj") # optional
ex_conf = ogs.ExecutionConfig # optional (rethink naming)
# includes:
# path to binary, container
# optiuonal parallelization
# loglevel and all ogs binary args
model = ogs.Model(mesh, prj, ex_conf) # map new meshes to prj??
model.run(
...
Edited by Florian Zill