anisotropy/openfoam/meshManipulation.py

37 lines
986 B
Python
Raw Normal View History

2021-05-26 22:02:44 +05:00
import re
2021-05-26 17:18:39 +05:00
def createPatch(dictfile: str = None, case: str = None):
args = ["-overwrite"]
if dictfile:
args.extend(["-dict", dictfile])
application("createPatch", *args, case = case, stderr = True)
def transformPoints(scale: tuple, case: str = None):
scale_ = "{}".format(scale).replace(",", "")
application("transformPoints", "-scale", scale_, case = case, stderr = True)
def checkMesh(case: str = None):
application("checkMesh", "-allGeometry", "-allTopology", case = case, stderr = True)
2021-05-26 22:02:44 +05:00
out = ""
2021-05-26 17:18:39 +05:00
with open("checkMesh.log", "r") as io:
warnings = []
for line in io:
if re.search("\*\*\*", line):
warnings.append(line.replace("***", "").strip())
if warnings:
2021-05-26 22:02:44 +05:00
out = "checkMesh:\n\t{}".format("\n\t".join(warnings))
return out
2021-05-26 17:18:39 +05:00
def renumberMesh(case: str = None):
application("renumberMesh", "-parallel", "-overwrite", useMPI = True, case = case, stderr = True)