forked from nextfoam/baram
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'snappy/main' into snappyMerging
- Loading branch information
Showing
143 changed files
with
18,671 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,4 +145,4 @@ dmypy.json | |
.idea/ | ||
|
||
# Solver | ||
solvers/ | ||
solvers/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
import sys | ||
from pathlib import Path | ||
from typing import Optional | ||
|
||
from PySide6.QtCore import QObject, QTranslator, QCoreApplication, QLocale | ||
|
||
from db.project import Project | ||
from resources import resource | ||
from settings.app_settings import AppSettings | ||
from settings.project_manager import ProjectManager | ||
from openfoam.file_system import FileSystem | ||
|
||
|
||
if getattr(sys, 'frozen', False): | ||
APP_PATH = Path(sys.executable).parent.resolve() | ||
else: | ||
APP_PATH = Path(__file__).parent.resolve() | ||
|
||
|
||
class App(QObject): | ||
def __init__(self): | ||
super().__init__() | ||
|
||
self._properties = None | ||
self._settings = None | ||
self._project: Optional[Project] = None | ||
self._fileSystem = None | ||
|
||
self._window = None | ||
self._translator = None | ||
self._projectManager = ProjectManager() | ||
|
||
@property | ||
def properties(self): | ||
return self._properties | ||
|
||
@property | ||
def settings(self): | ||
return self._settings | ||
|
||
@property | ||
def window(self): | ||
return self._window | ||
|
||
@property | ||
def project(self): | ||
return self._project | ||
|
||
@property | ||
def fileSystem(self): | ||
return self._fileSystem | ||
|
||
@property | ||
def db(self): | ||
return self._project.db() if self._project else None | ||
|
||
@property | ||
def consoleView(self): | ||
return self._window.consoleView | ||
|
||
@window.setter | ||
def window(self, window): | ||
self._window = window | ||
|
||
def setupApplication(self, properties): | ||
self._properties = properties | ||
self._settings = AppSettings(properties.name) | ||
|
||
def applyLanguage(self): | ||
QCoreApplication.removeTranslator(self._translator) | ||
self._translator = QTranslator() | ||
self._translator.load(QLocale(QLocale.languageToCode(QLocale(self._settings.getLanguage()).language())), | ||
'baram', '_', str(resource.file('locale'))) | ||
QCoreApplication.installTranslator(self._translator) | ||
|
||
def createProject(self, path): | ||
assert(self._project is None) | ||
|
||
self._project = self._projectManager.createProject(path) | ||
self._settings.updateRecents(self._project.path, True) | ||
self._fileSystem = FileSystem(self._project.path) | ||
self._fileSystem.createCase(APP_PATH / 'resources/openfoam/case') | ||
|
||
return self._project | ||
|
||
def openProject(self, path): | ||
assert(self._project is None) | ||
|
||
self._project = self._projectManager.openProject(path) | ||
self._settings.updateRecents(self._project.path) | ||
self._fileSystem = FileSystem(self._project.path) | ||
|
||
return self._project | ||
|
||
def closeProject(self): | ||
if self._project: | ||
self._project.close() | ||
self._project = None | ||
|
||
|
||
app = App() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
import yaml | ||
|
||
from .file_db import writeConfigurations, readConfigurations, FileGroup, newFiles | ||
from .simple_db import SimpleDB | ||
from .migrate import migrate | ||
|
||
|
||
FILE_NAME = 'configurations.h5' | ||
DB_KEY = 'configurations' | ||
|
||
|
||
class Configurations(SimpleDB): | ||
_geometryNextKey = 0 | ||
|
||
def __init__(self, schema): | ||
super().__init__(schema) | ||
|
||
self._path = None | ||
self._files = newFiles() | ||
|
||
def load(self, path): | ||
self._path = path / FILE_NAME | ||
if self._path.exists(): | ||
data, files, maxIds = readConfigurations(self._path) | ||
self._db = self.validateData(migrate(yaml.full_load(data)), fillWithDefault=True) | ||
self._files = files | ||
Configurations._geometryNextKey = maxIds[FileGroup.GEOMETRY_POLY_DATA.value] | ||
else: | ||
self.createData() | ||
|
||
def save(self): | ||
if self.isModified(): | ||
writeConfigurations(self._path, self.toYaml(), self._files) | ||
self._modified = False | ||
|
||
def addGeometryPolyData(self, pd): | ||
Configurations._geometryNextKey += 1 | ||
key = f'Geometry{Configurations._geometryNextKey}' | ||
|
||
self._files['geometry'][key] = pd | ||
self._modified = True | ||
|
||
return key | ||
|
||
def removeGeometryPolyData(self, key): | ||
self._files['geometry'][key] = None | ||
|
||
def geometryPolyData(self, key): | ||
return self._files['geometry'][key] | ||
|
||
def commit(self, data): | ||
for key in data._files: | ||
self._files[key].update(data._files[key]) | ||
|
||
super().commit(data) | ||
|
||
def _newDB(self, schema, editable=False): | ||
db = Configurations(schema) | ||
db._editable = editable | ||
|
||
return db | ||
|
||
def print(self): | ||
print(self.toYaml()) | ||
print(self._files['geometry']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
|
||
from enum import Enum, auto, IntEnum | ||
|
||
from .simple_schema import FloatType, IntKeyList, EnumType, IntType, TextType, BoolType, PositiveIntType | ||
from .simple_schema import VectorComposite | ||
|
||
|
||
class Step(IntEnum): | ||
NONE = -1 | ||
|
||
GEOMETRY = 0 | ||
REGION = auto() | ||
BASE_GRID = auto() | ||
CASTELLATION = auto() | ||
SNAP = auto() | ||
BOUNDARY_LAYER = auto() | ||
EXPORT = auto() | ||
|
||
LAST_STEP = EXPORT | ||
|
||
|
||
class GeometryType(Enum): | ||
SURFACE = 'surface' | ||
VOLUME = 'volume' | ||
|
||
|
||
class Shape(Enum): | ||
TRI_SURFACE_MESH = 'triSurfaceMesh' | ||
HEX = 'hex' | ||
CYLINDER = 'cylinder' | ||
SPHERE = 'sphere' | ||
HEX6 = 'hex6' | ||
X_MIN = 'xMin' | ||
X_MAX = 'xMax' | ||
Y_MIN = 'yMin' | ||
Y_MAX = 'yMax' | ||
Z_MIN = 'zMin' | ||
Z_MAX = 'zMax' | ||
|
||
PLATES = [X_MIN, X_MAX, Y_MIN, Y_MAX, Z_MIN, Z_MAX] | ||
|
||
|
||
class CFDType(Enum): | ||
NONE = 'none' | ||
CELL_ZONE = 'cellZone' | ||
BOUNDARY = 'boundary' | ||
INTERFACE = 'interface' | ||
|
||
|
||
class RegionType(Enum): | ||
FLUID = 'fluid' | ||
SOLID = 'solid' | ||
|
||
|
||
class ThicknessModel(Enum): | ||
FIRST_AND_OVERALL = 'firstAndOverall' | ||
FIRST_AND_EXPANSION = 'firstAndExpansion' | ||
FINAL_AND_OVERALL = 'finalAndOverall' | ||
FINAL_AND_EXPANSION = 'finalAndExpansion' | ||
OVERALL_AND_EXPANSION = 'overallAndExpansion' | ||
FIRST_AND_RELATIVE_FINAL = 'firstAndRelativeFinal' | ||
|
||
|
||
geometry = { | ||
'gType': EnumType(GeometryType), | ||
'volume': IntType().setOptional(), | ||
'name': TextType(), | ||
'shape': EnumType(Shape), | ||
'cfdType': EnumType(CFDType), | ||
'nonConformal': BoolType(False), | ||
'interRegion': BoolType(False), | ||
'path': TextType().setOptional(), | ||
'point1': VectorComposite().schema(), | ||
'point2': VectorComposite().setDefault(1, 1, 1).schema(), | ||
'radius': FloatType().setDefault(1), | ||
'castellationGroup': IntType().setOptional().setDefault(None), | ||
'layerGroup': IntType().setOptional().setDefault(None), | ||
'slaveLayerGroup': IntType().setOptional().setDefault(None) | ||
} | ||
|
||
region = { | ||
'name': TextType(), | ||
'type': EnumType(RegionType), | ||
'point': VectorComposite().schema() | ||
} | ||
|
||
surfaceRefinement = { | ||
'groupName': TextType(), | ||
'surfaceRefinementLevel': IntType().setDefault(1), | ||
'featureEdgeRefinementLevel': IntType().setDefault(1), | ||
} | ||
|
||
volumeRefinement = { | ||
'groupName': TextType(), | ||
'volumeRefinementLevel': PositiveIntType().setDefault(1) | ||
} | ||
|
||
layer = { | ||
'groupName': TextType(), | ||
'nSurfaceLayers': PositiveIntType().setDefault(1), | ||
'thicknessModel': EnumType(ThicknessModel).setDefault(ThicknessModel.FINAL_AND_EXPANSION), | ||
'relativeSizes': BoolType(True), | ||
'firstLayerThickness': FloatType().setDefault(0.3), | ||
'finalLayerThickness': FloatType().setDefault(0.5), | ||
'thickness': FloatType().setDefault(0.5), | ||
'expansionRatio': FloatType().setDefault(1.2), | ||
'minThickness': FloatType().setDefault(0.3) | ||
} | ||
|
||
|
||
schema = { | ||
'step': EnumType(Step).setDefault(Step.GEOMETRY), | ||
'geometry': IntKeyList(geometry), | ||
'region': IntKeyList(region), | ||
'baseGrid': { | ||
'numCellsX': PositiveIntType().setDefault(10), | ||
'numCellsY': PositiveIntType().setDefault(10), | ||
'numCellsZ': PositiveIntType().setDefault(10) | ||
}, | ||
'castellation': { | ||
'vtkNonManifoldEdges': BoolType(False), | ||
'vtkBoundaryEdges': BoolType(True), | ||
'nCellsBetweenLevels': IntType().setDefault(3), | ||
'resolveFeatureAngle': FloatType().setDefault(30), | ||
'maxGlobalCells': IntType().setDefault('1e8'), | ||
'maxLocalCells': IntType().setDefault('1e7'), | ||
'minRefinementCells': IntType().setDefault(0), | ||
'maxLoadUnbalance': FloatType().setDefault('0.5'), | ||
'allowFreeStandingZoneFaces': BoolType(True), | ||
'refinementSurfaces': IntKeyList(surfaceRefinement), | ||
'refinementVolumes': IntKeyList(volumeRefinement), | ||
}, | ||
'snap': { | ||
'nSmoothPatch': IntType().setDefault(3), | ||
'nSmoothInternal': IntType().setDefault(3), | ||
'nSolveIter': IntType().setDefault(30), | ||
'nRelaxIter': IntType().setDefault(5), | ||
'nFeatureSnapIter': IntType().setDefault(15), | ||
'multiRegionFeatureSnap': BoolType(False), | ||
'tolerance': FloatType().setDefault(3), | ||
'concaveAngle': FloatType().setDefault(45), | ||
'minAreaRation': FloatType().setDefault(0.3) | ||
}, | ||
'addLayers': { | ||
# 'thicknessModel': EnumType(ThicknessModel).setDefault(ThicknessModel.FINAL_AND_OVERALL), | ||
# 'relativeSizes': BoolType(True), | ||
# 'firstLayerThickness': FloatType().setDefault(0.3), | ||
# 'finalLayerThickness': FloatType().setDefault('0.5'), | ||
# 'thickness': FloatType().setDefault('0.5'), | ||
# 'expansionRatio': FloatType().setDefault(1.2), | ||
# 'minThickness': FloatType().setDefault(0.3), | ||
'layers': IntKeyList(layer), | ||
'nGrow': IntType().setDefault(0), | ||
'featureAngle': FloatType().setDefault(120), | ||
'maxFaceThicknessRatio': FloatType().setDefault(0.5), | ||
'nSmoothSurfaceNormals': IntType().setDefault(1), | ||
'nSmoothThickness': FloatType().setDefault(10), | ||
'minMedialAxisAngle': FloatType().setDefault(90), | ||
'maxThicknessToMedialRatio': FloatType().setDefault(0.3), | ||
'nSmoothNormals': IntType().setDefault(3), | ||
'slipFeatureAngle': FloatType().setDefault(30), | ||
'nRelaxIter': IntType().setDefault(10), | ||
'nBufferCellsNoExtrude': IntType().setDefault(0), | ||
'nLayerIter': IntType().setDefault(50), | ||
'nRelaxedIter': IntType().setDefault(20) | ||
}, | ||
'meshQuality': { | ||
'maxNonOrtho': FloatType().setDefault(65), | ||
'maxBoundarySkewness': FloatType().setDefault(65), | ||
'maxInternalSkewness': FloatType().setDefault(4), | ||
'maxConcave': FloatType().setDefault(80), | ||
'minVol': FloatType().setDefault('1e-13'), | ||
'minTetQuality': FloatType().setDefault('1e-15'), | ||
'minVolCollapseRatio': FloatType().setDefault(0.5), | ||
'minArea': FloatType().setDefault(-1), | ||
'minTwist': FloatType().setDefault(0.02), | ||
'minDeterminant': FloatType().setDefault('1e-13'), | ||
'minFaceWeight': FloatType().setDefault(0.05), | ||
'minFaceFlatness': FloatType().setDefault(-1), | ||
'minVolRatio': FloatType().setDefault(0.01), | ||
'minTriangleTwist': FloatType().setDefault(-1), | ||
'nSmoothScale': IntType().setDefault(4), | ||
'errorReduction': FloatType().setDefault(0.75), | ||
'mergeTolerance': FloatType().setDefault(1e-6), | ||
'relaxed': { | ||
'maxNonOrtho': FloatType().setDefault(65) | ||
} | ||
} | ||
} |
Oops, something went wrong.