Skip to content

Commit efaf1f3

Browse files
committed
examples/205_multivof: add sharpening_circle
1 parent 3e4203e commit efaf1f3

File tree

10 files changed

+202
-2
lines changed

10 files changed

+202
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
velocity.pdf
2+
build
3+
add.conf
4+
b.dat
5+
*.pyc
6+
*.swp
7+
*.log
8+
*.status
9+
*.h5
10+
*.xmf
11+
*.vts
12+
*.pvd
13+
stat.dat
14+
*.pdf
15+
pid
16+
arg
17+
out
18+
job.id.last
19+
job.id
20+
base.conf
21+
mesh.conf
22+
np
23+
*.csv
24+
s*.vtk
25+
a.conf
26+
add.conf
27+
tl
28+
*.png
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
m = 16 16 1
2+
bs = 16 16 1
3+
np = 1
4+
tl = 1440
5+
6+
include $(shell ap.makesim)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
set -eu
3+
d=smooth
4+
echo > add.conf
5+
make cleanrun
6+
(cd vis && rm -vf *.png && ./vis_vf.py ../s_*.vtk)
7+
(cd vis && mkdir -p "$d" && mv -v a_*.png "$d")
8+
(vis/plot_volume_error.py --output vis/$d/volume_error.pdf)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
set -eu
3+
d=stepwise
4+
echo "include stepwise.conf" > add.conf
5+
make cleanrun
6+
(cd vis && rm -vf *.png && ./vis_vf.py ../s_*.vtk)
7+
(cd vis && mkdir -p "$d" && mv -v a_*.png "$d")
8+
(vis/plot_volume_error.py --output vis/$d/volume_error.pdf)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# 2d
2+
set int dim 2
3+
set int hypre_periodic_z 1
4+
5+
set double extent 4
6+
7+
# numerical
8+
set int sharpen 1
9+
set double sharpen_cfl 0.1
10+
set int enable_fluid 0
11+
set string bc_path inline
12+
13+
# time
14+
set double dtmax 1
15+
set double tmax 10
16+
set double dump_field_dt 1
17+
set int dumpinit 1
18+
set string dumplist vf
19+
set int verbose_stages 0
20+
set int dumppolymarch 0
21+
22+
# volume fraction
23+
set string init_vf radial_trapezoid
24+
set vect radial_trapezoid_c 2 2 0
25+
set double radial_trapezoid_rmin 0.5
26+
set double radial_trapezoid_rmax 1.5
27+
28+
#include stepwise.conf
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
set double radial_trapezoid_rmin 1
2+
set double radial_trapezoid_rmax 1.000001
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env python3
2+
3+
import numpy as np
4+
import argparse
5+
from argparse import Namespace
6+
import plottools
7+
import matplotlib.pyplot as plt
8+
import aphros
9+
import os
10+
11+
myname = os.path.splitext(os.path.basename(__file__))[0]
12+
13+
14+
def load_stat(path):
15+
u = np.genfromtxt(path, names=True)
16+
res = Namespace(**{k: u[k] for k in u.dtype.names})
17+
return res
18+
19+
20+
parser = argparse.ArgumentParser()
21+
parser.add_argument('dir', nargs='?', type=str, default='.')
22+
parser.add_argument('--output', type=str, default="volume_error.pdf")
23+
parser.add_argument('--ylim', nargs='*', type=float, default=[-1, 1])
24+
parser.add_argument('--yscpow', nargs='*', type=int, default=-15)
25+
args = parser.parse_args()
26+
27+
plottools.apply_params(plt)
28+
29+
stat = load_stat(os.path.join(args.dir, "stat.dat"))
30+
31+
fig, ax = plt.subplots(figsize=(1.9,1.5))
32+
yscpow = args.yscpow
33+
if args.ylim:
34+
ax.set_ylim(*args.ylim)
35+
ax.set_xlabel('step')
36+
ax.set_ylabel(r'volume error $[10^{{{:}}}]$'.format(yscpow))
37+
ax.plot(stat.step, stat.vol2_diff * 10 ** (-yscpow))
38+
plottools.savefig(fig, args.output)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/usr/bin/env pvbatch
2+
3+
# state file generated using paraview version 5.9.0
4+
5+
from paraview.simple import *
6+
paraview.simple._DisableFirstRenderCameraReset()
7+
8+
import argparse
9+
import os
10+
import re
11+
import paratools
12+
13+
14+
parser = argparse.ArgumentParser(
15+
description="Renders interface shapes from s_*.vtk files.")
16+
parser.add_argument('files', nargs='*', help="list of data files 's_*.vtk'")
17+
parser.add_argument('--force',
18+
action="store_true",
19+
help="overwrite existing files")
20+
args = parser.parse_args()
21+
22+
renderView1 = CreateView('RenderView')
23+
renderView1.ViewSize = [1080, 1080]
24+
renderView1.OrientationAxesVisibility = 0
25+
renderView1.UseLight = 0
26+
renderView1.CameraPosition = [2, 2, 4]
27+
renderView1.CameraFocalPoint = [2, 2, 0]
28+
renderView1.CameraFocalDisk = 1.0
29+
renderView1.CameraParallelProjection = 1
30+
renderView1.CameraParallelScale = 1.5
31+
renderView1.Background = [1] * 3
32+
33+
# https://github.com/OrdnanceSurvey/GeoDataViz-Toolkit/tree/master/Colours
34+
clhex_geo = [
35+
"FF1F5B", "00CD6C", "009ADE", "AF58BA", "FFC61E", "F28522", "A0B1BA",
36+
"A6761D", "E9002D", "FFAA00", "00B000"
37+
]
38+
39+
40+
def rgb(h):
41+
return list(int(h[i:i + 2], 16) / 255. for i in (0, 2, 4))
42+
43+
44+
steps = paratools.ReplaceFilename(args.files, '{}', keep_dir=False)
45+
source_s = LegacyVTKReader(
46+
FileNames=paratools.ReplaceFilename(args.files, 's_{}.vtk'))
47+
source_vf = XDMFReader(
48+
FileNames=paratools.ReplaceFilename(args.files, 'vf_{}.xmf'))
49+
source_vf.CellArrayStatus = ['vf']
50+
sources_ft, timearrays = paratools.ApplyForceTime([source_s, source_vf])
51+
source_s, source_vf = sources_ft
52+
53+
vfDisplay = Show(source_vf, renderView1)
54+
vfLUT = GetColorTransferFunction('vf')
55+
vfLUT.AutomaticRescaleRangeMode = 'Never'
56+
vfLUT.RGBPoints = [0.0] + [1] * 3 + [1.0] + rgb(clhex_geo[2])
57+
vfLUT.ColorSpace = 'RGB'
58+
vfLUT.NanColor = [1.0, 0.0, 0.0]
59+
vfLUT.Discretize = 0
60+
vfLUT.ScalarRangeInitialized = 1.0
61+
vfPWF = GetOpacityTransferFunction('vf')
62+
vfPWF.ScalarRangeInitialized = 1
63+
vfDisplay.Representation = 'Surface'
64+
vfDisplay.ColorArrayName = ['CELLS', 'vf']
65+
vfDisplay.LookupTable = vfLUT
66+
67+
surfDisplay = Show(source_s, renderView1)
68+
surfDisplay.Representation = 'Wireframe'
69+
surfDisplay.AmbientColor = [0.0, 0.0, 0.0]
70+
surfDisplay.ColorArrayName = ['POINTS', '']
71+
surfDisplay.DiffuseColor = [0.0, 0.0, 0.0]
72+
surfDisplay.LineWidth = 8
73+
74+
paratools.SetTimeStep(1, sources_ft, timearrays)
75+
76+
paratools.SaveAnimation(steps,
77+
renderView1,
78+
sources_ft,
79+
timearrays,
80+
force=args.force)

src/client.cmake

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
cmake_minimum_required(VERSION 3.3.0)
22

33
# Allow using <PackageName>_ROOT variables
4-
cmake_policy(SET CMP0074 NEW)
4+
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12")
5+
cmake_policy(SET CMP0074 NEW)
6+
endif()
57

68
if (DEFINED ENV{APHROS_PREFIX})
79
set(CMAKE_INSTALL_PREFIX $ENV{APHROS_PREFIX}

src/kernel/hydro.ipp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ void Hydro<M>::InitStat(const MEB& eb) {
11891189
"tu" + sl + "_outrate", "outlet volumetric rate of tracer " + sl, //
11901190
[&ffv, &fcu = tracer_->GetVolumeFraction()[l], this, &meb = eb, l]() {
11911191
Scal sum = 0;
1192-
mebc_fluid_.LoopBCond(meb, [&](auto cf, IdxCell c, auto bc) { //
1192+
mebc_fluid_.LoopBCond(meb, [&, this](auto cf, IdxCell c, auto bc) {
11931193
if (m.IsInner(c)) {
11941194
if (bc.type == BCondFluidType::outlet ||
11951195
bc.type == BCondFluidType::outletpressure) {

0 commit comments

Comments
 (0)