Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
8b50d6d
simulation vec result
martinspetlik Jul 11, 2019
46c304e
temporary disable pbs flow test
martinspetlik Jul 11, 2019
8d66c34
comment memory profiler
martinspetlik Jul 11, 2019
7128a30
mlmc vec flow - first proposal
Jul 11, 2019
099ecbb
add pbs
Jul 11, 2019
6f98125
sample fix
martinspetlik Jul 19, 2019
8a06f91
moments ref domain
martinspetlik Jul 20, 2019
965412b
moments evaluation
martinspetlik Jul 20, 2019
1b292ad
fix density
martinspetlik Jul 21, 2019
47ef5e0
load python modules
martinspetlik Jul 21, 2019
7136f23
Fix gmsh_io
jbrezmorf Jul 22, 2019
904f58a
gmsh_io fix
martinspetlik Jul 22, 2019
88b5030
Revert "gmsh_io fix"
martinspetlik Jul 22, 2019
0114cd7
gmsh_io versions merge
martinspetlik Jul 22, 2019
451729c
select param default value
martinspetlik Jul 24, 2019
5dfaf27
Revert "gmsh_io versions merge"
jbrezmorf Jul 24, 2019
9b30bdc
PBS abs path for PBS.work_dir
jbrezmorf Jul 24, 2019
91e001e
subsample by indices
martinspetlik Jul 25, 2019
3ebf101
remove adhoc Pbs argument
jbrezmorf Jul 26, 2019
3481300
avoid collect samples during load
jbrezmorf Jul 28, 2019
91b3f47
Fix for sample_indices
jbrezmorf Jul 28, 2019
0aa05f4
Fix failed copy
jbrezmorf Jul 29, 2019
9d6ed05
Fix MCLevel.n_samples
jbrezmorf Jul 30, 2019
8c7238c
Add fracture module
jbrezmorf Aug 22, 2019
08fe93b
Add von Misses distribution
jbrezmorf Aug 22, 2019
f872c23
Fractures imporovements
jbrezmorf Sep 8, 2019
556b575
Resonable fracture network sampling
jbrezmorf Sep 11, 2019
41045b1
Apply fix in Segment.vector update from GeoMop
jbrezmorf Sep 11, 2019
ead9c4d
Matplotlib segments plot
jbrezmorf Sep 11, 2019
9741fb5
Minor improvements in MLMC
jbrezmorf Sep 11, 2019
ee1a2bf
Simplify attr support in decomposition.
jbrezmorf Sep 13, 2019
23df44f
Fix reading gmsh data fields
jbrezmorf Sep 14, 2019
5d967b9
Avoid moving outer boundary
jbrezmorf Sep 15, 2019
53e0b9f
Strugling to make MLMC work, too unstable.
jbrezmorf Sep 15, 2019
68c8476
Fix gmsh_io
jbrezmorf Sep 17, 2019
c340172
Merge branch 'JB_endorse' into JB_merge_endorse
jbrezmorf Apr 2, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def read(*names, **kwargs):
license='GPL 3.0',
description='Multilevel Monte Carlo method.',
long_description=long_description,
author='Jan Brezina, Martin Spetlik, Klara Steklova',
author='Jan Brezina, Martin Spetlik',
author_email='jan.brezina@tul.cz',
url='https://github.com/GeoMop/MLMC',
classifiers=[
Expand Down Expand Up @@ -65,9 +65,9 @@ def read(*names, **kwargs):
py_modules=[splitext(basename(path))[0] for path in glob.glob('src/*.py')],
package_data={
# If any package contains *.txt or *.rst files, include them:
'': ['*.txt', '*.rst'],
#'': ['*.txt', '*.rst'],
# And include any *.msg files found in the 'hello' package, too:
'hello': ['*.msg'],
#'hello': ['*.msg'],
},

# include automatically all files in the template MANIFEST.in
Expand All @@ -77,9 +77,8 @@ def read(*names, **kwargs):
# eg: 'aspectlib==1.1.1', 'six>=1.7',
],
extras_require={
# eg:
# 'rst': ['docutils>=0.11'],
# ':python_version=="2.6"': ['argparse'],
# requirements for optional features
'gmsh': ['gmsh-tools'],
}
# entry_points={
# 'console_scripts': [
Expand Down
Empty file added src/create_fields.py
Empty file.
Empty file added src/create_mesh.py
Empty file.
145 changes: 73 additions & 72 deletions src/frac_geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import geomop.format_last as lg
import geomop.layers_io
import geomop.geometry
#from geomop.plot_polygons import plot_polygon_decomposition
from geomop.plot_polygons import plot_polygon_decomposition



