-
Notifications
You must be signed in to change notification settings - Fork 36
StatisticsProbe
StatisticsProbe
is a class that can be used to probe a position and for sampling statistics. It is intended for use with turbulence simulations where one typically is interested in average velocites and covariances like the Reynolds stress tensor.
A StatisticsProbe
is used much like the Probe
class, but there are som significant differences. A StatisticsProbe
assumes that it will evaluate a velocity vector with 3 components. It is only valid in 3D, bacause you cannot have a turbulent flow field in 2 dimensions. The probe collects statistics for all three velocity components + the Reynolds stress tensor:
mesh = UnitCubeMesh(10, 10, 10)
V = FunctionSpace(mesh, 'CG', 1)
VV = VectorFunctionSpace(mesh, 'CG', 1)
x = array([0.2, 0.4])
segregatedprobe = StatisticsProbe(x, V, True)
vectorprobe = StatisticsProbe(x, VV, False)
# Segregated velocity vector:
u0 = interpolate(Expression("sin(pi*x[0])"), V)
u1 = interpolate(Expression("cos(pi*x[1])"), V)
u2 = interpolate(Expression("cos(pi*x[2]/3.)"), V)
# Regular velocity vector
u = interpolate(Expression(("sin(pi*x[0])", "cos(pi*x[1])", "cos(pi*x[2]/3.)")), VV)
# Evaluate probes
segregatedprobe(u0, u1, u2)
vectorprobe(u)
The two probes do exactly the same thing. Each velocity component has two values. The first value is the average and the second is the latest snapshot
print vectorprobe[0] # Average values
print vectorprobe[1] # Latest snapshot
results in
[ 0.58778525 0.30901699 0.8660254 0.3454915 0.0954915 0.75
0.18163563 0.50903696 0.26761657]
[ 0.58778525 0.30901699 0.8660254 0. 0. 0. 0.
0. 0. ]
The snapshot values are not stored for the Reynolds stress. The first three values in each list are for the three velocity components (u, v, w) and the next 6 are for (uu, vv, ww, uv, uw, vw).
If we modify the Function
and resample we obtain
u.vector()._scale(0.5)
vectorprobe(u)
print vectorprobe[0]
print vectorprobe[1]
[ 0.88167788 0.46352549 1.29903811 0.43186438 0.11936438 0.9375
0.22704454 0.6362962 0.33452071]
[ 0.29389263 0.1545085 0.4330127 0. 0. 0. 0.
0. 0. ]
The first 9 values are the sum of the two samplings. To get the average one needs to divide by the number of evaluations
print "Number of evals = ", vectorprobe.number_of_evaluations()
print vectorprobe[0] / vectorprobe.number_of_evaluations()
which leads to
Number of evals = 2
[ 0.44083894 0.23176275 0.64951905 0.21593219 0.05968219 0.46875
0.11352227 0.3181481 0.16726035]