Skip to content

Commit

Permalink
Fixed Groups in some Shallow_water examples (#290)
Browse files Browse the repository at this point in the history
* Fixed Groups to reduce time of simulation
  • Loading branch information
yaaanshk committed Dec 23, 2020
1 parent ce5d856 commit 5d5725b
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 246 deletions.
94 changes: 38 additions & 56 deletions pysph/examples/shallow_water/cylindrical_dambreak.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Cylindrical dam break over a dry bed. (3 min)
"""Cylindrical dam break over a dry bed. (1.5 mins)
The case is described in "A corrected smooth particle hydrodynamics formulation
of the shallow-water equations", Miguel Rodriguez-Paz and Javier Bonet,
Expand Down Expand Up @@ -121,72 +121,58 @@ def create_equations(self):
equations = [
Group(
equations=[
InitialGuessDensity(dim=dim, dest='fluid',
sources=['fluid'])
]
),
InitialGuessDensity(dim=dim, dest='fluid',
sources=['fluid']),
UpdateSmoothingLength(dim=dim, dest='fluid')
], update_nnps=True
),

Group(
equations=[
UpdateSmoothingLength(dim=dim, dest='fluid')
], update_nnps=True
),
CorrectionFactorVariableSmoothingLength(
dest='fluid', sources=['fluid']),
SummationDensity(dest='fluid', sources=['fluid']),
DensityResidual('fluid')
]
),

Group(
equations=[
Group(
equations=[
CorrectionFactorVariableSmoothingLength(
dest='fluid', sources=['fluid']
),
]
),
Group(
equations=[
SummationDensity(dest='fluid', sources=['fluid']),
]
),
Group(
equations=[
DensityResidual('fluid'),
DensityNewtonRaphsonIteration(dim=dim,
dest='fluid')
]
),
Group(
equations=[
DensityNewtonRaphsonIteration(dim=dim,
dest='fluid'),
UpdateSmoothingLength(dim=dim, dest='fluid')
], update_nnps=True
),
Group(
equations=[
SummationDensity(dest='fluid', sources=['fluid'])
],
),
], update_nnps=True
),

Group(
equations=[
CorrectionFactorVariableSmoothingLength(
dest='fluid', sources=['fluid']),
SummationDensity(dest='fluid', sources=['fluid']),
DensityResidual(dest='fluid'),
CheckConvergence(dest='fluid')
],
)], iterate=True, max_iterations=10
],
)
], iterate=True, max_iterations=10
),

Group(
equations=[
CorrectionFactorVariableSmoothingLength(
dest='fluid', sources=['fluid']
),
]
),
Group(
equations=[
SWEOS(dest='fluid'),
]
),
dest='fluid', sources=['fluid']),
SWEOS(dest='fluid')
]
),

Group(
equations=[
ParticleAcceleration(dim=dim, dest='fluid',
sources=['fluid']),
],
),
]
sources=['fluid'])
]
),
]
return equations

def post_process(self, info_fname):
Expand Down Expand Up @@ -273,14 +259,10 @@ def compute_initial_props(particles):
Group(
equations=[
CorrectionFactorVariableSmoothingLength(dest='fluid',
sources=['fluid'])
]
),
Group(
equations=[
sources=['fluid']),
SWEOS(dest='fluid')
],
)
]
)
]
kernel = CubicSpline(dim=2)
sph_eval = SPHEvaluator(particles, one_time_equations, dim=2,
Expand Down
94 changes: 38 additions & 56 deletions pysph/examples/shallow_water/cylindrical_dambreak_sloping_bed.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Cylindrical dam break over a sloping parabolic dry bed. (56 min)
"""Cylindrical dam break over a sloping parabolic dry bed. (24 mins)
The case is described in "A corrected smooth particle hydrodynamics formulation
of the shallow-water equations", Miguel Rodriguez-Paz and Javier Bonet,
Expand Down Expand Up @@ -176,86 +176,68 @@ def create_equations(self):
Group(
equations=[
InitialGuessDensity(dim=dim, dest='fluid',
sources=['fluid'])
]
),
sources=['fluid']),
UpdateSmoothingLength(dim=dim, dest='fluid')
], update_nnps=True
),

Group(
equations=[
UpdateSmoothingLength(dim=dim, dest='fluid')
], update_nnps=True
),
CorrectionFactorVariableSmoothingLength(
dest='fluid', sources=['fluid']),
SummationDensity(dest='fluid', sources=['fluid']),
DensityResidual('fluid')
]
),

Group(
equations=[
Group(
equations=[
CorrectionFactorVariableSmoothingLength(
dest='fluid', sources=['fluid']
)
]
),
Group(
equations=[
SummationDensity(dest='fluid', sources=['fluid'])
]
),
Group(
equations=[
DensityResidual('fluid'),
DensityNewtonRaphsonIteration(dim=dim,
dest='fluid')
]
),
Group(
equations=[
DensityNewtonRaphsonIteration(dim=dim,
dest='fluid'),
UpdateSmoothingLength(dim=dim, dest='fluid')
], update_nnps=True
),
Group(
equations=[
SummationDensity(dest='fluid', sources=['fluid'])
],
),
], update_nnps=True
),

