Skip to content
GitLab
Menu
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
1bb24325
Commit
1bb24325
authored
Dec 18, 2020
by
Dennis Gläser
Browse files
[ex2] modify example code
parent
4200f8e7
Changes
2
Hide whitespace changes
Inline
Side-by-side
appl/example2/README.md
View file @
1bb24325
...
...
@@ -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 th
e
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
...
...
appl/example2/example2.py
View file @
1bb24325
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
(
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.6
),
# strike length
uniformSampler
(
0.4
,
0.6
))
# dip length
quadSampler1
=
QuadSampler
(
pointSampler
=
pointSampler
,
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.6
),
dipLengthSampler
=
uniformSampler
(
0.4
,
0.6
))
# sampler for quadrilaterals of the secondary orientation
quadSampler2
=
QuadSampler
(
pointSampler
,
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.6
),
# strike length
uniformSampler
(
0.4
,
0.6
))
# dip length
quadSampler2
=
QuadSampler
(
pointSampler
=
pointSampler
,
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.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
(
toR
adians
(
30.0
))
c
.
setMinIntersectingAngle
(
math
.
r
adians
(
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
(
toR
adians
(
40.0
))
;
constraintsOnOther
.
setMinIntersectingAngle
(
math
.
r
adians
(
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)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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