add rigid connections - add spring stiffness for point connections

This commit is contained in:
Jesusbill
2020-08-17 17:05:31 +02:00
parent eac72dc852
commit 7f48923153
4 changed files with 151 additions and 83 deletions
+44 -24
View File
@@ -7,6 +7,9 @@ import salome
import salome_notebook
import salome_version
import numpy as np
import itertools
flatten = itertools.chain.from_iterable
class MODEL:
def __init__(self, dataFilename, medFilename, meshSize):
@@ -73,10 +76,10 @@ class MODEL:
shapeType = 'FACE'
return self.geompy.MakePartition(objects, [], [], [], self.geompy.ShapeType[shapeType], 0, [], 1)
# def getLinkGeometry(self, ecc, orientation, finalPoint):
# vector = np.array(orientation).transpose().dot(ecc['vector'])
# initialPoint = (np.array(finalPoint) - vector).tolist()
# return [initialPoint, finalPoint]
def getLinkGeometry(self, ecc, orientation, finalPoint):
vector = np.array(orientation).transpose().dot(ecc['vector'])
initialPoint = (np.array(finalPoint) - vector).tolist()
return [initialPoint, finalPoint]
def length(self, geometry):
return ((
@@ -150,16 +153,23 @@ class MODEL:
el['elemObj'] = self.makeObject(el['geometry'], el['geometryType'])
el['connObjs'] = [None for _ in el['connections']]
el['linkObjs'] = [None for _ in el['connections']]
el['linkPointObjs'] = [[None, None] for _ in el['connections']]
for j,rel in enumerate(el['connections']):
conn = [c for c in connections if c['ifcName'] == rel['relatedConnection']][0]
if rel['eccentricity']:
rel['index'] = len(conn['relatedElements']) + 1
conn['relatedElements'].append(rel)
if conn['geometryType'] == 'point':
if not rel['eccentricity']:
el['connObjs'][j] = self.makeObject(conn['geometry'], conn['geometryType'])
else:
pass
# geometry = self.getLinkGeometry(rel['eccentricity'], el['orientation'], conn['geometry'])
# el['linkObjs'][j] = self.makeObject(geometry, 'line')
geometry = self.getLinkGeometry(rel['eccentricity'], el['orientation'], conn['geometry'])
el['connObjs'][j] = self.makeObject(geometry[0], conn['geometryType'])
el['linkPointObjs'][j][0] = self.geompy.MakeVertex(geometry[0][0], geometry[0][1], geometry[0][2])
el['linkPointObjs'][j][1] = self.geompy.MakeVertex(geometry[1][0], geometry[1][1], geometry[1][2])
el['linkObjs'][j] = self.geompy.MakeLineTwoPnt(el['linkPointObjs'][j][0], el['linkPointObjs'][j][1])
elif conn['geometryType'] == 'line':
pass
elif conn['geometryType'] == 'surface':
@@ -170,18 +180,15 @@ class MODEL:
el['elemObj'] = geompy.GetInPlace(el['partObj'], el['elemObj'])
for j,rel in enumerate(el['connections']):
el['connObjs'][j] = geompy.GetInPlace(el['partObj'], el['connObjs'][j])
# if rel['eccentricity']:
# el['linkObjs'][j] = geompy.GetInPlace(el['partObj'], el['linkObjs'][j])
for conn in connections:
# if conn['appliedCondition']:
conn['connObj'] = self.makeObject(conn['geometry'], conn['geometryType'])
# Make assemble of Building Object
bldObjs = []
bldObjs.extend([el['partObj'] for el in elements])
bldObjs.extend(flatten([[link for link in el['linkObjs'] if link] for el in elements]))
bldObjs.extend([conn['connObj'] for conn in connections])
# bldObjs.extend([conn['connObj'] for conn in connections if conn['appliedCondition']])
bldComp = geompy.MakeCompound(bldObjs)
# bldComp = geompy.MakePartition(bldObjs, [], [], [], self.geompy.ShapeType[buildingShapeType], 0, [], 1)
@@ -193,11 +200,13 @@ class MODEL:
geompy.addToStudyInFather(el['partObj'], el['elemObj'], self.getGroupName(el['ifcName']))
for j,rel in enumerate(el['connections']):
geompy.addToStudyInFather(el['partObj'], el['connObjs'][j], self.getGroupName(el['ifcName']) + '_0DC_' + self.getGroupName(rel['relatedConnection']))
# if rel['eccentricity']:
# geompy.addToStudyInFather(el['partObj'], el['linkObjs'][j], self.getGroupName(el['ifcName']) + '_1DC_' + self.getGroupName(rel['relatedConnection']))
if rel['eccentricity']:
pass
# geompy.addToStudy(el['linkObjs'][j], self.getGroupName(el['ifcName']) + '_1DR_' + self.getGroupName(rel['relatedConnection']))
# geompy.addToStudyInFather(el['linkObjs'][j], el['linkPointObjs'][j][0], self.getGroupName(rel['relatedConnection']) + '_0DC_' + self.getGroupName(el['ifcName']))
# geompy.addToStudyInFather(el['linkObjs'][j], el['linkPointObjs'][j][0], self.getGroupName(rel['relatedConnection']) + '_0DC_%g' % rel['index'])
for conn in connections:
# if conn['appliedCondition']:
# geompy.addToStudy(conn['connObj'], self.getGroupName(conn['ifcName']))
geompy.addToStudyInFather(conn['connObj'], conn['connObj'], self.getGroupName(conn['ifcName']))
@@ -232,12 +241,12 @@ class MODEL:
for j,rel in enumerate(el['connections']):
geompy.addToStudyInFather(bldComp, el['connObjs'][j], self.getGroupName(el['ifcName']) + '_0DC_' + self.getGroupName(rel['relatedConnection']))
# if rel['eccentricity']:
# el['linkObjs'][j].SetColor(SALOMEDS.Color(0, 0, 0))
# geompy.addToStudyInFather(bldComp, el['linkObjs'][j], self.getGroupName(el['ifcName']) + '_1DC_' + self.getGroupName(rel['relatedConnection']))
if rel['eccentricity']:
geompy.addToStudyInFather(bldComp, el['linkObjs'][j], self.getGroupName(el['ifcName']) + '_1DR_' + self.getGroupName(rel['relatedConnection']))
geompy.addToStudyInFather(bldComp, el['linkPointObjs'][j][0], self.getGroupName(rel['relatedConnection']) + '_0DC_' + self.getGroupName(el['ifcName']))
geompy.addToStudyInFather(bldComp, el['linkPointObjs'][j][1], self.getGroupName(rel['relatedConnection']) + '_0DC_%g' % rel['index'])
for conn in connections:
# if conn['appliedCondition']:
# conn['connObj'] = geompy.RestoreGivenSubShapes(bldComp, [conn['connObj']], GEOM.FSM_GetInPlace, False, False)[0]
geompy.addToStudyInFather(bldComp, conn['connObj'], self.getGroupName(conn['ifcName']))
@@ -312,9 +321,17 @@ class MODEL:
tempgroup = bldMesh.GroupOnGeom(el['connObjs'][j], self.getGroupName(el['ifcName']) + '_0DC_' + self.getGroupName(rel['relatedConnection']), SMESH.NODE)
smesh.SetName(tempgroup, self.getGroupName(el['ifcName']) + '_0DC_' + self.getGroupName(rel['relatedConnection']))
rel['node'] = (bldMesh.GetIDSource(tempgroup.GetNodeIDs(), SMESH.NODE)).GetIDs()[0]
# if rel['eccentricity']:
# tempgroup = bldMesh.GroupOnGeom(el['linkObjs'][j], self.getGroupName(el['ifcName']) + '_1DC_' + self.getGroupName(rel['relatedConnection']), SMESH.EDGE)
# smesh.SetName(tempgroup, self.getGroupName(el['ifcName']) + '_1DC_' + self.getGroupName(rel['relatedConnection']))
if rel['eccentricity']:
tempgroup = bldMesh.GroupOnGeom(el['linkObjs'][j], self.getGroupName(el['ifcName']) + '_1DR_' + self.getGroupName(rel['relatedConnection']), SMESH.EDGE)
smesh.SetName(tempgroup, self.getGroupName(el['ifcName']) + '_1DR_' + self.getGroupName(rel['relatedConnection']))
tempgroup = bldMesh.GroupOnGeom(el['linkPointObjs'][j][0], self.getGroupName(rel['relatedConnection']) + '_0DC_' + self.getGroupName(el['ifcName']), SMESH.NODE)
smesh.SetName(tempgroup, self.getGroupName(rel['relatedConnection']) + '_0DC_' + self.getGroupName(el['ifcName']))
rel['eccNode'] = (bldMesh.GetIDSource(tempgroup.GetNodeIDs(), SMESH.NODE)).GetIDs()[0]
tempgroup = bldMesh.GroupOnGeom(el['linkPointObjs'][j][1], self.getGroupName(rel['relatedConnection']) + '_0DC_' + self.getGroupName(rel['relatedConnection']), SMESH.NODE)
smesh.SetName(tempgroup, self.getGroupName(rel['relatedConnection']) + '_0DC_%g' % rel['index'])
for conn in connections:
# if conn['appliedCondition']:
@@ -330,8 +347,11 @@ class MODEL:
for j,rel in enumerate(el['connections']):
grpName = bldMesh.CreateEmptyGroup(SMESH.EDGE, self.getGroupName(el['ifcName']) + '_1DS_' + self.getGroupName(rel['relatedConnection']))
smesh.SetName(grpName, self.getGroupName(el['ifcName']) + '_1DS_' + self.getGroupName(rel['relatedConnection']))
conn = [conn for conn in connections if conn['ifcName'] == rel['relatedConnection']][0]
grpName.Add([bldMesh.AddEdge([conn['node'], rel['node']])])
if not rel['eccentricity']:
conn = [conn for conn in connections if conn['ifcName'] == rel['relatedConnection']][0]
grpName.Add([bldMesh.AddEdge([conn['node'], rel['node']])])
else:
grpName.Add([bldMesh.AddEdge([rel['eccNode'], rel['node']])])
self.mesh = bldMesh
self.meshNodes = bldMesh.GetNodesId()
@@ -365,7 +385,7 @@ class MODEL:
print('ALL Operations Completed in %g sec' % (elapsed_time))
if __name__ == '__main__':
fileNames = ['cantilever_01', 'portal_01']
fileNames = ['cantilever_01']
files = fileNames
meshSize = 0.1