Commit 17f518a1 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[ex1] use new quad sampler

parent ecb9333d
...@@ -20,15 +20,16 @@ For example, we instantiate an instance of this class by writing: ...@@ -20,15 +20,16 @@ For example, we instantiate an instance of this class by writing:
static constexpr int worldDimension = 3; static constexpr int worldDimension = 3;
using ctype = double; using ctype = double;
using Distro = std::normal_distribution<ctype>; using NormalDistro = std::normal_distribution<ctype>;
using UniformDistro = std::uniform_real_distribution<ctype>;
using QuadSampler = QuadrilateralSampler<worldDimension>; using QuadSampler = QuadrilateralSampler<worldDimension>;
Box<ctype> domain(0.0, 0.0, 0.0, 1.0, 1.0, 1.0); Box<ctype> domain(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
QuadSampler quadSampler(makeUniformPointSampler(domain), // point sampler that samples the center points of the quadrilaterals QuadSampler quadSampler(makeUniformPointSampler(domain), // point sampler that samples the center points of the quadrilaterals
Distro(toRadians(0.0), toRadians(5.0)), // strike angle: mean value & standard deviation NormalDistro(toRadians(0.0), toRadians(5.0)), // strike angle: mean value & standard deviation
Distro(toRadians(0.0), toRadians(5.0)), // dip angle: mean value & standard deviation NormalDistro(toRadians(0.0), toRadians(5.0)), // dip angle: mean value & standard deviation
Distro(0.5, 0.1), // edge length: mean value & standard deviation UniformDistro(0.4, 0.8), // strike length
0.05); // threshold for minimum edge length UniformDistro(0.4, 0.8)); // dip length
``` ```
The first constructor argument is a point sampler with which the center points of The first constructor argument is a point sampler with which the center points of
...@@ -36,9 +37,8 @@ the quadrilaterals are sampled. Here we use uniformly sampled points in the unit ...@@ -36,9 +37,8 @@ the quadrilaterals are sampled. Here we use uniformly sampled points in the unit
cube, which is represented by an instance of the `Box` class, stored in the cube, which is represented by an instance of the `Box` class, stored in the
variable `domain`. The second and third arguments define the distributions for variable `domain`. The second and third arguments define the distributions for
the strike and dip angle (for details see the [class documentation][2]), where in this case we use uniform distributions with the strike and dip angle (for details see the [class documentation][2]), where in this case we use uniform distributions with
a mean value of 0° and a standard deviation of 5°. The fourth argument is the a mean value of 0° and a standard deviation of 5°. The fourth and last arguments
distribution to be used for sampling the edge lengths, while the last argument are distributions for the sizes of the quadrilaterals in strike and dip direction.
defines a minimum value below which the edge length must not fall.
In the example, the quadrilaterals are sampled from the two samplers `quadSampler1` and In the example, the quadrilaterals are sampled from the two samplers `quadSampler1` and
`quadSampler2`, using the `()` operator: `quadSampler2`, using the `()` operator:
......
...@@ -42,21 +42,22 @@ int main() ...@@ -42,21 +42,22 @@ int main()
// edge length (see class description for more details). Moreover, we define // edge length (see class description for more details). Moreover, we define
// a minimum edge length. // a minimum edge length.
using QuadSampler = QuadrilateralSampler<worldDimension>; using QuadSampler = QuadrilateralSampler<worldDimension>;
using Distro = std::normal_distribution<ctype>; using NormalDistro = std::normal_distribution<ctype>;
using UniformDistro = std::uniform_real_distribution<ctype>;
QuadSampler quadSampler1(pointSampler, QuadSampler quadSampler1(pointSampler,
Distro(toRadians(45.0), toRadians(5.0)), // strike angle: mean value & standard deviation NormalDistro(toRadians(45.0), toRadians(5.0)), // strike angle: mean value & standard deviation
Distro(toRadians(90.0), toRadians(5.0)), // dip angle: mean value & standard deviation NormalDistro(toRadians(90.0), toRadians(5.0)), // dip angle: mean value & standard deviation
Distro(0.5, 0.1), // edge length: mean value & standard deviation UniformDistro(0.4, 0.8), // strike length
0.05); // threshold for minimum edge length UniformDistro(0.4, 0.8)); // dip length
// We use this sampler to create quadrilaterals based on the distributions. // We use this sampler to create quadrilaterals based on the distributions.
// However, we want to create another set of quadrilaterals, whose entities // However, we want to create another set of quadrilaterals, whose entities
// are approximately orthogonal to those defined with the above sampler. // are approximately orthogonal to those defined with the above sampler.
QuadSampler quadSampler2(makeUniformPointSampler(domain), // use a new point sampler instance! QuadSampler quadSampler2(makeUniformPointSampler(domain), // use a new point sampler instance!
Distro(toRadians(0.0), toRadians(5.0)), // strike angle: mean value & standard deviation NormalDistro(toRadians(0.0), toRadians(5.0)), // strike angle: mean value & standard deviation
Distro(toRadians(0.0), toRadians(5.0)), // dip angle: mean value & standard deviation NormalDistro(toRadians(0.0), toRadians(5.0)), // dip angle: mean value & standard deviation
Distro(0.5, 0.1), // edge length: mean value & standard deviation UniformDistro(0.4, 0.8), // strike length
0.05); // threshold for minimum edge length UniformDistro(0.4, 0.8)); // dip length
// We want to enforce some constraints on the set of quadrilaterals. // We want to enforce some constraints on the set of quadrilaterals.
// In particular, for entities of the same set we want a minimum spacing // In particular, for entities of the same set we want a minimum spacing
......
...@@ -5,7 +5,6 @@ box = geometry.Box(0.0, 0.0, 0.0, 1.0, 1.0, 1.0) ...@@ -5,7 +5,6 @@ box = geometry.Box(0.0, 0.0, 0.0, 1.0, 1.0, 1.0)
# we sample points uniformly within the domain # we sample points uniformly within the domain
from frackit.sampling import makeUniformPointSampler from frackit.sampling import makeUniformPointSampler
pointSampler = makeUniformPointSampler(box)
# returns a sampler from a gaussian distribution with mean and std deviation # returns a sampler from a gaussian distribution with mean and std deviation
def gaussianSampler(mean, stdDev): def gaussianSampler(mean, stdDev):
...@@ -14,21 +13,28 @@ def gaussianSampler(mean, stdDev): ...@@ -14,21 +13,28 @@ def gaussianSampler(mean, stdDev):
return random.gauss(mean, stdDev) return random.gauss(mean, stdDev)
return sample 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)
return sample
# we sample quadrialeterals within the box with gaussian distributions for the parameters # we sample quadrialeterals within the box with gaussian distributions for the parameters
from frackit.common import toRadians from frackit.common import toRadians
from frackit.sampling import QuadrilateralSampler as QuadSampler from frackit.sampling import QuadrilateralSampler as QuadSampler
quadSampler1 = QuadSampler(pointSampler, quadSampler1 = QuadSampler(makeUniformPointSampler(box),
gaussianSampler(toRadians(45.0), toRadians(5.0)), # strike angle gaussianSampler(toRadians(45.0), toRadians(5.0)), # strike angle
gaussianSampler(toRadians(90.0), toRadians(5.0)), # dip angle gaussianSampler(toRadians(90.0), toRadians(5.0)), # dip angle
gaussianSampler(0.5, 0.1), # edge length uniformSampler(0.4, 0.8), # strike length
0.05) # threshold for minimum edge length uniformSampler(0.4, 0.8)) # dip length
# sampler for quadrilaterals of the secondary orientation # sampler for quadrilaterals of the secondary orientation
quadSampler2 = QuadSampler(pointSampler, quadSampler2 = QuadSampler(makeUniformPointSampler(box),
gaussianSampler(toRadians(0.0), toRadians(5.0)), # strike angle gaussianSampler(toRadians(0.0), toRadians(5.0)), # strike angle
gaussianSampler(toRadians(0.0), toRadians(5.0)), # dip angle gaussianSampler(toRadians(0.0), toRadians(5.0)), # dip angle
gaussianSampler(0.5, 0.1), # edge length uniformSampler(0.4, 0.8), # strike length
0.05) # threshold for minimum edge length uniformSampler(0.4, 0.8)) # dip length
# We want to enforce some constraints on the set of quadrilaterals. # We want to enforce some constraints on the set of quadrilaterals.
# In particular, for entities of the same set we want a minimum spacing # In particular, for entities of the same set we want a minimum spacing
......
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