# Exporting a FEM mesh from a parametric surface

How is it possible to export a mesh for suitable finite element analysis (such as Abaqus) from a parametric surface expressions? I'm working on this kind of surface:

RS[u_, v_] =
{(R*Cos[v] + a*(1 - Sin[v])*Cos[n*u])*Cos[u],
(R*Cos[v] + a*(1 - Sin[v])*Cos[n*u])*Sin[u],R*Sin[v]};

I have already exported the surface in .dxf files, but the input to export is not in a suitable format, because I need a 3D solid model instead of a 3D surface.

## 2 Answers

RS[u_, v_] := {(R*Cos[v] + a*(1 - Sin[v])*Cos[n*u])*
Cos[u], (R*Cos[v] + a*(1 - Sin[v])*Cos[n*u])*Sin[u],
R*Sin[v]} /. {R -> 5, a -> 3, n -> 2};
surf = DiscretizeRegion[
ParametricRegion[RS[u, v], {{u, 0, 2 π}, {v, 0, 2 π}}]]
Needs["NDSolveFEM"]
mesh = ToBoundaryMesh[surf]
mesh["Wireframe"]

• I tried  surf = DiscretizeRegion[ ParametricRegion[RS[u, v], {{u, 0, 2 [Pi]}, {v, 0, 2 [Pi]}}]] but the software is unable to execute and reports this warning DiscretizeRegion::defbnds: Unable to compute bounds for the region. Using default bounds of {-1, 1} in all dimensions. and DiscretizeRegion::drf: DiscretizeRegion was unable to discretize the region ParametricRegion[<<2>>]. Commented Nov 6, 2020 at 14:06
• @MatteoLai I am using 12.1.1 version. The code work. Commented Nov 6, 2020 at 14:11
• thanks, I clear the kernel, and after a while is working. Thanks a lot. How can I use the command "export .dfx " in the code you sent me ? Commented Nov 6, 2020 at 14:18

It is possible to export a parametric region to a DXF file that is suitable for analysis in another FEM system such as Abaqus. However, in your case, your parametric region contains many non-manifold features that will not make it suitable for other codes. I recently discussed non-manifold geometry in my answer 234105.

# Example workflow with a valid parametric region

Here is an example of a valid manifold parametric region taken from the documentation here.

Needs["NDSolveFEM"]
surf1 = ParametricRegion[{{x, y, z + y*x}, x^2 + y^2 + z^2 <= 1}, {x,
y, z}];
bmesh1 = ToBoundaryMesh[surf1];
mr1 = MeshRegion@bmesh1;
bmesh1["Wireframe"];
Export["docpshape.dxf", mr1];
FindMeshDefects[mr1]

As you can see, the mesh appears to be defect free. We can take the DXF file and imported into SolidWorks and knit the surface mesh into a solid as shown in the image below:

# Workflow applied to OP parametric region

If we apply the same workflow to the OP parametric region, we will see that we produce a lot of mesh defects (N.B., These processes can really slow down your computer):

RS[u_,v_]:={(R*Cos[v]+a*(1-Sin[v])*Cos[n*u])*Cos[u],(R*Cos[v]+a*(1-Sin[v])*Cos[n*u])*Sin[u],R*Sin[v]}/.{R->5,a->3,n->2};
surf=ParametricRegion[RS[u,v],{{u,0,2 \[Pi]},{v,0,2 \[Pi]}}];
bmesh=ToBoundaryMesh[surf];
mr=MeshRegion@bmesh;
bmesh["Wireframe"];
Export["pshape.dxf",mr];
FindMeshDefects[mr]

This mesh has a lot of errors associated with it and will require a lot of cleanup before it is suitable to be used in another FEM system. The DXF file can be imported into SolidWorks, but it cannot be knitted to form a solid due to all the mesh defects (N.B., The import process is very slow due to the greater than 50,000 surfaces contained in the DXF file):

You can also visualize the complex intersecting internal surfaces in Mathematica using something like this:

Table[ParametricPlot3D[RS[u, v], {u, 0, 2 Pi}, {v, 0, 2 Pi},
RegionFunction -> Function[{x, y, z, u, v}, i], Mesh -> None,
BoundaryStyle -> Red, PlotRange -> 5, PlotLabel -> i, Axes -> None,
PlotStyle ->
Directive[LightGreen, Opacity[0.5],
Specularity[White, 20]]], {i, {0 < x < 5, 0 < y < 5, 0 < z < 5,
0 < u < Pi/2, 0 < v < 3 Pi/4}}]

# Conclusions and recommendations

Mathematica can export parametric regions that are suitable for use in other FEM codes, but not all parametric regions are suitable. The parametric region ought to be a proper bounding surface without non-manifold features such as tangencies.