# MeshTools package: can one translate 3d meshes in order to then merge them?

I have created a 3d region for Laplace's eqn

Needs["NDSolveFEM"]
Needs["MeshTools"]

r=1.12;
R2d1 =
RegionUnion[Disk[{1 + r, 0}, r], Disk[{-1 - r, 0}, r],
Disk[{0, -1 - r}, r], Disk[{0, 1 + r}, r]];
R2d = RegionDifference[Disk[{0, 0}, 4], R2d1];

M2d = ToElementMesh[R2d, "MeshOrder" -> 1,
MaxCellMeasure -> {"Length" -> 0.1}];
S2d = SmoothenMesh@TriangleToQuadMesh[M2d];
mesh3D = ExtrudeMesh[S2d, 5, 15];


and I managed to use this successfully in NDSolve, (and it had worked using the standard NDSolve FEM package), but I need to do more (at which NDSolve failed).

I need to add simple cylindrical regions at both ends (for z<0 and z>5).

I cannot figure out how to translate (shift) 3d meshes created by MeshTools (in order to merge them). The TransformMesh function appears to be limited to 2d meshes, and ExtrudeMesh doesn't seem to have the option to set the initial z-coordinate; or am I missing something?

• Do you really use this mesh ElementMesh[{{-4., 4.}, {-4., 4.}, {0., 5.}}, {HexahedronElement[ "<" 810045 ">"]}]? May 31 '20 at 23:28
• TransformMesh function should work just fine with 3D meshes, try TransformMesh[mesh3D, TranslationTransform[{0, 0, 5}]]. It is true that ExtrudeMesh doesn't have the option to set the Z coordinate, because one can use TransformMesh for all subsequent transformations. Jun 1 '20 at 10:55
• See also this answer for ideas on how to combine different extruded meshes. As as sidenote I suggest that you start experimenting with less dense meshes, make your approach work and then refine the mesh for producing the final result (if required). Jun 1 '20 at 11:06
• thank you, Pinti, this works well! Jun 2 '20 at 2:36
• @markoh, you could selfanswer your question. May be useful for future visitors. Jun 2 '20 at 4:47

## 1 Answer

You can make use of the FEMAddOns to do this now:

ResourceFunction["FEMAddOnsInstall"][]
Needs["FEMAddOns"]
r = 1.12;
R2d1 = RegionUnion[Disk[{1 + r, 0}, r], Disk[{-1 - r, 0}, r],
Disk[{0, -1 - r}, r], Disk[{0, 1 + r}, r]];
R2d = RegionDifference[Disk[{0, 0}, 4], R2d1];

M2d = ToElementMesh[R2d, "MeshOrder" -> 1(*,
MaxCellMeasure\[Rule]{"Length"\[Rule]0.1}*)];
S2d = ElementMeshSmoothing[ToQuadMesh[M2d]];
mesh3D = ExtrudeMesh[S2d, 5, 15];
mesh3D["Wireframe"]