Commit b506dedd authored by Baptiste Durand's avatar Baptiste Durand

Clean geometry __init__.py

create the __all__ list;
minor syntax fixes in geometry sub-modules.
parent 30837335
...@@ -13,20 +13,37 @@ sources : ...@@ -13,20 +13,37 @@ sources :
import logging import logging
import math import math
import warnings import warnings
from pathlib import Path
import gmsh import gmsh
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import numpy as np import numpy as np
from .point import Point from .curves import AbstractCurve, Arc, Line, bndry_logger
from .curves import AbstractCurve, Arc, Line
from .surfaces import LineLoop, Surface, AbstractSurface, surfaces_bool_cut, surfaces_bool_intersect
from .physical import PhysicalGroup from .physical import PhysicalGroup
from .point import Point
from .surfaces import (
AbstractSurface,
LineLoop,
PlaneSurface,
surface_bool_cut,
surface_bool_intersect,
)
from .tools import (
angle_between,
bisector,
dual_base,
macro_line_fragments,
offset,
remove_duplicates,
round_corner,
unit_vect,
)
from .transformations import plane_reflection, point_reflection, rotation, translation
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
# nice shortcuts # nice shortcuts
model = gmsh.model model = gmsh.model
factory = model.occ factory = model.occ
...@@ -34,9 +51,6 @@ factory = model.occ ...@@ -34,9 +51,6 @@ factory = model.occ
warnings.simplefilter("always") warnings.simplefilter("always")
# ? Doc: https://docs.python.org/3.6/library/warnings.html # ? Doc: https://docs.python.org/3.6/library/warnings.html
# info about gmsh module
logger.info(f"gmsh module path : {Path(gmsh.__file__).resolve()}")
def set_gmsh_option(option, val): def set_gmsh_option(option, val):
""" """
...@@ -68,17 +82,22 @@ def init_geo_tools(): ...@@ -68,17 +82,22 @@ def init_geo_tools():
The Gmsh Python API must be initialized before using any functions. The Gmsh Python API must be initialized before using any functions.
In addition, some options are set to custom values. In addition, some options are set to custom values.
""" """
gmsh.initialize() #? Utiliser l'argument sys.argv ? cf script boolean.py gmsh.initialize() # ? Utiliser l'argument sys.argv ? cf script boolean.py
set_gmsh_option("General.Terminal", 1) set_gmsh_option("General.Terminal", 1)
set_gmsh_option("General.Verbosity", 5) set_gmsh_option("General.Verbosity", 5)
set_gmsh_option("Geometry.AutoCoherence", 0) set_gmsh_option("Geometry.AutoCoherence", 0)
set_gmsh_option("Mesh.ColorCarousel", 2) #0=by element type, 1=by elementary entity, 2=by physical entity, 3=by partition set_gmsh_option("Mesh.ColorCarousel", 2)
set_gmsh_option("Mesh.MeshOnlyVisible", 0) #TODO : Should be in the init file of the mesh_tools module. # * 0=by element type, 1=by elementary entity, 2=by physical entity, 3=by partition
set_gmsh_option('Mesh.CharacteristicLengthExtendFromBoundary', 0) set_gmsh_option("Mesh.MeshOnlyVisible", 0)
# TODO : Should be in the init file of the mesh_tools module.
set_gmsh_option("Mesh.CharacteristicLengthExtendFromBoundary", 0)
set_gmsh_option("Mesh.SaveAll", 0) set_gmsh_option("Mesh.SaveAll", 0)
set_gmsh_option("Mesh.Binary", 0) set_gmsh_option("Mesh.Binary", 0)
set_gmsh_option('Mesh.MshFileVersion', 2.2) set_gmsh_option("Mesh.MshFileVersion", 2.2)
set_gmsh_option('Mesh.Algorithm', 5) #* 2D mesh algorithm (1=MeshAdapt, 2=Automatic,...) set_gmsh_option("Mesh.Algorithm", 5)
# * 2D mesh algorithm (1=MeshAdapt, 2=Automatic,...)
# info about gmsh module
logger.info(f"gmsh module path : {Path(gmsh.__file__).resolve()}")
logger.info("Gmsh SDK version : %s", gmsh.option.getString("General.Version")) logger.info("Gmsh SDK version : %s", gmsh.option.getString("General.Version"))
...@@ -88,12 +107,39 @@ def reset(): ...@@ -88,12 +107,39 @@ def reset():
gmsh.clear() gmsh.clear()
__all__ = [
# * geometry global
"logger",
"set_gmsh_option",
"init_geo_tools",
"reset"
# * points
"Point",
# * curves
"AbstractCurve",
"Arc",
"Line",
"bndry_logger",
# * physical entities
"PhysicalGroup",
# * surfaces
"LineLoop",
"PlaneSurface",
"AbstractSurface",
"surface_bool_cut",
"surface_bool_intersect",
# * tools
"angle_between",
"bisector",
"dual_base",
"macro_line_fragments",
"offset",
"remove_duplicates",
"round_corner",
"unit_vect",
# * transformations
"plane_reflection",
"point_reflection",
"rotation",
"translation",
]
...@@ -198,7 +198,8 @@ class AbstractCurve(Curve): ...@@ -198,7 +198,8 @@ class AbstractCurve(Curve):
def get_boundary(self, get_coords=True): def get_boundary(self, get_coords=True):
""" """
Récupérer les points correspondants aux extrémités de la courbe dans le modèle Gmsh. Récupérer les points correspondants aux extrémités de la courbe
dans le modèle Gmsh.
Parameters Parameters
---------- ----------
......
...@@ -67,6 +67,3 @@ class Point(object): ...@@ -67,6 +67,3 @@ class Point(object):
return None # for information purposes only. return None # for information purposes only.
self.tag = factory.addPoint(*self.coord, self.mesh_size) self.tag = factory.addPoint(*self.coord, self.mesh_size)
return self.tag return self.tag
...@@ -330,7 +330,7 @@ class AbstractSurface(object): ...@@ -330,7 +330,7 @@ class AbstractSurface(object):
return def_crv return def_crv
def surfaces_bool_cut(body, tool): def surface_bool_cut(body, tool):
""" """
Boolean operation of cutting performed on surfaces. Boolean operation of cutting performed on surfaces.
...@@ -392,7 +392,7 @@ def surfaces_bool_cut(body, tool): ...@@ -392,7 +392,7 @@ def surfaces_bool_cut(body, tool):
return new_surf return new_surf
def bool_intersect(body, tool): def surface_bool_intersect(body, tool):
""" """
Boolean operation of intersection performed on surfaces. Boolean operation of intersection performed on surfaces.
......
...@@ -227,4 +227,3 @@ def rotation_basis(pt_coord, angle, direction, point=None): ...@@ -227,4 +227,3 @@ def rotation_basis(pt_coord, angle, direction, point=None):
rotation = geo_transformation_factory(rotation_basis) rotation = geo_transformation_factory(rotation_basis)
# TODO : tester cette fonction # TODO : tester cette fonction
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