Expand All @@ -15,85 +15,86 @@



def make_frac_mesh(box, mesh_step, fractures, frac_step):
def make_frac_mesh(root_polygon, mesh_step:float, fractures, frac_step:float, mesh_base="fractured_2d"):
"""
:param root_polygon: List[Point2d]
:param fractures: List[(Point2d, Point2d)]

Make geometry and mesh for given 2d box and set of fractures.
:param box: [min_point, max_point]; points are np.arrays
:param fractures: Array Nx2x2, one row for every fracture given by endpoints: [p0, p1]
:return: GmshIO object with physical groups:
box: 1,
fractures: 1000 + i, i = 0, ... , N-1
"bulk": 1
"side_<n>", n + 1
"frac_<n>", 1000 + n
"""
regions = make_regions(mesh_step, fractures, frac_step)
decomp, reg_map = make_decomposition(box, fractures, regions)
geom = fill_lg(decomp, reg_map, regions)
regions = []
add_reg(regions, "NONE", -1, not_used=True)
i_r_bulk = add_reg(regions, "bulk", 2, mesh_step)
i_r_side = [
add_reg(regions, "side_{}".format(s_id), 1, step=frac_step, bc=True)
for s_id in range(len(root_polygon))
]
i_r_frac = [
add_reg(regions, "frac_{}".format(f_id), 1, step=frac_step)
for f_id in range(len(fractures))
]
decomp = make_decomposition(root_polygon, fractures, regions, i_r_bulk, i_r_side, i_r_frac, frac_step)

geom = fill_lg(decomp, regions, mesh_base=mesh_base)
return make_mesh(geom)


def add_reg(regions, name, dim, step=0.0, bc=False, not_used =False):
reg = lg.Region(dict(name=name, dim=dim, mesh_step=step, boundary=bc, not_used=not_used))
reg._id = len(regions)
regions.append(reg)
return reg._id

def make_regions(mesh_step, fractures, frac_step):
regions = []
add_reg(regions, "NONE", -1, not_used=True)
add_reg(regions, "bulk_0", 2, mesh_step)
add_reg(regions, ".bc_inflow", 1, bc=True)
add_reg(regions, ".bc_outflow", 1, bc=True)
for f_id in range(len(fractures)):
add_reg(regions, "frac_{}".format(f_id), 1, frac_step)
return regions


def make_decomposition(box, fractures, regions):
box_pd = poly.PolygonDecomposition()
p00, p11 = box
p01 = np.array([p00[0], p11[1]])
p10 = np.array([p11[0], p00[1]])
box_pd.add_line(p00, p01)
seg_outflow, = box_pd.add_line(p01, p11)
box_pd.add_line(p11, p10)
seg_inflow, = box_pd.add_line(p10, p00)

decompositions = [box_pd]
for p0, p1 in fractures:
pd = poly.PolygonDecomposition()
pd.add_line(p0, p1)
decompositions.append(pd)

common_decomp, maps = merge.intersect_decompositions(decompositions)
#plot_polygon_decomposition(common_decomp)
#print(maps)

# Map common_decomp objects to regions.
none_region_id = 0
box_reg_id = 1
bc_inflow_id = 2
bc_outflow_id = 3
frac_id_shift = 4
decomp_shapes = [common_decomp.points, common_decomp.segments, common_decomp.polygons]
reg_map = [{key: regions[none_region_id] for key in decomp_shapes[d].keys()} for d in range(3)]
for i_frac, f_map in enumerate(maps[1:]):
for id, orig_seg_id in f_map[1].items():
reg_map[1][id] = regions[frac_id_shift + i_frac]

for id, orig_poly_id in maps[0][2].items():
if orig_poly_id == 0:
continue
reg_map[2][id] = regions[box_reg_id]

