Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tools
frackit
Commits
4200f8e7
Commit
4200f8e7
authored
Dec 18, 2020
by
Dennis Gläser
Browse files
[ex] edit example code
parent
2cc46a9c
Changes
2
Hide whitespace changes
Inline
Side-by-side
appl/example1/example1.cc
View file @
4200f8e7
...
...
@@ -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
>
;
...
...
appl/example1/example1.py
View file @
4200f8e7
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
(
toR
adians
(
45.0
),
toR
adians
(
5.0
)),
# strike angle
gaussianSampler
(
toR
adians
(
90.0
),
toR
adians
(
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
.
r
adians
(
45.0
),
math
.
r
adians
(
5.0
)),
dipAngleSampler
=
gaussianSampler
(
math
.
r
adians
(
90.0
),
math
.
r
adians
(
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
(
toR
adians
(
0.0
),
toR
adians
(
5.0
)),
# strike angle
gaussianSampler
(
toR
adians
(
0.0
),
toR
adians
(
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
.
r
adians
(
0.0
),
math
.
r
adians
(
5.0
)),
dipAngleSampler
=
gaussianSampler
(
math
.
r
adians
(
0.0
),
math
.
r
adians
(
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
(
toR
adians
(
30.0
))
constraintsOnSelf
.
setMinIntersectingAngle
(
math
.
r
adians
(
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
(
toR
adians
(
40.0
))
;
constraintsOnOther
.
setMinIntersectingAngle
(
math
.
r
adians
(
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)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment