Skip to content
Merged
16 changes: 8 additions & 8 deletions src/myna/application/adamantine/temperature_part_pvd/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,55 +84,55 @@ def parse_mynafile_path_to_dict(self, mynafile):

def parse_configure_arguments(self):
"""Check for arguments relevant to the configure step and update app settings"""
self.parser.add_argument(
self.register_argument(
"--mesh-substrate-depth",
default=1e-3,
type=float,
help="Depth of the substrate to mesh below the scan path, in meters",
)
self.parser.add_argument(
self.register_argument(
"--mesh-substrate-xy-pad",
default=0.5e-3,
type=float,
help="XY padding of the substrate relative to the scan "
"path bounds, in meters",
)
self.parser.add_argument(
self.register_argument(
"--mesh-size-factor",
default=1,
type=float,
help="Multiplicative factor to modify the mesh size. "
"In x and y, the mesh size is equal to the factor * nominal spot size. "
"In z, the mesh size is equal to the factor * layer thickness",
)
self.parser.add_argument(
self.register_argument(
"--write-frequency-factor",
default=5,
type=float,
help="Multiplicative factor to modify the output frequency. "
"Output frequency is equal to the"
"(factor * nominal spot size) / median scan speed",
)
self.parser.add_argument(
self.register_argument(
"--convection-heat-transfer-coef",
default=100.0,
type=float,
help="Heat transfer coefficient for the solid & liquid "
"convective boundary condition (W m^-2)",
)
self.parser.add_argument(
self.register_argument(
"--convection-temperature-infty",
default=300.0,
type=float,
help="Temperature at x -> infinity for convective boundary condition (K)",
)
self.parser.add_argument(
self.register_argument(
"--radiation-temperature-infty",
default=300.0,
type=float,
help="Temperature at x -> infinity for radiative boundary condition (K)",
)
self.parser.add_argument(
self.register_argument(
"--courant",
default=0.1,
type=float,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,65 +34,65 @@ def __init__(self):
def parse_configure_arguments(self):
"""Check for arguments relevant to the configure step and update app settings"""
# Parse app-specific arguments
self.parser.add_argument(
self.register_argument(
"--exaca-mesh",
default=2.5e-6,
type=float,
help="Mesh size for the ExaCA simulations, in meters",
)
self.parser.add_argument(
self.register_argument(
"--rx",
default=1e-3,
type=float,
help="(float) width of region along X-axis, in meters",
)
self.parser.add_argument(
self.register_argument(
"--ry",
default=1e-3,
type=float,
help="(float) width of region along Y-axis, in meters",
)
self.parser.add_argument(
self.register_argument(
"--rz",
default=1e-3,
type=float,
help="(float) depth of region along Z-axis, in meters",
)
self.parser.add_argument(
self.register_argument(
"--pad-xy",
default=2e-3,
type=float,
help="(float) size of single-refinement mesh region around"
+ " the double-refined region in XY, in meters",
)
self.parser.add_argument(
self.register_argument(
"--pad-z",
default=1e-3,
type=float,
help="(float) size of single-refinement mesh region around"
+ " the double-refined region in Z, in meters",
)
self.parser.add_argument(
self.register_argument(
"--pad-sub",
default=1e-3,
type=float,
help="(float) size of coarse mesh cubic region below"
+ " the refined regions in Z, in meters",
)
self.parser.add_argument(
self.register_argument(
"--coarse",
default=640e-6,
type=float,
help="(float) size of fine mesh, in meters",
)
self.parser.add_argument(
self.register_argument(
"--refine-layer",
default=5,
type=int,
help="(int) number of region mesh refinement"
+ " levels in layer (each level halves coarse mesh)",
)
self.parser.add_argument(
self.register_argument(
"--refine-region",
default=1,
type=int,
Expand Down Expand Up @@ -478,7 +478,7 @@ def execute_case(self, mynafile):

def postprocess(self):
"""Postprocesses all cases"""
_, _, files_are_valid = self.component.get_output_files()
_, _, files_are_valid = self.get_output_file_status()
if not all(files_are_valid):
mynafiles = self.settings["data"]["output_paths"][self.step_name]
for mynafile in mynafiles:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,19 @@ def __init__(self):
self.class_name = "solidification_region_reduced_stl"
self.stl_mesh_dict_name = "stl_mesh_dict.yaml"

def configure(self):
"""Configure all cases for the application"""
# Check for arguments relevant to the configure step
self.parse_configure_arguments() # args from the AdditiveFOAMRegionReduced app
self.parser.add_argument(
def parse_configure_arguments(self):
self.register_argument(
"--scale",
default=0.001,
type=float,
help="Multiple by which to scale the STL file dimensions (default = 0.001, mm -> m)",
)
self.parse_known_args()
super().parse_configure_arguments()

def configure(self):
"""Configure all cases for the application"""
# Check for arguments relevant to the configure step
self.parse_configure_arguments()

# Get list of expected output files and iterate through the cases
mynafiles = self.settings["data"]["output_paths"][self.step_name]
Expand Down
18 changes: 16 additions & 2 deletions src/myna/application/cubit/cubit.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ class CubitApp(MynaApp):
def __init__(self):
super().__init__()
self.app_type = "cubit"
self.parser.add_argument(

def parse_shared_arguments(self):
self.register_argument(
"--cubitpath",
default=None,
type=str,
help="Path to the root Cubit install directory",
)
self.parse_known_args()

def _validate_cubit_executables(self):
"""Check that Cubit executables are accessible for the parsed options."""

# Check that all needed executables are accessible. This overrides the
# assumed behavior that each app only has one executable passed through the
Expand All @@ -49,3 +53,13 @@ def __init__(self):
)
else:
self.args.exec = original_executable_arg

def parse_configure_arguments(self):
self.parse_shared_arguments()
self.parse_known_args()
self._validate_cubit_executables()

def parse_execute_arguments(self):
self.parse_shared_arguments()
self.parse_known_args()
self._validate_cubit_executables()
35 changes: 15 additions & 20 deletions src/myna/application/cubit/vtk_to_exodus_region/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,39 +32,41 @@ class CubitVtkToExodusApp(CubitApp):
def __init__(self):
super().__init__()
self.class_name = "vtk_to_exodus"
self.parser.add_argument(

def parse_execute_arguments(self):
self.register_argument(
"--field",
default="GrainID",
type=str,
help="(str) field name of material ids in ExaCA VTK file to use for "
+ "conformal meshing",
)
self.parser.add_argument(
self.register_argument(
"--spn",
default="material_ids.spn",
type=str,
help="output file name containing 1D array of material ids in volume",
)
self.parser.add_argument(
self.register_argument(
"--downsample",
default=5,
type=int,
help="Sample frequency in XYZ (1 is full dataset)",
)
self.parser.add_argument(
self.register_argument(
"--sculptflags",
default="-S 2 -CS 5 -LI 2 -OI 150 -df 1 -rb 0.2 -A 7 -SS 5",
type=str,
help="(str) flags to pass to `psculpt` to control mesh generation",
)
self.parser.add_argument(
self.register_argument(
"--exacainput",
default="inputs.json",
type=str,
help="(str) name of input file in ExaCA Myna workflow step template"
+ "generated the VTK file",
)
self.parse_known_args()
super().parse_execute_arguments()

def get_vtk_file_data(self, vtk_file):
"""Extract the data object from a VTK file
Expand Down Expand Up @@ -158,13 +160,7 @@ def mesh_vtk_file(self, vtk_file, exodus_file):
stdout=f,
stderr=subprocess.STDOUT,
)
returncode = process.wait()
if returncode != 0:
error_msg = (
f"Subprocess exited with return code {returncode}."
+ "Check {log_file} for details."
)
raise subprocess.SubprocessError(error_msg)
self.wait_for_process_success(process)

# If mesh was generated in parallel, combine and clean the split mesh
tmp_files = glob.glob(exodus_prefix + ".e.*")
Expand All @@ -175,13 +171,7 @@ def mesh_vtk_file(self, vtk_file, exodus_file):
stdout=f,
stderr=subprocess.STDOUT,
)
returncode = process.wait()
if returncode != 0:
error_msg = (
f"Subprocess exited with return code {returncode}."
+ " Check {log_file} for details."
)
raise subprocess.SubprocessError(error_msg)
self.wait_for_process_success(process)

for tmp_file in tmp_files:
os.remove(tmp_file)
Expand Down Expand Up @@ -239,3 +229,8 @@ def mesh_all_cases(self):
for vtk_file, exodus_file in zip(vtk_files, exodus_files):
if (not os.path.exists(exodus_file)) or (self.args.overwrite):
self.mesh_vtk_file(vtk_file, exodus_file)

def execute(self):
"""Execute all cubit/vtk_to_exodus_region cases."""
self.parse_execute_arguments()
self.mesh_all_cases()
5 changes: 2 additions & 3 deletions src/myna/application/cubit/vtk_to_exodus_region/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@


def execute():
"""Configure all cubit/vtk_to_exodus case directories"""
# Create app instance and configure all cases
"""Execute all cubit/vtk_to_exodus case directories."""
app = CubitVtkToExodusApp()
app.mesh_all_cases()
app.execute()


if __name__ == "__main__":
Expand Down
24 changes: 6 additions & 18 deletions src/myna/application/deer/creep_timeseries_region/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ def __init__(self):

def parse_configure_arguments(self):
"""Check for arguments relevant to the configure step and update app settings"""
self.parser.add_argument(
self.register_argument(
"--loaddir",
default="z",
type=str,
help='(str) loading direction ("x" , "y", "z")',
)
self.parser.add_argument(
self.register_argument(
"--load",
default="100",
type=float,
help="(float) load in Newtons",
)
self.parse_known_args()
super().parse_configure_arguments()

def configure_case(self, case_dir, exodus_file):
"""Configure a single case
Expand Down Expand Up @@ -121,6 +121,7 @@ def run_case(self, exodus_mesh_file, case_dir):

def execute(self):
"""Run all cases for the Myna step"""
self.parse_execute_arguments()
exodus_files = self.settings["data"]["output_paths"][self.last_step_name]
csv_files = self.settings["data"]["output_paths"][self.step_name]
processes = []
Expand All @@ -133,24 +134,11 @@ def execute(self):
if self.args.batch:
processes.append(process)
else:
returncode = process.wait()
if returncode != 0:
error_msg = (
f"Subprocess exited with return code {returncode}."
+ " Check case log files for details."
)
raise subprocess.SubprocessError(error_msg)
self.wait_for_process_success(process)

# Wait for batched jobs to finish
if self.args.batch:
for process in processes:
returncode = process.wait()
if returncode != 0:
error_msg = (
f"Subprocess exited with return code {returncode}. "
+ "Check case log files for details."
)
raise subprocess.SubprocessError(error_msg)
self.wait_for_all_process_success(processes)

# Copy output to the Myna format
# Deer output has the following column names (units):
Expand Down
11 changes: 10 additions & 1 deletion src/myna/application/deer/deer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,19 @@ class DeerApp(MynaApp):
def __init__(self):
super().__init__()
self.app_type = "deer"
self.parser.add_argument(

def parse_shared_arguments(self):
self.register_argument(
"--moosepath",
default=None,
type=str,
help="Path to the root Moose install directory",
)

def parse_configure_arguments(self):
self.parse_shared_arguments()
self.parse_known_args()

def parse_execute_arguments(self):
self.parse_shared_arguments()
self.parse_known_args()
Loading
Loading