Control volumes and their geometric coefficients from Delaunay
triangle and tet meshes: Voronoi control volumes, median control
volumes, or a hybrid between Voronoi and median. This manual covers
the stand-alone program cv_dual and its library and LaGriT entry
point (section 17). The
LaGriT command (dump / control_volume) is described in
DUMP_CONTROL_VOLUME.md.
cv_dual was developed as del_vor in
github.com/cwgable/del_vor
(archived; its history is in LaGriT’s).
Contents
cv_dual reads a mesh of triangles (a 2D mesh, or a fracture network
in 3D) or of tets, and computes, for every vertex, its control volume,
and for every mesh edge ij, the area A(ij) of the face between the
control volumes of i and j and the edge length d(ij). These are the
geometric coefficients of two-point-flux finite-volume codes. cv_dual
writes them as FEHM .stor, PFLOTRAN .uge and TOUGH MESH files.
The option cv chooses the control volumes
(section 9):
voronoi (the default): the cell of the Voronoi diagram around each
vertex, cut to the mesh (the dual points are the circumcenters);median: the median control volume (the dual points are the
centroids); the mesh need not be Delaunay;hybrid: Voronoi wherever that gives no negative coefficient, moved
toward median only in the cells, and only as far, as needed to
remove the negative ones;blend: one fixed mix of the two everywhere (alpha, 1 = Voronoi,
0 = median).A run has four steps:
cv median the
run goes on (median control volumes need no Delaunay mesh);Nothing is written unless every check passes, except the report and the violations file, which say why.
cv_dual is built with LaGriT, from the top of the LaGriT checkout:
cmake -S . -B build -D CMAKE_BUILD_TYPE=Release
cmake --build build --parallel 6
This builds build/lagrit and, beside it, build/cv_dual and the two
programs the test suites use, build/cv_dual_selftest and
build/cv_dual_entry_test. The source is in src/cv_dual/; it needs
no LaGriT library, only a Fortran 2008 compiler (gfortran 9 or later,
or Intel Fortran), and is compiled with LaGriT’s flags (8-byte
integers; a zero is written 0.0000000000000000E+00, without a
sign).
cv_dual -avs MESH.inp [-stor FILE] [-uge FILE] [-tough FILE]
[-zero_area remove|keep] [-zero_tol X] [-compress on|off]
[-cv voronoi|median|blend|hybrid] [-alpha X]
[-hybrid_tol X] [-alpha_min X] [-hybrid_iter N]
[-alpha_file FILE] [-delaunay_tol X] [-violations FILE]
[-check_only on|off] [-report FILE]
[-paraview ROOT] [-paraview_faces on|off]
[-paraview_subset all|boundary|flagged|material N|box ...]
[-vtu_format binary|ascii] [-vtu_layout new|legacy]
[-matrix FILE] [-matrix_bins N] [-outside_area FILE]
Options are keyword / value pairs, in any order; the dash is
optional (stor a.stor is -stor a.stor). cv_dual -help lists
them. Section 4 has the full table.
Examples:
cv_dual -avs mesh.inp -stor mesh.stor
checks mesh.inp and writes the FEHM .stor.
cv_dual -avs mesh.inp -stor mesh.stor -uge mesh.uge -tough MESH
three outputs from one run; the geometry is computed once.
cv_dual -avs mesh.inp -check_only on -report mesh.report
checks the mesh only, and keeps a copy of the screen output in
mesh.report.
cv_dual -avs mesh.inp -stor mesh.stor -zero_area keep -compress off
one matrix entry per mesh edge, zero-area ones included, every value
written out (the .stor most like LaGriT’s matbld2d).
cv_dual -avs mesh.inp -stor mesh.stor -cv hybrid -alpha_file alpha.vtu
control volumes moved away from Voronoi only where a coefficient
would be negative (section 9), with
the weight of each cell in alpha.vtu for ParaView.
lanl/voronoi’s options -type fehm|pflotran|tough, -o FILE and
-compress with no value also work, so old scripts run unchanged.
| keyword | value | default | meaning |
|---|---|---|---|
avs |
file | (required) | the mesh: AVS UCD, all triangles or all tets |
stor |
file | voronoi.stor if no output is given |
FEHM .stor |
uge |
file | PFLOTRAN .uge |
|
tough |
file | TOUGH MESH (tough2, the older name, also works) |
|
zero_area |
remove, keep |
remove |
remove: zero-area connections are left out of every file; keep: one connection per mesh edge |
zero_tol |
number >= 0 | 1e-12 |
zero area: |A| <= zero_tol d² (tets), zero_tol d (triangles) |
compress |
on, off |
on |
.stor: each distinct value written once |
cv |
voronoi, median, blend, hybrid |
voronoi |
where each cell’s dual point goes (section 9) |
alpha |
number from 0 to 1 | cv blend only, and required there: 1 = Voronoi, 0 = median |
|
hybrid_tol |
number >= 0 | 0 |
cv hybrid only: how negative a coefficient may stay, relative to the sum of its pieces |
alpha_min |
number from 0 to 1 | 0 |
cv hybrid only: the lowest alpha it may give a cell |
hybrid_iter |
whole number >= 1 | 100 |
cv hybrid only: the most stage B passes |
alpha_file |
file | none | the mesh with alpha and stage per cell, for ParaView |
paraview |
root | none | the ParaView files ROOT.pvd, ROOT_mesh.vtu, ROOT_cells.vtu, ROOT_negative.vtu (section 10) |
paraview_faces |
on, off |
off |
also ROOT_faces.vtu, the dual faces (tets) |
paraview_subset |
all, boundary, flagged, material N, box x1 y1 z1 x2 y2 z2 |
all |
the vertices that get a cell |
vtu_format |
binary, ascii |
binary |
appended raw data, or text |
vtu_layout |
new, legacy |
new |
VTK’s polyhedron layout: new for ParaView 6, legacy for ParaView 5 |
matrix |
file | none | the coefficient matrix for ParaView (section 10) |
matrix_bins |
whole number >= 1 | none | with matrix: also an N x N image of the matrix |
outside_area |
file | none | each boundary vertex’s vector area, the boundary part of its control volume (section 10); an output: with it alone, no voronoi.stor |
delaunay_tol |
number >= 0 | 1e-10 |
a tie within ±delaunay_tol; below -delaunay_tol a facet is not Delaunay |
delaunay_fatal |
number >= 0 | 1e-2 |
between -delaunay_fatal and -delaunay_tol: a warning, the run goes on; below -delaunay_fatal: fatal |
violations |
file | violations.vtu |
the flagged facets; written only when some facet is flagged |
check_only |
on, off |
off |
on: the mesh and Delaunay checks only; no coefficient file is written |
report |
file | none | a copy of the screen output |
timing |
on, off |
off |
development only: the wall and CPU time of each step and the peak memory, at the end of the report |
lanl/voronoi’s -type fehm|pflotran|tough with -o FILE (default
names voronoi.stor, pflotran.uge, MESH_VORONOI) and -compress
with no value are also accepted.
An AVS UCD file (.inp), as LaGriT’s dump / avs writes it:
nvertices ncells nvertex_data ncell_data 0
1 x y z one line per vertex
...
1 itetclr tri i j k one line per cell
... (or: tet i j k l)
nfields 1 1 ... vertex data, optional
imt1, integer
itp1, integer
1 imt1 itp1 one line per vertex
...
tri) or all tets (tet). Other types,
or a mix, are refused.itetclr, the name cv_dual’s messages
and files use). Two cells of different material ids sharing a face
are a material interface; in a fracture network each fracture has
its own material id.avs_cells.f), so a tet
LaGriT wrote with positive volume is read with positive volume.imt1 (or imt, integer_material_type),
itp1 (or itp) and isn1 (or isn) are read; other vertex and
cell data are skipped. imt1 gives the TOUGH material of each
vertex. These are LaGriT’s vertex attributes: the vertex material,
the vertex type (boundary, interface, parent) and the parent/child
link; LaGriT’s
mesh object page
describes them, and itetclr, in full.D exponent (1.0D+00); a vertex’s data may run onto more lines
(LaGriT wraps them when a mesh has many vertex attributes).dump / avs now writes 17
significant digits, which keeps every double exactly. Older files
have 13; that rounding shows in ties (see
section 7) and in the last digits of the
coefficients.Before any geometry, cv_dual builds the face neighbors of every cell
(LaGriT’s jtet) and checks the mesh. Each of these is fatal: the
run stops with exit status 1 and writes nothing.
| check | message | what is wrong |
|---|---|---|
| cell types | “mixed cell types; all triangles or all tets” | triangles and tets in one mesh |
| “cell type quad not allowed; triangles or tets only” | any other cell type | |
| “cell refers to a vertex that does not exist” | a vertex number above the vertex count | |
| positive area/volume | “ERROR: N tets with zero or negative volume” | an inverted tet (negative volume in LaGriT’s vertex order), a flat one, or one naming a vertex twice |
| “ERROR: N triangles with zero area” | three vertices on one line | |
| conformity | “ERROR: N tet faces shared by 3 or more tets” | not a conforming tet mesh |
| “ERROR: N edges in 3 or more triangles of one itetclr” | a “book” of triangles in one surface | |
| orientation | “ERROR: N pairs of neighboring triangles oriented differently” | two neighbors of one itetclr run along their shared edge the same way: one is turned over (or the surface, like a Moebius strip, cannot be oriented) |
| parent/child chains | “cv_dual: this mesh has parent/child chains (N vertices with itp1 = 41)”, then “cv_dual: run resetpts / parent, then rmpoint / compress; nothing is written” | vertices with itp1 = 41, LaGriT’s parents (settets / parents makes them at interfaces); split control volumes are not built yet. Checked before the others |
Each ERROR line is followed by first: cell ... naming the first
cell (or pair of cells) found, so it can be looked at in LaGriT or
ParaView.
Not errors:
jtet = mbndry + the neighbor, as in LaGriT).vertices in no cell; LaGriT’s
dudded vertices look like this) and no control volume.The block ends with the counts:
cv_dual mesh checks
faces paired, same itetclr 685
faces paired, other itetclr 0
boundary faces 166
mesh checks passed
(for triangles: edges paired, boundary edges, and the number of
fracture intersection edges).
Left and middle: the same four vertices with either diagonal. Right:
a boundary triangle. Drawn by figures/make_figures.py from the
coordinates shown.
A facet is a face of a tet, or an edge of a triangle. For each facet shared by two cells T1 and T2, cv_dual computes their circumcenters c1 and c2 and
delta = (c2 - c1) . n
with n the unit normal of the facet pointing from T1 into T2 (for triangles, in the triangles’ plane). delta is the signed length of the Voronoi edge dual to the facet. It is positive when the facet is locally Delaunay (the fourth vertex is outside the circle or sphere of the other cell), zero when the vertices are co-circular or co-spherical, and negative when it is not Delaunay (left and middle of the figure). A mesh in which every facet is locally Delaunay is a Delaunay mesh.
delta is judged relative to L, the facet’s length (triangles) or the mean of its three edge lengths (tets), so the test does not depend on the units:
| delta/L | the facet is | |
|---|---|---|
| < -delaunay_fatal | not Delaunay | fatal: no coefficient file |
| between -delaunay_fatal and -delaunay_tol | slightly not Delaunay | a WARNING; the run goes on |
| between -delaunay_tol and delaunay_tol | a tie | accepted |
| > delaunay_tol | Delaunay |
Every facet below -delaunay_tol goes to the violations file, warned or fatal.
The default, 1e-10, is set by what was measured on the test meshes
(compared with exact rational arithmetic, test_cv_dual_delaunay):
1e-10 lies between, with margin for coordinates rounded to 13 digits
(older LaGriT files)
by dump / avs.
A mesh is not rejected for a little jitter or round-off. Facets with delta/L between -delaunay_fatal (default 1e-2) and -delaunay_tol are slightly not Delaunay: their vertices are nearly co-circular or co-spherical. cv_dual says so and goes on:
WARNING: 15 faces slightly not Delaunay (delta/L >= -1.0E-02):
nearly co-circular / co-spherical; the coefficients there are
accurate to about |delta/L| of a typical coefficient (violations file)
Delaunay check passed (with the warning above)
Why this is safe: at such a facet the Voronoi edge dual to it has a small negative length, delta, instead of a small positive one. That changes the Voronoi faces of the facet’s edges by about |delta| L, so their coefficients by about |delta/L| of a typical coefficient. The control volumes still add up to the mesh volume. An edge whose coefficient is itself near zero (nearly co-spherical) can carry an error as large as its value, so its sign is not reliable there; its size stays tiny.
Where it comes from: LaGriT’s connect does not always make an
exactly Delaunay mesh. On jittered grids (test_cv_dual_timing) it left 9
facets with delta/L down to -1.5e-5 in a mesh of 960,000 tets and 15
down to -3.6e-4 in one of a million tets (both confirmed in exact
arithmetic), and down to -3.7e-4 at 3 million tets and
-2.3e-3 at 10.4 million; none in 10 million triangles. In the
million-tet mesh no coefficient came out negative (the smallest A/d
was +9.5e-14, a near-zero face); the 45 edges of the 15 facets all
kept positive coefficients.
The default 1e-2 is about 4 times beyond the worst seen from
connect, and a real fault is far beyond it: the flipped edges and
faces of the test meshes give delta/L from -0.14 to -21. At
delta/L = -1e-2 a coefficient is off by about 1 % of a typical one.
delaunay_fatal equal to delaunay_tol makes every facet beyond the
tolerance fatal; a delaunay_fatal below delaunay_tol is raised to
it.
Circumcenters are computed relative to a vertex of the facet, so the check gives the same answer at UTM-size coordinates (tested at (7e5, 3.2e6, 1.5e3)) as at the origin.
A facet between two material ids (a material interface) is tested the same way and counted separately. In a triangle mesh only triangles of one material id are paired, so a fracture network is tested fracture by fracture.
For a facet on the boundary of cell T, cv_dual measures how far T’s circumcenter c lies beyond the facet:
s = (c - x) . n_out / L
with x a vertex of the facet and n_out the outward normal (right of the figure). s > delaunay_tol means the circumcenter is outside the mesh there (for triangles: the angle opposite the boundary edge is obtuse). The Voronoi cell is then cut by the boundary, and a negative coefficient at that edge is likely. These are counted and written to the violations file, but never stop the run: many good meshes have them, and they are a property of the boundary, not an error.
For each flagged facet cv_dual also records R / shortest edge of its cells (R the circumradius). Cells with a ratio above 5 are counted as slivers. A large |delta| from a sliver may be round-off rather than a real violation; the ratio in the violations file tells them apart.
cv_dual Delaunay check (delaunay_tol 1.0E-10, delaunay_fatal 1.0E-02)
interior faces checked 685
ties (|delta/L| <= tol) 201
violations 0
beyond delaunay_fatal 0
smallest delta/L -2.3733E-16 cells 178 and 250
at 4.166667E+04 3.333333E+05 2.083333E+05 itetclr 1
delta/L histogram
-inf to -1.0E-02 0
-1.0E-02 to -1.0E-06 0
-1.0E-06 to -1.0E-10 0
-1.0E-10 to 0.0E+00 27
0.0E+00 to 1.0E-10 174
1.0E-10 to 1.0E-06 0
1.0E-06 to 1.0E-02 0
1.0E-02 to +inf 484
boundary faces checked 166
boundary circumcenter outside 0
slivers (R/shortest edge > 5) 0
largest R / shortest edge 1.6583E+00
Delaunay check passed
This is the block for mesh_3D.inp, a test mesh of
lanl/voronoi, the code cv_dual’s
kernels and writers were ported from (the file:
test/sanity_check/mesh_3D.inp;
cv_dual’s tests have a copy,
test/suite/test_cv_dual_voronoi_gold/inputs/mesh_3D.inp). It is a
cube of side 1e6 cut into 384 tets on 116 vertices, graded toward one
corner. Many of its vertices lie on common spheres, so 201 interior
facets are ties: delta/L is exactly 0 in exact arithmetic, and
computed it is within round-off of 0 (27 of the 201 come out slightly
negative, by at most 2.4e-16). None is a violation. The histogram
shows how close the mesh comes to failing: a facet counted in the
three bins below -1e-10 (delaunay_tol) would be a violation; the
facets just above it are the near ties.
When there is a violation the block ends with
Delaunay check FAILED: the mesh is not Delaunay beyond delaunay_fatal;
no Voronoi coefficients are written. See the violations file.
and the run stops with exit status 1, after writing the violations file and the report.
When the Delaunay check flags any facet (a violation, or a boundary
circumcenter outside), cv_dual writes the flagged facets to
violations.vtu (or the file given by -violations), whether or not
the run goes on. With nothing flagged, no file is written.
It is a VTK XML unstructured grid, in ASCII, which ParaView opens
directly. Open the mesh .inp in the same ParaView window (ParaView
reads AVS UCD) to see where the facets are. Each flagged facet is one
cell: a triangle (tet meshes) or a line segment (triangle meshes),
with its own copies of the facet’s vertices.
| cell data | meaning |
|---|---|
kind |
1 violation; 2 violation across a material interface; 3 boundary facet with the cell’s circumcenter outside |
delta_over_L |
kinds 1 and 2: delta/L (negative); kind 3: s/L (positive) |
cell1, cell2 |
the cells on either side (cell2 = 0 for kind 3) |
itetclr1, itetclr2 |
their materials |
ratio |
the larger R / shortest edge of the two cells (large: a sliver) |
| point data | meaning |
|---|---|
vertex |
the mesh vertex number |
In ParaView: color by kind or delta_over_L; use Threshold on
kind to see only the violations; select a cell to read cell1,
cell2 and the vertex numbers.
For each cell, cv_dual computes the cell’s share, or piece, of the control volume of each of its vertices and of the dual face of each of its edges, from the cell’s dual point (for Voronoi, its circumcenter) and those of its faces and edges, and adds the pieces up over all cells. The sums give, for every vertex i, its control volume V(i) (an area for triangles), and for every edge ij, the area A(ij) of the dual face between the control volumes of i and j (a length for triangles) and d(ij) = |x(j) - x(i)|. A(ij)/d(ij) is the coefficient of the two-point flux between i and j (the .stor stores -A(ij)/d(ij)).
A piece can be negative. When a cell’s circumcenter lies outside the
cell (an obtuse triangle, or a tet whose circumcenter is outside it),
the cell’s piece of A(ij) is negative for one or more of its edges
(in a triangle, the edge opposite the obtuse angle): that part of the
dual face points backward. With Voronoi control volumes on a
Delaunay mesh, the pieces of an interior edge always add up to
A(ij) >= 0; an edge on the boundary has fewer cells around it, and
its sum A(ij) can come out negative. A negative coefficient, in
this manual, means exactly that: a negative face area A(ij), and so a
negative A(ij)/d(ij), with which the two-point flux between i and j
would run from the lower value to the higher. The
summary counts them (negative A(ij)); the policies below, the
hybrid above all, are there to remove them.
The control volumes still add up to the mesh volume, negative pieces included; each run prints the relative difference (round-off, about 1e-15).
Where each cell’s dual point goes. A cell T gets a weight alpha(T) from 0 to 1 and its point is
P(T) = G(T) + alpha(T) (C(T) - G(T))
with C the circumcenter and G the centroid. In 3D each face point is the same blend of the face’s circumcenter and centroid, with alpha(f) = min(alpha(T1), alpha(T2)) over the face’s two tets, so the two halves of a dual face meet and every control volume stays closed. Edge midpoints never move. Whatever the points, the volumes add up to the mesh volume.
cv |
alpha | Delaunay check | use |
|---|---|---|---|
voronoi (default) |
1 everywhere | required | true Voronoi control volumes; faces perpendicular to edges |
median |
0 everywhere | advisory: reported, the run goes on | meshes that are not Delaunay; never negative in 2D |
blend |
alpha X everywhere |
required | sensitivity studies |
hybrid |
per cell, the largest with no negative coefficient | required | an M-matrix from a mesh that cannot be repaired |
Above: a boundary triangle whose angle opposite the boundary edge is
obtuse. With Voronoi its circumcenter lies outside, and its piece of
the boundary edge’s coefficient is negative. With median it is
positive. The hybrid’s stage A puts the point on the edge, so the
piece is 0. (Drawn by figures/make_figures.py.)
The hybrid keeps alpha = 1 (Voronoi) wherever it can:
An edge counts as negative when A(ij) < -hybrid_tol times the sum of
|its cells’ pieces|, unless it is a zero-area edge (|A| <= zero_tol
d², above): round-off on co-spherical ties is not a negative
coefficient. Edges still negative when every cell around them is at
alpha_min, or when hybrid_iter passes are used up, give a
WARNING; the files are still written.
Measured (test_cv_dual_policy):
.stor is byte for byte the
Voronoi one.dump / stor reports the same). cv median runs on it with none;
cv hybrid stops.blend with alpha 0.5 on the same 3D mesh has 21 negative
coefficients, against 75 for Voronoi and 0 for median: in 3D a
coefficient is not linear in alpha, because cell and face points
both move. In 2D it is linear.alpha_file FILE writes the mesh as a VTK file for ParaView, with
cell data alpha, stage (0 untouched, 1 stage A, 2 stage B),
negative (1 on the cells of an edge still negative) and itetclr.
On co-circular or co-spherical vertices (the ties of the Delaunay
check) some edges get a Voronoi face of zero area: they are mesh
edges, but not Voronoi neighbors. With -zero_area remove (the
default) they are left out of every output file; with -zero_area
keep the coefficient matrix has one entry per mesh edge, zero ones
included. An edge has zero area when
|A(ij)| <= zero_tol d(ij)^2 (tets)
|A(ij)| <= zero_tol d(ij) (triangles)
with zero_tol 1e-12 by default. True zeros measured on the test meshes are at most 1.3e-16 (relative), the smallest real faces 5.7e-10. The control volumes are never changed by this choice.
Several outputs can be written in one run; with none given (nor
outside_area), cv_dual writes voronoi.stor. No two files of one run may share a name, and
no output may be named like the mesh.
FEHM .stor (-stor FILE): ASCII, in the layout LaGriT’s
matbld2d_stor and matbld3d_stor write: the volumes, the row
pointers, the column numbers of every row (lower neighbors, itself,
upper neighbors, in increasing order), the pointers into the values,
the diagonal pointers, and the values -A(ij)/d(ij) (0 on the
diagonal). Volumes and values are written with 17 significant digits
(1pe24.16), enough to give back every double exactly; LaGriT’s
dump / stor writes 13. FEHM reads these blocks list-directed, so
the wider fields need nothing on its side. With -compress on (the default), values equal within
1e-14 of the largest |value| are written once and shared through the
pointer block (LaGriT’s compressmatrixvalues rule); with -compress
off, one value per matrix entry.
The two header lines say how the file was made (FEHM reads 72
characters of each and ignores them, so they can hold anything).
Line 1 names the policy: Voronoi, Median, Blend or Hybrid
Coefficients. Line 2 is LaGriT’s date and model text, then in
parentheses the command that made the file, as it was typed:
fehmstor ascir8i4 LaGriT Sparse Matrix Voronoi Coefficients
Sun Nov 15 15:14:31 2026 3-D Linear Diffusion Model (cv_dual -avs mesh.inp -stor mesh.stor -zero_area keep -compress off)
An argument holding a blank, a quote or a parenthesis is shown in
single quotes, as a shell needs it, so the command can be run again
as it stands. The first word in the parentheses is the writer’s name,
which test/suite/cv_dual_tools/stor_compare.py reads (LaGriT’s files have
(matbld3d_astor) and the like). Options left at their defaults do
not appear here; the report lists every option of the run, defaults
included (section 12).
PFLOTRAN .uge (-uge FILE):
CELLS n
id x y z volume one line per vertex
CONNECTIONS m
i j x y z area one line per edge, i < j
The connection point is the edge midpoint, as in lanl/voronoi. Coordinates, volumes and areas have 17 significant digits; the longest line is 128 characters (PFLOTRAN reads input lines of up to 512).
TOUGH MESH (-tough FILE): ELEME (one record per vertex:
name, material, volume, AHTX, x, y, z) and CONNE (one record per edge:
names, ISOT, d1 = d2 = d/2, area, BETAX = cos of the angle to
gravity), column for column as lanl/voronoi wrote them. The material
is the rank of the vertex’s imt1 among its distinct values. AHTX is
written equal to the volume, as lanl/voronoi did; this is an open
question for TOUGH users.
ParaView (-paraview ROOT): the control volumes as cells, to
look at, clip and color in ParaView. Open ROOT.pvd; it loads:
| file | cells | data |
|---|---|---|
ROOT_mesh.vtu |
the input triangles or tets | cell: itetclr, alpha, stage; vertex: vertex, volume, imt1, boundary |
ROOT_cells.vtu |
one per control volume: a polygon (triangles; in a fracture network one per vertex per fracture) or a polyhedron (tets) | vertex, volume, material, boundary, nfaces, min_coefficient |
ROOT_negative.vtu |
one segment per negative coefficient (written only if there is one) | coefficient, class (1 boundary, 2 interior, 3 interface), vertex_i, vertex_j |
ROOT_faces.vtu |
with -paraview_faces on (tets): each dual face, one polygon (Voronoi) or its triangles |
vertex_i, vertex_j, area (along the edge), coefficient, angle |
| the violations file | when the Delaunay check flagged facets | (section 8) |
The cells are drawn from exactly the dual points the coefficients
came from: with cv hybrid, the moved points. A polyhedron’s faces
are the Voronoi faces of its edges, one planar polygon each, and, on
the boundary, the part of each boundary triangle nearer the vertex.
A dual face with a moved point (cv hybrid near the cells it
changed, cv median and cv blend everywhere) is not planar and is
written as the kernel’s triangles; with cv hybrid, every edge
whose cells all kept their circumcenters (alpha 1) still gets its
one Voronoi polygon, so only the changed region shows triangles
(poi3: 12,706 triangles instead of 186,912).
Every polyhedron is closed, its faces point outward, and its volume
is the control volume (test_cv_dual_paraview measures both).
With cv voronoi only true corners are written. When an angle
opposite an edge is obtuse, the circumcenter lies past the edge: the
edge midpoint (2D), or a face circumcenter (3D), is then on the line
through its two neighbors but not between them, so it is left out;
the same holds for an edge midpoint between two coplanar boundary
triangles, whose boundary pieces are merged into one polygon (a
vertex inside a flat boundary patch is then no corner either). With
cv hybrid, stage A can put a dual point exactly on a facet; an
outline then folds back along that facet. This is the geometry of
the moved points, not a drawing error, and the volumes still match.
-paraview_subset limits the cells: boundary (vertices on the
boundary), flagged (vertices of a negative coefficient, or of a
cell with alpha < 1), material N (vertices of cells of material
id N), box x1 y1 z1 x2 y2 z2 (vertices inside). The mesh file then
holds the cells that touch those vertices.-vtu_format binary (default) or ascii (text, for small cases).-vtu_layout new (default: VTK’s polyhedron layout since VTK 9.4,
read by ParaView 6) or legacy (the older layout, for ParaView 5
and other older readers).Sizes: a million tets give 157,000 polyhedra, a 210 MB cells file
(Voronoi or hybrid), about 8 s, and a peak of 620 MB for the whole
run (680 MB hybrid; a Linux workstation); 10 million about ten times
that. For large meshes, a subset is the way to look:
boundary on a million tets takes 0.9 s.
-matrix FILE writes the coefficient matrix for ParaView, to see its
shape: one point per entry of the .stor matrix at (x, y, z) =
(j, -i, 0), so row 1 is at the top, as a printed matrix. Both halves,
(i, j) and (j, i), and the diagonal (i, i) are written; the entries
are exactly those of the .stor (zero-area connections only with
-zero_area keep, and then flagged). Each point is a VTK vertex
cell, so Threshold and Extract Selection work on single entries.
-paraview_subset limits the file to the rows of its vertices. The
file is written on its own: -paraview is not needed, and it is not
listed in ROOT.pvd (its coordinates are matrix positions, not
space).
| point data | meaning |
|---|---|
i, j |
row and column, 1-based as in the .stor |
area, distance, coefficient |
A(ij) (signed), d(ij), A/d; on the diagonal 0 (the .stor diagonal value) |
class |
0 diagonal, 1 boundary, 2 interior, 3 interface (as in ROOT_negative.vtu) |
negative, zero_area |
1: A/d < 0; 1: a zero-area connection (-zero_area keep) |
alpha_min |
the smallest alpha of the cells around the edge (of the vertex, on the diagonal); 1 with Voronoi |
angle |
degrees between the edge and its dual face’s vector area (the sum of the face’s pieces): 0 for a Voronoi face, 180 for one that points backward (a negative coefficient), between them for moved points |
material_i, material_j |
the vertices’ imt1 |
volume |
the control volume (diagonal points; 0 elsewhere) |
In ParaView: open the file, Apply; set the representation to Point
Gaussian (fast at millions of points; Shader Preset “Plain square”
or “Sphere”, and a Gaussian Radius of about 0.4) and color by any
point data. A negative entry: Threshold on negative. The report
gives the bandwidth (the largest |i - j|) and the profile (the sum
over the rows of i minus the row’s first column) of the whole
matrix, which depend on the vertex numbering.
-matrix_bins N also writes an image of the whole matrix (the
matrix file’s name with .vti, or .vti added): the rows and the
columns are cut into N groups (at most one per row) and each pixel
holds the entries of its block: count, negative (how many are
negative) and min_coefficient (the smallest off-diagonal A/d). It
lies over the points, so the two can be opened together. For a
large matrix it shows the shape at a glance; then look closely with
a subset.
Sizes: a million tets give 2.5 million entries, a 364 MB matrix file written in 1.2 s; the image is 24 MB at N = 1000, whatever the mesh.
Unlike lanl/voronoi, .uge and MESH keep the sign of volumes and
areas (voronoi wrote absolute values, which hides negative
coefficients); a negative TOUGH number is written with one digit
less to fit its 10 columns. Whether this is what PFLOTRAN and TOUGH
users want is also an open question.
-outside_area FILE lists, for each vertex on the mesh boundary
(on an exterior face, or edge in 2D), the part of its control volume
on the boundary as a vector area (Ax, Ay, Az), pointing outward. A
flux through the boundary, such as infiltration, multiplies it. The
pieces come from the same dual points as the coefficients:
cv voronoi F is the face’s circumcenter (a circumcenter
outside the face makes a negative piece), with cv median its
centroid (a third to each vertex), with cv hybrid or blend the
point the policy chose;# cv_dual outside_area: Voronoi boundary vector areas, 803 boundary vertices
# vertex Ax Ay Az
1 -1.2266332204474229E-04 -1.2094912154999060E-04 -1.0718696382558404E-04
...
# sum -1.0316183671199575E-16 9.0530881402539620E-18 -3.7947076036992655E-18
On a closed boundary the sum is zero. LaGriT’s dump / fehm and
dump / zone_outside with cv_dual write the same numbers in FEHM’s
outside zones (_outside_vor.area, _med, _hyb; section
17); for
Voronoi and median they equal LaGriT’s own (get_xcontab) to
rounding.
A fracture network from dfnWorks or LaGriT is a triangle mesh in 3D:
each fracture is a planar triangle mesh with its own material id
(itetclr), and
fractures cross along shared edges. An intersection edge is in two
triangles of each fracture that crosses there.
cv_dual handles this directly:
The mesh check block reports the intersection edges:
cv_dual mesh checks
edges paired, same itetclr 2025
edges paired, other itetclr 0
boundary edges 168
fracture intersection edges 16
mesh checks passed
An edge in 3 or more triangles of one material id is still an error: it is a fork within one fracture, not an intersection.
Everything cv_dual prints goes to the screen. -report FILE writes a
copy of it, line for line, to FILE, which is useful for scripts and
for runs whose screen output is lost. A run prints, in order:
cv_dual: options, then every option of the run as keyword=value,
defaults included, in lines of at most 78 characters (the mesh with
its full path); and cv_dual: reading MESH;check_only on):cv_dual summary
vertices 116
tets 384
edges 582
positive tets 384
negative tets 0
mesh volume 1.000000000000E+18
sum of control volume 1.000000000000E+18
relative difference -6.40E-16
negative volumes 0
zero-area edges 120 (zero_tol 1.0E-12)
zero_area remove: left out of the output files
negative A(ij) 0
minimum A(ij)/d(ij) 4.882812500000E+02
cv other than voronoi, the policy block, here for the
hybrid on test_poisson_3d case 1:cv_dual control volumes: hybrid
negative coefficients boundary interior smallest A/sum|A|
Voronoi 75 0 -1.00E+00
after stage A 0 0 0.00E+00
after stage B 0 0 0.00E+00
alpha: 1 in 7680, 0 in 0, between in 108
smallest alpha 0.140691399
cells lowered: stage A 108, stage B 0
stage B passes 0 alpha_min 0.000
non-orthogonality: max 80.16 deg, area-weighted mean 0.366 deg
The rows count negative coefficients (as the hybrid judges them) on boundary and interior edges at each step; “smallest A/sum|A|” is the most negative, relative to the sum of its pieces (-1: all pieces negative). Non-orthogonality is the angle between each dual face’s vector area and its edge (0 for Voronoi), the price paid for positivity; the mean is weighted by area, because edges of nearly zero area have angles near 90 degrees that say little;
cv_dual: wrote stor a.stor.Exit status 0: every check passed and every file was written (with
check_only on: every check passed).
Exit status 1, and no coefficient file written:
| cause | message (examples) |
|---|---|
| an unknown keyword | “cv_dual: unknown keyword -zero_areas”, then “cv_dual: keywords are” and the list |
| a keyword with no value | “cv_dual: keyword zero_tol needs a value” |
| a bad value | “cv_dual: delaunay_tol -1: must be a number >= 0”, “cv_dual: check_only maybe: must be on or off” |
| two files with one name | “cv_dual: output file a.stor given twice” |
| an output named like the mesh | “cv_dual: mesh.inp is the mesh; it would be overwritten” |
| no mesh | “cv_dual: no mesh given (-avs MESH.inp)” |
| the mesh cannot be read | “read_avs: cannot open nothere.inp”, “read_avs: MESH: bad vertex line”, and the cell type messages of section 6 |
| parent/child chains | “cv_dual: this mesh has parent/child chains (3 vertices with itp1 = 41)”, “cv_dual: run resetpts / parent, then rmpoint / compress; nothing is written” |
| a mesh check fails | the ERROR lines of section 6, then “cv_dual: the mesh failed its checks (above)” |
| not Delaunay (delta/L < -delaunay_fatal) | “Delaunay check FAILED …”, then “cv_dual: not Delaunay; nothing else is written” (the violations file and the report are written). With “cv median” the run goes on instead: “cv_dual: cv median does not need a Delaunay mesh: going on” |
a keyword for another cv |
“cv_dual: alpha is for cv blend (here cv is hybrid)”, “cv_dual: hybrid_tol is for cv hybrid (here cv is median)”, “cv_dual: cv blend needs alpha (a number from 0 to 1)” |
gfortran adds the line STOP 1 after the message.
cd test/suite
ONLY=cv_dual JOBS=6 sh run_all.sh # cv_dual's 13 suites, about 15 s
JOBS=6 sh run_all.sh # with every LaGriT suite
then open test/suite/summary.html (LaGriT’s run_all.sh). Each suite judges cv_dual
against answers worked out independently (formulas, exact
arithmetic, LaGriT’s and lanl/voronoi’s files), draws a picture of
every case, and has a page with a “What it does” note for each case.
test/suite/cv_dual_tools/README.md lists the suites; each suite’s
00README says what it checks and how. test_cv_dual_timing, for
development, runs only with BIG=1 (BIG=1 ONLY=test_cv_dual_timing
sh run_all.sh; it needs LaGriT and makes big meshes).
test/suite/cv_dual_tools/stor_compare.py compares two .stor files of one mesh, pair
by pair and vertex by vertex, and labels every difference with what
explains it. It is how cv_dual is compared with LaGriT
(test_cv_dual_parity), and it works on any two .stor files.
python3 -I test/suite/cv_dual_tools/stor_compare.py A.stor B.stor --mesh MESH.inp
It prints the pairs in one file only, the largest differences with
the pairs and vertices where they are, the volume totals, a layout
check of each file, and every difference explained (exit 0) or
UNEXPLAINED differences: N (exit 1). Options: --mesh (needed for
some labels), --eps (LaGriT’s compress_eps, default 1e-8),
--zero_tol, --coord_digits, --json FILE, --worst N.
| label | explains |
|---|---|
digits |
the same number printed with the fewer significant digits of the two files (17 for cv_dual; LaGriT 13 before V3.4.0, 17 since) |
round_off |
small values made by cancellation, within 64 u (1.4e-14) of the largest |
coord_digits |
coordinates rounded in the mesh file (with --coord_digits) |
merge |
LaGriT’s compression stored one value for all within 1e-8 of the largest (anothermatbld3d) |
abs_coords |
LaGriT’s 3D writer computes tet volumes from absolute coordinates |
nstor_magnitude |
LaGriT’s old 3D writer stores |A|/d: negative coefficients come out with the wrong sign |
zero_area |
a zero-area pair left out by one of the codes |
dropped, dropped_share |
a pair below 1e-8 of the largest that LaGriT left out, and its share of its vertices’ volumes |
test_cv_dual_parity compares cv_dual with LaGriT’s dump / stor on 14
meshes (lanl/voronoi’s, LaGriT’s Poisson meshes and level01 meshes, a
two-material mesh, a mesh at UTM-size coordinates, two fracture
networks) and, outside git, dfnWorks TPL_nonuniform (114,739
triangles). Every difference is explained; most pairs agree to every
digit LaGriT prints. test_cv_dual_vs_matbld runs LaGriT’s own decks
with matbld and with cv_dual; cv_dual and matbld compared sums up both. Found in LaGriT along
the way:
dump / stor ... / none uses LaGriT’s old writer
(matbld3d_stor), which stores |A|/d: every negative coefficient
comes out positive (all 75 of LaGriT’s test_poisson_3d case 1).
The default dump / stor keeps the sign.Every step takes time in proportion to the mesh size. test_cv_dual_timing
fits log time against log size; on an Intel Mac (6 cores; Nov
10, 2026), from 9,126 to 10.4 million tets and from 9,800 to 10
million triangles, the slope of cv_dual’s total is 1.02 (tets) and
1.01 (triangles), and of every step 0.995 to 1.042. LaGriT’s
dump / stor alone grows a little faster (slopes 1.08 and 1.06).
| mesh | cv_dual | peak | LaGriT read + dump / stor |
peak |
|---|---|---|---|---|
| 1,019,162 tets | 7.2 s | 275 MB | 14.8 s | 424 MB |
| 3,003,241 tets | 20.3 s | 805 MB | 45.3 s | 1,190 MB |
| 10,404,079 tets | 74.8 s | 2,317 MB | 175.7 s | 3,459 MB |
| 996,872 triangles | 5.4 s | 338 MB | 11.6 s | 996 MB |
| 9,990,450 triangles | 60.4 s | 2,981 MB | 143.2 s | 6,433 MB |
cv_dual is 2.4 times faster at 10 million cells and needs 1.5 (tets)
to 2.2 (triangles) times less memory: about 220 bytes per tet and 300
per triangle. The steps that do the work of dump / stor (edge CSR,
assembly, writing the .stor) take 37.7 s at 10.4 million tets,
against 140.2 s for dump / stor. cv_dual’s largest steps at 10
million cells: writing the .stor (37 % for tets, 64 % for
triangles) and jtet (32 % for tets).
Everything after the mesh is read is one library routine,
run_mesh (src/cv_dual_run.F90); the program (src/cv_dual.F90)
parses the options, reads the AVS file and calls it. The library
never stops: an error comes back in ierr, its message already
written, and nothing more is written. LaGriT calls the same routine
through the entry point cv_dual_lagrit_entry
(src/cv_dual_entry.F90), an external subroutine its fixed-form code
calls with no interface block:
call cv_dual_lagrit_entry(nnodes, nelements, nen, xic, yic, zic,
* itettyp, itetoff, itet, itetclr, imt1, itp1, isn1,
* options, command, vol, want_area, barea, ierr)
-fdefault-integer-8; 8-byte reals), used in
place: never copied, never changed. The cells must be all triangles
(nen 3, itettyp 3) or all tets (nen 4, itettyp 5), with
itetoff(it) = nen*(it-1). jtet is built inside.options is one string of the program’s keywords and values,
separated by blanks, commas or slashes, a keyword’s dash optional:
'stor, mesh.stor / zero_area, keep'. Same parser, defaults and
messages as the program; avs is refused (the mesh is the
arguments).command is the text for the end of the .stor’s second line,
(COMMAND); blank gives (cv_dual OPTIONS). LaGriT passes its
command as typed: cv_dual dump / control_volume / mo_name / ....vol (nnodes) gets the control volumes; with check_only on or
after an error it is left as it was. ierr is 0, or 1 after an
error.want_area 1, barea (3, nnodes) gets each vertex’s
boundary vector area (section 10; 0
inside); with no output named in options, no file is written
(LaGriT’s dump / zone_outside). With 0, barea is not touched.cv_dual_log; log_set_sink(p) sends the
lines to a routine p(line) instead of the screen (inside LaGriT,
one that calls writloga).LaGriT’s command dump / control_volume / mo_name / keyword, value
/ ... (its page;
src/dump_control_volume.f90) takes the mesh object’s arrays with
cmo_get_info, joins the rest of the command into options (numbers
with every digit), sends cv_dual’s lines to LaGriT’s log, and calls
the entry point. Its keywords of its own: attribute_cv_volume
[, name] puts the control volumes in a vertex attribute (default
cv_volume), and the ten ccoef_* keywords put per-vertex extremes
of the connections in vertex attributes (the smallest and largest
A(ij), A(ij)/d(ij) and d(ij), and the vertex at the other end of the
A and A/d extremes; zero-area connections left out; vertex_stats in
cv_dual_run.F90). An error gives cv_dual’s message and LaGriT’s ERROR
line; nothing is written and LaGriT goes on.
Since V3.4.0 dump / stor, dump / fehm,
dump / pflotran and dump / zone_outside run cv_dual on the
mesh object for those commands’ files, unless the command says
matbld
(cv_dual OR matbld;
src/dump_cv_dual.f90): the .stor (zero-area connections left out
unless nofilter_zero; all, coefs compress, graph, none do
not), the .uge (filter_zero, the default, leaves zero-area
connections out), and the boundary areas in FEHM’s outside zones.
voronoi (default), median or hybrid (cv_dual’s) choose the
control volumes. Flagged facets go to ROOT_violations.vtu, beside
the dump’s files. Options cv_dual does not have (vector and area
coefficients, binary, pflotran’s verbose) and meshes of other cells
than triangles or tets leave the dump to matbld, with one line saying
so; a mesh cv_dual refuses gives an ERROR whose message names
matbld. matbld is LaGriT’s earlier code, unchanged.
The suite test_cv_dual_control_volume runs the command on meshes
LaGriT makes or reads and checks that every file equals the
program’s on the mesh written with dump / avs, that the attribute
equals the .stor’s volumes, and that errors leave LaGriT going. The
suite test_cv_dual_entry calls the entry point from fixed-form Fortran
compiled with LaGriT’s flags (the harness cv_dual_entry_test, built
next to cv_dual) and checks that every file, the screen output and
the volumes equal the program’s on the same mesh, and that errors
come back cleanly and the next call works. The suite
test_cv_dual_dump_keyword runs the dump commands with cv_dual and
matbld and checks that each .stor and .uge equals the
program’s, that the geometry and zone files equal matbld’s, and that
the boundary areas equal the program’s outside_area lists, matbld’s
for Voronoi and median, and add up to each side of a box.