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:

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).

import clr

clr.AddReferenceToFileAndPath("C:\Program Files\Rhino 6\Plug-ins\Karamba\Karamba.gha")
clr.AddReferenceToFileAndPath("C:\Program Files\Rhino 6\Plug-ins\Karamba\KarambaCommon.dll")

import Karamba.Models.Model as Model
import Karamba.Elements.ModelShell as Shell
import feb.ShellMesh as ShellMesh
import feb.TriShell3D as TriShell
import feb.VectSurface3DSigEps as TriStates
import feb.EnergyVisitor as EnergyVisitor

for element in Model_in.elems:
   if type(element) != Shell:
       continue

   print "shell!"
   femesh = Model_in.febmodel.triMesh(element.fe_id)
   n_tri = femesh.numberOfElems()
   print "number of triangle elements:", n_tri

   energy_visitor = EnergyVisitor(Model_in.febmodel, Model_in.febmodel.state(0), 0);
   energy_visitor.visit(Model_in.febmodel);

   for ind in xrange(n_tri):
       print "Axial Energy ", energy_visitor.axialEnergy(Model_in.elems[0].fe_id + ind)
       print "Bending Energy ", energy_visitor.bendingEnergy(Model_in.elems[0].fe_id + ind)

   tri_states = tri_states = femesh.elementSigEps(Model_in.febmodel, 0, Model_in.lc_super_model_displacements)
   for tri_state in tri_states:
       s = tri_state.sig_princ()
       print "first principal stress (kN/cm2):",s.x()/10000
       print "second principal stress (kN/cm2):",s.y()/10000

print "Number of elements", Model_in.elems.Count

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.

Last updated