Commit 1bb24325 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[ex2] modify example code

parent 4200f8e7
......@@ -67,7 +67,7 @@ raw entities. This can potentially fail to detect small length scales that appea
the entities to the domain. A possibilty to address this and make the algorithm more robust
(but computationally more demanding) is discussed at the end of this page.
As you can see in the above code snippet, the `Cylinder` class provides functions for obtaining th
As you can see in the above code snippet, the `Cylinder` class provides functions for obtaining the
representations of the top, bottom and lateral boundaries. The top and bottom boundaries are
represented by instances of the `Disk` class, while the lateral surface is described by the class
`CylinderSurface`. Please also note that for the lateral surface, we enforce the constraints
......
import frackit.geometry as geometry
import random
import math
# we want to use a cylindrical domain with radius=0.5 and height=1.0
domain = geometry.Cylinder(0.5, 1.0)
domain = geometry.Cylinder(radius=0.5, height=1.0)
# we sample points uniformly within the shifted unit cube such
# that the origin is in the center of the bottom boundary of the domain
from frackit.sampling import makeUniformPointSampler
box = geometry.Box(-0.5, -0.5, 0.0, 0.5, 0.5, 1.0)
box = geometry.Box(xmin=-0.5, ymin=-0.5, zmin=0.0,
xmax=0.5, ymax=0.5, zmax=1.0)
pointSampler = makeUniformPointSampler(box)
# returns a sampler from a gaussian distribution with mean and std deviation
def gaussianSampler(mean, stdDev):
import random
def sample():
return random.gauss(mean, stdDev)
def sample(): return random.gauss(mean, stdDev)
return sample
#returns a sampler from a uniform distribution between min and max
def uniformSampler(min, max):
import random
def sample():
return random.uniform(min, max)
def sample(): return random.uniform(min, max)
return sample
# we sample quadrialeterals within the box with gaussian distributions for the parameters
from frackit.common import toRadians
from frackit.sampling import QuadrilateralSampler as QuadSampler
quadSampler1 = QuadSampler(pointSampler,
gaussianSampler(toRadians(45.0), toRadians(5.0)), # strike angle
gaussianSampler(toRadians(90.0), toRadians(5.0)), # dip angle
uniformSampler(0.4, 0.6), # strike length
uniformSampler(0.4, 0.6)) # dip length
quadSampler1 = QuadSampler(pointSampler = pointSampler,
strikeAngleSampler = gaussianSampler(math.radians(45.0), math.radians(5.0)),
dipAngleSampler = gaussianSampler(math.radians(90.0), math.radians(5.0)),
strikeLengthSampler = uniformSampler(0.4, 0.6),
dipLengthSampler = uniformSampler(0.4, 0.6))
# sampler for quadrilaterals of the secondary orientation
quadSampler2 = QuadSampler(pointSampler,
gaussianSampler(toRadians(0.0), toRadians(5.0)), # strike angle
gaussianSampler(toRadians(0.0), toRadians(5.0)), # dip angle
uniformSampler(0.4, 0.6), # strike length
uniformSampler(0.4, 0.6)) # dip length
quadSampler2 = QuadSampler(pointSampler = pointSampler,
strikeAngleSampler = gaussianSampler(math.radians(0.0), math.radians(5.0)),
dipAngleSampler = gaussianSampler(math.radians(0.0), math.radians(5.0)),
strikeLengthSampler = uniformSampler(0.4, 0.6),
dipLengthSampler = uniformSampler(0.4, 0.6))
# constructs a constraints object with default settings for this example
from frackit.entitynetwork import EntityNetworkConstraints
def makeDefaultConstraints():
c = EntityNetworkConstraints()
c.setMinDistance(0.05)
c.setMinIntersectingAngle(toRadians(30.0))
c.setMinIntersectingAngle(math.radians(30.0))
c.setMinIntersectionMagnitude(0.05)
c.setMinIntersectionDistance(0.05)
return c
......@@ -59,7 +56,7 @@ constraintsOnSelf = makeDefaultConstraints()
# with respect to entities of the other set, we want to have larger intersection angles
constraintsOnOther = makeDefaultConstraints()
constraintsOnOther.setMinIntersectingAngle(toRadians(40.0));
constraintsOnOther.setMinIntersectingAngle(math.radians(40.0))
# we use the default constraints w.r.t. to the domain boundary
constraintsOnBoundary = makeDefaultConstraints()
......@@ -114,7 +111,7 @@ while not status.finished():
# reject entities whose contained part is too small
from frackit.geometry import computeContainedMagnitude
containedArea = computeContainedMagnitude(quad, domain);
containedArea = computeContainedMagnitude(quad, domain)
if (containedArea < 0.01):
status.increaseRejectedCounter()
continue
......@@ -135,19 +132,19 @@ from frackit.entitynetwork import ContainedEntityNetworkBuilder
builder = ContainedEntityNetworkBuilder()
# our domain confines all entities and receives the id 1
builder.addConfiningSubDomain(domain, Id(1));
builder.addConfiningSubDomain(domain, Id(1))
# define all entities to be embedded in this domain
builder.addSubDomainEntities(entities1, Id(1));
builder.addSubDomainEntities(entities2, Id(1));
builder.addSubDomainEntities(entities1, Id(1))
builder.addSubDomainEntities(entities2, Id(1))
# let the builder construct the network and write it to gmsh file format
print("\n --- Constructing entity network from the raw entities ---\n")
network = builder.build();
network = builder.build()
print("\n --- Writing .geo file ---\n")
from frackit.io import GmshWriter
writer = GmshWriter(network);
writer = GmshWriter(network)
writer.setMeshSize(GmshWriter.GeometryTag.entity, 0.1)
writer.setMeshSize(GmshWriter.GeometryTag.subDomain, 0.1)
writer.write("network") # filename of the .geo files (will add extension .geo automatically)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment