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
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ dependencies:
- pyiron_base=0.11.8
- pygraphviz=1.14
- aiida-workgraph=0.5.1
- conda_subprocess =0.0.6
42 changes: 23 additions & 19 deletions nfdi_ing_workflow.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
import subprocess
from conda_subprocess import check_output
import shutil

source_directory = os.path.join(os.path.dirname(os.path.abspath(__file__)), "source")
Expand All @@ -11,24 +11,26 @@ def generate_mesh(domain_size: float = 2.0) -> str:
source_file_name ="unit_square.geo"
os.makedirs(stage_name, exist_ok=True)
_copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name)
_ = subprocess.check_output(
_ = check_output(
[
"conda", "run", "-n", stage_name, "gmsh", "-2", "-setnumber",
"domain_size", str(domain_size), source_file_name, "-o", gmsh_output_file_name
"gmsh", "-2", "-setnumber", "domain_size", str(domain_size),
source_file_name, "-o", gmsh_output_file_name
],
prefix_name=stage_name,
cwd=stage_name,
universal_newlines=True,
).split("\n")
return os.path.abspath(os.path.join(stage_name, gmsh_output_file_name))


def convert_to_xdmf(gmsh_output_file : str) -> str:
def convert_to_xdmf(gmsh_output_file : str) -> dict:
stage_name = "preprocessing"
meshio_output_file_name = "square.xdmf"
os.makedirs(stage_name, exist_ok=True)
_copy_file(stage_name=stage_name, source_file=gmsh_output_file)
_ = subprocess.check_output(
["conda", "run", "-n", stage_name, "meshio", "convert", os.path.basename(gmsh_output_file), meshio_output_file_name],
_ = check_output(
["meshio", "convert", os.path.basename(gmsh_output_file), meshio_output_file_name],
prefix_name=stage_name,
cwd=stage_name,
universal_newlines=True,
).split("\n")
Expand All @@ -47,12 +49,12 @@ def poisson(meshio_output_xdmf: str, meshio_output_h5: str) -> dict:
_copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name)
_copy_file(stage_name=stage_name, source_file=meshio_output_xdmf)
_copy_file(stage_name=stage_name, source_file=meshio_output_h5)
_ = subprocess.check_output(
_ = check_output(
[
"conda", "run", "-n", stage_name, "python", "poisson.py",
"--mesh", os.path.basename(meshio_output_xdmf), "--degree", "2",
"python", "poisson.py", "--mesh", os.path.basename(meshio_output_xdmf), "--degree", "2",
"--outputfile", poisson_output_pvd_file_name, "--num-dofs", poisson_output_numdofs_file_name
],
prefix_name=stage_name,
cwd=stage_name,
universal_newlines=True,
).split("\n")
Expand All @@ -71,8 +73,9 @@ def plot_over_line(poisson_output_pvd_file: str, poisson_output_vtu_file: str) -
_copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name)
_copy_file(stage_name=stage_name, source_file=poisson_output_pvd_file)
_copy_file(stage_name=stage_name, source_file=poisson_output_vtu_file)
_ = subprocess.check_output(
["conda", "run", "-n", stage_name, "pvbatch", source_file_name, os.path.basename(poisson_output_pvd_file), pvbatch_output_file_name],
_ = check_output(
["pvbatch", source_file_name, os.path.basename(poisson_output_pvd_file), pvbatch_output_file_name],
prefix_name=stage_name,
cwd=stage_name,
universal_newlines=True,
).split("\n")
Expand All @@ -88,13 +91,13 @@ def substitute_macros(pvbatch_output_file: str, ndofs: int, domain_size: float =
_copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name)
_copy_file_from_source(stage_name=stage_name, source_file_name=template_file_name)
_copy_file(stage_name=stage_name, source_file=pvbatch_output_file)
_ = subprocess.check_output(
_ = check_output(
[
"conda", "run", "-n", stage_name, "python", "prepare_paper_macros.py",
"--macro-template-file", template_file_name, "--plot-data-path", os.path.basename(pvbatch_output_file),
"--domain-size", str(domain_size), "--num-dofs", str(ndofs),
"--output-macro-file", macros_output_file_name,
"python", "prepare_paper_macros.py", "--macro-template-file", template_file_name,
"--plot-data-path", os.path.basename(pvbatch_output_file), "--domain-size", str(domain_size),
"--num-dofs", str(ndofs), "--output-macro-file", macros_output_file_name,
],
prefix_name=stage_name,
cwd=stage_name,
universal_newlines=True,
).split("\n")
Expand All @@ -109,8 +112,9 @@ def compile_paper(macros_tex: str, plot_file: str) -> str:
_copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name)
_copy_file(stage_name=stage_name, source_file=macros_tex)
_copy_file(stage_name=stage_name, source_file=plot_file)
_ = subprocess.check_output(
["conda", "run", "-n", stage_name, "tectonic", source_file_name],
_ = check_output(
["tectonic", source_file_name],
prefix_name=stage_name,
universal_newlines=True,
cwd=stage_name,
).split("\n")
Expand Down
Loading