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

[entitybuilder] use id class

Moreover, this commit removes the bool in the function arguments to
addSubDomain() to indicate whether or not a sub-domain is to be taken as
confining or not. Now, there are two interfaces:

* addSubDomain(...) -> adds a non-confining sub-domain
* addConfiningSubDomain(...) -> adds a confining sub-domain
parent 2966c1f7
......@@ -213,13 +213,13 @@ int main(int argc, char** argv)
ContainedEntityNetworkBuilder containedConfinedBuilder;
// define sub-domains
containedConfinedBuilder.addSubDomain(solids[0], /*subDomainIndex*/1);
containedConfinedBuilder.addSubDomain(networkDomain, /*subDomainIndex*/2);
containedConfinedBuilder.addSubDomain(solids[2], /*subDomainIndex*/3);
containedConfinedBuilder.addConfiningSubDomain(solids[0], Id(1));
containedConfinedBuilder.addConfiningSubDomain(networkDomain, Id(2));
containedConfinedBuilder.addConfiningSubDomain(solids[2], Id(3));
// define entity network for sub-domain 2
containedConfinedBuilder.addSubDomainEntities(diskSet1, 2);
containedConfinedBuilder.addSubDomainEntities(diskSet2, 2);
containedConfinedBuilder.addSubDomainEntities(diskSet1, Id(2));
containedConfinedBuilder.addSubDomainEntities(diskSet2, Id(2));
// build network
const auto containedConfinedNetwork = containedConfinedBuilder.build();
......@@ -230,15 +230,13 @@ int main(int argc, char** argv)
ContainedEntityNetworkBuilder containedUnconfinedBuilder;
// define sub-domains
containedUnconfinedBuilder.addSubDomain(solids[0], /*subDomainIndex*/1);
containedUnconfinedBuilder.addSubDomain(solids[2], /*subDomainIndex*/3);
containedUnconfinedBuilder.addSubDomain(networkDomain,
/*subDomainIndex*/2,
/*confineEmbeddedNetwork*/false);
containedUnconfinedBuilder.addSubDomain(solids[0], Id(1));
containedUnconfinedBuilder.addSubDomain(solids[2], Id(3));
containedUnconfinedBuilder.addSubDomain(networkDomain, Id(2));
// define entity network for sub-domain 2
containedUnconfinedBuilder.addSubDomainEntities(diskSet1, 2);
containedUnconfinedBuilder.addSubDomainEntities(diskSet2, 2);
containedUnconfinedBuilder.addSubDomainEntities(diskSet1, Id(2));
containedUnconfinedBuilder.addSubDomainEntities(diskSet2, Id(2));
// build network
const auto containedUnconfinedNetwork = containedUnconfinedBuilder.build();
......@@ -251,13 +249,11 @@ int main(int argc, char** argv)
EntityNetworkBuilder uncontainedConfinedBuilder;
// define sub-domains
uncontainedConfinedBuilder.addSubDomain(networkDomain,
/*subDomainIndex*/1,
/*confineEmbeddedNetwork*/true);
uncontainedConfinedBuilder.addConfiningSubDomain(networkDomain, Id(1));
// define entity network for sub-domain 2
uncontainedConfinedBuilder.addSubDomainEntities(diskSet1, 1);
uncontainedConfinedBuilder.addSubDomainEntities(diskSet2, 1);
uncontainedConfinedBuilder.addSubDomainEntities(diskSet1, Id(1));
uncontainedConfinedBuilder.addSubDomainEntities(diskSet2, Id(1));
// build network
const auto uncontainedConfinedNetwork = uncontainedConfinedBuilder.build();
......
......@@ -18,7 +18,7 @@
*****************************************************************************/
/*!
* \file
* \brief TODO
* \brief Contains builder classes for entity networks.
*/
#ifndef FRACKIT_ENTITY_NETWORK_BUILDER_HH
#define FRACKIT_ENTITY_NETWORK_BUILDER_HH
......@@ -33,10 +33,12 @@
#include <TopTools_ListOfShape.hxx>
#include <TopoDS_Shape.hxx>
#include <frackit/occ/breputilities.hh>
#include <frackit/common/id.hh>
#include <frackit/common/extractdimension.hh>
#include <frackit/precision/defaultepsilon.hh>
#include <frackit/precision/precision.hh>
#include <frackit/occ/breputilities.hh>
#include "entitynetwork.hh"
#include "containedentitynetwork.hh"
......@@ -108,38 +110,53 @@ public:
/*!
* \brief Defines a sub-domain which potentially
* contains an embedded entity network.
* Networks defined for this sub-domain
* will not be confined by the sub-domain's
* boundary.
* \param domain The sub-domain geometry
* \param index The index to be used for this sub-domain
* \param boundsNetwork If set to true, the entity network
* defined for this sub-domain will be
* confined to it, cutting away entities
* or those parts of entities that lie outside.
* \param subDomainId The identifier (index) to be used for this sub-domain
*/
template<class Domain>
void addSubDomain(const Domain& domain, std::size_t index, bool boundsNetwork = true)
void addSubDomain(const Domain& domain, Id subDomainId)
{
const auto domainDim = getDimension(domain);
if (!networks_.empty() && domainDim <= entityDimension_)
throw std::runtime_error("Sub-domain dimension must be greater than entity dimension");
if (!subDomains_.empty() && domainDim != domainDimension_)
throw std::runtime_error("Sub-domain dimension does not match to previously added");
if (subDomains_.find(index) != subDomains_.end())
throw std::runtime_error("Sub-domain index already taken!");
if (subDomains_.find(subDomainId.get()) != subDomains_.end())
throw std::runtime_error("Sub-domain id already taken!");
domainDimension_ = domainDim;
subDomains_[index] = OCCUtilities::getShape(domain);
subDomainBoundsNetwork_[index] = boundsNetwork;
subDomains_[subDomainId.get()] = OCCUtilities::getShape(domain);
subDomainBoundsNetwork_[subDomainId.get()] = false;
}
/*!
* \brief Defines a sub-domain which potentially
* contains an embedded entity network.
* Using this interface, the sub-domain is
* defined as confining, that is, the
* network embedded in it will be confined
* by the sub-domain's boundary.
* \param domain The sub-domain geometry
* \param subDomainId The identifier (index) to be used for this sub-domain
*/
template<class Domain>
void addConfiningSubDomain(const Domain& domain, Id subDomainId)
{
addSubDomain(domain, subDomainId);
subDomainBoundsNetwork_[subDomainId.get()] = true;
}
/*!
* \brief Adds an entity to the network embedded in
* the sub-domain with index subDomainIndex.
* \param entity The entity geometry
* \param subDomainIndex The index of the sub-domain
* this entity is embedded in
* \param subDomainId The identifier (index) to be used for this sub-domain
*/
template<class Entity>
void addSubDomainEntity(const Entity& entity, std::size_t subDomainIndex)
void addSubDomainEntity(const Entity& entity, Id subDomainId)
{
const auto entityDim = getDimension(entity);
if (!networks_.empty() && getDimension(entity) != entityDimension_)
......@@ -148,21 +165,20 @@ public:
throw std::runtime_error("Entity dimension must be smaller than domain dimension");
entityDimension_ = entityDim;
networks_[subDomainIndex].Append(OCCUtilities::getShape(entity));
networks_[subDomainId.get()].Append(OCCUtilities::getShape(entity));
}
/*!
* \brief Adds a set of entities to the network
* embedded in sub-domain with index subDomainIndex.
* \param entities The set of entities
* \param subDomainIndex The index of the sub-domain in which
* the given entities are embedded.
* \param subDomainId The identifier (index) to be used for this sub-domain
*/
template<class EntityNetwork>
void addSubDomainEntities(const EntityNetwork& entities, std::size_t subDomainIndex)
void addSubDomainEntities(const EntityNetwork& entities, Id subDomainId)
{
for (const auto& entity : entities)
addSubDomainEntity(entity, subDomainIndex);
addSubDomainEntity(entity, subDomainId);
}
/*!
......
......@@ -13,10 +13,13 @@
#include <frackit/geometry/cylinder.hh>
#include <frackit/geometry/disk.hh>
#include <frackit/precision/precision.hh>
#include <frackit/magnitude/magnitude.hh>
#include <frackit/magnitude/containedmagnitude.hh>
#include <frackit/common/id.hh>
#include <frackit/occ/breputilities.hh>
#include <frackit/precision/precision.hh>
#include <frackit/sampling/pointsampling.hh>
#include <frackit/sampling/geometrysampling.hh>
......@@ -28,9 +31,10 @@
//! create 3 disk-shaped fractures and write geo (gmsh file format) file
int main(int argc, char** argv)
{
using namespace Frackit;
using ctype = double;
using Domain = Frackit::Cylinder<ctype>;
using Disk = Frackit::Disk<ctype>;
using Domain = Cylinder<ctype>;
using Disk = Disk<ctype>;
using Point = typename Disk::Point;
using Direction = typename Disk::Direction;
using Vector = typename Direction::Vector;
......@@ -43,18 +47,18 @@ int main(int argc, char** argv)
Domain domain(0.5, 1.0);
Domain domain2(Disk(Point(0.0, 0.0, 1.0), e1, e2, 1.0, 1.0), 1.0);
Frackit::ContainedEntityNetworkBuilder builder;
builder.addSubDomain(domain, 1);
builder.addSubDomainEntity(Disk(Point(0.0, 0.0, 0.1), e1, e2, 1.0, 1.0), 1);
builder.addSubDomainEntity(Disk(Point(0.0, 0.0, 0.5), e1, e3, 2.0, 2.0), 1);
builder.addSubDomainEntity(Disk(Point(0.0, 0.0, 0.75), e1, e2, 1.0, 1.0), 1);
ContainedEntityNetworkBuilder builder;
builder.addSubDomain(domain, Id(1));
builder.addSubDomainEntity(Disk(Point(0.0, 0.0, 0.1), e1, e2, 1.0, 1.0), Id(1));
builder.addSubDomainEntity(Disk(Point(0.0, 0.0, 0.5), e1, e3, 2.0, 2.0), Id(1));
builder.addSubDomainEntity(Disk(Point(0.0, 0.0, 0.75), e1, e2, 1.0, 1.0), Id(1));
builder.addSubDomain(domain2, 2);
builder.addSubDomainEntity(Disk(Point(0.0, 0.0, 1.1), e1, e2, 1.0, 1.0),2);
builder.addSubDomainEntity(Disk(Point(0.0, 0.0, 1.5), e1, e3, 2.0, 2.0),2);
builder.addSubDomainEntity(Disk(Point(0.0, 0.0, 1.75), e1, e2, 1.0, 1.0),2);
builder.addSubDomain(domain2, Id(2));
builder.addSubDomainEntity(Disk(Point(0.0, 0.0, 1.1), e1, e2, 1.0, 1.0), Id(2));
builder.addSubDomainEntity(Disk(Point(0.0, 0.0, 1.5), e1, e3, 2.0, 2.0), Id(2));
builder.addSubDomainEntity(Disk(Point(0.0, 0.0, 1.75), e1, e2, 1.0, 1.0), Id(2));
Frackit::GmshWriter writer(builder.build());
GmshWriter writer(builder.build());
writer.write("final", 1.0, 1.0);
std::cout << "All tests passed" << std::endl;
......
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