2.7.1: Results Retrieval on Shells
The example file “SimpleShellESO.gh” (see fig. 2.7.1.1) contains two Python-scripts which will be explained below. The first script retrieves results from Karamba3D’s triangular shell elements:
Fig. 2.7.1.1: "SimpleShellESO"
Two python scripts: the first retrieves shell results (see code block below), the second one performs a simplified variant of an evolutionary structural optimization (ESO) procedure (see section 2.7.2).
1
import clr
2
3
clr.AddReferenceToFileAndPath("C:\Program Files\Rhino 6\Plug-ins\Karamba\Karamba.gha")
4
clr.AddReferenceToFileAndPath("C:\Program Files\Rhino 6\Plug-ins\Karamba\KarambaCommon.dll")
5
6
import Karamba.Models.Model as Model
7
import Karamba.Elements.ModelShell as Shell
8
import feb.ShellMesh as ShellMesh
9
import feb.TriShell3D as TriShell
10
import feb.VectSurface3DSigEps as TriStates
11
import feb.EnergyVisitor as EnergyVisitor
12
13
for element in Model_in.elems:
14
if type(element) != Shell:
15
continue
16
17
print "shell!"
18
femesh = Model_in.febmodel.triMesh(element.fe_id)
19
n_tri = femesh.numberOfElems()
20
print "number of triangle elements:", n_tri
21
22
energy_visitor = EnergyVisitor(Model_in.febmodel, Model_in.febmodel.state(0), 0);
23
energy_visitor.visit(Model_in.febmodel);
24
25
for ind in xrange(n_tri):
26
print "Axial Energy ", energy_visitor.axialEnergy(Model_in.elems[0].fe_id + ind)
27
print "Bending Energy ", energy_visitor.bendingEnergy(Model_in.elems[0].fe_id + ind)
28
29
tri_states = tri_states = femesh.elementSigEps(Model_in.febmodel, 0, Model_in.lc_super_model_displacements)
30
for tri_state in tri_states:
31
s = tri_state.sig_princ()
32
print "first principal stress (kN/cm2):",s.x()/10000
33
print "second principal stress (kN/cm2):",s.y()/10000
34
35
print "Number of elements", Model_in.elems.Count
Copied!
Lines 3 and 4 reference the Karamba3D DotNet-assemblies. Depending on how you installed Rhino it might be necessary to adapt the paths. In case that one of them can not be located an error will be issued.
Plug the output of “out” into a panel. If there is only one line of output, type “GrasshopperDeveloperSettings” in the Rhino text window and check whether the “Memory load *.GHA assemblies using COFF byte arrays”-option is unhooked.
The retrieval of axial- and bending-energies works via the visitor-pattern (see [2] for details on that). Line 22 creates such a visitor object for the elastic element energies by handing over a reference to a C++ model, a state, a load-case index and possibly a load-case factor. Unless one performs non-linear calculations state “0” is the right one to chose.
A shell patch consists of several shell elements. This might lead to some confusion since in the Grasshopper UI shell patches are named “elements”, in the C++ model however the patches consist of several triangular shell elements. In lines 26 and 27 the property “fe_ind” returns the index of a C++ element that corresponds to a given C#-element. In case of shell-patches this corresponds to the first C++-element.
Other shell results like principal stresses can be retrieved directly from the FE-mesh like in lines 29 to 33. “Model_in.superimpFacsStates” represents a list of load-factors which gets defined via the “Result-Case”-setting or the input-plug “R-Factors” of the “ModelView”-component.
SimpleShellEso.gh
25KB
Binary
Last modified 16d ago
Copy link