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

Time series logging #96

Merged
merged 227 commits into from
Feb 25, 2021
Merged
Show file tree
Hide file tree
Changes from 217 commits
Commits
Show all changes
227 commits
Select commit Hold shift + click to select a range
88daa08
initial logging
matthiasdiener Sep 11, 2020
9eba876
flake8
matthiasdiener Sep 11, 2020
6cf0c54
Merge branch 'master' into logging
matthiasdiener Sep 29, 2020
e966864
add logpyle
matthiasdiener Sep 29, 2020
bc96f56
use new interface for sod-mpi
matthiasdiener Sep 29, 2020
58e6bde
updates
matthiasdiener Oct 1, 2020
e614232
callback
matthiasdiener Oct 5, 2020
0b8edf0
flake8
matthiasdiener Oct 5, 2020
b726541
fix wave eager
matthiasdiener Oct 5, 2020
aedbd05
Merge branch 'master' into logging
matthiasdiener Oct 6, 2020
8995505
add kernel profile
matthiasdiener Oct 6, 2020
83b533d
better names
matthiasdiener Oct 6, 2020
a468bc9
unique
matthiasdiener Oct 8, 2020
ef278dd
cleanups
matthiasdiener Oct 8, 2020
b8e3b2e
cleanups 2
matthiasdiener Oct 8, 2020
6777a01
Merge branch 'master' into logging
matthiasdiener Oct 8, 2020
13c6401
clean state passing
matthiasdiener Oct 8, 2020
9574ded
Merge remote-tracking branch 'origin/master' into logging
matthiasdiener Oct 12, 2020
0237e58
fix order
matthiasdiener Oct 13, 2020
1985888
add comments
matthiasdiener Oct 13, 2020
af72af0
install mirgecom for docs
matthiasdiener Oct 13, 2020
2a6b347
undo wave-eager changes
matthiasdiener Oct 13, 2020
8405f81
test conda
matthiasdiener Oct 13, 2020
07e43cd
test workaround
matthiasdiener Oct 13, 2020
306ff5d
more doc
matthiasdiener Oct 13, 2020
b5f47cc
Merge branch 'master' into logging
matthiasdiener Oct 13, 2020
fb94cde
fix flake8
matthiasdiener Oct 13, 2020
2ce99cf
Merge branch 'master' into logging
matthiasdiener Oct 13, 2020
191eb02
Merge branch 'master' into logging
matthiasdiener Oct 23, 2020
53d0098
add to vortex-mpi
matthiasdiener Oct 25, 2020
25a2cd1
add pyinstrument
matthiasdiener Oct 27, 2020
cb25add
Merge branch 'master' into logging
matthiasdiener Oct 27, 2020
1632f9f
add non-loopy profiling
matthiasdiener Oct 29, 2020
428f82c
Update doc/running.rst
matthiasdiener Oct 29, 2020
17c14f1
Update mirgecom/logging_quantities.py
matthiasdiener Oct 29, 2020
5a7a240
Update mirgecom/logging_quantities.py
matthiasdiener Oct 29, 2020
9935309
set state to none
matthiasdiener Oct 29, 2020
c4b3f6f
Merge branch 'master' into logging
matthiasdiener Oct 29, 2020
a802005
add pyinstrument dep
matthiasdiener Oct 29, 2020
df6aa5a
increase nel
matthiasdiener Oct 30, 2020
298522f
split into conserved quantities/dependent quantities
matthiasdiener Nov 3, 2020
cff209d
Merge branch 'master' into logging
matthiasdiener Nov 3, 2020
f43feb8
add docstring
matthiasdiener Nov 3, 2020
26aa0f6
remove pyinstrument
matthiasdiener Nov 3, 2020
c0449cf
lots of fixes
matthiasdiener Nov 5, 2020
0d894ab
pydocstyle
matthiasdiener Nov 5, 2020
a99b34f
add logpyle intersphinx
matthiasdiener Nov 5, 2020
e1fcb4a
add vis timer
matthiasdiener Nov 5, 2020
8040ac8
allow choosing rank aggregators
matthiasdiener Nov 9, 2020
dce2eef
Merge branch 'master' into logging
matthiasdiener Nov 9, 2020
0c01c57
pydocstyle
matthiasdiener Nov 9, 2020
053f3d9
add versions
matthiasdiener Nov 11, 2020
9ad2494
add versions
matthiasdiener Nov 11, 2020
11e7b4e
rename function
matthiasdiener Nov 11, 2020
3b2f8df
Merge branch 'master' into logging
matthiasdiener Nov 12, 2020
f9b017a
fix
matthiasdiener Nov 12, 2020
fa30da7
fix version logging
matthiasdiener Nov 13, 2020
6fde017
some package versions clarifications
matthiasdiener Nov 16, 2020
ba257cc
Apply suggestions from code review
matthiasdiener Nov 16, 2020
f742eea
fixup
matthiasdiener Nov 16, 2020
5b06f46
fixup
matthiasdiener Nov 16, 2020
1465b4d
flake8
matthiasdiener Nov 16, 2020
234ad02
fixup
matthiasdiener Nov 16, 2020
5604f33
reset sod-mpi to master
matthiasdiener Nov 16, 2020
ce9ff4f
enable logging in kernel profiler
matthiasdiener Nov 16, 2020
1bc56b1
use context for vis_timer
matthiasdiener Nov 17, 2020
6e93b5b
fix FD leak
matthiasdiener Nov 17, 2020
bc1889a
cleanup
matthiasdiener Nov 17, 2020
019f4fe
fix (?) units
matthiasdiener Nov 17, 2020
4ea38a0
fix conserved name
matthiasdiener Nov 17, 2020
2602ed9
more docs
matthiasdiener Nov 17, 2020
966b8c1
more doc, pass mpi comm
matthiasdiener Nov 17, 2020
5c3b8f3
flake8
matthiasdiener Nov 17, 2020
6c13bdd
fix doc
matthiasdiener Nov 17, 2020
8f0f808
more docs
matthiasdiener Nov 17, 2020
33f0b91
subprocess instead of os.popen
matthiasdiener Nov 17, 2020
9c262dc
catch exception
matthiasdiener Nov 17, 2020
06096ba
rank aggregator
matthiasdiener Nov 17, 2020
1de9482
Merge branch 'master' into logging
matthiasdiener Nov 19, 2020
87c6774
init monkey
matthiasdiener Nov 20, 2020
e44006d
monkey patch
matthiasdiener Nov 20, 2020
0a55e9b
warn about units
matthiasdiener Nov 20, 2020
c461d9d
fix autodoc
matthiasdiener Nov 20, 2020
196a319
Merge branch 'master' into logging
matthiasdiener Nov 20, 2020
0277146
add device name
matthiasdiener Nov 23, 2020
26a7464
flake8
matthiasdiener Nov 23, 2020
4728ae1
Merge branch 'master' into logging
matthiasdiener Nov 30, 2020
9d0bbff
f2py
matthiasdiener Nov 30, 2020
f4de7c1
Merge branch 'master' into logging
matthiasdiener Nov 30, 2020
bc949af
add memory profiling
matthiasdiener Dec 1, 2020
c060d4b
Merge branch 'master' into logging
matthiasdiener Dec 1, 2020
c907025
silence pylint
matthiasdiener Dec 1, 2020
7074a86
fix module
matthiasdiener Dec 1, 2020
99c7869
pylint
matthiasdiener Dec 1, 2020
00a9e4c
Merge branch 'master' into logging
matthiasdiener Dec 1, 2020
0ef4ed6
units for kernel profile
matthiasdiener Dec 2, 2020
a1db7d3
fix pyopencl_array
matthiasdiener Dec 2, 2020
35ead1c
kernel profile fixes
matthiasdiener Dec 2, 2020
2008f98
MirgecomLogManager
matthiasdiener Dec 2, 2020
aff7156
fix kernel names
matthiasdiener Dec 2, 2020
e6102f6
fix
matthiasdiener Dec 2, 2020
3156e19
remove unused func
matthiasdiener Dec 2, 2020
43aa38d
fix doc
matthiasdiener Dec 2, 2020
c44eec5
monkey patch other pyopencl functions
matthiasdiener Dec 3, 2020
00d6464
warn when memory_profiler missing
matthiasdiener Dec 4, 2020
96121ae
small doc fix
matthiasdiener Dec 4, 2020
566bb16
only enable monkey patching when profiling
matthiasdiener Dec 4, 2020
ccb958e
Merge branch 'master' into logging
matthiasdiener Dec 8, 2020
d8f2d56
fix
matthiasdiener Dec 9, 2020
d33e818
f2
matthiasdiener Dec 9, 2020
d477383
Merge branch 'master' into logging
matthiasdiener Dec 9, 2020
fbb1fe3
Merge branch 'master' into logging
matthiasdiener Dec 15, 2020
bde029b
Merge branch 'master' into logging
matthiasdiener Dec 17, 2020
112f0e4
Apply suggestions from code review
matthiasdiener Dec 17, 2020
d0cc579
Merge branch 'master' into logging
matthiasdiener Dec 17, 2020
64dc916
first batch of review fixes
matthiasdiener Dec 22, 2020
38795ff
monkey patching
matthiasdiener Dec 22, 2020
1d152eb
footprint, del, doc fix
matthiasdiener Dec 22, 2020
e9f65ff
pylint
matthiasdiener Dec 22, 2020
9b7b35e
cleanup module finding
matthiasdiener Dec 22, 2020
1667379
reduce timeout
matthiasdiener Dec 22, 2020
8cdd471
fix test
matthiasdiener Dec 22, 2020
7e41669
take 2
matthiasdiener Dec 22, 2020
61be500
remove useless code
matthiasdiener Dec 22, 2020
a054f2e
Merge branch 'master' into logging
matthiasdiener Dec 22, 2020
5523d6d
Merge branch 'master' into logging
matthiasdiener Jan 4, 2021
e780b8f
remove MirgeComLogManager class and change to set_sim_state
matthiasdiener Jan 4, 2021
086b310
document op choices
matthiasdiener Jan 4, 2021
e7c8696
add norm2
matthiasdiener Jan 4, 2021
ac7203d
clarify reduction
matthiasdiener Jan 4, 2021
636f978
fix doc
matthiasdiener Jan 5, 2021
33a6dbc
more doc fixes
matthiasdiener Jan 5, 2021
447b36d
factor out dim check
matthiasdiener Jan 5, 2021
4729369
ignore logging sqlite files
matthiasdiener Jan 5, 2021
4e3f120
remove sum
matthiasdiener Jan 7, 2021
2e2e3f8
Merge branch 'master' into logging
matthiasdiener Jan 11, 2021
1919f46
switch to new elwise interface
matthiasdiener Jan 15, 2021
6567afb
fix flake8
matthiasdiener Jan 15, 2021
dd98830
fix doc
matthiasdiener Jan 15, 2021
b590bd6
undo req change
matthiasdiener Jan 18, 2021
b06ddca
profiling: add pyopencl.Array elementwise kernels
matthiasdiener Jan 18, 2021
f9be344
adjust comment
matthiasdiener Jan 18, 2021
96ef084
small cleanup
matthiasdiener Jan 18, 2021
81d87ec
Merge branch 'profiling-fixes' into logging
matthiasdiener Jan 18, 2021
717ca93
Merge branch 'master' into logging
matthiasdiener Jan 20, 2021
02c2d9b
fix merge errors
matthiasdiener Jan 20, 2021
eba5457
Merge branch 'master' into logging
matthiasdiener Jan 20, 2021
964b744
fix
matthiasdiener Jan 22, 2021
b4760e7
Merge branch 'master' into logging
matthiasdiener Jan 22, 2021
7ca816d
Merge branch 'master' into logging
matthiasdiener Jan 26, 2021
bec4d62
Propose extract_vars/set_sim_state interface generalization
inducer Jan 28, 2021
cbcf356
More refactoring of name-getting for LogQuantities
inducer Jan 28, 2021
78005c1
Merge branch 'master' into logging
matthiasdiener Feb 3, 2021
7bfd8a3
change cv/dv interface
matthiasdiener Feb 4, 2021
1613299
add comments
matthiasdiener Feb 4, 2021
9a651c0
fix
matthiasdiener Feb 4, 2021
bf88d97
rename
matthiasdiener Feb 4, 2021
a7edc40
Add utils.asdict_shallow, use for passing of log quantities
inducer Feb 4, 2021
3c271a5
Merge branch 'master' into logging
matthiasdiener Feb 4, 2021
6672bce
fix pydocstyle
matthiasdiener Feb 4, 2021
99d379b
remove unnessescary class
matthiasdiener Feb 4, 2021
317e824
fix doc
matthiasdiener Feb 4, 2021
bf34af1
make it clearer that the logged discretization quantities are just th…
matthiasdiener Feb 4, 2021
3893e90
fix doc
matthiasdiener Feb 4, 2021
7af3cba
unitless by default
matthiasdiener Feb 8, 2021
2ba88a8
Merge branch 'master' into logging
matthiasdiener Feb 8, 2021
42a152f
add overhead note
matthiasdiener Feb 8, 2021
f1d75a2
Merge branch 'master' into logging
matthiasdiener Feb 8, 2021
ff9e2ea
flake8
matthiasdiener Feb 8, 2021
0403ad0
simplify
matthiasdiener Feb 8, 2021
eed409e
Merge branch 'master' into logging
matthiasdiener Feb 8, 2021
995ba44
remove incorrect note
matthiasdiener Feb 8, 2021
18046dd
Apply suggestions from code review
matthiasdiener Feb 9, 2021
3e19de3
Merge branch 'master' into logging
matthiasdiener Feb 9, 2021
b42f70f
Merge branch 'master' into logging
matthiasdiener Feb 9, 2021
a966ef4
Merge branch 'master' into logging
matthiasdiener Feb 10, 2021
3332688
fix optional
matthiasdiener Feb 11, 2021
cace79f
elwise fix
matthiasdiener Feb 11, 2021
1b18f98
remove global var
matthiasdiener Feb 11, 2021
c8435a3
dim -> axis
matthiasdiener Feb 11, 2021
353c831
change to psutil
matthiasdiener Feb 11, 2021
bcc1121
more flexible kernel stats
matthiasdiener Feb 11, 2021
71c0793
merge elwise kernel stats into actx
matthiasdiener Feb 11, 2021
418b6fd
simplify elwise
matthiasdiener Feb 11, 2021
ed93cf3
avoid duplicating state var calculation
matthiasdiener Feb 11, 2021
7b4fdf1
pylint
matthiasdiener Feb 11, 2021
f68b09f
Merge branch 'master' into logging
matthiasdiener Feb 11, 2021
d0f68c6
remove psutil import attempt
matthiasdiener Feb 11, 2021
caaed36
fix doc
matthiasdiener Feb 11, 2021
8c6f4bb
fix pylint
matthiasdiener Feb 11, 2021
da9611b
dict for state vars
matthiasdiener Feb 11, 2021
8e73c17
Merge branch 'master' into logging
inducer Feb 15, 2021
047c885
Apply suggestions from code review
matthiasdiener Feb 15, 2021
68e0a21
rename fixes
matthiasdiener Feb 15, 2021
4a183cd
more doc
matthiasdiener Feb 15, 2021
3101c9e
fix mem usage doc
matthiasdiener Feb 15, 2021
c3e8469
fix type
matthiasdiener Feb 15, 2021
639b949
simplify units
matthiasdiener Feb 15, 2021
ff7cfbf
Merge branch 'master' into logging
matthiasdiener Feb 15, 2021
df2e82b
Merge branch 'master' into logging
matthiasdiener Feb 17, 2021
15dfda3
Merge branch 'master' into logging
matthiasdiener Feb 18, 2021
4637314
Apply suggestions from code review
matthiasdiener Feb 19, 2021
0bb2b40
merge
matthiasdiener Feb 19, 2021
4b8f2ec
more fixes
matthiasdiener Feb 19, 2021
487f9fe
fix doc
matthiasdiener Feb 19, 2021
d728693
cleanup
matthiasdiener Feb 19, 2021
9050d17
flake8
matthiasdiener Feb 19, 2021
1d32305
Merge branch 'master' into logging
matthiasdiener Feb 22, 2021
f12ccfb
Update mirgecom/profiling.py
matthiasdiener Feb 22, 2021
fd22ce5
rename function
matthiasdiener Feb 22, 2021
e8fb9b7
undo name addition
matthiasdiener Feb 22, 2021
7eea01b
remove wait_for_events arg
matthiasdiener Feb 22, 2021
a6492cd
rename key, value
matthiasdiener Feb 22, 2021
785efc0
key value rename
matthiasdiener Feb 22, 2021
a457741
fix+comments
matthiasdiener Feb 23, 2021
8ea0a61
index profile_results by kernel name
matthiasdiener Feb 23, 2021
305b658
separate get and reset
matthiasdiener Feb 24, 2021
3beff13
fix doc
matthiasdiener Feb 24, 2021
b0a2d3e
Apply suggestions from code review
matthiasdiener Feb 24, 2021
5c74dc7
fix fail
matthiasdiener Feb 24, 2021
0a0b216
be more explicit about averages
matthiasdiener Feb 24, 2021
1a14442
rename logmgr_add_many_discretization_quantities
matthiasdiener Feb 24, 2021
16962c2
add StatisticsAccumulator
matthiasdiener Feb 25, 2021
99e56e3
fix Statistics
matthiasdiener Feb 25, 2021
f23b1c8
move StatisticsAccumulator to mirgecom.utils
matthiasdiener Feb 25, 2021
0ec5294
type annotations
matthiasdiener Feb 25, 2021
944d5c9
change scale_factor to multiply
matthiasdiener Feb 25, 2021
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ run-debug-*
.pytest_cache

