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

[test][io] add test for gmsh writer

parent 3ca26579
......@@ -2,5 +2,6 @@ add_subdirectory(distance)
add_subdirectory(entitynetwork)
add_subdirectory(geometry)
add_subdirectory(intersection)
add_subdirectory(io)
add_subdirectory(magnitude)
add_subdirectory(sampling)
# test write of networks to gmsh output format
frackit_add_test(NAME test_write_gmsh
SOURCES test_write_gmsh.cc
LABELS io gmsh)
set(CMAKE_BUILD_TYPE Debug)
DBRep_DrawableShape
CASCADE Topology V1, (c) Matra-Datavision
Locations 6
1
1 0 0 0
0 1 0 100
0 0 1 0
1
1 0 0 0
0 1 0 0
0 0 1 25
2 1 1 2 1 0
2 1 -1 0
2 2 -1 0
2 2 -1 1 -1 0
Curve2ds 12
1 0 0 1 0
1 0 -100 1 0
1 0 0 1 0
1 0 -25 1 0
1 0 0 1 0
1 0 -25 1 0
1 0 0 0 -1
1 1 0 0 -1
1 0 0 0 -1
1 0 0 0 -1
1 1 0 0 -1
1 1 0 0 -1
Curves 7
6 0 3 0 0 0 50 0 25 100 0 0 150 0 0
1 0 0 0 0 1 0
1 150 0 0 0 1 0
1 0 0 0 0 0 1
1 0 100 0 0 0 1
1 150 0 0 0 0 1
1 150 100 0 0 0 1
Polygon3D 0
PolygonOnTriangulations 0
Surfaces 5
6 -0 -1 -0
6 0 3 0 0 0 50 0 25 100 0 0 150 0 0
6 -0 -0 -1
6 0 3 0 0 0 50 0 25 100 0 0 150 0 0
6 -0 -0 -1
6 0 3 0 100 0 50 100 25 100 100 0 150 100 0
1 0 0 0 -1 0 0 0 1 0 0 0 -1
1 150 0 0 -1 0 0 0 1 0 0 0 -1
Triangulations 0
TShapes 24
Ve
1e-07
0 0 0
0 0
0101101
*
Ve
1e-07
50 0 25
0 0
0101101
*
Ve
1e-07
100 0 0
0 0
0101101
*
Ve
1e-07
150 0 0
0 0
0101101
*
Ed
1e-07 1 1 0
1 1 0 0 1
2 1 1 0 0 1
2 2 1 4 0 1
2 3 2 0 0 1
2 4 2 5 0 1
2 5 3 4 0 1
2 6 3 6 0 1
0
0101000
+24 0 -21 0 *
Ed
1e-07 1 1 0
1 2 0 0 100
2 7 1 0 0 100
0
0101000
+24 0 -24 1 *
Ed
1e-07 1 1 0
1 3 0 0 100
2 8 1 0 0 100
0
0101000
+21 0 -21 1 *
Ed
1e-07 1 1 0
1 4 0 0 25
2 9 2 0 0 25
0
0101000
+24 0 -24 2 *
Ed
1e-07 1 1 0
1 5 0 0 25
2 10 3 0 0 25
0
0101000
+24 1 -24 3 *
Ed
1e-07 1 1 0
1 6 0 0 25
2 11 2 0 0 25
0
0101000
+21 0 -21 2 *
Ed
1e-07 1 1 0
1 7 0 0 25
2 12 3 0 0 25
0
0101000
+21 1 -21 3 *
Wi
0101100
+19 0 -18 0 -20 0 +20 1 *
Wi
0101100
+17 0 -16 0 -19 0 +19 2 *
Wi
0101100
+15 0 -14 0 -18 0 +18 2 *
Wi
0101100
+17 0 -15 0 -20 0 +20 2 *
Wi
0101100
+16 0 -14 0 -20 1 +20 3 *
Fa
0 1e-07 1 0
0101000
+13 0 *
Fa
0 1e-07 4 0
0101000
+12 0 *
Fa
0 1e-07 5 0
0101000
+11 0 *
Fa
0 1e-07 2 0
0101000
+10 0 *
Fa
0 1e-07 3 0
0101000
+9 0 *
Sh
0101100
+7 0 -6 0 -5 0 +4 0 +8 0 -8 2 *
So
0100000
+3 0 *
Co
1100000
+24 0 +23 0 +22 0 +21 0 -24 1 +21 1 -24 2 +24 3 +21 2 -21 3
+20 0 +19 0 -18 0 +20 1 +17 0 -16 0 +19 2 -15 0 +14 0 -18 2
-20 2 +20 3 +13 0 +12 0 -11 0 -10 0 +9 0 -13 2 +8 0 +7 0
-6 0 -5 0 +4 0 -8 2 +3 0 +2 0 *
+1 0
\ No newline at end of file
SetFactory("OpenCASCADE");
// Bottom Volume
Point(1) = {0, 0, 0, 1.0};
Point(2) = {50, 0, 25, 1.0};
Point(3) = {100, 0, 0, 1.0};
Point(4) = {150, 0, 0, 1.0};
Bezier(1) = {1, 2, 3, 4};
Extrude {0, 100, 0} { Curve{1}; }
Extrude {0, 0, 25} { Surface{1}; }
// Center Volume
Point(11) = {0, 0, 55, 1.0};
Point(12) = {50, 0, 55, 1.0};
Point(13) = {120, 0, 40, 1.0};
Point(14) = {150, 0, 55, 1.0};
Bezier(13) = {11, 12, 13, 14};
Extrude {0, 100, 0} { Curve{13}; }
Line(17) = {11, 7};
Line(18) = {14, 9};
Line(19) = {16, 10};
Line(20) = {15, 8};
Curve Loop(8) = {7, -20, -14, 17};
Plane Surface(8) = {8};
Curve Loop(9) = {17, 11, -18, -13};
Plane Surface(9) = {9};
Curve Loop(10) = {10, -19, -15, 18};
Plane Surface(10) = {10};
Curve Loop(12) = {19, -12, -20, 16};
Plane Surface(11) = {12};
Surface Loop(2) = {8, 11, 10, 7, 9, 6};
Volume(2) = {2};
// Top Volume
Point(18) = {0, 0, 75, 1.0};
Point(19) = {50, 0, 75, 1.0};
Point(20) = {120, 0, 60, 1.0};
Point(21) = {150, 0, 65, 1.0};
Bezier(21) = {18, 19, 20, 21};
Extrude {0, 100, 0} { Curve{21}; }
Line(25) = {18, 11};
Line(26) = {21, 14};
Line(27) = {23, 16};
Line(28) = {22, 15};
Curve Loop(16) = {28, -14, -25, 22};
Plane Surface(15) = {16};
Curve Loop(17) = {25, 13, -26, -21};
Plane Surface(16) = {17};
Curve Loop(18) = {26, 15, -27, -23};
Plane Surface(17) = {18};
Curve Loop(19) = {27, -16, -28, 24};
Plane Surface(18) = {19};
Surface Loop(3) = {14, 15, 18, 17, 16, 7};
Volume(3) = {3};
#include <iostream>
#include <random>
#include <fstream>
#include <unordered_map>
#include <BRepTools.hxx>
#include <BRep_Builder.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_DataMapOfShapeInteger.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Solid.hxx>
#include <TopoDS.hxx>
#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/occ/breputilities.hh>
#include <frackit/sampling/pointsampling.hh>
#include <frackit/sampling/geometrysampling.hh>
#include <frackit/entitynetwork/containedentitynetwork.hh>
#include <frackit/entitynetwork/networkbuilder.hh>
#include <frackit/io/gmshwriter.hh>
//! create 3 disk-shaped fractures and write geo (gmsh file format) file
int main(int argc, char** argv)
{
using ctype = double;
using Domain = Frackit::Cylinder<ctype>;
using Disk = Frackit::Disk<ctype>;
using Point = typename Disk::Point;
using Direction = typename Disk::Direction;
using Vector = typename Direction::Vector;
const Direction e1(Vector(1.0, 0.0, 0.0));
const Direction e2(Vector(0.0, 1.0, 0.0));
const Direction e3(Vector(0.0, 0.0, 1.0));
// Domain in which the disks are embedded
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);
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);
Frackit::GmshWriter writer(builder.build());
writer.write("final", 1.0, 1.0);
std::cout << "All tests passed" << std::endl;
return 0;
}
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