Skip to content

Commit

Permalink
run_jobs:
Browse files Browse the repository at this point in the history
 - fixed timing & cleanup
 - added recursive
f06:
 - got rid of legacy xlim
 - fixed spastic loading
 - fixed VL/VF not appearing for EAS
 - don't filter flutter modes if damping > 0
 - get rid of double VL/VF elements
  • Loading branch information
SteveDoyle2 committed Jan 24, 2025
1 parent ad55bc0 commit 20a791b
Show file tree
Hide file tree
Showing 7 changed files with 323 additions and 227 deletions.
82 changes: 41 additions & 41 deletions pyNastran/bdf/bdf_interface/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1396,44 +1396,44 @@ def get_param(self, key: str, default: int | float | str | list[float]

#--------------------
# deprecations
@property
def dmis(self) -> dict[str, DMI]:
self.deprecated('dmis', 'dmi', '1.5')
return self.dmi
@property
def dmigs(self) -> dict[str, DMIG]:
self.deprecated('dmig', 'dmigs', '1.5')
return self.dmig
@property
def dmiks(self) -> dict[str, DMIK]:
self.deprecated('dmik', 'dmiks', '1.5')
return self.dmik
@property
def dmijs(self) -> dict[str, DMIJ]:
self.deprecated('dmij', 'dmijs', '1.5')
return self.dmij
@property
def dmijis(self) -> dict[str, DMIJI]:
self.deprecated('dmiji', 'dmiji', '1.5')
return self.dmiji

@dmis.setter
def dmis(self, dmi):
self.deprecated('dmis', 'dmi', '1.5')
self.dmi = dmi
@dmigs.setter
def dmigs(self, dmig):
self.deprecated('dmig', 'dmigs', '1.5')
self.dmig = dmig
@dmiks.setter
def dmiks(self, dmik):
self.deprecated('dmik', 'dmiks', '1.5')
self.dmik = dmik
@dmijs.setter
def dmijs(self, dmij):
self.deprecated('dmij', 'dmijs', '1.5')
self.dmij = dmij
@dmijis.setter
def dmijis(self, dmiji):
self.deprecated('dmiji', 'dmiji', '1.5')
self.dmiji = dmiji
# @property
# def dmis(self) -> dict[str, DMI]:
# self.deprecated('dmis', 'dmi', '1.5')
# return self.dmi
# @property
# def dmigs(self) -> dict[str, DMIG]:
# self.deprecated('dmig', 'dmigs', '1.5')
# return self.dmig
# @property
# def dmiks(self) -> dict[str, DMIK]:
# self.deprecated('dmik', 'dmiks', '1.5')
# return self.dmik
# @property
# def dmijs(self) -> dict[str, DMIJ]:
# self.deprecated('dmij', 'dmijs', '1.5')
# return self.dmij
# @property
# def dmijis(self) -> dict[str, DMIJI]:
# self.deprecated('dmiji', 'dmiji', '1.5')
# return self.dmiji
#
# @dmis.setter
# def dmis(self, dmi):
# self.deprecated('dmis', 'dmi', '1.5')
# self.dmi = dmi
# @dmigs.setter
# def dmigs(self, dmig):
# self.deprecated('dmig', 'dmigs', '1.5')
# self.dmig = dmig
# @dmiks.setter
# def dmiks(self, dmik):
# self.deprecated('dmik', 'dmiks', '1.5')
# self.dmik = dmik
# @dmijs.setter
# def dmijs(self, dmij):
# self.deprecated('dmij', 'dmijs', '1.5')
# self.dmij = dmij
# @dmijis.setter
# def dmijis(self, dmiji):
# self.deprecated('dmiji', 'dmiji', '1.5')
# self.dmiji = dmiji
96 changes: 56 additions & 40 deletions pyNastran/bdf/bdf_interface/write_mesh.py

Large diffs are not rendered by default.

70 changes: 51 additions & 19 deletions pyNastran/bdf/test/run_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
import pyNastran
from pyNastran.utils import print_bad_path
from pyNastran.utils.nastran_utils import run_nastran
from pyNastran.utils.dev import get_files_of_type


def cmd_line_run_jobs(argv=None, quiet: bool=False):
"""
run_nastran_job dirname
run_nastran_job filename.bdf -x C:\bin\nastran.exe
run_nastran_job . -x C:\bin\nastran.exe
run_nastran_job . -x C:\bin\nastran.exe --cleanup -r
"""
FILE = os.path.abspath(__file__)
if argv is None:
Expand All @@ -27,7 +28,8 @@ def cmd_line_run_jobs(argv=None, quiet: bool=False):
parser.add_argument("bdf_dirname_filename", help='path to Nastran filename')
#parser.add_argument('-o', '--overwrite', default=False, help='overwrite files')
parser.add_argument('-x', '--exe', default='nastran', help='path to Nastran execuable')
parser.add_argument('-c', '--cleanup', default=True, help='cleanup the junk output files (log, f04, plt)')
parser.add_argument('-c', '--cleanup', action='store_true', help='cleanup the junk output files (log, f04, plt)')
parser.add_argument('-r', '--recursive', action='store_false', help='recursively search for directories')
#parent_parser.add_argument('-h', '--help', help='show this help message and exits', action='store_true')
parser.add_argument('-v', '--version', action='version',
version=pyNastran.__version__)
Expand All @@ -36,23 +38,26 @@ def cmd_line_run_jobs(argv=None, quiet: bool=False):
if not quiet: # pragma: no cover
print(args)

recursive = args.recursive
bdf_filename_dirname = Path(args.bdf_dirname_filename)
nastran_exe = args.exe
if nastran_exe is None:
nastran_exe = 'nastran'
elif '.bat' in nastran_exe or '.exe' in nastran_exe:
# if nastran_exe is None:
# nastran_exe = 'nastran'
if '.bat' in nastran_exe or '.exe' in nastran_exe:
nastran_exe = Path(nastran_exe)
assert nastran_exe.exists(), print_bad_path(nastran_exe)
assert nastran_exe.is_file(), nastran_exe

cleanup = args.cleanup
extensions = ['.dat', '.bdf']
run_jobs(bdf_filename_dirname, nastran_exe,
extensions=extensions, cleanup=cleanup)
extensions=extensions, cleanup=cleanup,
recursive=True)


