Commit 4200f8e7 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[ex] edit example code

parent 2cc46a9c
......@@ -36,11 +36,10 @@ int main(int argc, char** argv)
// These points will be used as the quadrilateral centers.
auto pointSampler = makeUniformPointSampler(domain);
// Sampler class for quadrilaterals. Per default, this uses
// uniform distributions for all parameters defining the quadrilaterals.
// Quadrilateral samplers require distributions for strike angle, dip angle,
// edge length (see class description for more details). Moreover, we define
// a minimum edge length.
// Sampler class for quadrilaterals. Per default, this uses uniform distributions
// for all parameters defining the quadrilaterals. Quadrilateral samplers require
// distributions for strike angle, dip angle, edge length (see class description
// for more details).
using QuadSampler = QuadrilateralSampler<worldDimension>;
using NormalDistro = std::normal_distribution<ctype>;
using UniformDistro = std::uniform_real_distribution<ctype>;
......
import frackit.geometry as geometry
import random
import math
# we use the unit cube as domain
box = geometry.Box(0.0, 0.0, 0.0, 1.0, 1.0, 1.0)
box = geometry.Box(xmin=0.0, ymin=0.0, zmin=0.0,
xmax=1.0, ymax=1.0, zmax=1.0)
# we sample points uniformly within the domain
from frackit.sampling import makeUniformPointSampler
# 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
# we sample quadrilaterals within the box with gaussian distributions for the parameters
from frackit.sampling import QuadrilateralSampler as QuadSampler
quadSampler1 = QuadSampler(makeUniformPointSampler(box),
gaussianSampler(toRadians(45.0), toRadians(5.0)), # strike angle
gaussianSampler(toRadians(90.0), toRadians(5.0)), # dip angle
uniformSampler(0.4, 0.8), # strike length
uniformSampler(0.4, 0.8)) # dip length
quadSampler1 = QuadSampler(pointSampler = makeUniformPointSampler(box),
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.8),
dipLengthSampler = uniformSampler(0.4, 0.8))
# sampler for quadrilaterals of the secondary orientation
quadSampler2 = QuadSampler(makeUniformPointSampler(box),
gaussianSampler(toRadians(0.0), toRadians(5.0)), # strike angle
gaussianSampler(toRadians(0.0), toRadians(5.0)), # dip angle
uniformSampler(0.4, 0.8), # strike length
uniformSampler(0.4, 0.8)) # dip length
quadSampler2 = QuadSampler(pointSampler = makeUniformPointSampler(box),
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.8),
dipLengthSampler = uniformSampler(0.4, 0.8))
# We want to enforce some constraints on the set of quadrilaterals.
# In particular, for entities of the same set we want a minimum spacing
......@@ -45,14 +43,14 @@ quadSampler2 = QuadSampler(makeUniformPointSampler(box),
from frackit.entitynetwork import EntityNetworkConstraints
constraintsOnSelf = EntityNetworkConstraints()
constraintsOnSelf.setMinDistance(0.05)
constraintsOnSelf.setMinIntersectingAngle(toRadians(30.0))
constraintsOnSelf.setMinIntersectingAngle(math.radians(30.0))
constraintsOnSelf.setMinIntersectionMagnitude(0.05)
constraintsOnSelf.setMinIntersectionDistance(0.05)
# with respect to entities of the other set, we want to have larger intersection angles
constraintsOnOther = EntityNetworkConstraints()
constraintsOnOther.setMinDistance(0.05)
constraintsOnOther.setMinIntersectingAngle(toRadians(40.0));
constraintsOnOther.setMinIntersectingAngle(math.radians(40.0))
constraintsOnOther.setMinIntersectionMagnitude(0.05)
constraintsOnOther.setMinIntersectionDistance(0.05)
......@@ -105,16 +103,16 @@ print("\n --- Finished entity sampling ---\n")
# We can now create an entity network from the two sets
from frackit.entitynetwork import EntityNetworkBuilder
builder = EntityNetworkBuilder()
builder.addEntities(entities1);
builder.addEntities(entities2);
builder.addEntities(entities1)
builder.addEntities(entities2)
# 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.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