diff --git a/anisotropy/core/config.py b/anisotropy/core/config.py index 82e1a23..3943ce7 100644 --- a/anisotropy/core/config.py +++ b/anisotropy/core/config.py @@ -136,7 +136,8 @@ def default_config() -> Config: "velocityOutlet": None, "velocityInternal": [0., 0., 0.], "density": 1000, - "viscosity": 1e-3 + "viscosity": 1e-3, + "scale": [1e-5, 1e-5, 1e-5] }) return config diff --git a/anisotropy/core/runner.py b/anisotropy/core/runner.py index 4c06280..f01afe8 100644 --- a/anisotropy/core/runner.py +++ b/anisotropy/core/runner.py @@ -6,6 +6,7 @@ from os import environ from datetime import datetime import pathlib import logging +import numpy as np from anisotropy.database import Database, tables from anisotropy import shaping @@ -34,15 +35,15 @@ class UltimateRunner(object): self.exec_id = None if exec_id is not None: - if self.database.getExecution(exec_id): - self.exec_id = exec_id + if self.database.getExecution(int(exec_id)): + self.exec_id = int(exec_id) else: logger.warning(f"Execution id '{ exec_id }' not found. Creating new.") if self.exec_id is None: with self.database: - self.exec_id = tables.Execution.create(date = datetime.now()) + self.exec_id = tables.Execution.create(date = datetime.now()).exec_id if self.type == "master": logger.info(f"Current execution id: { self.exec_id }") @@ -176,8 +177,8 @@ class UltimateRunner(object): else: shapeParams.shapeStatus = "done" - shapeParams.volume = shape.shape.volume - shapeParams.volumeCell = shape.cell.volume + shapeParams.volume = shape.shape.volume * np.prod(params["scale"]) + shapeParams.volumeCell = shape.cell.volume * np.prod(params["scale"]) shapeParams.porosity = shapeParams.volume / shapeParams.volumeCell # commit parameters @@ -287,6 +288,7 @@ class UltimateRunner(object): path = self.casepath, direction = params["direction"], patches = shape.patches(group = True, shiftIndex = True, prefix = "patch"), + scale = params["scale"], **flowParamsDict ) diff --git a/anisotropy/solving/onephase.py b/anisotropy/solving/onephase.py index 2a9fe0f..b903045 100644 --- a/anisotropy/solving/onephase.py +++ b/anisotropy/solving/onephase.py @@ -21,6 +21,7 @@ class FlowOnePhase: velocityInternal: float = None, density: float = None, viscosityKinematic: float = None, + scale: list[float] = None, **kwargs ): @@ -38,6 +39,7 @@ class FlowOnePhase: self.velocityInternal = velocityInternal self.density = density self.viscosityKinematic = viscosityKinematic + self.scale = scale def controlDict(self) -> of.FoamFile: ff = presets.controlDict() @@ -246,9 +248,12 @@ class FlowOnePhase: commands.createPatch() commands.checkMesh() - commands.transformPoints({ - "scale": [1e-5, 1e-5, 1e-5] - }) + + if self.scale is not None: + commands.transformPoints({ + "scale": self.scale + }) + commands.renumberMesh() if approximation: