# How to draw a generic 3D closed shape to be analyzed in AceFEM?

I would like to draw a 3D shape to test my AceGen procedure. I will insert the AceFEM part of my code. In this example, I have performed the analysis on a hexahedron element.

<< AceFEM

{Nx , Ny , Nz} = {3 , 3, 15};
{Lx , Ly , Lz} = {3 , 3 , 10};
points = {{0 , 0 , 0} , {Lx , 0 , 0} , {Lx , Ly , 0} , {0 , Ly ,
0} , {0 , 0 , Lz} , {Lx , 0 , Lz} , {Lx , Ly  , Lz} , {0 , Ly ,
Lz}};
SMTInputData[];
"3Dpseudoelasticity-Micromorphic" , {"E *" -> 80000 ,
"\[Nu] *" -> 0.3 , "BdT *" -> 0.15*(12.5 + 40) , "fc *" -> 4 ,
"\[Epsilon]T *" -> 0.05 , "H *" -> -3.5 ,
"\[Rho]\[Eta] *" -> 1000 , "Lint *" -> 0.05 , "chi *" -> 100}}];
SMTAddMesh[Hexahedron[points], "A" , "H1" , {Nx , Ny , Nz}];
Polygon[{{0, 0, 0} , {Lx , 0 , 0} , {Lx , Ly , 0} , {0 , Ly ,
0}}] , 1 -> 0 , 2 -> 0 , 3 -> 0];
Polygon[{{0 , 0 , Lz} , {Lx , 0 , Lz} , {Lx , Ly , Lz} , {0 , Ly ,
Lz}}] , 1 -> 0 , 2 -> 0 , 3 -> Lz];
SMTAnalysis["Output" -> "3DExample.out"];

SMTShowMesh["BoundaryConditions" -> True ,  ImageSize -> 200]


These commands will give me a hexahedron shape. What I would like to do is to be able to create any 3D arbitrary shape in order to test my FEM procedure. The aim here is to impose a geometrical imperfection in my hexahedron, i.e. making a small hole in the volume of the hexahedron or cut out just a small piece on its edge. The shape that I am trying to create looks like

It should be noted here that the geometrical imperfection that I made is just an arbitrary shape to demonstrate my intention. Now the question is: Is there any certain way to generate something like that by means of giving coordinates and elements?

• What do you mean by "any 3D function that is required"? How are you defining that? Look at the Region functions. Oct 23 '17 at 21:10
• What's AceFEM and AceGen, and most importantly, why would you think a significant portion of this community would know them? Oct 23 '17 at 22:38
• @David, it's a commercial package for FEM work. There have been a lot of previous questions on this, and there are a number of users of this package, so this question is fine. Oct 24 '17 at 2:27
• @b3m2a1 sorry a typo. What I mean is to create any arbitrary 3D geometry in mathematica. Oct 24 '17 at 6:23
• @M.Rock Recent versions of AceFEM seamlessly accept Mathematica ElementMesh objects (after version 6.815, I think). I suggest you use that approach. Please check Mathematica tutorial and corresponding topic in AceFEM documentation. I found these tutorials really helpful. Oct 24 '17 at 7:04

One way of creating an imperfection is by slightly moving some nodes in otherwise uniform mesh. This way you don't need to create some complicated 3D geometries and meshes. I will demonstrate this on a case of uni-axial extension (of hyperelastic material).

<< AceFEM

{Nx, Ny, Nz} = {10, 5, 5};
{Lx, Ly, Lz} = {2, 1, 1};
points = {{0, 0, 0}, {Lx, 0, 0}, {Lx, Ly, 0}, {0, Ly, 0}, {0, 0, Lz}, {Lx, 0, Lz}, {Lx, Ly, Lz}, {0, Ly, Lz}};


Definition of function for setup of analysis.

setup1[] := (
SMTInputData[];
(* Element is taken from online library - with default material parameters. *)
SMTAddMesh[Hexahedron[points], "A", "H1", {Nx, Ny, Nz}];
SMTAddEssentialBoundary[{ "X" == 0 &, 1 -> 0}, {"Y" == 0 &, 2 -> 0}, { "Z" == 0 &, 3 -> 0}, { "X" == Lx &, 1 -> 1}];
SMTAnalysis[];
)

setup1[]


Showing the undeformed configuration.

SMTShowMesh["BoundaryConditions" -> True, ImageSize -> 300, ViewVertical -> {0, 0, 1}, Axes -> True, AxesLabel -> {"X", "Y", "Z"}, Ticks -> None]


After extension for 1 unit we see that (Mises) stress is homogeneous, just as it should be for uniaxial case.

SMTNextStep["\[Lambda]" -> 1];
While[SMTConvergence[10^-8, 10], SMTNewtonIteration[];];

SMTShowMesh["DeformedMesh" -> True, "Field" -> "Mises*", ImageSize -> 300, ViewVertical -> {0, 0, 1}, Axes -> True, AxesLabel -> {"X", "Y", "Z"}, Ticks -> None, "Legend" -> False]


Then we setup the analysis again, select one (or more) node on the edge, and slightly change it undeformed coordinates.

setup1[]
node = First@SMTFindNodes[Point[{Lx/2, Ly, Lz}]];
SMTNodeData[node, "X"]
SMTNodeData[node, "X", {1., 0.99, 0.99}]
(* {1., 1., 1.} *)
(* {1., 0.99, 0.99} *)


To see the change of position we should also update postprocessing data first, as described in this thread.

SMTUpdatePostData[];


As expected the stress is not homogeneous any more, because there is an imperfection in the shape of domain.

I am not sure if I have understood the OP question correctly, but the alternative is to create a more complicated mesh in Mathematica (or any other meshing software) and import it in AceFEM procedure. This example mimics the picture given in OP question.

We create symbolic region as difference of large hexahedron and small ball and mesh it with Mathematica function ToElementMesh. It will create mesh of tetrahedra. Unfortunately I don't know how to make it with non-uniform mesh density distribution.

reg = RegionDifference[Hexahedron[points], Ball[{Lx/2, Ly, Lz}, 0.1]];
mesh = ToElementMesh[reg, RegionBounds[reg], "MeshOrder" -> 1]


Then we simply use this mesh in AceFEM setup procedure.

setup2[] := (
SMTInputData[];
(* Tetrahedron element - code O1 *)