Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TurTLE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TurTLE
TurTLE
Commits
851dbd7f
Commit
851dbd7f
authored
9 years ago
by
Cristian Lalescu
Browse files
Options
Downloads
Patches
Plain Diff
slight differentiation of parameters per base class
parent
9ce7c5ff
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
bfps/Launcher.py
+77
-50
77 additions, 50 deletions
bfps/Launcher.py
bfps/__main__.py
+4
-0
4 additions, 0 deletions
bfps/__main__.py
tests/test_main.py
+6
-0
6 additions, 0 deletions
tests/test_main.py
with
87 additions
and
50 deletions
bfps/Launcher.py
+
77
−
50
View file @
851dbd7f
...
...
@@ -38,34 +38,83 @@ class Launcher:
self
,
base_class
=
NavierStokes
):
self
.
base_class
=
base_class
self
.
parser
=
argparse
.
ArgumentParser
(
prog
=
'
bfps
'
+
self
.
base_class
.
__name__
)
self
.
parser
=
argparse
.
ArgumentParser
(
prog
=
'
bfps-
'
+
self
.
base_class
.
__name__
)
# generic arguments, all classes may use these
self
.
parser
.
add_argument
(
'
-v
'
,
'
--version
'
,
action
=
'
version
'
,
version
=
'
%(prog)s
'
+
bfps
.
__version__
)
self
.
parser
.
add_argument
(
'
-n
'
,
type
=
int
,
dest
=
'
n
'
,
default
=
32
,
metavar
=
'
N
'
,
help
=
'
code is run by default in a grid of NxNxN
'
)
self
.
parser
.
add_argument
(
'
--ncpu
'
,
type
=
int
,
dest
=
'
ncpu
'
,
default
=
2
)
self
.
parser
.
add_argument
(
'
--precision
'
,
type
=
str
,
dest
=
'
precision
'
,
default
=
'
single
'
)
self
.
parser
.
add_argument
(
'
--simname
'
,
type
=
str
,
dest
=
'
simname
'
,
default
=
'
test
'
)
self
.
parser
.
add_argument
(
'
--environment
'
,
type
=
str
,
dest
=
'
environment
'
,
default
=
''
)
self
.
parser
.
add_argument
(
'
--wd
'
,
type
=
str
,
dest
=
'
work_dir
'
,
default
=
'
./
'
)
# now add class specific arguments
self
.
add_class_specific_arguments
(
self
.
base_class
.
__name__
)
# now add code parameters
c
=
self
.
base_class
()
for
k
in
sorted
(
c
.
parameters
.
keys
()):
self
.
parser
.
add_argument
(
'
--{0}
'
.
format
(
k
),
type
=
type
(
c
.
parameters
[
k
]),
dest
=
k
,
default
=
None
)
return
None
def
add_class_specific_arguments
(
self
,
class_name
):
"""
add arguments specific to different classes.
.. warning:: Reimplement this for custom classes.
"""
if
class_name
in
[
'
NavierStokes
'
,
'
FluidResize
'
]:
self
.
parser
.
add_argument
(
'
--src-wd
'
,
type
=
str
,
dest
=
'
src_work_dir
'
,
default
=
'
./
'
)
self
.
parser
.
add_argument
(
'
--src-simname
'
,
type
=
str
,
dest
=
'
src_simname
'
,
default
=
''
)
self
.
parser
.
add_argument
(
'
--src-iteration
'
,
type
=
int
,
dest
=
'
src_iteration
'
,
default
=
0
)
if
class_name
==
'
FluidResize
'
:
self
.
parser
.
add_argument
(
'
-n
'
,
type
=
int
,
dest
=
'
n
'
,
default
=
32
,
metavar
=
'
N
'
,
help
=
'
resize to N
'
)
if
class_name
==
'
NavierStokes
'
:
self
.
parser
.
add_argument
(
'
-n
'
,
type
=
int
,
dest
=
'
n
'
,
default
=
32
,
metavar
=
'
N
'
,
help
=
'
code is run by default in a grid of NxNxN
'
)
self
.
parser
.
add_argument
(
'
--precision
'
,
type
=
str
,
dest
=
'
precision
'
,
default
=
'
single
'
)
self
.
parser
.
add_argument
(
'
--njobs
'
,
type
=
int
,
dest
=
'
njobs
'
,
...
...
@@ -86,33 +135,11 @@ class Launcher:
dest
=
'
dtfactor
'
,
default
=
0.5
,
help
=
'
dt is computed as DTFACTOR / N
'
)
self
.
parser
.
add_argument
(
'
--environment
'
,
type
=
str
,
dest
=
'
environment
'
,
default
=
''
)
self
.
parser
.
add_argument
(
'
--src-simname
'
,
type
=
str
,
dest
=
'
src_simname
'
,
default
=
''
)
self
.
parser
.
add_argument
(
'
--src-iteration
'
,
type
=
int
,
dest
=
'
src_iteration
'
,
default
=
0
)
self
.
parser
.
add_argument
(
'
--particle-rand-seed
'
,
type
=
int
,
dest
=
'
particle_rand_seed
'
,
default
=
None
)
c
=
self
.
base_class
()
for
k
in
sorted
(
c
.
parameters
.
keys
()):
self
.
parser
.
add_argument
(
'
--{0}
'
.
format
(
k
),
type
=
type
(
c
.
parameters
[
k
]),
dest
=
k
,
default
=
None
)
return
None
def
__call__
(
self
,
...
...
This diff is collapsed.
Click to expand it.
bfps/__main__.py
+
4
−
0
View file @
851dbd7f
...
...
@@ -45,7 +45,11 @@ def main():
'
FluidConvert
'
,
'
FluidResize
'
],
type
=
str
)
# first option is the choice of base class or -h or -v
# all other options are passed on to the Launcher instance
opt
=
parser
.
parse_args
(
sys
.
argv
[
1
:
2
])
# error is thrown if first option is not a base class, so Launcher
# cannot be executed by mistake.
l
=
eval
(
'
Launcher(base_class = {0})
'
.
format
(
opt
.
base_class
))
l
(
sys
.
argv
[
2
:])
return
None
...
...
This diff is collapsed.
Click to expand it.
tests/test_main.py
0 → 100644
+
6
−
0
View file @
851dbd7f
import
bfps
from
bfps.__main__
import
main
if
__name__
==
'
__main__
'
:
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment