# AceFEM: How to mirror a domain in postprocessing?

Note: This question is about AceFEM package for finite element analysis in Mathematica.

In finite element analyses we usually take advantage of symmetry of geometry and loading to model only a portion of computational domain. SMTShowMesh only shows this explicitly modeled portion of domain. How can I plot results of analysis over the whole domain in the postprocessing phase?

Bellow I have prepared a test function that stretches a square domain with symmetry BC on axis X and axis Y.

<< AceFEM;

(* A test function. Its argument is the number of elements on one edge. *)
Clear[testAnalysis]
testAnalysis[n_Integer] := Module[{},
SMTInputData[];
"OL:SEPEQ1DFHYQ1NeoHooke", {"E *" -> 1000., "\[Nu] *" -> 0.3}];
SMTMesh["test", "Q1", {n, n}, {{{0, 0}, {1, 0}}, {{0, 1}, {1, 1}}}];
SMTAddEssentialBoundary[{ "X" == 0 &, 1 -> 0}, {"Y" == 0 &,
2 -> 0}, { "Y" == 1 &, 1 -> 0, 2 -> 0.5}];
SMTAnalysis[];
SMTNextStep["\[Lambda]" -> 1];
While[SMTConvergence[10^-8, 10], SMTNewtonIteration[];];
]

(* Execute test analysis. *)
testAnalysis


Standard use of SMTShowMesh plots only explicitly modeled part (one quarter) of the domain. How can I plot the whole assumed domain?

SMTShowMesh["BoundaryConditions" -> True, "Contour" -> True,
"DeformedMesh" -> True, "Field" -> "Eyy", "Mesh" -> White,
Axes -> True, AxesLabel -> {"X", "Y"}, ImageSize -> 200,
Ticks -> None] • You can look at examples for the visualization of PeriodicBoundaryCondition to get an idea how this could be done. – user21 Mar 30 '17 at 11:19

I am not aware of any built in options that would automatically mirror the domain over a specified plane / line. One solution is to add additional transformed plots of mesh through the option SMTShowMesh["User"->...]. Disadvantage of this approach is that you have to think about how to correctly transform values of the field you are plotting. SMTShowMesh["Field"->...] plots a scalar field, but this may be just a component of another vector field (displacements) or tensor field (stress, strain).

First we run a test analysis to produce some results with the function defined in the OP question. Then we collect necessary quantities to shorten the syntax.

<< AceFEM;
testAnalysis;

X = SMTNodeData["X"];(* initial position of nodes *)
u = SMTNodeData["at"];(* displacements of nodes *)
(* TransformationFunction[] for mirroring over Y axis. *)
rtY = ReflectionTransform[{1, 0}];

(* Get a suitable range of values for creating a contour lines and
the legend. Shear strain "Exy" is chosen for example. *)
limit = 0.85*Max[Abs[SMTPostData["Exy"]]]


This shows the domain mirrored over Y axis. Multiple mirrored domains can be added like this "User"->{ First@SMTShowMesh[...], First@SMTShowMesh[...], ... }.

SMTShowMesh[
"DeformedMesh" -> True,
"Field" -> "Exy",
"Contour" -> {-limit, limit, 6},
(* Add another SMTShowMesh for option "User"->... *)
"User" -> First@SMTShowMesh[
(* Subtract initial coodinates, then add transformed initial coordinates
and (if needed) add transformed displacements. *)
"DeformedMesh" -> Transpose[-X + (rtY /@ X) + (rtY /@ u)],
(* Transformation of field values. (Multiply shear strain "Exy" by -1) *)
"Field" -> -SMTPostData["Exy"],
(* Range of "Contour" has to be set explicity to include the negative interval. *)
"Contour" -> {-limit, limit, 6},
"Legend" -> False
],
Axes -> True,
AxesLabel -> {"X", "Y"},
ImageSize -> 300,
Ticks -> None
] Same approach can be used for showing domains with periodic symmetry.

(* This intentionally shows overlapping domains to emphasis rotational transform. *)
rot = RotationTransform[Pi/3, {0, 0}];

SMTShowMesh[
"DeformedMesh" -> True,
"Field" -> None,
"User" -> First@SMTShowMesh[
"DeformedMesh" -> Transpose[-X + (rot /@ X) + (rot /@ u)],
"Field" -> None
],
Axes -> True,
AxesLabel -> {"X", "Y"},
ImageSize -> 300,
Ticks -> None
] My code just shows basic approach to the problem and not a comprehensive solution, especially with respect to transforming the "Field"->... values. Ideally we could have just another option to SMTShowMesh to take care of everything (e.g. SMTShowMesh[..., "some option name"->{ reflection transform 1, reflection transform 2,...}] ).

EDIT:

Alternative solution to plot the whole domain was proposed by @user21 in the comments to the question. We can map geometric transformation to Graphics expression (at appropriate position) and show multiple plots together with Show.

(* Important fact: Plot is for "Exy" component of strain tensor field. *)
mesh = SMTShowMesh["BoundaryConditions" -> True, "Contour" -> True,
"DeformedMesh" -> True, "Field" -> "Exy", "Legend" -> False,
"Mesh" -> White, Axes -> True, AxesLabel -> {"X", "Y"},
ImageSize -> 150, Ticks -> None]


This solution is elegant and flexible, but it doesn't transform field values of vector and tensor fields. It works for scalar fields.

(* geometric transformation functions for reflection over X and Y axis *)
flipX = GeometricTransformation[#, ReflectionTransform[{1, 0}]] &;
flipY = GeometricTransformation[#, ReflectionTransform[{0, 1}]] &;

(* Warning! Domain geometry is transformed correctly, but field values are not.  *)
Show[
mesh,
MapAt[flipX, mesh, 1],
MapAt[Composition[flipY, flipX], mesh, 1],
MapAt[flipY, mesh, 1],
PlotRange -> All] 