test/nodal-dg

# Logging output files
*.sqlite
*.sqlite-journal
2 changes: 2 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@
"https://documen.tician.de/loopy/": None,
"https://documen.tician.de/pymbolic/": None,
"https://documen.tician.de/pytools/": None,
"https://logpyle.readthedocs.io/en/latest/": None,
"https://psutil.readthedocs.io/en/latest/": None,
}

autoclass_content = "class"
Expand Down
18 changes: 17 additions & 1 deletion doc/running/profiling.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Profiling and logging
=====================


Profiling kernel execution
==========================
--------------------------

You can use :class:`mirgecom.profiling.PyOpenCLProfilingArrayContext` instead of
:class:`~meshmode.array_context.PyOpenCLArrayContext` to profile kernel executions.
Expand All @@ -12,3 +16,15 @@ In addition to using this array context, you also need to enable profiling in th
Note that profiling has a performance impact (~20% at the time of this writing).

.. automodule:: mirgecom.profiling


Time series logging
-------------------

Mirgecom supports logging of simulation and profiling quantities with the help
of :mod:`logpyle`. Logpyle requires
classes to describe how quantities for logging are calculated. For mirgecom, these classes are described below.

.. automodule:: mirgecom.logging_quantities

An overview of how to use logpyle is given in the :any:`Logpyle documentation <logpyle>`.
2 changes: 2 additions & 0 deletions doc/support/tools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ Random Pile'o'Tools
===================

