Skip to content

Commit a649d7e

Browse files
authored
Enabled auto-check if primalBC and objFunc keys are valid (#488)
* Auto-checked objFunc and primalBC dict. * Fixed an issue.
1 parent 35e4cd4 commit a649d7e

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

dafoam/pyDAFoam.py

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -724,9 +724,6 @@ def __init__(self, comm=None, options=None):
724724
# initialize comm for parallel communication
725725
self._initializeComm(comm)
726726

727-
# check if the combination of options is valid.
728-
self._checkOptions()
729-
730727
# Initialize families
731728
self.families = OrderedDict()
732729

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

773+
# check if the combination of options is valid.
774+
self._checkOptions()
775+
776776
# initialize the mesh point vector xvVec
777777
self._initializeMeshPointVec()
778778

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

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

1147+
# check the patchNames from primalBC dict
1148+
primalBCDict = self.getOption("primalBC")
1149+
for bcKey in primalBCDict:
1150+
try:
1151+
patches = primalBCDict[bcKey]["patches"]
1152+
except Exception:
1153+
continue
1154+
for patchName in patches:
1155+
if patchName not in self.boundaries.keys():
1156+
raise Error(
1157+
"primalBC-%s-patches-%s is not valid. Please use a patchName from the boundaries list: %s"
1158+
% (bcKey, patchName, self.boundaries.keys())
1159+
)
1160+
1161+
# check the patch names from objFunc dict
1162+
objFuncDict = self.getOption("objFunc")
1163+
for objKey in objFuncDict:
1164+
for part in objFuncDict[objKey]:
1165+
try:
1166+
patches = objFuncDict[objKey][part]["patches"]
1167+
except Exception:
1168+
continue
1169+
for patchName in patches:
1170+
if patchName not in self.boundaries.keys():
1171+
raise Error(
1172+
"objFunc-%s-%s-patches-%s is not valid. Please use a patchName from the boundaries list: %s"
1173+
% (objKey, part, patchName, self.boundaries.keys())
1174+
)
1175+
11461176
# check other combinations...
11471177

11481178
def saveMultiPointField(self, indexMP):

0 commit comments

Comments
 (0)