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
cd9ecd3d
Commit
cd9ecd3d
authored
6 years ago
by
Jean-Baptiste Keck
Browse files
Options
Downloads
Patches
Plain Diff
First try of periodisation
parent
c9e2ba79
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!10
Resolve "Fix default parameters for the periodic bubble example"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/particles_above_salt/particles_above_salt_periodic.py
+18
-5
18 additions, 5 deletions
...les/particles_above_salt/particles_above_salt_periodic.py
hysop/symbolic/directional.py
+12
-5
12 additions, 5 deletions
hysop/symbolic/directional.py
with
30 additions
and
10 deletions
examples/particles_above_salt/particles_above_salt_periodic.py
+
18
−
5
View file @
cd9ecd3d
...
...
@@ -169,9 +169,14 @@ def compute(args):
#> External force rot(-rho*g) = rot(Rs*S + C)
Fext
=
np
.
zeros
(
shape
=
(
dim
,),
dtype
=
object
).
view
(
SymbolicTensor
)
Fext
[
0
]
=
(
Rs
*
Ss
+
Cs
)
lhs
=
Ws
.
diff
(
frame
.
time
)
rhs
=
curl
(
Fext
,
frame
)
zs
=
space_symbols
[
0
]
cond
=
LogicalGT
(
zs
,
0.5
)
#fext = 1.0#-(Rs*Ss + Cs)
#Fext[-1] = fext
lhs
=
S
#Ws.diff(frame.time)
#rhs = curl(Fext, frame)
rhs
=
1.0
rhs
=
Select
(
-
rhs
,
+
rhs
,
cond
)
exprs
=
Assignment
.
assign
(
lhs
,
rhs
)
external_force
=
DirectionalSymbolic
(
name
=
'
Fext
'
,
implementation
=
impl
,
...
...
@@ -209,9 +214,17 @@ def compute(args):
S
:
npts
})
### Adaptive timestep operator
adapt_dt
=
AdaptiveTimeStep
(
dt
,
equivalent_CFL
=
True
,
max_dt
=
1e-3
,
# max_dt for diffusion
dx
=
np
.
min
(
np
.
divide
(
box
.
length
,
args
.
npts
))
dt_w
=
0.5
*
dx
**
2
/
1.0
dt_s
=
0.5
*
dx
**
2
/
nu_S
dt_c
=
0.5
*
dx
**
2
/
nu_C
max_dt
=
min
(
dt_s
,
dt_c
,
dt_w
)
adapt_dt
=
AdaptiveTimeStep
(
dt
,
equivalent_CFL
=
True
,
max_dt
=
max_dt
,
name
=
'
merge_dt
'
,
pretty_name
=
'
dt
'
,
)
dt_cfl
=
adapt_dt
.
push_cfl_criteria
(
cfl
=
args
.
cfl
,
Finf
=
min_max_U
.
Finf
,
dt_cfl
=
adapt_dt
.
push_cfl_criteria
(
cfl
=
args
.
cfl
,
Finf
=
min_max_U
.
Finf
,
equivalent_CFL
=
True
,
name
=
'
dt_cfl
'
,
pretty_name
=
'
CFL
'
)
dt_advec
=
adapt_dt
.
push_advection_criteria
(
lcfl
=
args
.
lcfl
,
Finf
=
min_max_W
.
Finf
,
...
...
This diff is collapsed.
Click to expand it.
hysop/symbolic/directional.py
+
12
−
5
View file @
cd9ecd3d
import
warnings
from
hysop.deps
import
np
,
sm
from
hysop.tools.types
import
first_not_None
,
check_instance
from
hysop.symbolic
import
space_symbols
from
hysop.symbolic.field
import
div
,
grad
from
hysop.tools.warning
import
HysopWarning
def
collect_direction
(
expr
,
var
):
is_tensor
=
isinstance
(
expr
,
np
.
ndarray
)
...
...
@@ -38,11 +40,16 @@ def split(F, coords=None):
coords
=
first_not_None
(
coords
,
space_symbols
)
for
i
,
xi
in
enumerate
(
coords
):
res
[
i
]
=
collect_direction
(
F
,
xi
)
residue
=
(
F
-
sum
(
res
.
values
())).
simplify
()
count
=
sum
((
r
!=
0
)
for
r
in
res
.
values
())
if
(
count
>
0
):
for
i
in
res
.
keys
():
res
[
i
]
+=
(
residue
/
count
)
try
:
residue
=
(
F
-
sum
(
res
.
values
())).
simplify
()
count
=
sum
((
r
!=
0
)
for
r
in
res
.
values
())
if
(
count
>
0
):
for
i
in
res
.
keys
():
res
[
i
]
+=
(
residue
/
count
)
except
AttributeError
:
msg
=
'
Failed to compute residue for expression {}.
'
msg
=
msg
.
format
(
F
)
warnings
.
warn
(
msg
,
HysopWarning
)
return
res
def
split_assignement
(
expr
,
coords
=
None
):
...
...
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