NGsolveCreateFFRFreducedOrder.py
You can view and download this file on Github: NGsolveCreateFFRFreducedOrder.py
1#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2# This is an EXUDYN example
3#
4# Details: New CreateFFRFReducedOrderObject function using NGsolve and ObjectGenericODE2;
5# uses super-functions to simplify creating of flexible bodies
6#
7# Author: Sebastian Weyrer, Johannes Gerstmayr
8# Date: 2025-12-27
9#
10# Copyright:This file is part of Exudyn. Exudyn is free software. You can redistribute it and/or modify it under the terms of the Exudyn license. See 'LICENSE.txt' for more details.
11#
12#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
13
14
15import exudyn as exu
16from exudyn.itemInterface import *
17from exudyn.utilities import * #includes itemInterface and rigidBodyUtilities
18import exudyn.graphics as graphics
19from exudyn.FEM import *
20
21SC = exu.SystemContainer()
22mbs = SC.AddSystem()
23
24import numpy as np
25
26import exudyn as exu
27import exudyn.graphics as graphics
28from exudyn.FEM import * # includes fem functionality
29from exudyn.utilities import * #includes itemInterface and rigidBodyUtilities
30from netgen import occ
31import ngsolve as ngs
32SC = exu.SystemContainer()
33mbs = SC.AddSystem()
34
35materials = {'steel':{'youngsModulus':2e11, 'poissonsRatio':0.3, 'density':7850}}
36L = 1
37W = 0.1
38cuboid = occ.Box((0, -W/2, -W/2), (L, W/2, W/2))
39boundaryNamesList = ['boundary0', 'boundary1']
40cuboid.faces.Min((1, 0, 0)).name = boundaryNamesList[0]
41cuboid.faces.Max((1, 0, 0)).name = boundaryNamesList[1]
42cuboid.name = 'steel'
43geo = occ.OCCGeometry(cuboid)
44
45mesh = ngs.Mesh(geo.GenerateMesh(maxh=0.025))
46
47cuboidFemInterface = FEMinterface()
48cuboidFemInterface.ImportMeshFromNGsolve(mesh=mesh,
49 materials=materials,
50 boundaryNamesList=boundaryNamesList,
51 meshOrder=1)
52[boundaryNodesList, boundaryWeightsList] = cuboidFemInterface.GetBoundaryNodeSetsAsLists()
53cuboidFemInterface.ComputeHurtyCraigBamptonModes(boundaryNodesList=boundaryNodesList,
54 nEigenModes=6,
55 boundaryNodesWeights=boundaryWeightsList)
56createFFRFObjectDict0 = mbs.CreateFFRFReducedOrderObject(name='cuboid0',
57 femInterface=cuboidFemInterface,
58 gravity=[0,0,-9.81])
59mBoundary00 = createFFRFObjectDict0['cuboid0:boundary0']
60mBoundary01 = createFFRFObjectDict0['cuboid0:boundary1']
61
62createFFRFObjectDict1 = mbs.CreateFFRFReducedOrderObject(name='cuboid1',
63 femInterface=cuboidFemInterface,
64 referencePosition=[L,0,0],
65 gravity=[0,0,-9.81])
66mBoundary10 = createFFRFObjectDict1['cuboid1:boundary0']
67mBoundary11 = createFFRFObjectDict1['cuboid1:boundary1']
68
69gGround = graphics.CheckerBoard(point=[0,0,-2.5], size=8, nTiles=10, normal=[0.,0,1])
70oGround = mbs.CreateGround(referencePosition=[0,0,0],
71 graphicsDataList=[gGround])
72
73#joints:
74mbs.CreateSphericalJoint(itemNumbers=[mBoundary00, oGround], jointRadius = W/4)
75mbs.CreateSphericalJoint(itemNumbers=[mBoundary01, mBoundary10], jointRadius = W/4)
76
77mbs.Assemble()
78simulationSettings = exu.SimulationSettings() #takes currently set values or default values
79simulationSettings.timeIntegration.numberOfSteps = 1000
80simulationSettings.timeIntegration.endTime = 2
81SC.visualizationSettings.nodes.show = False
82SC.visualizationSettings.openGL.light0.shadow = 0.2
83SC.visualizationSettings.openGL.multiSampling = 2
84
85SC.renderer.Start()
86SC.renderer.RestoreSavedState() #load last model view
87
88SC.renderer.DoIdleTasks() #press space to continue
89
90mbs.SolveDynamic(simulationSettings)
91
92SC.renderer.Stop() #safely close rendering window!
93
94mbs.SolutionViewer()