Skip to content

Commit

Permalink
download examples (#574)
Browse files Browse the repository at this point in the history
Co-authored-by: Mohamed Koubaa <koubaa@github.com>
  • Loading branch information
koubaa and Mohamed Koubaa authored Nov 11, 2024
1 parent aa61a7f commit d4f9d9a
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 12,115 deletions.
5 changes: 4 additions & 1 deletion examples/keywords/Buckling_Beer_Can/beercan.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@

from ansys.dyna.core import Deck, keywords as kwd
from ansys.dyna.core.run import run_dyna
from ansys.dyna.core.pre.examples.download_utilities import DownloadManager, EXAMPLES_PATH

mesh_file = DownloadManager().download_file("mesh.k", "ls-dyna", "Buckling_Beer_Can", destination=os.path.join(EXAMPLES_PATH, "Buckling_Beer_Can"))

dynadir = "run"
dynafile = "beer_can.k"
Expand Down Expand Up @@ -566,7 +569,7 @@ def run_post(filepath):


deck = write_deck(os.path.join(dynadir, dynafile))
shutil.copy("mesh.k", "run/mesh.k")
shutil.copy(mesh_file, "run/mesh.k")

###############################################################################
# View the model
Expand Down
6,766 changes: 0 additions & 6,766 deletions examples/keywords/Buckling_Beer_Can/mesh.k

This file was deleted.

1,585 changes: 0 additions & 1,585 deletions examples/keywords/John_Reid_Pendulum/nodes.k

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@

from ansys.dyna.core import Deck, keywords as kwd
from ansys.dyna.core.run import run_dyna
from ansys.dyna.core.pre.examples.download_utilities import DownloadManager, EXAMPLES_PATH

mesh_file = DownloadManager().download_file("nodes.k", "ls-dyna", "John_Reid_Pendulum", destination=os.path.join(EXAMPLES_PATH, "John_Reid_Pendulum"))

#folder = os.path.dirname(output)

dynadir = "run"
dynafile = "pendulum.k"
Expand Down Expand Up @@ -160,7 +165,7 @@ def run_post(filepath):


deck = write_deck(os.path.join(dynadir, dynafile))
shutil.copy("nodes.k", "run/nodes.k")
shutil.copy(mesh_file, "run/nodes.k")

###############################################################################
# View the model
Expand Down
3,759 changes: 0 additions & 3,759 deletions examples/keywords/John_Reid_Pipe/nodes.k

This file was deleted.

5 changes: 4 additions & 1 deletion examples/keywords/John_Reid_Pipe/plot_john_pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@

from ansys.dyna.core import Deck, keywords as kwd
from ansys.dyna.core.run import run_dyna
from ansys.dyna.core.pre.examples.download_utilities import DownloadManager, EXAMPLES_PATH

mesh_file = DownloadManager().download_file("nodes.k", "ls-dyna", "John_Reid_Pipe", destination=os.path.join(EXAMPLES_PATH, "John_Reid_Pipe"))

dynadir = "run"
dynafile = "pipe.k"
Expand Down Expand Up @@ -156,7 +159,7 @@ def run_post(filepath):


deck = write_deck(os.path.join(dynadir, dynafile))
shutil.copy("nodes.k", "run/nodes.k")
shutil.copy(mesh_file, "run/nodes.k")
deck.plot(cwd=dynadir)

###############################################################################
Expand Down
6 changes: 4 additions & 2 deletions examples/keywords/Taylor_Bar/plot_taylor_bar_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@
import ansys.dpf.core as dpf
from ansys.dyna.core import Deck, keywords as kwd
from ansys.dyna.core.run import run_dyna
from ansys.dyna.core.pre.examples.download_utilities import DownloadManager, EXAMPLES_PATH

mesh_file = DownloadManager().download_file("taylor_bar_mesh.k", "ls-dyna", "Taylor_Bar", destination=os.path.join(EXAMPLES_PATH, "Taylor_Bar"))

###############################################################################
# Create a deck and keywords
Expand Down Expand Up @@ -157,7 +159,7 @@ def create_input_deck(**kwargs):
# the absolute path. You may choose to solve this problem in a different
# way, for example by copying the mesh file to that working directory
# before solving and using only the file name without an absolute path
deck.append(kwd.Include(filename=os.path.abspath("taylor_bar_mesh.k")))
deck.append(kwd.Include(filename=mesh_file))

# Convert deck to string
deck_string = deck.write()
Expand All @@ -178,7 +180,7 @@ def create_input_deck(**kwargs):

def run(**kwargs):
wd = kwargs.get("wd")
shutil.copy("taylor_bar_mesh.k", f"{wd}/taylor_bar_mesh.k")
shutil.copy(mesh_file, f"{wd}/taylor_bar_mesh.k")
inputfile = os.path.join(wd, "input.k")
run_dyna(inputfile)
assert os.path.isfile(os.path.join(wd, "d3plot"))
Expand Down

0 comments on commit d4f9d9a

Please sign in to comment.