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

Enabled auto-check if primalBC and objFunc keys are valid #488

Merged
merged 2 commits into from
Sep 20, 2023
Merged
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
36 changes: 33 additions & 3 deletions dafoam/pyDAFoam.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,9 +724,6 @@ def __init__(self, comm=None, options=None):
# initialize comm for parallel communication
self._initializeComm(comm)

# check if the combination of options is valid.
self._checkOptions()

# Initialize families
self.families = OrderedDict()

Expand Down Expand Up @@ -773,6 +770,9 @@ def __init__(self, comm=None, options=None):
# initialize mesh information and read grids
self._readMeshInfo()

# check if the combination of options is valid.
self._checkOptions()

# initialize the mesh point vector xvVec
self._initializeMeshPointVec()

Expand Down Expand Up @@ -1124,6 +1124,7 @@ def _checkOptions(self):
if self.getOption("discipline") not in ["aero", "thermal"]:
raise Error("discipline: %s not supported. Options are: aero or thermal" % self.getOption("discipline"))

# check coupling Info
nActivated = 0
for coupling in self.getOption("couplingInfo"):
if self.getOption("couplingInfo")[coupling]["active"]:
Expand All @@ -1143,6 +1144,35 @@ def _checkOptions(self):
"Only one couplingSurfaceGroups is supported for aerostructural, while %i found" % nAeroStructSurfaces
)

# check the patchNames from primalBC dict
primalBCDict = self.getOption("primalBC")
for bcKey in primalBCDict:
try:
patches = primalBCDict[bcKey]["patches"]
except Exception:
continue
for patchName in patches:
if patchName not in self.boundaries.keys():
raise Error(
"primalBC-%s-patches-%s is not valid. Please use a patchName from the boundaries list: %s"
% (bcKey, patchName, self.boundaries.keys())
)

# check the patch names from objFunc dict
objFuncDict = self.getOption("objFunc")
for objKey in objFuncDict:
for part in objFuncDict[objKey]:
try:
patches = objFuncDict[objKey][part]["patches"]
except Exception:
continue
for patchName in patches:
if patchName not in self.boundaries.keys():
raise Error(
"objFunc-%s-%s-patches-%s is not valid. Please use a patchName from the boundaries list: %s"
% (objKey, part, patchName, self.boundaries.keys())
)

# check other combinations...

def saveMultiPointField(self, indexMP):
Expand Down
Loading