def get_bdf_filenames_to_run(bdf_filename_dirname: Path | list[Path],
extensions: list[str]) -> list[Path]:
extensions: list[str],
recursive: bool=False) -> list[Path]:
if isinstance(extensions, str):
extensions = [extensions]
assert isinstance(extensions, list), extensions
Expand All @@ -71,10 +76,18 @@ def get_bdf_filenames_to_run(bdf_filename_dirname: Path | list[Path],
for bdf_filename_dirnamei in bdf_filename_dirname_list:
assert bdf_filename_dirnamei.exists(), bdf_filename_dirnamei
if bdf_filename_dirnamei.is_dir():
dirname = bdf_filename_dirnamei
#suffixs = [fname.suffix for fname in dirname.iterdir() if '.test_bdf.' not in fname.name]
bdf_filenamesi = [dirname / fname.name for fname in dirname.iterdir()
if fname.suffix in extensions and '.test_bdf.' not in fname.name]
dirname = os.path.abspath(bdf_filename_dirnamei)
if recursive:
bdf_filenamesi = []
for ext in extensions:
files = get_files_of_type(
dirname, extension=ext, max_size=0.) # no size limit (in MB)
bdf_filenamesi += [Path(fname) for fname in files
if '.test_bdf.' not in os.path.basename(fname)]
else:
#suffixs = [fname.suffix for fname in dirname.iterdir() if '.test_bdf.' not in fname.name]
bdf_filenamesi = [dirname / fname.name for fname in dirname.iterdir()
if fname.suffix in extensions and '.test_bdf.' not in fname.name]
assert len(bdf_filenamesi) > 0, dirname

elif bdf_filename_dirnamei.is_file():
Expand All @@ -84,15 +97,24 @@ def get_bdf_filenames_to_run(bdf_filename_dirname: Path | list[Path],
bdf_filenames.extend(bdf_filenamesi)
for bdf_filename in bdf_filenames:
assert bdf_filename.exists(), print_bad_path(bdf_filename)
assert len(bdf_filenames) > 0, bdf_filenames
return bdf_filenames


def run_jobs(bdf_filename_dirname: Path, nastran_exe: str | Path,
extensions: list[str], cleanup: bool=True,
recursive: bool=False,
run: bool=True) -> int:
"""runs a series of jobs in a specific folder"""
"""runs a series of jobs in a specific folder
Parameters
----------
recursive: bool; default=False
finds all bdf/dat files in all sub-directories
NOTE: doesn't apply to files
"""
bdf_filenames = get_bdf_filenames_to_run(
bdf_filename_dirname, extensions)
bdf_filename_dirname, extensions, recursive=recursive)

log = SimpleLogger(level='debug')
bdf_filenames_str = [str(bdf_filename) for bdf_filename in bdf_filenames]
Expand All @@ -101,6 +123,7 @@ def run_jobs(bdf_filename_dirname: Path, nastran_exe: str | Path,
assert bdf_filename.exists(), print_bad_path(bdf_filename)

nfiles = len(bdf_filenames)
t_run_min = 0.
t_est_min = 0.
t_est_hr = 0.
t0 = time.time()
Expand All @@ -111,15 +134,24 @@ def run_jobs(bdf_filename_dirname: Path, nastran_exe: str | Path,
log.warning(f'skipping {str(bdf_filename)} because {op2_filename} already exists')
continue

percent = (ifile + 1) / nfiles * 100
log.debug(f'estimated time remaining: {t_est_min:.0f} min = {t_est_hr:.1f} hr')
log.info(f'running {ifile+1}/{nfiles}={percent:.0f}%: {str(bdf_filename)}')
#nfiles_remaining0 = nfiles - ifile
nfiles_remaining1 = nfiles - (ifile + 1)
percent0 = ifile / nfiles * 100
percent1 = (ifile + 1) / nfiles * 100
log.debug(f'estimated time remaining: {t_est_min:.0f} min = {t_est_hr:.1f} hr; time/run={t_run_min:.1f} min')
log.info(f'running {ifile+1}/{nfiles}={percent0:.0f}%: {str(bdf_filename)}')
run_nastran(bdf_filename, nastran_cmd=nastran_exe,
cleanup=cleanup, run=run)
log.debug(f'finished {ifile+1}/{nfiles}={percent:.0f}%: {str(bdf_filename)}')
log.debug(f'finished {ifile+1}/{nfiles}={percent1:.0f}%: {str(bdf_filename)}')

# if 0:
dt = time.time() - t0
t_est = (ifile / nfiles) * dt
t_est_min = t_est / 60.
# else:
# dt = 20. * 60. * (ifile + 1)

t_run_min = dt / (ifile + 1) / 60
t_est_sec = dt * nfiles_remaining1 / (ifile + 1)
t_est_min = t_est_sec / 60.
t_est_hr = t_est_min / 60.
log.info('done')
return nfiles
Expand Down
Loading

0 comments on commit 20a791b

Please sign in to comment.