Skip to content
Merged
Show file tree
Hide file tree
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
28 changes: 23 additions & 5 deletions examples/exec_scripts/exec_cfx.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ def execute(self):
inputs["cfx_startMethod"] = self.context.execution_context.get("cfx_startMethod", None)
inputs["cfx_runName"] = self.context.execution_context.get("cfx_runName", None)

cclFile = next((f for f in self.context.input_files if f["name"] == "ccl"), None)
if cclFile != None:
inputs["cfx_cclFile"] = cclFile["path"]
log.info("ccl file path: " + cclFile["path"])

defFile = next((f for f in self.context.input_files if f["name"] == "def"), None)
if defFile != None:
inputs["cfx_definitionFile"] = defFile["path"]
log.info("def file path: " + defFile["path"])

self.publish_to_default_log(
"Task inputs after applying default values to missing inputs:"
)
Expand Down Expand Up @@ -142,8 +152,9 @@ def execute(self):

# Create command line
# Add parallel options
cmd = [exe]
cmd.extend(["-fullname", self.active_run_name])
cmd = [os.path.basename(exe)]
cmd.append("-fullname")
cmd.append(self.active_run_name)
cmd.append("-batch")
cmd.append("-serial")

Expand All @@ -162,10 +173,11 @@ def execute(self):
for opt, i in sorted(options_arg.items()):
k = "cfx_" + i
if not inputs[k] == None:
cmd.extend([opt, inputs[k]])
cmd.append(opt)
cmd.append(inputs[k])

# Add additional options
if not inputs["cfx_additionalArgs"] == "":
if not inputs["cfx_additionalArgs"] == "" and not inputs["cfx_additionalArgs"] == None:
cmd.extend(shlex.split(inputs["cfx_additionalArgs"]))

# Start the solver
Expand All @@ -174,7 +186,13 @@ def execute(self):
rc = None
self.CFXOutputFile = None
self.CFXMonFile = None
with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as self.proc:
cfx_env = os.environ.copy()

with subprocess.Popen(
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=cfx_env, executable=exe
) as self.proc:
if self.proc == None:
raise Exception("CFX Solver did not start")
self.publish_to_default_log("CFX solver started\npid:" + format(self.proc.pid))
t1 = _thread.start_new_thread(self.process_output, (self.proc,))
t2 = _thread.start_new_thread(self.process_error, (self.proc,))
Expand Down
10 changes: 6 additions & 4 deletions examples/exec_scripts/exec_fluent.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def execute(self):
"fluent_otherEnvironment", "{}"
)
inputs["fluent_UDFBat"] = self.context.execution_context.get("fluent_UDFBat", None)
inputs["fluent_jouFile"] = self.context.execution_context.get("fluent_jouFile", None)
inputs["fluent_useGUI"] = self.context.execution_context.get("fluent_useGUI", False)
inputs["fluent_additionalArgs"] = self.context.execution_context.get(
"fluent_additionalArgs", ""
Expand Down Expand Up @@ -106,8 +105,11 @@ def execute(self):
for f in files:
log.info(" " + f)

if not os.path.isfile(inputs["fluent_jouFile"]):
raise Exception("File " + inputs["fluent_jouFile"] + " does not exist!")
jouFile = next((f for f in self.context.input_files if f["name"] == "jou"), None)
log.info("journal file path: " + jouFile["path"])

if jouFile == None or not os.path.isfile(jouFile["path"]):
raise Exception("File " + jouFile["path"] + " does not exist!")

# Add " around exe if needed for Windows
exe = app["executable"] # should already be platform specific
Expand Down Expand Up @@ -137,7 +139,7 @@ def execute(self):
args += " -mpi=" + format(inputs["fluent_MPIType"])
if inputs["fluent_numGPGPUsPerMachine"] > 0:
args += " -gpgp=" + format(inputs["fluent_numGPGPUsPerMachine"])
args += " -i " + inputs["fluent_jouFile"]
args += " -i " + jouFile["path"]
# args+= cnf
if not noGuiOptions == None:
args += noGuiOptions
Expand Down
1 change: 0 additions & 1 deletion examples/fluent_nozzle/project_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ def create_project(client, name, num_jobs=20, version=__external_version__):
"fluent_numGPGPUsPerMachine": 0,
"fluent_MPIType": "intel",
"fluent_otherEnvironment": "{}",
"fluent_jouFile": "solve.jou",
"fluent_useGUI": False,
},
max_execution_time=50.0,
Expand Down