.. automodule:: mirgecom.simutil

.. automodule:: mirgecom.utils
67 changes: 58 additions & 9 deletions examples/vortex-mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from grudge.eager import EagerDGDiscretization
from grudge.shortcuts import make_visualizer

from mirgecom.profiling import PyOpenCLProfilingArrayContext

from mirgecom.euler import inviscid_operator
from mirgecom.simutil import (
Expand All @@ -52,17 +53,36 @@
from mirgecom.initializers import Vortex2D
from mirgecom.eos import IdealSingleGas

from logpyle import IntervalTimer
from mirgecom.euler import extract_vars_for_logging, units_for_logging

from mirgecom.logging_quantities import (initialize_logmgr,
logmgr_add_default_discretization_quantities, logmgr_add_device_name)


logger = logging.getLogger(__name__)


@mpi_entry_point
def main(ctx_factory=cl.create_some_context):
def main(ctx_factory=cl.create_some_context, use_profiling=False, use_logmgr=False):
matthiasdiener marked this conversation as resolved.
Show resolved Hide resolved
"""Drive the example."""
from mpi4py import MPI
comm = MPI.COMM_WORLD

logmgr = initialize_logmgr(use_logmgr,
filename="vortex.sqlite", mode="wu", mpi_comm=comm)

cl_ctx = ctx_factory()
queue = cl.CommandQueue(cl_ctx)
actx = PyOpenCLArrayContext(queue,
allocator=cl_tools.MemoryPool(cl_tools.ImmediateAllocator(queue)))
if use_profiling:
queue = cl.CommandQueue(cl_ctx,
properties=cl.command_queue_properties.PROFILING_ENABLE)
actx = PyOpenCLProfilingArrayContext(queue,
allocator=cl_tools.MemoryPool(cl_tools.ImmediateAllocator(queue)),
logmgr=logmgr)
else:
queue = cl.CommandQueue(cl_ctx)
actx = PyOpenCLArrayContext(queue,
allocator=cl_tools.MemoryPool(cl_tools.ImmediateAllocator(queue)))

dim = 2
nel_1d = 16
Expand All @@ -89,8 +109,6 @@ def main(ctx_factory=cl.create_some_context):
box_ll = -5.0
box_ur = 5.0

from mpi4py import MPI
comm = MPI.COMM_WORLD
rank = comm.Get_rank()

if dim != 2:
Expand All @@ -108,6 +126,27 @@ def main(ctx_factory=cl.create_some_context):
nodes = thaw(actx, discr.nodes())
current_state = initializer(nodes)

vis_timer = None

if logmgr:
logmgr_add_device_name(logmgr, queue)
logmgr_add_default_discretization_quantities(logmgr, discr, dim,
extract_vars_for_logging, units_for_logging)

logmgr.add_watches(["step.max", "t_step.max", "t_log.max",
"min_temperature", "L2_norm_momentum1"])

try:
logmgr.add_watches(["memory_usage.max"])
except KeyError:
pass

if use_profiling:
logmgr.add_watches(["multiply_time.max"])

vis_timer = IntervalTimer("t_vis", "Time spent visualizing")
logmgr.add_quantity(vis_timer)

visualizer = make_visualizer(discr, order + 3 if dim == 2 else order)

initname = initializer.__class__.__name__
Expand All @@ -134,14 +173,16 @@ def my_checkpoint(step, t, dt, state):
return sim_checkpoint(discr, visualizer, eos, q=state,
exact_soln=initializer, vizname=casename, step=step,
t=t, dt=dt, nstatus=nstatus, nviz=nviz,
exittol=exittol, constant_cfl=constant_cfl, comm=comm)
exittol=exittol, constant_cfl=constant_cfl, comm=comm,
vis_timer=vis_timer)

