Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Archer2 updates #206

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions asQ/paradiag.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ def reset_diagnostics(self):
self.total_timesteps = 0
self.total_windows = 0
self.block_iterations.data()[:] = 0
jacobian = self.solver.jacobian
if hasattr(jacobian, "pc") and hasattr(jacobian.pc, "block_iterations"):
jacobian.pc.block_iterations.data(deepcopy=False)[:] = 0

@profiler()
def _record_diagnostics(self):
Expand Down
5 changes: 3 additions & 2 deletions asQ/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def write_solver_parameters(sparams, directory=""):

with open(file_name, "w") as f:
f.write(dumps(sparams, indent=4))
f.write("\n")

return

Expand Down Expand Up @@ -216,7 +217,7 @@ def write_paradiag_setup(pdg, directory=""):
f"global_comm.size = {pdg.ensemble.global_comm.size}\n"
jacobian = pdg.solver.jacobian
if hasattr(jacobian, "pc") and hasattr(jacobian.pc, "alpha"):
info += f"alpha = {pdg.solver.jacobian.pc.alpha}"
info += f"alpha = {pdg.solver.jacobian.pc.alpha}\n"
f.write(info)
return

Expand Down Expand Up @@ -254,7 +255,7 @@ def write_aaos_solve_metrics(pdg, directory=""):
f"nonlinear iterations per window = {nlits/nw}\n" + \
f"linear iterations per window = {lits/nw}\n" + \
f"linear iterations per nonlinear iteration = {lits/nlits}\n" + \
f"max iterations per block solve = {blits/lits}"
f"max iterations per block solve = {blits/lits}\n"
f.write(info)
return

Expand Down
2 changes: 1 addition & 1 deletion utils/compressible_flow/compressible_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def hydrostatic_rho(Vv, V2, mesh, thetan, rhon, pi_boundary,
Pif = pi_formula(rho, thetan, gas)

rhoeqn = gas.cp*(
(fd.inner(v, dv) - fd.div(dv*thetan)*Pif)*fd.dx
(fd.inner(v, dv) - fd.div(dv*thetan)*Pif)*fd.dx(degree=6)
+ drho*fd.div(thetan*v)*fd.dx
)

Expand Down
10 changes: 6 additions & 4 deletions utils/shallow_water/miniapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ def form_mass(u, h, v, q):
u0 = w0.subfunctions[self.velocity_index]
h0 = w0.subfunctions[self.depth_index]

u0.project(velocity_expression(*x))
h0.project(depth_expression(*x))
u0.project(velocity_expression(*x), quadrature_degree=6)
h0.interpolate(depth_expression(*x))

if reference_state:
self.reference_state = fd.Function(self.function_space())
Expand Down Expand Up @@ -235,7 +235,8 @@ def sync_diagnostics(self):

Until this method is called, diagnostic information is not guaranteed to be valid.
"""
self.cfl_series.synchronise()
if self.record_diagnostics['cfl']:
self.cfl_series.synchronise()

def solve(self,
nwindows=1,
Expand All @@ -261,7 +262,8 @@ def postprocess(pdg, w, rhs=None):
postproc(self, pdg, w)

# extend cfl array
self.cfl_series.resize(self.paradiag.total_windows + nwindows)
if self.record_diagnostics['cfl']:
self.cfl_series.resize(self.paradiag.total_windows + nwindows)

self.paradiag.solve(nwindows,
preproc=preprocess,
Expand Down
7 changes: 5 additions & 2 deletions utils/timing.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,16 @@ class SolverTimer(Timer):
'''
Time multiple solves and print out total/average etc times.
'''
def string(self, timesteps_per_solve=1, ndigits=None):
def string(self, timesteps_per_solve=1,
total_iterations=1, ndigits=None):
rnd = lambda x: x if ndigits is None else round(x, ndigits)
total_time = self.total_time()
average_time = self.average_time()
timestep_time = average_time/timesteps_per_solve
iteration_time = total_time/total_iterations
string = ''\
+ f'Total solution time: {rnd(total_time)}\n' \
+ f'Average solve solution time: {rnd(average_time)}\n' \
+ f'Average timestep solution time: {rnd(timestep_time)}'
+ f'Average timestep solution time: {rnd(timestep_time)}\n' \
+ f'Average iteration solution time: {rnd(iteration_time)}'
return string
Loading