Group(
equations=[
CorrectionFactorVariableSmoothingLength(
dest='fluid', sources=['fluid']),
SummationDensity(dest='fluid', sources=['fluid']),
DensityResidual(dest='fluid'),
CheckConvergence(dest='fluid')
],
)], iterate=True, max_iterations=100
],
)
], iterate=True, max_iterations=100
),

Group(
equations=[
CorrectionFactorVariableSmoothingLength(dest='fluid',
sources=['fluid'])
]
),
Group(
equations=[
SWEOS(dest='fluid'),
]
),
sources=['fluid']),
SWEOS(dest='fluid')
]
),

Group(
equations=[
ParticleAccelerationAnalytBottom(dim=dim, dest='fluid',
ParticleAccelerationAnalytBottom(dim=dim, dest='fluid',
sources=['fluid'])
],
),
]
]
)
]
return equations


def compute_initial_props(particles):
one_time_equations = [
Group(
equations=[
CorrectionFactorVariableSmoothingLength(dest='fluid',
sources=['fluid'])
]
),
Group(
equations=[
CorrectionFactorVariableSmoothingLength(dest='fluid',
sources=['fluid']),
SWEOS(dest='fluid')
],
)
]
),
]
kernel = CubicSpline(dim=2)
sph_eval = SPHEvaluator(particles, one_time_equations, dim=2,
Expand Down
95 changes: 39 additions & 56 deletions pysph/examples/shallow_water/rectangular_dambreak.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Rectangular dam break over a dry bed. (23 min)
"""Rectangular dam break over a dry bed. (8 mins)
The case is described in "A corrected smooth particle hydrodynamics formulation
of the shallow-water equations", Miguel Rodriguez-Paz and Javier Bonet,
Expand Down Expand Up @@ -108,70 +108,57 @@ def create_equations(self):
Group(
equations=[
InitialGuessDensity(dim=dim, dest='fluid',
sources=['fluid'])
]
),
sources=['fluid']),
UpdateSmoothingLength(dim=dim, dest='fluid')
], update_nnps=True
),

Group(
equations=[
UpdateSmoothingLength(dim=dim, dest='fluid')
], update_nnps=True
),
CorrectionFactorVariableSmoothingLength(dest='fluid',
sources=['fluid']),
SummationDensity(dest='fluid', sources=['fluid']),
DensityResidual('fluid')
]
),

Group(
equations=[
Group(
equations=[
CorrectionFactorVariableSmoothingLength(
dest='fluid', sources=['fluid']
),
]
),
Group(
equations=[
SummationDensity(dest='fluid', sources=['fluid'])
]
),
Group(
equations=[
DensityResidual('fluid'),
DensityNewtonRaphsonIteration(
dim=dim, dest='fluid')
]
),
Group(
equations=[
DensityNewtonRaphsonIteration(dim=dim,
dest='fluid'),
UpdateSmoothingLength(dim=dim, dest='fluid')
], update_nnps=True
),
Group(
equations=[
SummationDensity(dest='fluid', sources=['fluid'])
],
),
], update_nnps=True
),

Group(
equations=[
CorrectionFactorVariableSmoothingLength(
dest='fluid', sources=['fluid']),
SummationDensity(dest='fluid', sources=['fluid']),
DensityResidual(dest='fluid'),
CheckConvergence(dest='fluid')
],
)], iterate=True, max_iterations=10
],
)
], iterate=True, max_iterations=10
),

Group(
equations=[
CorrectionFactorVariableSmoothingLength(
dest='fluid', sources=['fluid'])
]
),
Group(
equations=[
SWEOS(dest='fluid'),
]
),
CorrectionFactorVariableSmoothingLength(dest='fluid',
sources=['fluid']),
SWEOS(dest='fluid')
]
),

Group(
equations=[
ParticleAcceleration(dim=dim, dest='fluid',
sources=['fluid'], u_only=True),
]
),
]
ParticleAcceleration(dim=dim, dest='fluid',
sources=['fluid'], u_only=True)
]
),
]
return equations

def post_process(self, info_fname):
Expand Down Expand Up @@ -273,14 +260,10 @@ def compute_initial_props(particles):
Group(
equations=[
CorrectionFactorVariableSmoothingLength(dest='fluid',
sources=['fluid'])
]
),
Group(
equations=[
sources=['fluid']),
SWEOS(dest='fluid')
]
)
]
)
]
kernel = CubicSpline(dim=2)
sph_eval = SPHEvaluator(particles, one_time_equations, dim=2,
Expand Down

0 comments on commit 5d5725b

Please sign in to comment.