try:
(current_step, current_t, current_state) = \
advance_state(rhs=my_rhs, timestepper=timestepper,
checkpoint=my_checkpoint,
get_timestep=get_timestep, state=current_state,
t=current_t, t_final=t_final)
t=current_t, t_final=t_final, logmgr=logmgr, eos=eos,
dim=dim)
except ExactSolutionMismatch as ex:
current_step = ex.step
current_t = ex.t
Expand All @@ -157,9 +198,17 @@ def my_checkpoint(step, t, dt, state):
if current_t - t_final < 0:
raise ValueError("Simulation exited abnormally")

if logmgr:
logmgr.close()
elif use_profiling:
print(actx.tabulate_profiling_data())


if __name__ == "__main__":
logging.basicConfig(format="%(message)s", level=logging.INFO)
main()
use_profiling = True
use_logging = True

main(use_profiling=use_profiling, use_logmgr=use_logging)

# vim: foldmethod=marker
2 changes: 1 addition & 1 deletion mirgecom/eos.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def gamma(self):
raise NotImplementedError()

def dependent_vars(self, q: ConservedVars) -> EOSDependentVars:
"""Get an agglomerated array of the depedent variables."""
"""Get an agglomerated array of the dependent variables."""
return EOSDependentVars(
pressure=self.pressure(q),
temperature=self.temperature(q),
Expand Down
26 changes: 26 additions & 0 deletions mirgecom/euler.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,32 @@ def get_inviscid_cfl(discr, eos, dt, q):
return dt / wanted_dt


# By default, run unitless
NAME_TO_UNITS = {
"mass": "",
"energy": "",
"momentum": "",
"temperature": "",
"pressure": ""
}


def units_for_logging(quantity: str) -> str:
"""Return unit for quantity."""
return NAME_TO_UNITS[quantity]
matthiasdiener marked this conversation as resolved.
Show resolved Hide resolved


def extract_vars_for_logging(dim: int, state: np.ndarray, eos) -> dict:
"""Extract state vars."""
cv = split_conserved(dim, state)
dv = eos.dependent_vars(cv)

Comment on lines +373 to +374
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on which EOS - this call can be quite expensive.

from mirgecom.utils import asdict_shallow
name_to_field = asdict_shallow(cv)
name_to_field.update(asdict_shallow(dv))
return name_to_field


def get_inviscid_timestep(discr, eos, cfl, q):
"""Routine (will) return the (local) maximum stable inviscid timestep.

Expand Down
Loading