Commit 08f06386 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[ex3] use new quad sampler

parent d8abb6c5
...@@ -53,23 +53,27 @@ const auto domainBBox = OCCUtilities::getBoundingBox(networkDomain); ...@@ -53,23 +53,27 @@ const auto domainBBox = OCCUtilities::getBoundingBox(networkDomain);
With this, we create a quadrilateral sampler in a similar way as in the previous examples With this, we create a quadrilateral sampler in a similar way as in the previous examples
```cpp ```cpp
QuadrilateralSampler<3> quadSampler(makeUniformPointSampler(domainBBox), // sampler for quadrilateral center points // we use the default sampler types, thus, default distributions (see traits classes)
Distro(toRadians(45.0), toRadians(5.0)), // strike angle: mean value & standard deviation using NormalDistro = std::normal_distribution<ctype>;
Distro(toRadians(90.0), toRadians(5.0)), // dip angle: mean value & standard deviation using UniformDistro = std::uniform_real_distribution<ctype>;
Distro(45.0, 5.0), // edge length: mean value & standard deviation
5.0); // threshold for minimum edge length QuadrilateralSampler<3> quadSampler(makeUniformPointSampler(domainBBox), // sampler for quadrilateral center points
NormalDistro(toRadians(45.0), toRadians(5.0)), // strike angle: mean value & standard deviation
NormalDistro(toRadians(90.0), toRadians(5.0)), // dip angle: mean value & standard deviation
UniformDistro(30.0, 60.0), // strike length
UniformDistro(30.0, 60.0)); // dip length
``` ```
For the entities of the other orientation, we want to use `Disk` objects in this case. For the entities of the other orientation, we want to use `Disk` objects in this case.
The instantiation of the corrensponding sampler class looks like this: The instantiation of the corrensponding sampler class looks like this:
```cpp ```cpp
DiskSampler diskSampler(makeUniformPointSampler(domainBBox), // sampler for disk center points DiskSampler diskSampler(makeUniformPointSampler(domainBBox), // sampler for disk center points
Distro(30.0, 6.5), // major axis length: mean value & standard deviation NormalDistro(30.0, 6.5), // major axis length: mean value & standard deviation
Distro(24.0, 4.5), // minor axis length: mean value & standard deviation NormalDistro(24.0, 4.5), // minor axis length: mean value & standard deviation
Distro(toRadians(0.0), toRadians(7.5)), // rotation around x-axis: mean value & standard deviation NormalDistro(toRadians(0.0), toRadians(7.5)), // rotation around x-axis: mean value & standard deviation
Distro(toRadians(0.0), toRadians(7.5)), // rotation around y-axis: mean value & standard deviation NormalDistro(toRadians(0.0), toRadians(7.5)), // rotation around y-axis: mean value & standard deviation
Distro(toRadians(0.0), toRadians(7.5))); // rotation around z-axis: mean value & standard deviation NormalDistro(toRadians(0.0), toRadians(7.5))); // rotation around z-axis: mean value & standard deviation
``` ```
......
...@@ -71,26 +71,27 @@ int main(int argc, char** argv) ...@@ -71,26 +71,27 @@ int main(int argc, char** argv)
// and disk/quadrilaterals as entities (using the sampled center points) // // and disk/quadrilaterals as entities (using the sampled center points) //
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// we use the default sampler types -> normal distributions for all parameters // we use the default sampler types, thus, default distributions (see traits classes)
using Distro = std::normal_distribution<ctype>; using NormalDistro = std::normal_distribution<ctype>;
using UniformDistro = std::uniform_real_distribution<ctype>;
// Bounding box of the domain in which we want to place the entities // Bounding box of the domain in which we want to place the entities
const auto domainBBox = OCCUtilities::getBoundingBox(networkDomain); const auto domainBBox = OCCUtilities::getBoundingBox(networkDomain);
// sampler for disks (orientation 1) // sampler for disks (orientation 1)
DiskSampler diskSampler(makeUniformPointSampler(domainBBox), // sampler for disk center points DiskSampler diskSampler(makeUniformPointSampler(domainBBox), // sampler for disk center points
Distro(30.0, 6.5), // major axis length: mean value & standard deviation NormalDistro(30.0, 6.5), // major axis length: mean value & standard deviation
Distro(24.0, 4.5), // minor axis length: mean value & standard deviation NormalDistro(24.0, 4.5), // minor axis length: mean value & standard deviation
Distro(toRadians(0.0), toRadians(7.5)), // rotation around x-axis: mean value & standard deviation NormalDistro(toRadians(0.0), toRadians(7.5)), // rotation around x-axis: mean value & standard deviation
Distro(toRadians(0.0), toRadians(7.5)), // rotation around y-axis: mean value & standard deviation NormalDistro(toRadians(0.0), toRadians(7.5)), // rotation around y-axis: mean value & standard deviation
Distro(toRadians(0.0), toRadians(7.5))); // rotation around z-axis: mean value & standard deviation NormalDistro(toRadians(0.0), toRadians(7.5))); // rotation around z-axis: mean value & standard deviation
// sampler for quadrilaterals (orientation 2) // sampler for quadrilaterals (orientation 2)
QuadrilateralSampler<3> quadSampler(makeUniformPointSampler(domainBBox), // sampler for quadrilateral center points QuadrilateralSampler<3> quadSampler(makeUniformPointSampler(domainBBox), // sampler for quadrilateral center points
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(45.0, 5.0), // edge length: mean value & standard deviation UniformDistro(30.0, 60.0), // strike length
5.0); // threshold for minimum edge length UniformDistro(30.0, 60.0)); // dip length
// Define ids for the two entity sets // Define ids for the two entity sets
const Id diskSetId(1); // we give the set of orientation one, consisting of disks, the id 1 const Id diskSetId(1); // we give the set of orientation one, consisting of disks, the id 1
......
...@@ -64,8 +64,8 @@ diskSampler = DiskSampler(makeUniformPointSampler(domainBBox), # sampl ...@@ -64,8 +64,8 @@ diskSampler = DiskSampler(makeUniformPointSampler(domainBBox), # sampl
quadSampler = QuadrilateralSampler(makeUniformPointSampler(domainBBox), # sampler for quadrilateral center points quadSampler = QuadrilateralSampler(makeUniformPointSampler(domainBBox), # sampler for quadrilateral center points
normalSampler(toRadians(45.0), toRadians(5.0)), # strike angle: mean value & standard deviation normalSampler(toRadians(45.0), toRadians(5.0)), # strike angle: mean value & standard deviation
normalSampler(toRadians(90.0), toRadians(5.0)), # dip angle: mean value & standard deviation normalSampler(toRadians(90.0), toRadians(5.0)), # dip angle: mean value & standard deviation
normalSampler(45.0, 5.0), # edge length: mean value & standard deviation uniformSampler(30.0, 60.0), # strike length
5.0) # threshold for minimum edge length uniformSampler(30.0, 60.0)) # dip length
# Define ids for the two entity sets # Define ids for the two entity sets
diskSetId = Id(1) # we give the set of orientation one, consisting of disks, the id 1 diskSetId = Id(1) # we give the set of orientation one, consisting of disks, the id 1
...@@ -103,15 +103,15 @@ constraintsOnOther.setMinIntersectingAngle(toRadians(40.0)) ...@@ -103,15 +103,15 @@ constraintsOnOther.setMinIntersectingAngle(toRadians(40.0))
# We can use the constraints matrix to facilitate constraint evaluation # We can use the constraints matrix to facilitate constraint evaluation
constraintsMatrix = EntityNetworkConstraintsMatrix() constraintsMatrix = EntityNetworkConstraintsMatrix()
constraintsMatrix.addConstraints(constraints1, # constraint instance constraintsMatrix.addConstraints(constraints1, # constraint instance
[diskSetId.get(), diskSetId.get()]) # sets between which to use these constraints [diskSetId, diskSetId]) # sets between which to use these constraints
constraintsMatrix.addConstraints(constraints2, # constraint instance constraintsMatrix.addConstraints(constraints2, # constraint instance
[quadSetId.get(), quadSetId.get()]) # sets between which to use these constraints [quadSetId, quadSetId]) # sets between which to use these constraints
constraintsMatrix.addConstraints(constraintsOnOther, # constraint instance constraintsMatrix.addConstraints(constraintsOnOther, # constraint instance
[[diskSetId.get(), quadSetId.get()], # sets between which to use these constraints [[diskSetId, quadSetId], # sets between which to use these constraints
[quadSetId.get(), diskSetId.get()]]) # sets between which to use these constraints [quadSetId, diskSetId]]) # sets between which to use these constraints
# Moreover, we define constraints w.r.t. the domain boundary # Moreover, we define constraints w.r.t. the domain boundary
constraintsOnDomain = makeDefaultConstraints() constraintsOnDomain = makeDefaultConstraints()
...@@ -130,7 +130,7 @@ status.setTargetCount(diskSetId, 12) # we want 11 entities of orientation 1 ...@@ -130,7 +130,7 @@ status.setTargetCount(diskSetId, 12) # we want 11 entities of orientation 1
status.setTargetCount(quadSetId, 16) # we want 13 entities of orientation 2 status.setTargetCount(quadSetId, 16) # we want 13 entities of orientation 2
# store all entity sets in a dictionary # store all entity sets in a dictionary
entitySets = {diskSetId.get(): [], quadSetId.get(): []} entitySets = {diskSetId: [], quadSetId: []}
# Alternate between set 1 & set 2 during sampling phase # Alternate between set 1 & set 2 during sampling phase
sampleIntoSet1 = True sampleIntoSet1 = True
...@@ -163,7 +163,7 @@ while not status.finished(): ...@@ -163,7 +163,7 @@ while not status.finished():
continue continue
# the geometry is admissible # the geometry is admissible
entitySets[id.get()].append(geom) entitySets[id].append(geom)
status.increaseCounter(id) status.increaseCounter(id)
status.print() status.print()
...@@ -184,7 +184,7 @@ print("\nEntity density of the contained network: {:f} m²/m³\n".format(density ...@@ -184,7 +184,7 @@ print("\nEntity density of the contained network: {:f} m²/m³\n".format(density
########################################################################## ##########################################################################
# construct and write a contained network, i.e. write out both network and domain. # construct and write a contained network, i.e. write out both network and domain.
print("Building and writing contained, confined network\n") print("Building and writing contained, confined network")
from frackit.entitynetwork import EntityNetworkBuilder, ContainedEntityNetworkBuilder from frackit.entitynetwork import EntityNetworkBuilder, ContainedEntityNetworkBuilder
builder = ContainedEntityNetworkBuilder(); builder = ContainedEntityNetworkBuilder();
...@@ -205,7 +205,7 @@ gmshWriter.write("contained_confined", # body of the filename to be used (will a ...@@ -205,7 +205,7 @@ gmshWriter.write("contained_confined", # body of the filename to be used (will a
# we can also not confine the network to its sub-domain, # we can also not confine the network to its sub-domain,
# simply by adding the sub-domains as non-confining # simply by adding the sub-domains as non-confining
print("Building and writing contained, unconfined network\n") print("Building and writing contained, unconfined network")
builder.clear(); builder.clear();
builder.addSubDomain(solids[0], Id(1)); builder.addSubDomain(solids[0], Id(1));
builder.addSubDomain(networkDomain, Id(2)); builder.addSubDomain(networkDomain, Id(2));
...@@ -226,7 +226,7 @@ gmshWriter = GmshWriter(uncontainedBuilder.build()); ...@@ -226,7 +226,7 @@ gmshWriter = GmshWriter(uncontainedBuilder.build());
gmshWriter.write("uncontained_confined", 2.5); gmshWriter.write("uncontained_confined", 2.5);
# ... or not confining it # ... or not confining it
print("Building and writing uncontained, unconfined network\n") print("Building and writing uncontained, unconfined network")
uncontainedBuilder.clear(); uncontainedBuilder.clear();
for setId in entitySets: uncontainedBuilder.addSubDomainEntities(entitySets[setId], Id(2)) for setId in entitySets: uncontainedBuilder.addSubDomainEntities(entitySets[setId], Id(2))
......
Supports Markdown
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