Skip to content

Commit

Permalink
Added 3d periodic test, removed perftest option from spheral_ats.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ldowen committed Nov 15, 2024
1 parent e351eb4 commit 5d9ea27
Show file tree
Hide file tree
Showing 3 changed files with 201 additions and 7 deletions.
4 changes: 1 addition & 3 deletions scripts/spheral_ats.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ def main():
help="Time limit for allocation.")
parser.add_argument("--ciRun", action="store_true",
help="Option to only be used by the CI")
parser.add_argument("--perfTest", action="store_true",
help="Turn on if doing a performance test.")
parser.add_argument("--atsHelp", action="store_true",
help="Print the help output for ATS. Useful for seeing ATS options.")
options, unknown_options = parser.parse_known_args()
Expand Down Expand Up @@ -173,7 +171,7 @@ def main():
# Launch ATS
#---------------------------------------------------------------------------
# If doing a CI run, set some more options
if (not options.perfTest):
if (options.ciRun):
if ("--logs" not in unknown_options):
ats_args.append(f"--logs {test_log_name}")
log_name = test_log_name
Expand Down
40 changes: 36 additions & 4 deletions tests/performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ def add_timer_cmds(cali_name, test_name):
num_nodes = 2
num_cores = 36

# NOH tests
test_dir = os.path.join(SpheralConfigs.test_install_path(), "functional/Hydro/Noh")

