Skip to content

Commit

Permalink
Merge pull request #70 from simbilod/refine_resolutionSpec
Browse files Browse the repository at this point in the history
refine method for ResolutionSpec
  • Loading branch information
simbilod authored Oct 3, 2024
2 parents 237047f + 45a155f commit 78be6cb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
4 changes: 4 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# [Changelog](https://keepachangelog.com/en/1.0.0/)

## 1.2.3

- resolution_factor method in ResolutionSpec [PR#70](https://github.com/simbilod/meshwell/pull/70)

## 1.1.2

- ResolutionSpec instead of resolution dict [PR#69](https://github.com/simbilod/meshwell/pull/69)
Expand Down
20 changes: 17 additions & 3 deletions meshwell/resolution.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from dataclasses import dataclass
import numpy as np
import copy
from pydantic import BaseModel


@dataclass
class ResolutionSpec:
class ResolutionSpec(BaseModel):
"""
Object holding resolution information for an entity and its boundaries.
Expand Down Expand Up @@ -45,3 +45,17 @@ class ResolutionSpec:
resolution_points: float = np.inf
distmax_points: float | None = None
sizemax_points: float | None = None

def refine(self, resolution_factor: float):
result = copy.copy(self)
result.resolution_volumes *= resolution_factor
result.resolution_surfaces *= resolution_factor
if result.sizemax_surfaces is not None:
result.sizemax_surfaces *= resolution_factor
result.resolution_curves *= resolution_factor
if result.sizemax_curves is not None:
result.sizemax_curves *= resolution_factor
result.resolution_points *= resolution_factor
if result.sizemax_points is not None:
result.sizemax_points *= resolution_factor
return result
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Operating System :: OS Independent",
]
version="1.1.2"
version="1.1.3"
authors = [
{name = "Simon Bilodeau", email = "[email protected]"},
]
Expand Down

0 comments on commit 78be6cb

Please sign in to comment.