Skip to content

Commit fac1e22

Browse files
committed
Update funtofem_model.py
1 parent 754486d commit fac1e22

File tree

1 file changed

+54
-45
lines changed

1 file changed

+54
-45
lines changed

funtofem/model/funtofem_model.py

+54-45
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,7 @@ def load_adjoint_states(self, comm, scenario):
14791479
return
14801480

14811481
def print_summary(
1482-
self, print_level=0, print_model_details=True, ignore_rigid=False
1482+
self, comm=None, print_level=0, print_model_details=True, ignore_rigid=False
14831483
):
14841484
"""
14851485
Print out a summary of the assembled model for inspection
@@ -1489,53 +1489,62 @@ def print_summary(
14891489
print_level: int
14901490
how much detail to print in the summary. Print level < 0 does not print all the variables
14911491
"""
1492+
print_here = True
1493+
if comm is not None:
1494+
comm.Barrier()
1495+
if comm.rank != 0:
1496+
print_here = False
1497+
1498+
if print_here:
1499+
print("==========================================================")
1500+
print("|| FUNtoFEM Model Summary ||")
1501+
print("==========================================================")
1502+
print(self)
1503+
1504+
if print_model_details:
1505+
self._print_functions()
1506+
self._print_variables()
1507+
1508+
print("\n------------------")
1509+
print("| Bodies Summary |")
1510+
print("------------------")
1511+
for body in self.bodies:
1512+
print(body)
1513+
for vartype in body.variables:
1514+
print("\n Variable type:", vartype)
1515+
print(
1516+
" Number of",
1517+
vartype,
1518+
"variables:",
1519+
len(body.variables[vartype]),
1520+
)
1521+
if (vartype == "rigid_motion") and ignore_rigid:
1522+
print(" Ignoring rigid_motion vartype list.")
1523+
else:
1524+
if print_level >= 0:
1525+
body._print_variables(vartype)
14921526

1493-
print("==========================================================")
1494-
print("|| FUNtoFEM Model Summary ||")
1495-
print("==========================================================")
1496-
print(self)
1497-
1498-
if print_model_details:
1499-
self._print_functions()
1500-
self._print_variables()
1501-
1502-
print("\n------------------")
1503-
print("| Bodies Summary |")
1504-
print("------------------")
1505-
for body in self.bodies:
1506-
print(body)
1507-
for vartype in body.variables:
1508-
print("\n Variable type:", vartype)
1509-
print(
1510-
" Number of",
1511-
vartype,
1512-
"variables:",
1513-
len(body.variables[vartype]),
1514-
)
1515-
if (vartype == "rigid_motion") and ignore_rigid:
1516-
print(" Ignoring rigid_motion vartype list.")
1517-
else:
1527+
print(" ")
1528+
print("--------------------")
1529+
print("| Scenario Summary |")
1530+
print("--------------------")
1531+
for scenario in self.scenarios:
1532+
print(scenario)
1533+
scenario._print_functions()
1534+
1535+
for vartype in scenario.variables:
1536+
print(" Variable type:", vartype)
1537+
print(
1538+
" Number of",
1539+
vartype,
1540+
"variables:",
1541+
len(scenario.variables[vartype]),
1542+
)
15181543
if print_level >= 0:
1519-
body._print_variables(vartype)
1544+
scenario._print_variables(vartype)
15201545

1521-
print(" ")
1522-
print("--------------------")
1523-
print("| Scenario Summary |")
1524-
print("--------------------")
1525-
for scenario in self.scenarios:
1526-
print(scenario)
1527-
scenario._print_functions()
1528-
1529-
for vartype in scenario.variables:
1530-
print(" Variable type:", vartype)
1531-
print(
1532-
" Number of",
1533-
vartype,
1534-
"variables:",
1535-
len(scenario.variables[vartype]),
1536-
)
1537-
if print_level >= 0:
1538-
scenario._print_variables(vartype)
1546+
if comm is not None:
1547+
comm.Barrier()
15391548

15401549
return
15411550

0 commit comments

Comments
 (0)