# Select which timing regions to compare (for CI)
regions = ["CheapRK2",
"CheapRK2PreInit",
Expand All @@ -66,6 +63,41 @@ def add_timer_cmds(cali_name, test_name):
# Select which timers to compare (for CI)
timers = ["sum#inclusive#sum#time.duration"] # Means the sum of the time from all ranks

# 3D convection test
test_dir = os.path.join(SpheralConfigs.test_install_path(), "unit/Boundary")

group(name="3D Convection test")
test_file = "testPeriodicBoundary-3d.py"
test_path = os.path.join(test_dir, test_file)
test_name = "3DCONV"

# Test with varying number of ranks
ranks = [1, 2, 4]
# We want 20 points per unit length
ref_len = 1.
sph_point_rho = 20. / ref_len
sph_per_core = 300
for i, n in enumerate(ranks):
caliper_filename = f"{test_name}_{i}_{int(time.time())}.cali"
timer_cmds = add_timer_cmds(caliper_filename, test_name)
ncores = int(num_nodes*num_cores/n)
total_sph_nodes = sph_per_core * ncores
npd = int(np.cbrt(total_sph_nodes))
new_len = npd * ref_len / sph_point_rho
inps = f"--nx {npd} --ny {npd} --nz {npd} --x1 {new_len} --y1 {new_len} --z1 {new_len} --steps 100 {timer_cmds}"
t = test(script=test_path, clas=inps,
label=test_name,
np=ncores,
caliper_filename=caliper_filename,
regions=regions,
timers=timers,
install_config=spheral_install_config)

endgroup()

# NOH tests
test_dir = os.path.join(SpheralConfigs.test_install_path(), "functional/Hydro/Noh")

# General input for all Noh tests
gen_noh_inps = "--crksph False --cfl 0.25 --Cl 1.0 --Cq 1.0 --xfilter 0.0 "+\
"--nPerh 2.01 --graphics False --clearDirectories False --doCompare False "+\
Expand Down Expand Up @@ -108,7 +140,7 @@ def add_timer_cmds(cali_name, test_name):
npd = int(np.cbrt(total_sph_nodes))
node_inps = f"--nx {npd} --ny {npd} --nz {npd}"
timer_cmds = add_timer_cmds(caliper_filename, test_name)
inps = f"{gen_noh_inps} {node_inps} --steps 3 {timer_cmds}"
inps = f"{gen_noh_inps} {node_inps} --steps 10 {timer_cmds}"
# WIP: Path to benchmark timing data
t = test(script=test_path, clas=inps,
label=test_name,
Expand Down
164 changes: 164 additions & 0 deletions tests/unit/Boundary/testPeriodicBoundary-3d.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
#ATS:t0 = test(SELF, "", np=10, label="Periodic boundary unit test -- 3-D (parallel)")
#-------------------------------------------------------------------------------
# 3D test of periodic boundaries -- we simply allow a pressureless fluid to
# cycle around a box and check the sum density
#-------------------------------------------------------------------------------
from math import *
from Spheral3d import *
from SpheralTestUtilities import *
from SpheralPointmeshSiloDump import dumpPhysicsState
import mpi

title("3D periodic boundary test.")

#-------------------------------------------------------------------------------
# Generic problem parameters
#-------------------------------------------------------------------------------
commandLine(nx = 20,
ny = 20,
nz = 20,
x0 = 0.0,
x1 = 1.0,
y0 = 0.0,
y1 = 1.0,
z0 = 0.0,
z1 = 1.0,

rho1 = 1.0,
cs2 = 1.0,
mu = 1.0,
vx1 = 1.0,
vy1 = 1.0,
vz1 = 1.0,

nPerh = 2.01,

hmin = 0.0001,
hmax = 0.5,
cfl = 0.5,

tol = 1.0e-3,
steps = 300,
dt = 0.0001,
dtMin = 1.0e-5,
dtMax = 0.1,
dtGrowth = 2.0,
dtverbose = False,
rigorousBoundaries = False,
maxSteps = None,
statsStep = 1,
smoothIters = 0,
HEvolution = IdealH,
densityUpdate = RigorousSumDensity,
compatibleEnergy = True,
gradhCorrection = True,
linearConsistent = False,
domainIndependent = False,

restoreCycle = None,
restartStep = 10000,
restartBaseName = None
)

#-------------------------------------------------------------------------------
# Material properties.
#-------------------------------------------------------------------------------
eos = IsothermalEquationOfStateMKS(cs2, mu)

#-------------------------------------------------------------------------------
# Interpolation kernels.
#-------------------------------------------------------------------------------
WT = TableKernel(BSplineKernel(), 1000)
WTPi = TableKernel(BSplineKernel(), 1000)

#-------------------------------------------------------------------------------
# Make the NodeList.
#-------------------------------------------------------------------------------
nodes1 = makeFluidNodeList("nodes1", eos,
hmin = hmin,
hmax = hmax,
nPerh = nPerh)

#-------------------------------------------------------------------------------
# Set the node properties.
#-------------------------------------------------------------------------------
from GenerateNodeDistribution3d import GenerateNodeDistribution3d
gen1 = GenerateNodeDistribution3d(nx, ny, nz,
rho = rho1,
distributionType = "lattice",
xmin = (x0, y0, z0),
xmax = (x1, y1, z1),
nNodePerh = nPerh,
SPH = True)
if mpi.procs > 1:
from PeanoHilbertDistributeNodes import distributeNodes3d
else:
from DistributeNodes import distributeNodes3d
distributeNodes3d((nodes1, gen1))

# Set the node positions, velocities, and densities.
nodes1.velocity(VectorField("tmp velocity", nodes1, Vector(vx1, vy1, vz1)))

#-------------------------------------------------------------------------------
# Construct a DataBase to hold our node list
#-------------------------------------------------------------------------------
db = DataBase()
db.appendNodeList(nodes1)

#-------------------------------------------------------------------------------
# Construct the artificial viscosity.
#-------------------------------------------------------------------------------
q = MonaghanGingoldViscosity(0.0, 0.0)

#-------------------------------------------------------------------------------
# Construct the hydro physics object.
#-------------------------------------------------------------------------------
hydro = SPH(dataBase = db,
W = WT,
Q = q,
cfl = cfl,
densityUpdate = RigorousSumDensity,
HUpdate = HEvolution)

#-------------------------------------------------------------------------------
# Create boundary conditions.
#-------------------------------------------------------------------------------
loVect = Vector(x0, y0, z0)
hiVect = Vector(x1, y1, z1)
bcs = []
for i in range(0,3):
nVect = Vector(0., 0., 0.)
nVect[i] = 1.
plane0 = Plane(loVect, nVect)
plane1 = Plane(hiVect, -nVect)
bcs.append(PeriodicBoundary(plane0, plane1))
# Segfault occurs if hydro is append directly in previous loop
for i in bcs:
hydro.appendBoundary(i)

#-------------------------------------------------------------------------------
# Construct a time integrator.
#-------------------------------------------------------------------------------
integrator = CheapSynchronousRK2Integrator(db)
integrator.appendPhysicsPackage(hydro)
integrator.lastDt = dt
integrator.dtMin = dtMin
integrator.dtMax = dtMax
integrator.dtGrowth = dtGrowth
integrator.rigorousBoundaries = rigorousBoundaries
integrator.domainDecompositionIndependent = domainIndependent
integrator.verbose = dtverbose

#-------------------------------------------------------------------------------
# Make the problem controller.
#-------------------------------------------------------------------------------
control = SpheralController(integrator, WT,
statsStep = statsStep,
restartStep = restartStep,
restartBaseName = restartBaseName,
restoreCycle = restoreCycle)

#-------------------------------------------------------------------------------
# Advance to the end time.
#-------------------------------------------------------------------------------
control.step(steps)

0 comments on commit 5d9ea27

Please sign in to comment.