Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refine method for ResolutionSpec #70

Merged
merged 4 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading