Skip to content

Commit

Permalink
Merge branch 'pixi'
Browse files Browse the repository at this point in the history
  • Loading branch information
Huite committed Dec 1, 2023
2 parents a1bafe4 + f5372c7 commit 2e91933
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 12 deletions.
2 changes: 2 additions & 0 deletions pandamesh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pandamesh import data
from pandamesh.gmsh_mesher import (
FieldCombination,
GeneralVerbosity,
GmshMesher,
MeshAlgorithm,
SubdivisionAlgorithm,
Expand All @@ -21,6 +22,7 @@
__all__ = (
"data",
"FieldCombination",
"GeneralVerbosity",
"GmshMesher",
"MeshAlgorithm",
"SubdivisionAlgorithm",
Expand Down
4 changes: 2 additions & 2 deletions pandamesh/common.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import functools
import operator
from enum import Enum
from enum import Enum, IntEnum
from itertools import combinations
from typing import Any, Sequence, Tuple

Expand Down Expand Up @@ -56,7 +56,7 @@ def _show_options(options: Enum) -> str:
return "\n".join(map(str, options))


def invalid_option(value: Any, options: Enum) -> str:
def invalid_option(value: Any, options: Enum | IntEnum) -> str:
return f"Invalid option: {value}. Valid options are:\n{_show_options(options)}"


Expand Down
39 changes: 30 additions & 9 deletions pandamesh/gmsh_mesher.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,18 @@ class FieldCombination(Enum):
MEAN = "Mean"


class GeneralVerbosity(IntEnum):
"""Level of information printed."""

SILENT = 0
ERRORS = 1
WARNINGS = 2
DIRECT = 3
INFORMATION = 4
STATUS = 5
DEBUG = 99


def coerce_field(field: Union[dict, str]) -> dict:
if not isinstance(field, (dict, str)):
raise TypeError("field must be a dictionary or a valid JSON dictionary string")
Expand Down Expand Up @@ -169,6 +181,8 @@ def __init__(self, gdf: gpd.GeoDataFrame) -> None:
self.mesh_size_from_curvature = False
self.field_combination = FieldCombination.MIN
self.subdivision_algorithm = SubdivisionAlgorithm.NONE
self.force_geometry = False
self.general_verbosity = GeneralVerbosity.SILENT

def __repr__(self):
return repr(self)
Expand Down Expand Up @@ -233,18 +247,14 @@ def recombine_all(self, value: bool) -> None:
gmsh.option.setNumber("Mesh.RecombineAll", value)

@property
def force_geometry(self) -> None:
raise NotImplementedError
# return self._force_geometry
def force_geometry(self) -> bool:
return self._force_geometry

@force_geometry.setter
def force_geometry(self, value: bool) -> None:
# Wait for the next release incorporating this change:
# https://gitlab.onelab.info/gmsh/gmsh/-/merge_requests/358
raise NotImplementedError
# if not isinstance(value, bool):
# raise TypeError("force_geometry must be a bool")
# self._force_geometry = value
if not isinstance(value, bool):
raise TypeError("force_geometry must be a bool")
self._force_geometry = value

@property
def mesh_size_extend_from_boundary(self):
Expand Down Expand Up @@ -336,6 +346,17 @@ def subdivision_algorithm(self, value):
self._subdivision_algorithm = value
gmsh.option.setNumber("Mesh.SubdivisionAlgorithm", value)

@property
def general_verbosity(self) -> GeneralVerbosity:
return self._general_verbosity

@general_verbosity.setter
def general_verbosity(self, value: GeneralVerbosity) -> None:
if value not in GeneralVerbosity:
raise ValueError(invalid_option(value, GeneralVerbosity))
self._general_verbosity = value
gmsh.option.setNumber("General.Verbosity", value)

# Methods
# -------

Expand Down
2 changes: 1 addition & 1 deletion pixi.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "pandamesh"
version = "0.1.3"
description = "Add a short description here"
description = "From geodataframe to mesh"
authors = ["Huite Bootsma <huitebootsma@gmail.com>"]
channels = ["conda-forge"]
platforms = ["win-64", "linux-64", "osx-arm64", "osx-64"]
Expand Down

0 comments on commit 2e91933

Please sign in to comment.