Skip to content

Commit 3c8d5b1

Browse files
committed
fmk - updating OpenSeesSimulation.py for ibrun offsetes for femora
1 parent 7a3adaa commit 3c8d5b1

File tree

1 file changed

+50
-2
lines changed

1 file changed

+50
-2
lines changed

modules/performSIMULATION/openSees/OpenSeesSimulation.py

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,65 @@ def main(args): # noqa: D103
152152
# Run OpenSees
153153
if subtype == "FemoraInput" or subtype == "SSISimulation":
154154
coresPerModel = samData.get("coresPerModel", 1)
155+
155156
# Run OpenSees in parallel using mpirun
157+
offset = 0
158+
numSamples = 0
159+
160+
coresPerNode = aimData.get("coresPerNode", 1)
161+
nodeCount = aimData.get("nodeCount",1)
162+
totalCores = coresPerNode*nodeCount
163+
164+
try:
165+
uq_data = aimData.get("UQ", {})
166+
print(f"uq_data {uq_data}")
167+
sampling = uq_data.get("samplingMethodData", {})
168+
numSamples = sampling.get("samples")
169+
print(f"numSamples {numSamples}")
170+
171+
# Basic validation
172+
if numSamples is None:
173+
raise KeyError("Missing one or more required keys: UQ.samplingMethodData.samples")
174+
175+
except KeyError as e:
176+
print(f" Key Error Getting NumSamples for femora in OpenSeesSimulation: {e}")
177+
except Exception as e:
178+
print(f" Error Getting numSamples for femora in OpnSeesSimulation: {e}")
179+
180+
181+
print(f"numSamples {numSamples} coresPerModel {coresPerModel} totalCores {totalCores}")
182+
183+
# offset depends on workdir number, workdirs start at 1
184+
# first 0 throgh numSamples-1 for dakota, rest for OpenSeesMP
185+
# numDakotaCores is how many dakota is started with: ibrun -n numDakoraCores dakota ...
186+
187+
numDakotaCores=totalCores/(1+coresPerModel)
188+
cwd = os.getcwd()
189+
x = int(cwd.split('workdir.')[-1])
190+
offset = int(numDakotaCores + ((x-1)%numDakotaCores)*coresPerModel)
191+
156192
if runtype == "runningLocal":
157-
openSeesCommand = f'mpirun -np {coresPerModel} OpenSeesMP example.tcl >> workflow.err 2>&1'
193+
194+
if offset == 0:
195+
openSeesCommand = f'mpirun -np {coresPerModel} OpenSeesMP example.tcl >> workflow.err 2>&1'
196+
else:
197+
openSeesCommand = f'mpirun -o {offset} -np {coresPerModel} OpenSeesMP example.tcl >> workflow.err 2>&1'
158198
elif runtype == "runningRemote":
199+
159200
# For remote runs, we assume OpenSeesMP is available on the remote machine
160-
openSeesCommand = f'ibrun -n {coresPerModel} OpenSeesMP example.tcl >> workflow.err 2>&1'
201+
if offset == 0:
202+
openSeesCommand = f'ibrun -n {coresPerModel} OpenSeesMP example.tcl >> workflow.err 2>&1'
203+
else:
204+
openSeesCommand = f'ibrun -o {offset} -n {coresPerModel} OpenSeesMP example.tcl >> workflow.err 2>&1'
161205
else:
162206
print(f"Error: Unsupported runType '{runtype}' in AIM file.")
163207
exit(1)
208+
209+
print(f" OpenSeesSimulation in workdir.{x}: {openSeesCommand}")
210+
164211
else:
165212
openSeesCommand = 'OpenSees example.tcl >> workflow.err 2>&1'
213+
print(f" OpenSeesSimulation: {openSeesCommand}")
166214

167215

168216
exit_code = subprocess.Popen( # noqa: S602

0 commit comments

Comments
 (0)