Giter VIP home page Giter VIP logo

pargeo's Introduction

ParGeo

Overview | Installation | Basic Usage | Getting Started | Documentation | Cite

Generate complex two-dimensional geometries for simulations based on mesh discretizations.

ParGeo Logo

Overview

With ParGeo you can create complex domains, where a domain is a two-dimensional geometry which is described by a collection of shapely Polygons and MultiPolygons called subdomains.

This domain could then be used for mesh generation, to further perform 2D mesh based simulations, like the Finite Element Methods (FEM). We provide mesh generating functionalities based on Gmsh.

To generate the desired domain you will use the pargeo.domain.Domain class and sequentially add subdomains. Each subdomain is associated with a visibility level. The visibility level is an integer, and subdomains with a higher visibility level will cover those with a lower one and be merged with those having the same one.

Following features support you with the domain-generating process:

  • Create Geometries (pargeo.geometry):

    Create common geometries that can easly be transformed into shapely Polygons.

    Following geometries are provided:

    • Box
    • Circle & Ellipse
    • Stellar
    • NStar
    • Raindrop
  • Transform Geometries (pargeo.transform)

    Pass transforms to your domain while adding new sub-domains. The sub-domain will then be first accordingly transformed before being added to the domain.

    Following transforms are provided:

    • Repeat
    • Periodic
    • Diffeomorphism
  • Impose Constraints (pargeo.constraint)

    Pass constraints to the domain while adding new sub-domains. The new sub-domain is only added, if the constraints are met.

    Following constraints are provided:

    • DistanceConstraint

Check out the documentation for more information.

Installation

Install the latest version of ParGeo from PyPI using pip:

pip install pargeo

Basic Usage

Here's a simple example of how to use ParGeo.

from pargeo import write_mesh
from pargeo.domain import Domain
from pargeo.geometry import Box, Circle, Stellar

# Create a domain
background = Box((0, 0), (1, 1)).to_polygon()
domain = Domain(background)

# Add some subdomains
subdomain = Circle((0.3, 0.5), 0.3).to_polygon(refs=50)
domain.add_subdomain(subdomain=subdomain, level=1)

subdomain = Circle((0.7, 0.5), 0.3).to_polygon(refs=50)
domain.add_subdomain(subdomain=subdomain, level=1)

subdomain = Stellar((0.5, 0.3), 0.2).to_polygon(refs=50)
domain.add_subdomain(subdomain=subdomain, level=2)

# Plot the domain
domain.plot()

# Mesh the domain using Gmsh and write the .MSH file
write_mesh(domain, "basic_usage")

Cite

If you use ParGeo in your research, please cite it. You can use the following BibTeX entry:

@software{Schafer_ParGeo_2024,
    author = {Schäfer, Till and Gruhlke, Robert},
    month = feb,
    title = {{ParGeo}},
    url = {https://github.com/Priusds/ParGeo},
    version = {0.3.2},
    year = {2024}
}

pargeo's People

Contributors

priusds avatar drachiro avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

hanyuegu

pargeo's Issues

Allow different types of domains (2D)

For now a two-dimensional geometry is based on an outer rectangle and some inner (non-intersecting) rectangles.
Do we want to allow different shapes?

Add tutorials

Make proper examples for the scenarios:

  • Constraints
  • Periodic Transforms
  • Diffeomorphis Transforms
  • Remove or update old examples with old syntax

Update of Bubbles

Generalize the concept of adding holes

General functionality

  • A hole individually can represent a void or a composite added in parallel.
  • Holes can be added everywhere. In particular Stellar that touch more than one edge currently cause errors and will not be added.
  • Give holes individual entities and level.
  • Boundary clipping with intersection point computation.

Merging and intersections

  • Option to respect collision with user defined distance value. The collision should not exist on a continuous level, as finer discretization may cause collision that not appear on coarser discretization.
  • If two holes are voids, enable merging if they have intersection. Simple cases: Intersection at 1 point. Intersection on a whole edge, then this edge can be removed. If the intersection cuts out an area of positive measure should be keep it (in case there is a point connection to remaining domain, e.g. touching moons) or remove it ( isolated subdomain).
    The latter involves the case, where a single void cuts a corner of the whole domain.
  • A merging of two holes that represent submaterial with intersection with positive measure should only be possible if composites have the same entity. Add a merge_allowed flag possibly. Such merged holes may be summarized in a complex_geometry object for future merging. which represents a polygon in discrete level and piecewise (switching at intersection points) the single hole geometry at continuous level.
  • If two material holes share a common edge (e.g. chessboard), in case of no collision option, there intersection interface should respect the discretization of both. (e.g. rectangles of different sizes). Here no entity restriction is necessary.
  • inclusions finally stored as Polygon ( with possible multiple interior)
  • the main domain must be flagged (level = 0) and is a list of Polygons.
  • if a polygon representing a inclusion (level > 0 ) intersection with main domain (level= 0) then clipping
  • inclusions have different entities and level, the higher level has priority in its full shape representation
  • additional flag mark if its a hole or an inclusion (realized via add_hole, add_inclusion - methods)
  1. topo.add_hole( hole, level = 2)
  2. topo.add_inclusion( hole_2, level = 1, entity = "copper")
  • i.e. if inclusion has smaller level and is completely contained in higher level polygon, don't add
  • if level is the same merge if allowed
  • Write Output information if a added Bubble is actually added (due to given rules)

Domain Concepts

  • The main domain can be choosen as a polygon. Complex polygons may be obtained from merging simpler shapes (circle + rectangular ) example.
  • API format :
  • domain = subdomain1 + subdomain2 (for merge), domain = subdomain1 - subdomain2 (for subset minus)
  • Periodische Randbedingungen auf main domains die rectangles sind.
  • #40
  • Periodische Randbedingungen und nicht periodische in parallel (nur kanten basiert)
  • Geometrieobject have is_reference_domain(), is_void(), is_inclusion() knowledge
  • Hole classes for special treatment: convex classes, stellar classes, rectangles.

Logo

Make some nice logo picture.

Ideas:

  • Write Bubbles with bubbles
  • Make a Bubbles background (Rectangle) and add bubbles as holes to make the bubbles writing.

Dolfin dependence

Is Dolfin's dependence needed? Is it just for testing purposes? I would prefer to remove it from the core package.

Segmetize Introduktion

The presents of geometry intersection with possible coarse boundary elements can cause very poor meshes when applying gmsh.

For this reason it is required to have more vertices on the boundary interface, in particular the intersection sub manifold of composite and domain boundary.

Here are multiple solutions:

  1. Solve with lc from gmsh.
  2. shapely segmentize, but this has to respect aligned amount of vertices in case of periodic domains to ensure proper periodic functions spaces later in fenics.

Sampler

Samplers

  • Provide Collision respecting sampler
  • Provide Volume constraint sampler

Projection on clipping plane

Improve the projection, a point on the manifold should be approximated on a hyperplane

Now: euclidean projection, just change the height

Gmsh Python API

Use the Python API provided by GMSH.

Questions:

  • Create holes, by defining physical groups and not assigning the hole to any PH, Gmsh claims that this mesh will be ignored and not be saved. (Test if true)

Refactor hole module

Themodule bubbles.two_d.holehas much redundant code, I think with pydantic it would become leaner.

3D: Todo list

  • Create reference mesh on a sphere via Gmsh with nodes in physical space. Compute reference coordinates (theta, phi) and map those through the Bubble transformation to obtain a discretization of the 2d manifold itself.

  • Introduce clipping based on projection ( non linear optimization with nonlinear constraints). Possible use mystic package for penalty based free optimization to incoorperate the constraint.

  • Introduce a framework that allows to decide how the triangles are "extended" or "clipped" to preserve high quality triangulation. This might based on a simple compare the choices of triangle that would arise via multiple projections of its vertices and compare those (angle based).

  • In the clipping plane separate lineloops need to be indified. Build a vertex (index) to connected line (hashmap : int -> list) Based on the idea to not allow lines with more than 2 neighbours, independend line loops can be detected.

  • A bubble should be placed within a Box. For this introduce a Box class, possible name : BoxWithBubbles. This class should handle box intersections with bubbles.

  • Build the actual geo / msh / xml file to have a bubble within a box.

  • Develop bubble subclasses, that allow for more complex structures.

  • Test periodicity of trafo via scatter plot

BoxWithFeatures

Construct classes derived from an abstractclass BoxWithFeatures

  • BoxWithLayers. Given a height/width/depth of a layer (per standard value > 0 ) gets a number n€IN of layers. Each layer should have an own physical attribute ( for later material differentiation.

  • BoxWithBubbles:

    • A box consists of 6 finite hyperplanes ( not necessary orthogonal), e.g. rectangle extruded or trapezoidal extruded.
      parameters : Height / widht/ depth , angle (controls trapezoidal) parameter.
    • manages bubbles and intersection of bubbles with its boundary (clipping),
    • a bubble is allowed to intersect with 1 or 2 ( optional even 3 ) sides
  • Merge 2 BoxWidthFeatures, s.t. a common grid is possible, e.g. with application to build a sandwich.

  • Build a sandwich BoxWithLayers / BoxWithBubbles / BoxWithLayers, where is width of the Boxwith layers is larger to equal to the frontal width of the BoxWithBubbles.

gmsh API : Check for existing gmsh installation.

The gmsh api consist of two separate blocks:

Not dependend on gmsh installation:
Classes/method to write a geo file.

dependend on gmsh installation
Classes/methods that require python install of gmsh

  • WIthin gmsh api try catch import of gmsh if additional features should be used else disable them.
  • Make gmsh independent block available independent of gmsh installation

Add loggings

Remove prints and add loggings.

Add warning for #14: mock data is used!

Mesh Vertices Alignment

If periodic boundaries are given, the mesh at the respective periodic edges (i.e. the vertices), must be aligned.

  • Check if it is already the case.
  • If not, solve it. For instance, write a python script that postprocesses the .MSH file. Maybe this is an iterative process.

Idea: Here the shapely.segmentize method might become handy, replacing lc handling from the shapely POV.

Use GMSH python API

We always directly wrote the .GEO file, instead of using the GMSH API. Is there a specific reason for?

Merge intersecting holes (two-dimensional case)

For now, adding new holes to a Topology object is only possible as long they are not intersecting old ones.
Do we want to lose this?

  • List all annoying edge cases.
  • How to parametrize non-stellar holes?

Bug fix empty sub-rects

Following code creates filled sub-rects, instead of empty one.

rect_out = [(0, 0), (2, 2)]
rect_in_1 = [(0.25, 0.25), (0.75, 0.75)]
rect_in_2 = [(1.25, 0.25), (1.75, 0.75)]
rect_in_3 = [(1.25, 1.25), (1.75, 1.75)]
rect_in_4 = [(0.25, 1.25), (0.75, 1.75)]

topo = Topology(
  rect_out, [rect_in_1, rect_in_2, rect_in_3, rect_in_4], periodic_boundary=True
)
geo = topo.get_geometry(lc=1.0, lc_subrects=0.1, filled=False)
write_geo(geo, DATA_DIR/"domain_without_holes_empty")

Debug minimal functionality

  • Provide minimal code example of needed but buggy functionality
  • Write test if possible
  • Open related issue for the solution

Refactor / Rename hole.py

I would suggest to rename hole.py to geometry.py.

and clean the existing stuff / or add geometries.

Maybe refactor the discretize_hole mechanics ?

Refactor

  • Update readme: How to set the environment up, What functionality is provided and how to use it?
  • Add module comments
  • Add requirements

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.