Consider the following hexagonal mesh, created from VoronoiMesh
L1 = 4; L2 = 4;
pts = Flatten[Table[{3/2 i ,
(Sqrt[3] j + Mod[i, 2] Sqrt[3]/2)
}, {i, L1 + 4}, {j, L2 + 4}], 1] // N;
mesh0 = VoronoiMesh[pts];
mesh1 = MeshRegion[MeshCoordinates[mesh0],
With[{a = PropertyValue[{mesh0, 2}, MeshCellMeasure]},
With[{m = 3}, Pick[MeshCells[mesh0, 2], UnitStep[a - m], 0]]]];
mesh = MeshRegion[MeshCoordinates[mesh1],
MeshCells[mesh1, {2, "Interior"}]]
I can get the connectivity matrix of such mesh by doing
conn = mesh["ConnectivityMatrix"[1, 2]];
lens = PropertyValue[{mesh, 1}, MeshCellMeasure];
$threshold = 0.;
keep = Pick[Range[MeshCellCount[mesh, 1]],
UnitStep[Subtract[$threshold, lens]], 0];
conn = conn[[keep]];
adj = Transpose[conn].conn;
arg = Unitize[adj];
ag = (UpperTriangularize[arg, 1] + LowerTriangularize[arg, -1]);
ag // MatrixForm
Is it possible to easily change this matrix such that it considers the periodic hexagonal mesh case? I'm aware of this question, but I am looking for something more general, that could be specifically applied to Voronoi meshes.
More generally, is it possible at all to get the periodic connectivity matrices of meshes like
which are generated by VoronoiMesh
?
Ultimately, and this might be reaching too far for now, how hard could it be to fabricate a Voronoi periodic mesh that takes into account the "need to fit" condition, that is, either of the following
Edit: Following Chip Hurst's answer below, I can get the periodicity of the hexagonal mesh by setting
Show[Table[
MeshRegion[
TransformedRegion[mesh,
TranslationTransform[{1.5 L1 i, Sqrt[3] L2 j}]],
MeshCellStyle -> {1 -> Black,
2 -> ColorData[112, 7 i + j + 25]}], {i, 0, 1}, {j, i, 1}]]
This is rather useful, as I can possibly even consider cylindrical periodicity. How would I now get the connectivity matrix from this setting? That is last step I need.
ntab
to yield the matrix that I want, but I'm still trying. Thank you for the other links, I will take a look. $\endgroup$