for id, orig_seg_id in maps[0][1].items():
if orig_seg_id == seg_inflow.id:
reg_map[1][id] = regions[bc_inflow_id]
if orig_seg_id == seg_outflow.id:
reg_map[1][id] = regions[bc_outflow_id]


return common_decomp, reg_map


def fill_lg(decomp, reg_map, regions):


def make_decomposition(root_polygon_points, fractures, regions, i_r_bulk, i_r_side, i_r_frac, tol):
# Create boundary polygon
box_pd = poly.PolygonDecomposition([regions[0], regions[0], regions[0]], tol)
last_pt = root_polygon_points[-1]
side_segments = {}
for i_side, pt in enumerate(root_polygon_points):
sub_segments = box_pd.add_line(last_pt, pt, attr=regions[i_r_side[i_side]])
last_pt = pt
assert type(sub_segments) == list and len(sub_segments) == 1
seg = sub_segments[0]
side_segments[seg.id] = i_side
assert len(box_pd.polygons) == 2
box_pd.polygons[1].attr = regions[i_r_bulk]

# Add fractures
outer_wire = box_pd.outer_polygon.outer_wire.childs
assert len(outer_wire) == 1
outer_wire = next(iter(outer_wire))
for i_fr, (p0, p1) in enumerate(fractures):
box_pd.decomp.check_consistency()
print(i_fr, "fr size:", np.linalg.norm(p1 - p0))

segments = box_pd.add_line(p0, p1, attr=regions[i_r_frac[i_fr]])

if type(segments) == list:
for seg in segments:
if seg.wire[0] == seg.wire[1] and seg.wire[0] == outer_wire:
points = seg.vtxs
box_pd.delete_segment(seg)
for pt in points:
if pt.is_free():
box_pd.remove_free_point(pt.id)

# TODO: remove outer segments


#common_decomp, maps = merge.intersect_decompositions(decompositions)
plot_polygon_decomposition(box_pd)
return box_pd


def fill_lg(decomp, regions, mesh_base="fractured_2d"):
"""
Create LayerGeometry object.
"""
Expand All @@ -112,9 +113,9 @@ def fill_lg(decomp, reg_map, regions):
layer = lg.FractureLayer(dict(
name = "layer",
top = iface_ns,
polygon_region_ids = [ reg_map[2][poly.id]._id for poly in decomp.polygons.values() ],
segment_region_ids = [ reg_map[1][seg.id]._id for seg in decomp.segments.values() ],
node_region_ids = [ reg_map[0][node.id]._id for node in decomp.points.values() ]
polygon_region_ids = [ poly.attr._id for poly in decomp.polygons.values() ],
segment_region_ids = [ seg.attr._id for seg in decomp.segments.values() ],
node_region_ids = [ node.attr._id for node in decomp.points.values() ]
))
geom.layers = [ layer ]
#geom.surfaces = [ClassFactory(Surface)]
Expand All @@ -132,9 +133,9 @@ def fill_lg(decomp, reg_map, regions):
nodes = nodes
))
geom.node_sets = [ nodeset ]
geomop.layers_io.write_geometry("fractured_2d.json", geom)
#geomop.layers_io.write_geometry(mesh_base + ".json", geom)
return geom


def make_mesh(geometry):
return geomop.geometry.make_geometry(geometry=geometry, layers_file="fractured_2d.json", mesh_step=1.0)
def make_mesh(geometry, mesh_base="fractured_2d"):
return geomop.geometry.make_geometry(geometry=geometry, layers_file=mesh_base + ".json", mesh_step=1.0)
2 changes: 2 additions & 0 deletions src/geomop/aabb_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ def closest_candidates(self, point):
return []
inf_dists = np.max(np.maximum(self.boxes[:, 0:2] - point, point - self.boxes[:, 2:4]), axis=1)
if np.amin(inf_dists) > 0.0:
# closest box not containing the point
i_closest = np.argmin(inf_dists)
c_boxes = boxes[i_closest:i_closest+1, :]
else:
# point is inside all boxes
c_boxes = boxes[np.where(inf_dists<=0.0)]
assert c_boxes.shape[0] != 0
# Max distance of closest boxes
Expand Down
Loading