Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
hysop
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
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
particle_methods
hysop
Commits
880d668c
Commit
880d668c
authored
6 years ago
by
Jean-Baptiste Keck
Browse files
Options
Downloads
Patches
Plain Diff
added hyperbolic function
parent
ef43a7e0
No related branches found
No related tags found
1 merge request
!3
Resolve "Sine and cosine transforms to solve homogeneous Neumann and Dirichlet problems"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/sediment_deposit/sediment_deposit_levelset.py
+25
-14
25 additions, 14 deletions
examples/sediment_deposit/sediment_deposit_levelset.py
hysop/backend/device/codegen/symbolic/map.py
+8
-4
8 additions, 4 deletions
hysop/backend/device/codegen/symbolic/map.py
with
33 additions
and
18 deletions
examples/sediment_deposit/sediment_deposit_levelset.py
+
25
−
14
View file @
880d668c
...
...
@@ -8,7 +8,10 @@ TANK_RATIO = 1
FILL_PCT
=
0.25
SEDIMENT_RADIUS
=
5e-3
SEDIMENT_COUNT
=
int
(
1.15
*
(
FILL_PCT
*
TANK_RATIO
/
(
np
.
pi
*
SEDIMENT_RADIUS
**
2
)))
DISCRETIZATION
=
4096
DISCRETIZATION
=
2048
BLOB_INIT
=
False
NB
=
5
# initialize vorticity
def
init_vorticity
(
data
,
coords
,
component
=
None
):
...
...
@@ -32,18 +35,21 @@ def init_phi(data, coords, nblobs, rblob):
R2
=
rblob
*
rblob
cache_file
=
'
/tmp/C_init_ls_{}_{}
'
.
format
(
'
_
'
.
join
(
str
(
x
)
for
x
in
data
.
shape
),
str
(
abs
(
hash
((
TANK_RATIO
,
nblobs
,
rblob
)))))
str
(
abs
(
hash
((
BLOB_INIT
,
NB
,
TANK_RATIO
,
nblobs
,
rblob
)))))
try
:
D
=
np
.
load
(
file
=
cache_file
+
'
.npz
'
)
vprint
(
'
*Initializing sediments from cache:
"
{}.npz
"
.
'
.
format
(
cache_file
))
data
[...]
=
D
[
'
data
'
]
except
:
vprint
(
'
*Initializing sediments of radius {} with {} random blobs.
'
.
format
(
rblob
,
nblobs
))
nb
=
5
data
[...]
=
np
.
sin
(
2
*
np
.
pi
*
nb
*
X
)
*
np
.
sin
(
2
*
np
.
pi
*
nb
*
Y
)
return
if
not
BLOB_INIT
:
vprint
(
'
*Initializing sediments with sines...
'
)
data
[...]
=
np
.
sin
(
2
*
np
.
pi
*
NB
*
X
)
*
np
.
sin
(
2
*
np
.
pi
*
NB
*
Y
)
data
[...]
=
np
.
abs
(
data
)
return
# we cache initialization
vprint
(
'
*Initializing sediments of radius {} with {} random blobs.
'
.
format
(
rblob
,
nblobs
))
np
.
savez_compressed
(
file
=
cache_file
,
data
=
data
)
vprint
(
'
*Caching data to
"
{}.npz
"
.
'
.
format
(
cache_file
))
...
...
@@ -230,7 +236,11 @@ def compute(args):
#e3 = Assignment(H, H_eps)
#e4 = Assignment(Ss, S1 + (S2-S1)*H)
#exprs = (e0,e1,e2,e3,e4)
e
=
Assignment
(
Ss
,
0.5
*
LogicalLE
(
phis
,
0
))
if
BLOB_INIT
:
e
=
Assignment
(
Ss
,
0.5
*
LogicalLE
(
phis
,
0
))
else
:
e
=
Assignment
(
Ss
,
0.5
*
LogicalGT
(
phis
,
0.5
))
#e = Assignment(Ss, 0.5*LogicalLE(phis, 0))
exprs
=
(
e
,)
eval_fields
=
DirectionalSymbolic
(
name
=
'
eval_fields
'
,
pretty_name
=
u
'
{}({})
'
.
format
(
...
...
@@ -305,8 +315,8 @@ def compute(args):
dump_fields
=
HDF_Writer
(
name
=
'
dump
'
,
io_params
=
io_params
,
force_backend
=
Backend
.
OPENCL
,
variables
=
{
velo
:
npts
,
vorti
:
npts
,
variables
=
{
#
velo: npts,
#
vorti: npts,
phi
:
npts
,
S
:
npts
},
**
extra_op_kwds
)
...
...
@@ -324,7 +334,7 @@ def compute(args):
### Adaptive timestep operator
adapt_dt
=
AdaptiveTimeStep
(
dt
,
equivalent_CFL
=
True
,
name
=
'
merge_dt
'
,
pretty_name
=
'
dt
'
,
max_dt
=
1e-
1
)
max_dt
=
1
)
dt_cfl
=
adapt_dt
.
push_cfl_criteria
(
cfl
=
args
.
cfl
,
Finf
=
min_max_U
.
Finf
,
equivalent_CFL
=
True
,
...
...
@@ -376,7 +386,8 @@ def compute(args):
# Initialize vorticity, velocity, S on all topologies
problem
.
initialize_field
(
field
=
velo
,
formula
=
init_velocity
)
problem
.
initialize_field
(
field
=
vorti
,
formula
=
init_vorticity
)
problem
.
initialize_field
(
field
=
phi
,
formula
=
init_phi
,
nblobs
=
nblobs
,
rblob
=
rblob
,
without_ghosts
=
True
)
problem
.
initialize_field
(
field
=
phi
,
formula
=
init_phi
,
nblobs
=
nblobs
,
rblob
=
rblob
,
without_ghosts
=
BLOB_INIT
)
# Finally solve the problem
problem
.
solve
(
simu
,
dry_run
=
args
.
dry_run
)
...
...
@@ -418,9 +429,9 @@ if __name__=='__main__':
parser
.
set_defaults
(
impl
=
'
cl
'
,
ndim
=
2
,
npts
=
(
TANK_RATIO
*
DISCRETIZATION
+
1
,
DISCRETIZATION
+
1
),
box_origin
=
(
0.0
,),
box_length
=
(
1.0
,),
tstart
=
0.0
,
tend
=
100
00
.1
,
dt
=
1e-6
,
cfl
=
0.5
0
,
lcfl
=
0.50
,
dump_times
=
tuple
(
float
(
100
*
x
)
for
x
in
range
(
10
0
)),
tstart
=
0.0
,
tend
=
100.1
,
dt
=
1e-6
,
cfl
=
8.0
0
,
lcfl
=
0.50
,
dump_times
=
tuple
(
float
(
5
*
x
)
for
x
in
range
(
2
0
)),
dump_freq
=
0
)
parser
.
run
(
compute
)
...
...
This diff is collapsed.
Click to expand it.
hysop/backend/device/codegen/symbolic/map.py
+
8
−
4
View file @
880d668c
...
...
@@ -39,7 +39,8 @@ def map_expression(csc, expr, args, reqs):
def
_map_ctypes
(
expr
,
args
):
if
isinstance
(
expr
,
sm
.
functions
.
elementary
.
trigonometric
.
TrigonometricFunction
):
if
isinstance
(
expr
,
(
sm
.
functions
.
elementary
.
trigonometric
.
TrigonometricFunction
,
sm
.
functions
.
elementary
.
hyperbolic
.
HyperbolicFunction
)):
(
args
,
ctype
)
=
OpenClCastUtils
.
promote_expressions_to_required_signature
(
args
,
'
ftype
'
,
ret
=
0
)
elif
isinstance
(
expr
,
Select
):
...
...
@@ -133,7 +134,10 @@ _func_mappings = {
Select
:
OpenClSelect
,
BroadCast
:
OpenClBroadCast
,
Expand
:
OpenClExpand
,
sm
.
cos
:
BuiltinFunction
(
'
cos
'
),
sm
.
sin
:
BuiltinFunction
(
'
sin
'
),
sm
.
tan
:
BuiltinFunction
(
'
tan
'
),
sm
.
cos
:
BuiltinFunction
(
'
cos
'
),
sm
.
sin
:
BuiltinFunction
(
'
sin
'
),
sm
.
tan
:
BuiltinFunction
(
'
tan
'
),
sm
.
cosh
:
BuiltinFunction
(
'
cosh
'
),
sm
.
sinh
:
BuiltinFunction
(
'
sinh
'
),
sm
.
tanh
:
BuiltinFunction
(
'
tanh
'
),
}
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