# Mesh import - Contra-intuitive results of simple AceFEM analysis

I am doing AceFEM analysis with mesh imported from external software. I use ELFEN to create tetrahedral mesh, write its properties to a text file and then read this file into Mathematica, extracting node coordinates and their connectivity. The procedure works fine, but I get weird results when I calculate displacements, as illustrated in the following small example.

(* Node coordinates and element connectivity imported from text file written \
by ELFEN *)
nodes = {{0, 10, 0}, {10, 10, 0}, {10, 10, 20}, {10, 0, 20}, {0, 0, 20}, {0,
10, 20}, {10, 0, 0}, {0, 0, 0}, {6.67, 6.67, 4.21}};
connectivity = {{5, 4, 7, 6}, {6, 7, 5, 8}, {8, 6, 7, 1}, {2, 1, 7, 9}, {3, 4,
6, 9}, {9, 4, 6, 7}, {9, 6, 3, 1}, {9, 3, 4, 2}, {7, 9, 4, 2}, {1, 9, 6,
7}, {1, 3, 9, 2}};

<< AceFEM

SMTInputData[];
SMTAddMesh[nodes, {"A" -> connectivity}];(* syntax for imported meshes *)
SMTAddEssentialBoundary[{ "Z" == 0 &, 1 -> 0, 2 -> 0, 3 -> 0}];
SMTAddNaturalBoundary[{ "Z" == 20 &, 2 -> -1}];
SMTAnalysis[];

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


My boundary conditions are fixed nodes on one side (displacement is 0) and prescribed force in negative Y direction on the other side. Why do I get displacements in positive Y direction? This is wrong and contra-intuitive and can be clearly seen in the image bellow.

(* Blue lines show undeformed shape of elements *)
Show[
SMTShowMesh["DeformedMesh" -> False, "FillElements" -> False,
ImageSize -> 300, Axes -> True, AxesLabel -> {"X", "Y", "Z"},
AxesStyle -> 16, "Mesh" -> Blue],
SMTShowMesh["BoundaryConditions" -> True, "DeformedMesh" -> True]
]


It looks like that software where you created your mesh uses different convention for consecutive numbering of nodes of tetrahedron. This image shows node numbers of the first element in your mesh and generic AceFEM tetrahedron. Compare the consecutive (local) numbering of their global nodes (mapping: local->global) and you can see that elements are "inverted".

I think that AceFEM receives nodes in the wrong order, calculates negative Jacobian determinant from isoparametric mapping and this results in opposite sign for calculated displacements. The problem can be simply fixed by swapping the last two node numbers in element connectivity lists and passing this to SMTAddMesh.

modifiedConectivity = {#1, #2, #4, #3} & @@@ connectivity
(*{{5, 4, 6, 7}, {6, 7, 8, 5}, {8, 6, 1, 7}, {2, 1, 9, 7}, {3,4, 9, 6},
{9, 4, 7, 6}, {9, 6, 1, 3}, {9, 3, 2, 4}, {7, 9, 2,4}, {1, 9, 7, 6}, {1, 3, 2, 9}}*)

(* Replace this line in the original code *)
`