@@ -658,7 +658,11 @@ def setup(self):
658
658
nACTDVars = len (designVariables [dvName ]["comps" ])
659
659
self .add_input (dvName , distributed = False , shape = nACTDVars , tags = ["mphys_coupling" ])
660
660
elif dvType == "Field" : # add field variables
661
- self .add_input (dvName , distributed = True , shape_by_conn = True , tags = ["mphys_coupling" ])
661
+ # user can prescribe whether the field var is distributed. Default is True
662
+ distributed = True
663
+ if "distributed" in designVariables [dvName ]:
664
+ distributed = designVariables [dvName ]["distributed" ]
665
+ self .add_input (dvName , distributed = distributed , shape_by_conn = True , tags = ["mphys_coupling" ])
662
666
elif dvType == "RegPar" :
663
667
nParameters = self .DASolver .solver .getNRegressionParameters ()
664
668
self .add_input (dvName , distributed = False , shape = nParameters , tags = ["mphys_coupling" ])
@@ -893,7 +897,15 @@ def apply_linear(self, inputs, outputs, d_inputs, d_outputs, d_residuals, mode):
893
897
DASolver .solverAD .calcdRdFieldTPsiAD (
894
898
DASolver .xvVec , DASolver .wVec , resBarVec , inputName .encode (), prodVec
895
899
)
896
- fieldBar = DASolver .vec2Array (prodVec )
900
+ # user can prescribe whether the field var is distributed. Default is True
901
+ distributed = True
902
+ if "distributed" in designVariables [inputName ]:
903
+ distributed = designVariables [inputName ]["distributed" ]
904
+
905
+ if distributed :
906
+ fieldBar = DASolver .vec2Array (prodVec )
907
+ else :
908
+ fieldBar = DASolver .convertMPIVec2SeqArray (prodVec )
897
909
d_inputs [inputName ] += fieldBar
898
910
899
911
elif self .dvType [inputName ] == "RegPar" :
@@ -962,27 +974,27 @@ def solve_linear(self, d_outputs, d_residuals, mode):
962
974
# to check if a recompute is needed. In other words, we only recompute the PC for the first obj func
963
975
# adjoint solution
964
976
965
- if DASolver .getOption ("writeDeformedFFDs" ):
966
- if self .DVGeo is None :
967
- raise RuntimeError (
968
- "writeDeformedFFDs is set but no DVGeo object found! Please call add_dvgeo in the run script!"
969
- )
970
- else :
971
- self .DVGeo .writeTecplot ("deformedFFDs_%d.dat" % self .solution_counter )
972
-
973
- if DASolver .getOption ("writeDeformedConstraints" ):
974
- if self .DVCon is None :
975
- raise RuntimeError (
976
- "writeDeformedConstraints is set but no DVCon object found! Please call add_dvcon in the run script!"
977
- )
978
- else :
979
- self .DVCon .writeTecplot ("deformedConstraints_%d.dat" % self .solution_counter )
980
-
981
977
solutionTime , renamed = DASolver .renameSolution (self .solution_counter )
982
978
983
979
if renamed :
984
980
# write the deformed FFD for post-processing
985
- # DASolver.writeDeformedFFDs(self.solution_counter)
981
+ if DASolver .getOption ("writeDeformedFFDs" ):
982
+ if self .DVGeo is None :
983
+ raise RuntimeError (
984
+ "writeDeformedFFDs is set but no DVGeo object found! Please call add_dvgeo in the run script!"
985
+ )
986
+ else :
987
+ self .DVGeo .writeTecplot ("deformedFFDs_%d.dat" % self .solution_counter )
988
+
989
+ # write the deformed constraints for post-processing
990
+ if DASolver .getOption ("writeDeformedConstraints" ):
991
+ if self .DVCon is None :
992
+ raise RuntimeError (
993
+ "writeDeformedConstraints is set but no DVCon object found! Please call add_dvcon in the run script!"
994
+ )
995
+ else :
996
+ self .DVCon .writeTecplot ("deformedConstraints_%d.dat" % self .solution_counter )
997
+
986
998
# print the solution counter
987
999
if self .comm .rank == 0 :
988
1000
print ("Driver total derivatives for iteration: %d" % self .solution_counter )
@@ -1220,7 +1232,11 @@ def setup(self):
1220
1232
nACTDVars = len (designVariables [dvName ]["comps" ])
1221
1233
self .add_input (dvName , distributed = False , shape = nACTDVars , tags = ["mphys_coupling" ])
1222
1234
elif dvType == "Field" : # add field variables
1223
- self .add_input (dvName , distributed = True , shape_by_conn = True , tags = ["mphys_coupling" ])
1235
+ # user can prescribe whether the field var is distributed. Default is True
1236
+ distributed = True
1237
+ if "distributed" in designVariables [dvName ]:
1238
+ distributed = designVariables [dvName ]["distributed" ]
1239
+ self .add_input (dvName , distributed = distributed , shape_by_conn = True , tags = ["mphys_coupling" ])
1224
1240
elif dvType == "RegPar" :
1225
1241
nParameters = self .DASolver .solver .getNRegressionParameters ()
1226
1242
self .add_input (dvName , distributed = False , shape = nParameters , tags = ["mphys_coupling" ])
@@ -1421,7 +1437,17 @@ def compute_jacvec_product(self, inputs, d_inputs, d_outputs, mode):
1421
1437
DASolver .solverAD .calcdFdFieldAD (
1422
1438
DASolver .xvVec , DASolver .wVec , objFuncName .encode (), inputName .encode (), dFdField
1423
1439
)
1424
- fieldBar = DASolver .vec2Array (dFdField )
1440
+
1441
+ # user can prescribe whether the field var is distributed. Default is True
1442
+ distributed = True
1443
+ if "distributed" in designVariables [inputName ]:
1444
+ distributed = designVariables [inputName ]["distributed" ]
1445
+
1446
+ if distributed :
1447
+ fieldBar = DASolver .vec2Array (dFdField )
1448
+ else :
1449
+ fieldBar = DASolver .convertMPIVec2SeqArray (dFdField )
1450
+
1425
1451
d_inputs [inputName ] += fieldBar * fBar
1426
1452
1427
1453
elif self .dvType [inputName ] == "RegPar" :
0 commit comments