Dear Dennis, Apologies for posting my question here. Now I am able to generate 1D random fractures using the feature/2d-entity-networks branch. Thank you so much for the detailed explanation and example code snippet.
Regards, Anup On Mon, 13 Sept 2021 at 21:43, Dennis Gläser < dennis.glae...@iws.uni-stuttgart.de> wrote: > Hi Anup, > > First of all, I am happy to hear that you are interested in using Frackit! > One thing though, this mailing list is for questions related to DuMuX, so I > guess this is not the right place to ask questions related to Frackit. We > have no mailing list for that, yet, but you can email me directly in the > future until we have one (which depends on the question if a user base > develops). > > Regarding your question: the code currently focuses on 3d, which is the > much more difficult case to handle. Therefore, random entity geometry > generators are currently only implemented for 3d geometries, and some of > the constraints evaluations as well. However, adding support for 1d > geometries in the constraints and in the network builder (which you use in > your snippet) seemed to be pretty straightforward. I added this to a branch > and opened a draft merge request: > > > https://git.iws.uni-stuttgart.de/tools/frackit/-/tree/feature/2d-entity-networks > > https://git.iws.uni-stuttgart.de/tools/frackit/-/merge_requests/210 > > > There was another issue with your example, though: You were using lines as > fracture geometries. This represents an infinite line, while fracture > geometries must be finite. Thus, you should use segments as fracture > geometries. Using the above-mentioned branch, the snippet that I added to > the end of this mail works for me. The snippet also contains some checks of > the constraints at the end. Before merging this, it would be good to more > thoroughly test it. Would you mind using this branch to see if your > application works? I assume you have cloned the repository and built the > python bindings locally, so you would just have to go to the frackit folder > and do > > git fetch > git checkout feature/2d-entity-networks > cd build > make && make install_python > > to update your local bindings installation. If you have an account at > https://git.iws.uni-stuttgart.de/ you can then comment or implement > things into the above-mentioned merge request if you want. > > To summarize, this gives you the possibility to evaluate constraints on > fracture entities and then create (possibly embedded) networks of entities, > where all intersections are computed. Then, you can write the result to > Gmsh format to produce meshes that are usable in Dumux. What is still > missing is the random generation of fracture entity candidates. But In 2d > and in Python, you can do this quite easily yourself in a few lines of code > I suppose. Moreover, note that the snippet uses a three-dimensional ambient > space, while using z-coordinates of 0 everywhere. In the future it would be > nice to do all computations in 2d, but for this I need to invest some more > work. As said, the focus so far was 3d. > > > *Code snippet:* > > from frackit.common import Id > from frackit.geometry import Point_3, Quadrilateral_3, Segment_3 > from frackit.entitynetwork import EntityNetworkBuilder > from frackit.entitynetwork import ContainedEntityNetworkBuilder > from frackit.io import GmshWriter > > quad = Quadrilateral_3( > Point_3(0, 0, 0), > Point_3(1, 0, 0), > Point_3(0, 1, 0), > Point_3(1, 1, 0) > ) > > # define two fracture segments > fracture1 = Segment_3(Point_3(0.1, 0.1, 0.0), > Point_3(0.8, 0.1, 0.0)) > fracture2 = Segment_3(Point_3(0.1, 0.8, 0.0), > Point_3(0.8, 0.1, 0.0)) > > # Non-contained entity network > builder = EntityNetworkBuilder() > builder.addEntities([fracture1, fracture2]) > network = builder.build() > > writer = GmshWriter(network) > writer.setMeshSize(GmshWriter.GeometryTag.entity, 0.1) > writer.write("network_uncontained") > > # Contained entity network > builder = ContainedEntityNetworkBuilder() > builder.addSubDomain(quad, Id(1)) > builder.addSubDomainEntities([fracture1, fracture2], Id(1)) > network = builder.build() > > writer = GmshWriter(network) > writer.setMeshSize(GmshWriter.GeometryTag.subDomain, 0.1) > writer.setMeshSize(GmshWriter.GeometryTag.entity, 0.1) > writer.write("network_contained") > > ### Code for testing purposes of the constraints bindings, remove > afterwards > import math > from frackit.entitynetwork import EntityNetworkConstraints > constraints = EntityNetworkConstraints() > constraints.setMinDistance(0.05) > constraints.setMinIntersectingAngle(math.radians(40.0)) > constraints.setMinIntersectionDistance(0.05) > > # violating the minimum distance to fracture 1 > assert not constraints.evaluate( > Segment_3(Point_3(0.1, 0.14, 0.0), Point_3(1.0, 1.0, 0.0)), > fracture1 > ) > > # not violating the minimum distance to fracture 1 > assert constraints.evaluate( > Segment_3(Point_3(0.1, 0.16, 0.0), Point_3(1.0, 1.0, 0.0)), > fracture1 > ) > > # violating the minimum intersection distance to fracture 1 > assert not constraints.evaluate( > Segment_3(Point_3(0.5, 0.06, 0.0), Point_3(0.5, 1.0, 0.0)), > fracture1 > ) > > # not violating the minimum intersection distance to fracture 1 > assert constraints.evaluate( > Segment_3(Point_3(0.5, 0.04, 0.0), Point_3(0.5, 1.0, 0.0)), > fracture1 > ) > > # violating the minimum intersection angle with fracture 1 > assert not constraints.evaluate( > Segment_3(Point_3(0.0, 0.05, 0.0), Point_3(1.0, 0.5, 0.0)), > fracture1 > ) > > On 11.09.21 03:31, Anup Kumar wrote: > > Hi > My question is regarding frackit package: > https://git.iws.uni-stuttgart.de/tools/frackit > > I want to create 1D random embedded fracture in 2D domain. > > *Test code-python:* > > from frackit.geometry import Point_3, Quadrilateral_3, Direction_3, > Line_3, Vector_3 > > # we use the unit quad as domain > # 2--3 > # | | > # 0--1 > > p0 = Point_3(0,0,0) > p1 = Point_3(1,0,0) > p2 = Point_3(0,1,0) > p3 = Point_3(1,1,0) > quad = Quadrilateral_3(p0,p1,p2,p3) > > # get a line Line(point, direction) > line1 = Line_3(Point_3(0.1,0.1,0), Direction_3(Vector_3(0.5,0.5,0))) > > # We can now create an entity network > from frackit.entitynetwork import EntityNetworkBuilder > builder = EntityNetworkBuilder() > builder.addEntities([line1]) # single fracture only > > ## 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() > > print("\n --- Writing .geo file ---\n") > from frackit.io import GmshWriter > writer = GmshWriter(network) > writer.setMeshSize(GmshWriter.GeometryTag.entity, 0.1) > writer.write("network") # filename of the .geo files (will add extension > .geo automatically) > > print("\n --- Finished writing .geo file ---\n") > > > Output error message: > > frackit@54b158438b4a:~/frackit/appl/example1$ python3 example_1Din2D.py > Traceback (most recent call last): > File "example_1Din2D.py", line 22, in <module> > builder.addEntities([line1]) > File > "/frackit/.local/lib/python3.6/site-packages/frackit/entitynetwork/__init__.py", > line 116, in addEntities > id = super().addEntity(entity) > TypeError: addEntity(): incompatible function arguments. The following > argument types are supported: > 1. (self: > frackit.entitynetwork._entitynetwork._EntityNetworkBuilderWrapper, arg0: > frackit.geometry._geometry.Disk) -> Frackit::Id > 2. (self: > frackit.entitynetwork._entitynetwork._EntityNetworkBuilderWrapper, arg0: > frackit.geometry._geometry.Quadrilateral_3) -> Frackit::Id > 3. (self: > frackit.entitynetwork._entitynetwork._EntityNetworkBuilderWrapper, arg0: > frackit.geometry._geometry.Polygon_3) -> Frackit::Id > 4. (self: > frackit.entitynetwork._entitynetwork._EntityNetworkBuilderWrapper, arg0: > frackit.geometry._geometry.OCCFaceWrapper) -> Frackit::Id > > Invoked with: <frackit.entitynetwork.EntityNetworkBuilder object at > 0x7f6ade4f2a40>, Frackit::Line<3> > > > > How can I use Line shape in the network builder? > > Thank you, > > Regards > Anup Shahi > Ph.D. Student > > > > > _______________________________________________ > DuMux mailing > listdu...@listserv.uni-stuttgart.dehttps://listserv.uni-stuttgart.de/mailman/listinfo/dumux > >
_______________________________________________ DuMux mailing list DuMux@listserv.uni-stuttgart.de https://listserv.uni-stuttgart.de/mailman/listinfo/dumux