Mod: real volume

This commit is contained in:
L-Nafaryus 2022-02-16 12:27:36 +05:00
parent fea53d0db7
commit c5d2bf1783
No known key found for this signature in database
GPG Key ID: C76D8DCD2727DBB7
3 changed files with 17 additions and 9 deletions

View File

@ -136,7 +136,8 @@ def default_config() -> Config:
"velocityOutlet": None, "velocityOutlet": None,
"velocityInternal": [0., 0., 0.], "velocityInternal": [0., 0., 0.],
"density": 1000, "density": 1000,
"viscosity": 1e-3 "viscosity": 1e-3,
"scale": [1e-5, 1e-5, 1e-5]
}) })
return config return config

View File

@ -6,6 +6,7 @@ from os import environ
from datetime import datetime from datetime import datetime
import pathlib import pathlib
import logging import logging
import numpy as np
from anisotropy.database import Database, tables from anisotropy.database import Database, tables
from anisotropy import shaping from anisotropy import shaping
@ -34,15 +35,15 @@ class UltimateRunner(object):
self.exec_id = None self.exec_id = None
if exec_id is not None: if exec_id is not None:
if self.database.getExecution(exec_id): if self.database.getExecution(int(exec_id)):
self.exec_id = exec_id self.exec_id = int(exec_id)
else: else:
logger.warning(f"Execution id '{ exec_id }' not found. Creating new.") logger.warning(f"Execution id '{ exec_id }' not found. Creating new.")
if self.exec_id is None: if self.exec_id is None:
with self.database: 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": if self.type == "master":
logger.info(f"Current execution id: { self.exec_id }") logger.info(f"Current execution id: { self.exec_id }")
@ -176,8 +177,8 @@ class UltimateRunner(object):
else: else:
shapeParams.shapeStatus = "done" shapeParams.shapeStatus = "done"
shapeParams.volume = shape.shape.volume shapeParams.volume = shape.shape.volume * np.prod(params["scale"])
shapeParams.volumeCell = shape.cell.volume shapeParams.volumeCell = shape.cell.volume * np.prod(params["scale"])
shapeParams.porosity = shapeParams.volume / shapeParams.volumeCell shapeParams.porosity = shapeParams.volume / shapeParams.volumeCell
# commit parameters # commit parameters
@ -287,6 +288,7 @@ class UltimateRunner(object):
path = self.casepath, path = self.casepath,
direction = params["direction"], direction = params["direction"],
patches = shape.patches(group = True, shiftIndex = True, prefix = "patch"), patches = shape.patches(group = True, shiftIndex = True, prefix = "patch"),
scale = params["scale"],
**flowParamsDict **flowParamsDict
) )

View File

@ -21,6 +21,7 @@ class FlowOnePhase:
velocityInternal: float = None, velocityInternal: float = None,
density: float = None, density: float = None,
viscosityKinematic: float = None, viscosityKinematic: float = None,
scale: list[float] = None,
**kwargs **kwargs
): ):
@ -38,6 +39,7 @@ class FlowOnePhase:
self.velocityInternal = velocityInternal self.velocityInternal = velocityInternal
self.density = density self.density = density
self.viscosityKinematic = viscosityKinematic self.viscosityKinematic = viscosityKinematic
self.scale = scale
def controlDict(self) -> of.FoamFile: def controlDict(self) -> of.FoamFile:
ff = presets.controlDict() ff = presets.controlDict()
@ -246,9 +248,12 @@ class FlowOnePhase:
commands.createPatch() commands.createPatch()
commands.checkMesh() commands.checkMesh()
if self.scale is not None:
commands.transformPoints({ commands.transformPoints({
"scale": [1e-5, 1e-5, 1e-5] "scale": self.scale
}) })
commands.renumberMesh() commands.renumberMesh()
if approximation: if approximation: