mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 14:23:53 +00:00
add curve connections
This commit is contained in:
+57
-33
@@ -78,7 +78,6 @@ class CA2IFC:
|
|||||||
ifcElements[i] = self.f.createIfcStructuralCurveMember(self.guid(), ownerHistory, el['name'], None, None, localPlacement, prodDefShape, el['predefinedType'], localZAxis)
|
ifcElements[i] = self.f.createIfcStructuralCurveMember(self.guid(), ownerHistory, el['name'], None, None, localPlacement, prodDefShape, el['predefinedType'], localZAxis)
|
||||||
|
|
||||||
if el['geometryType'] == 'surface':
|
if el['geometryType'] == 'surface':
|
||||||
# element
|
|
||||||
ifcElements[i] = self.f.createIfcStructuralSurfaceMember(self.guid(), ownerHistory, el['name'], None, None, localPlacement, prodDefShape, el['predefinedType'], el['thickness'])
|
ifcElements[i] = self.f.createIfcStructuralSurfaceMember(self.guid(), ownerHistory, el['name'], None, None, localPlacement, prodDefShape, el['predefinedType'], el['thickness'])
|
||||||
|
|
||||||
# create structural point connections
|
# create structural point connections
|
||||||
@@ -86,19 +85,34 @@ class CA2IFC:
|
|||||||
for i,conn in enumerate(self.data['connections']):
|
for i,conn in enumerate(self.data['connections']):
|
||||||
# geometry - product definition shape
|
# geometry - product definition shape
|
||||||
prodDefShape = self.create_geometry(conn)
|
prodDefShape = self.create_geometry(conn)
|
||||||
# local axes
|
|
||||||
localAxes = self.create_orientation(conn['orientation'])
|
|
||||||
# boundary conditions
|
# boundary conditions
|
||||||
if conn['appliedCondition']:
|
if conn['appliedCondition']:
|
||||||
bc = self.create_node_applied_conditions(conn['appliedCondition'])
|
bc = self.create_applied_conditions(conn['appliedCondition'], conn['geometryType'])
|
||||||
appliedCondition = self.f.createIfcBoundaryNodeCondition(None, bc['dx'], bc['dy'], bc['dz'], bc['drx'], bc['dry'], bc['drz'])
|
if conn['geometryType'] == 'point':
|
||||||
|
appliedCondition = self.f.createIfcBoundaryNodeCondition(None, bc['dx'], bc['dy'], bc['dz'], bc['drx'], bc['dry'], bc['drz'])
|
||||||
|
if conn['geometryType'] == 'line':
|
||||||
|
appliedCondition = self.f.createIfcBoundaryEdgeCondition(None, bc['dx'], bc['dy'], bc['dz'], bc['drx'], bc['dry'], bc['drz'])
|
||||||
|
if conn['geometryType'] == 'surface':
|
||||||
|
appliedCondition = self.f.createIfcBoundaryFaceCondition(None, bc['dx'], bc['dy'], bc['dz'])
|
||||||
else:
|
else:
|
||||||
appliedCondition = None
|
appliedCondition = None
|
||||||
|
|
||||||
# connection
|
|
||||||
if conn['geometryType'] == 'point':
|
if conn['geometryType'] == 'point':
|
||||||
|
# local axes
|
||||||
|
localAxes = self.create_orientation(conn['orientation'])
|
||||||
|
# connection
|
||||||
ifcConnections[i] = self.f.createIfcStructuralPointConnection(self.guid(), ownerHistory, conn['name'], None, None, localPlacement, prodDefShape, appliedCondition, localAxes)
|
ifcConnections[i] = self.f.createIfcStructuralPointConnection(self.guid(), ownerHistory, conn['name'], None, None, localPlacement, prodDefShape, appliedCondition, localAxes)
|
||||||
|
|
||||||
|
if conn['geometryType'] == 'line':
|
||||||
|
# z axis TODO: group by elements
|
||||||
|
localZAxis = self.f.createIfcDirection(tuple(conn['orientation'][2]))
|
||||||
|
# connection
|
||||||
|
ifcConnections[i] = self.f.createIfcStructuralCurveConnection(self.guid(), ownerHistory, conn['name'], None, None, localPlacement, prodDefShape, appliedCondition, localZAxis)
|
||||||
|
|
||||||
|
if conn['geometryType'] == 'surface':
|
||||||
|
ifcConnections[i] = self.f.createIfcStructuralSurfaceConnection(self.guid(), ownerHistory, conn['name'], None, None, localPlacement, prodDefShape, appliedCondition)
|
||||||
|
|
||||||
# assign material-profile-sets
|
# assign material-profile-sets
|
||||||
for i,mpSet in enumerate(mpSets):
|
for i,mpSet in enumerate(mpSets):
|
||||||
groupOfElements = []
|
groupOfElements = []
|
||||||
@@ -121,20 +135,34 @@ class CA2IFC:
|
|||||||
# create connections with elements
|
# create connections with elements
|
||||||
for i,el in enumerate(self.data['elements']):
|
for i,el in enumerate(self.data['elements']):
|
||||||
for conn in el['connections']:
|
for conn in el['connections']:
|
||||||
localAxes = self.create_orientation(conn['orientation'])
|
j = [c['ifcName'] for c in self.data['connections']].index(conn['relatedConnection'])
|
||||||
|
geometryType = self.data['connections'][j]['geometryType']
|
||||||
|
|
||||||
if conn['appliedCondition']:
|
if conn['appliedCondition']:
|
||||||
bc = self.create_node_applied_conditions(conn['appliedCondition'])
|
bc = self.create_applied_conditions(conn['appliedCondition'], geometryType)
|
||||||
appliedCondition = self.f.createIfcBoundaryNodeCondition(None, bc['dx'], bc['dy'], bc['dz'], bc['drx'], bc['dry'], bc['drz'])
|
if geometryType == 'point':
|
||||||
|
appliedCondition = self.f.createIfcBoundaryNodeCondition(None, bc['dx'], bc['dy'], bc['dz'], bc['drx'], bc['dry'], bc['drz'])
|
||||||
|
if geometryType == 'line':
|
||||||
|
appliedCondition = self.f.createIfcBoundaryEdgeCondition(None, bc['dx'], bc['dy'], bc['dz'], bc['drx'], bc['dry'], bc['drz'])
|
||||||
|
if geometryType == 'surface':
|
||||||
|
appliedCondition = self.f.createIfcBoundaryFaceCondition(None, bc['dx'], bc['dy'], bc['dz'])
|
||||||
else:
|
else:
|
||||||
appliedCondition = None
|
appliedCondition = None
|
||||||
j = [c['ifcName'] for c in self.data['connections']].index(conn['relatedConnection'])
|
|
||||||
if not conn['eccentricity']:
|
# local axes
|
||||||
|
localAxes = self.create_orientation(conn['orientation'])
|
||||||
|
|
||||||
|
if geometryType == 'point':
|
||||||
|
if not conn['eccentricity']:
|
||||||
|
self.f.createIfcRelConnectsStructuralMember(self.guid(), ownerHistory, None, None, ifcElements[i], ifcConnections[j], appliedCondition, None, None, localAxes)
|
||||||
|
else:
|
||||||
|
pointOnElement = self.f.createIfcCartesianPoint(tuple(conn['eccentricity']['pointOnElement']))
|
||||||
|
vector = conn['eccentricity']['vector']
|
||||||
|
connPointEcc = self.f.createIfcConnectionPointEccentricity(pointOnElement, None, vector[0], vector[1], vector[2])
|
||||||
|
self.f.createIfcRelConnectsWithEccentricity(self.guid(), ownerHistory, None, None, ifcElements[i], ifcConnections[j], appliedCondition, None, None, localAxes, connPointEcc)
|
||||||
|
|
||||||
|
if geometryType in ['line', 'surface']:
|
||||||
self.f.createIfcRelConnectsStructuralMember(self.guid(), ownerHistory, None, None, ifcElements[i], ifcConnections[j], appliedCondition, None, None, localAxes)
|
self.f.createIfcRelConnectsStructuralMember(self.guid(), ownerHistory, None, None, ifcElements[i], ifcConnections[j], appliedCondition, None, None, localAxes)
|
||||||
else:
|
|
||||||
pointOnElement = self.f.createIfcCartesianPoint(tuple(conn['eccentricity']['pointOnElement']))
|
|
||||||
vector = conn['eccentricity']['vector']
|
|
||||||
connPointEcc = self.f.createIfcConnectionPointEccentricity(pointOnElement, None, vector[0], vector[1], vector[2])
|
|
||||||
self.f.createIfcRelConnectsWithEccentricity(self.guid(), ownerHistory, None, None, ifcElements[i], ifcConnections[j], appliedCondition, None, None, localAxes, connPointEcc)
|
|
||||||
|
|
||||||
# assign elements and connections to group
|
# assign elements and connections to group
|
||||||
self.f.createIfcRelAssignsToGroup(self.guid(), ownerHistory, None, None, tuple(ifcElements + ifcConnections), None, model)
|
self.f.createIfcRelAssignsToGroup(self.guid(), ownerHistory, None, None, tuple(ifcElements + ifcConnections), None, model)
|
||||||
@@ -287,38 +315,34 @@ class CA2IFC:
|
|||||||
|
|
||||||
return faceProdDefShape
|
return faceProdDefShape
|
||||||
|
|
||||||
def create_node_applied_conditions(self, bc):
|
def create_applied_conditions(self, bc, geometryType):
|
||||||
for dof in ['dx', 'dy', 'dz']:
|
for dof in ['dx', 'dy', 'dz']:
|
||||||
if isinstance(bc[dof], bool):
|
if isinstance(bc[dof], bool):
|
||||||
bc[dof] = self.f.createIfcBoolean(bc[dof])
|
bc[dof] = self.f.createIfcBoolean(bc[dof])
|
||||||
else:
|
else:
|
||||||
bc[dof] = self.f.createIfcLinearStiffnessMeasure(bc[dof])
|
if geometryType == 'point':
|
||||||
|
bc[dof] = self.f.createIfcLinearStiffnessMeasure(bc[dof])
|
||||||
|
if geometryType == 'line':
|
||||||
|
bc[dof] = self.f.createIfcModulusOfLinearSubgradeReactionMeasure(bc[dof])
|
||||||
|
if geometryType == 'surface':
|
||||||
|
bc[dof] = self.f.createIfcModulusOfSubgradeReactionMeasure(bc[dof])
|
||||||
|
|
||||||
for dof in ['drx', 'dry', 'drz']:
|
for dof in ['drx', 'dry', 'drz']:
|
||||||
if isinstance(bc[dof], bool):
|
if isinstance(bc[dof], bool):
|
||||||
bc[dof] = self.f.createIfcBoolean(bc[dof])
|
bc[dof] = self.f.createIfcBoolean(bc[dof])
|
||||||
else:
|
else:
|
||||||
bc[dof] = self.f.createIfcRotationalStiffnessMeasure(bc[dof])
|
if geometryType == 'point':
|
||||||
|
bc[dof] = self.f.createIfcRotationalStiffnessMeasure(bc[dof])
|
||||||
|
if geometryType == 'line':
|
||||||
|
bc[dof] = self.f.createIfcModulusOfRotationalSubgradeReactionMeasure(bc[dof])
|
||||||
|
|
||||||
return bc
|
return bc
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
inputFilename = 'grid_of_beams.json'
|
inputFilename = 'structure_01.json'
|
||||||
outputFilename = 'grid_of_beams.ifc'
|
outputFilename = 'structure_01.ifc'
|
||||||
|
|
||||||
ca2ifc = CA2IFC(inputFilename, outputFilename)
|
ca2ifc = CA2IFC(inputFilename, outputFilename)
|
||||||
ca2ifc.convert()
|
ca2ifc.convert()
|
||||||
#
|
|
||||||
# inputFilename = 'portal_01.json'
|
|
||||||
# outputFilename = 'portal_01.ifc'
|
|
||||||
#
|
|
||||||
# ca2ifc = CA2IFC(inputFilename, outputFilename)
|
|
||||||
# ca2ifc.convert()
|
|
||||||
#
|
|
||||||
# inputFilename = 'building_01.json' # json file to read
|
|
||||||
# outputFilename = 'building_01.ifc' # ifc file to write
|
|
||||||
#
|
|
||||||
# ca2ifc = CA2IFC(inputFilename, outputFilename)
|
|
||||||
# ca2ifc.convert()
|
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
## A change log of the ifc2ca files
|
## A change log of the ifc2ca files
|
||||||
|
|
||||||
|
##### 14/10/20
|
||||||
|
- Add curve connections betweeen elements and as supports according to the defined orientation - stiffness is not yet considered
|
||||||
|
|
||||||
##### 17/08/20
|
##### 17/08/20
|
||||||
- Add rigid links for point connection to elements
|
- Add rigid links for point connection to elements
|
||||||
|
|
||||||
##### 14/07/20
|
##### 14/07/20
|
||||||
- Add internal springs for point connection to elements and external springs for point connections according to the defined orientation
|
- Add internal springs for point connection to elements according to the defined orientation
|
||||||
|
- Add external springs for point connections according to the defined orientation
|
||||||
|
|
||||||
##### 27/05/20
|
##### 27/05/20
|
||||||
- Add orientation for point, curve and surface geometries
|
- Add orientation for point, curve and surface geometries
|
||||||
|
|||||||
+65
-13
@@ -98,7 +98,7 @@ class IFC2CA:
|
|||||||
for c in connections:
|
for c in connections:
|
||||||
if c['eccentricity']:
|
if c['eccentricity']:
|
||||||
if np.linalg.norm(np.array(c['eccentricity']['pointOnElement'])) > length + self.tol:
|
if np.linalg.norm(np.array(c['eccentricity']['pointOnElement'])) > length + self.tol:
|
||||||
print((np.linalg.norm(np.array(c['eccentricity']['pointOnElement'])), '>', length))
|
print(np.linalg.norm(np.array(c['eccentricity']['pointOnElement'])), '>', length)
|
||||||
self.warnings.append('Eccentricity in %s corrected' % (item.is_a() + '|' + str(item.id())))
|
self.warnings.append('Eccentricity in %s corrected' % (item.is_a() + '|' + str(item.id())))
|
||||||
c['eccentricity']['pointOnElement'][0] = length
|
c['eccentricity']['pointOnElement'][0] = length
|
||||||
# End <--
|
# End <--
|
||||||
@@ -181,7 +181,32 @@ class IFC2CA:
|
|||||||
'geometryType': 'point',
|
'geometryType': 'point',
|
||||||
'geometry': geometry,
|
'geometry': geometry,
|
||||||
'orientation': orientation,
|
'orientation': orientation,
|
||||||
'appliedCondition': self.get_connection_input(item),
|
'appliedCondition': self.get_connection_input(item, 'point'),
|
||||||
|
'relatedElements': [con.is_a() + '|' + str(con.id()) for con in item.ConnectsStructuralMembers]
|
||||||
|
}
|
||||||
|
|
||||||
|
elif item.is_a('IfcStructuralCurveConnection'):
|
||||||
|
representation = self.get_representation(item, 'Edge')
|
||||||
|
if not representation:
|
||||||
|
self.warnings.append('No representation defined for %s. Connection excluded' % (item.is_a() + '|' + str(item.id())))
|
||||||
|
return
|
||||||
|
|
||||||
|
geometry = self.get_geometry(representation)
|
||||||
|
orientation = self.get_1D_orientation(geometry, item.Axis)
|
||||||
|
if not orientation:
|
||||||
|
orientation = np.eye(3).tolist()
|
||||||
|
if transformation:
|
||||||
|
geometry = self.transform_vectors(geometry, transformation)
|
||||||
|
orientation = self.transform_vectors(orientation, transformation, include_translation=False)
|
||||||
|
|
||||||
|
return {
|
||||||
|
'ifcName': item.is_a() + '|' + str(item.id()),
|
||||||
|
'name': item.Name,
|
||||||
|
'id': item.GlobalId,
|
||||||
|
'geometryType': 'line',
|
||||||
|
'geometry': geometry,
|
||||||
|
'orientation': orientation,
|
||||||
|
'appliedCondition': self.get_connection_input(item, 'line'),
|
||||||
'relatedElements': [con.is_a() + '|' + str(con.id()) for con in item.ConnectsStructuralMembers]
|
'relatedElements': [con.is_a() + '|' + str(con.id()) for con in item.ConnectsStructuralMembers]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -412,7 +437,7 @@ class IFC2CA:
|
|||||||
'relatingElement': rel.RelatingStructuralMember.is_a() + '|' + str(rel.RelatingStructuralMember.id()),
|
'relatingElement': rel.RelatingStructuralMember.is_a() + '|' + str(rel.RelatingStructuralMember.id()),
|
||||||
'relatedConnection': rel.RelatedStructuralConnection.is_a() + '|' + str(rel.RelatedStructuralConnection.id()),
|
'relatedConnection': rel.RelatedStructuralConnection.is_a() + '|' + str(rel.RelatedStructuralConnection.id()),
|
||||||
'orientation': self.get_0D_orientation(rel.ConditionCoordinateSystem),
|
'orientation': self.get_0D_orientation(rel.ConditionCoordinateSystem),
|
||||||
'appliedCondition': self.get_connection_input(rel),
|
'appliedCondition': self.get_connection_input(rel, self.get_geometry_type_from_connection(rel.RelatedStructuralConnection)),
|
||||||
'eccentricity': None if not rel.is_a('IfcRelConnectsWithEccentricity') else {
|
'eccentricity': None if not rel.is_a('IfcRelConnectsWithEccentricity') else {
|
||||||
'vector': [
|
'vector': [
|
||||||
0.0 if not rel.ConnectionConstraint.EccentricityInX else rel.ConnectionConstraint.EccentricityInX,
|
0.0 if not rel.ConnectionConstraint.EccentricityInX else rel.ConnectionConstraint.EccentricityInX,
|
||||||
@@ -423,16 +448,43 @@ class IFC2CA:
|
|||||||
}
|
}
|
||||||
} for rel in itemList]
|
} for rel in itemList]
|
||||||
|
|
||||||
def get_connection_input(self, connection):
|
def get_geometry_type_from_connection(self, connection):
|
||||||
|
if connection.is_a('IfcStructuralPointConnection'):
|
||||||
|
return 'point'
|
||||||
|
if connection.is_a('IfcStructuralCurveConnection'):
|
||||||
|
return 'line'
|
||||||
|
if connection.is_a('IfcStructuralSurfaceConnection'):
|
||||||
|
return 'surface'
|
||||||
|
|
||||||
|
def get_connection_input(self, connection, geometryType):
|
||||||
if connection.AppliedCondition:
|
if connection.AppliedCondition:
|
||||||
return {
|
if geometryType == 'point':
|
||||||
'dx': connection.AppliedCondition.TranslationalStiffnessX.wrappedValue,
|
return {
|
||||||
'dy': connection.AppliedCondition.TranslationalStiffnessY.wrappedValue,
|
'dx': connection.AppliedCondition.TranslationalStiffnessX.wrappedValue,
|
||||||
'dz': connection.AppliedCondition.TranslationalStiffnessZ.wrappedValue,
|
'dy': connection.AppliedCondition.TranslationalStiffnessY.wrappedValue,
|
||||||
'drx': connection.AppliedCondition.RotationalStiffnessX.wrappedValue,
|
'dz': connection.AppliedCondition.TranslationalStiffnessZ.wrappedValue,
|
||||||
'dry': connection.AppliedCondition.RotationalStiffnessY.wrappedValue,
|
'drx': connection.AppliedCondition.RotationalStiffnessX.wrappedValue,
|
||||||
'drz': connection.AppliedCondition.RotationalStiffnessZ.wrappedValue
|
'dry': connection.AppliedCondition.RotationalStiffnessY.wrappedValue,
|
||||||
}
|
'drz': connection.AppliedCondition.RotationalStiffnessZ.wrappedValue
|
||||||
|
}
|
||||||
|
|
||||||
|
if geometryType == 'line':
|
||||||
|
return {
|
||||||
|
'dx': connection.AppliedCondition.TranslationalStiffnessByLengthX.wrappedValue,
|
||||||
|
'dy': connection.AppliedCondition.TranslationalStiffnessByLengthY.wrappedValue,
|
||||||
|
'dz': connection.AppliedCondition.TranslationalStiffnessByLengthZ.wrappedValue,
|
||||||
|
'drx': connection.AppliedCondition.RotationalStiffnessByLengthX.wrappedValue,
|
||||||
|
'dry': connection.AppliedCondition.RotationalStiffnessByLengthY.wrappedValue,
|
||||||
|
'drz': connection.AppliedCondition.RotationalStiffnessByLengthZ.wrappedValue
|
||||||
|
}
|
||||||
|
|
||||||
|
if geometryType == 'surface':
|
||||||
|
return {
|
||||||
|
'dx': connection.AppliedCondition.TranslationalStiffnessByAreaX.wrappedValue,
|
||||||
|
'dy': connection.AppliedCondition.TranslationalStiffnessByAreaY.wrappedValue,
|
||||||
|
'dz': connection.AppliedCondition.TranslationalStiffnessByAreaZ.wrappedValue
|
||||||
|
}
|
||||||
|
|
||||||
return connection.AppliedCondition
|
return connection.AppliedCondition
|
||||||
|
|
||||||
def get_i_section_properties(self, profile, profileShape):
|
def get_i_section_properties(self, profile, profileShape):
|
||||||
@@ -455,7 +507,7 @@ class IFC2CA:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
fileNames = ['cantilever_01', 'portal_01', 'grid_of_beams']
|
fileNames = ['cantilever_01', 'portal_01', 'grid_of_beams', 'slab_01', 'structure_01']
|
||||||
files = fileNames
|
files = fileNames
|
||||||
|
|
||||||
for fileName in files:
|
for fileName in files:
|
||||||
|
|||||||
+130
-14
@@ -33,16 +33,25 @@ class COMMANDFILE:
|
|||||||
for el in elements:
|
for el in elements:
|
||||||
for rel in el['connections']:
|
for rel in el['connections']:
|
||||||
conn = [c for c in connections if c['ifcName'] == rel['relatedConnection']][0]
|
conn = [c for c in connections if c['ifcName'] == rel['relatedConnection']][0]
|
||||||
|
rel['conn_string'] = None
|
||||||
if conn['geometryType'] == 'point':
|
if conn['geometryType'] == 'point':
|
||||||
rel['groupName1'] = self.getGroupName(rel['relatingElement']) + '_0DC_' + self.getGroupName(rel['relatedConnection'])
|
rel['conn_string'] = '_0DC_'
|
||||||
if rel['eccentricity']:
|
|
||||||
rel['groupName2'] = self.getGroupName(rel['relatedConnection']) + '_0DC_' + self.getGroupName(rel['relatingElement'])
|
|
||||||
rel['index'] = len(conn['relatedElements']) + 1
|
|
||||||
rel['unifiedGroupName'] = self.getGroupName(rel['relatedConnection']) + '_0DC_%g' % rel['index']
|
|
||||||
else:
|
|
||||||
rel['groupName2'] = self.getGroupName(rel['relatedConnection'])
|
|
||||||
rel['springGroupName'] = self.getGroupName(rel['relatingElement']) + '_1DS_' + self.getGroupName(rel['relatedConnection'])
|
rel['springGroupName'] = self.getGroupName(rel['relatingElement']) + '_1DS_' + self.getGroupName(rel['relatedConnection'])
|
||||||
self.calculateConstraints(rel)
|
if conn['geometryType'] == 'line':
|
||||||
|
rel['conn_string'] = '_1DC_'
|
||||||
|
rel['springGroupName'] = None
|
||||||
|
if conn['geometryType'] == 'surface':
|
||||||
|
rel['conn_string'] = '_2DC_'
|
||||||
|
rel['springGroupName'] = None
|
||||||
|
|
||||||
|
rel['groupName1'] = self.getGroupName(rel['relatingElement']) + rel['conn_string'] + self.getGroupName(rel['relatedConnection'])
|
||||||
|
if rel['eccentricity']:
|
||||||
|
rel['groupName2'] = self.getGroupName(rel['relatedConnection']) + '_0DC_' + self.getGroupName(rel['relatingElement'])
|
||||||
|
rel['index'] = len(conn['relatedElements']) + 1
|
||||||
|
rel['unifiedGroupName'] = self.getGroupName(rel['relatedConnection']) + '_0DC_%g' % rel['index']
|
||||||
|
else:
|
||||||
|
rel['groupName2'] = self.getGroupName(rel['relatedConnection'])
|
||||||
|
self.calculateConstraints(rel)
|
||||||
conn['relatedElements'].append(rel)
|
conn['relatedElements'].append(rel)
|
||||||
# End <--
|
# End <--
|
||||||
|
|
||||||
@@ -51,8 +60,9 @@ class COMMANDFILE:
|
|||||||
|
|
||||||
edgeGroupNames = tuple([self.getGroupName(el['ifcName']) for el in elements if el['geometryType'] == 'line'])
|
edgeGroupNames = tuple([self.getGroupName(el['ifcName']) for el in elements if el['geometryType'] == 'line'])
|
||||||
faceGroupNames = tuple([self.getGroupName(el['ifcName']) for el in elements if el['geometryType'] == 'surface'])
|
faceGroupNames = tuple([self.getGroupName(el['ifcName']) for el in elements if el['geometryType'] == 'surface'])
|
||||||
point0DGroupNames = tuple([self.getGroupName(el['ifcName']) for el in connections if el['geometryType'] == 'point'])
|
point0DGroupNames = tuple([self.getGroupName(el['ifcName']) + '_0D' for el in connections if el['geometryType'] == 'point'])
|
||||||
spring1DGroupNames = tuple(flatten([[rel['springGroupName'] for rel in el['connections']] for el in elements]))
|
spring1DGroupNames = tuple(flatten([[rel['springGroupName'] for rel in el['connections'] if rel['springGroupName']] for el in elements]))
|
||||||
|
point1DGroupNames = tuple([self.getGroupName(el['ifcName']) + '_0D' for el in connections if el['geometryType'] == 'line'])
|
||||||
|
|
||||||
unifiedConnection = False
|
unifiedConnection = False
|
||||||
rigidLinkGroupNames = []
|
rigidLinkGroupNames = []
|
||||||
@@ -156,6 +166,21 @@ model = AFFE_MODELE(
|
|||||||
|
|
||||||
f.write(template.format(**context))
|
f.write(template.format(**context))
|
||||||
|
|
||||||
|
if point1DGroupNames:
|
||||||
|
template = \
|
||||||
|
'''
|
||||||
|
_F(
|
||||||
|
GROUP_MA = {groupNames},
|
||||||
|
PHENOMENE = 'MECANIQUE',
|
||||||
|
MODELISATION = 'DIS_TR'
|
||||||
|
),'''
|
||||||
|
|
||||||
|
context = {
|
||||||
|
'groupNames': point1DGroupNames
|
||||||
|
}
|
||||||
|
|
||||||
|
f.write(template.format(**context))
|
||||||
|
|
||||||
if rigidLinkGroupNames:
|
if rigidLinkGroupNames:
|
||||||
template = \
|
template = \
|
||||||
'''
|
'''
|
||||||
@@ -365,7 +390,7 @@ element = AFFE_CARA_ELEM(
|
|||||||
),'''
|
),'''
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
'groupName': self.getGroupName(conn['ifcName']),
|
'groupName': self.getGroupName(conn['ifcName']) + '_0D',
|
||||||
'stiffnesses': conn['stiffnesses']
|
'stiffnesses': conn['stiffnesses']
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,6 +414,23 @@ element = AFFE_CARA_ELEM(
|
|||||||
|
|
||||||
f.write(template.format(**context))
|
f.write(template.format(**context))
|
||||||
|
|
||||||
|
for conn in [conn for conn in connections if conn['geometryType'] == 'line']:
|
||||||
|
|
||||||
|
template = \
|
||||||
|
'''
|
||||||
|
_F(
|
||||||
|
GROUP_MA = '{groupName}',
|
||||||
|
CARA = 'K_TR_D_N',
|
||||||
|
VALE = {stiffnesses},
|
||||||
|
REPERE = 'LOCAL'
|
||||||
|
),'''
|
||||||
|
|
||||||
|
context = {
|
||||||
|
'groupName': self.getGroupName(conn['ifcName']) + '_0D',
|
||||||
|
'stiffnesses': conn['stiffnesses']
|
||||||
|
}
|
||||||
|
|
||||||
|
f.write(template.format(**context))
|
||||||
|
|
||||||
f.write(
|
f.write(
|
||||||
'''
|
'''
|
||||||
@@ -428,7 +470,7 @@ element = AFFE_CARA_ELEM(
|
|||||||
),'''
|
),'''
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
'groupName': self.getGroupName(conn['ifcName']),
|
'groupName': self.getGroupName(conn['ifcName']) + '_0D',
|
||||||
'localAxesXY': tuple(conn['orientation'][0] + conn['orientation'][1])
|
'localAxesXY': tuple(conn['orientation'][0] + conn['orientation'][1])
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,6 +493,23 @@ element = AFFE_CARA_ELEM(
|
|||||||
|
|
||||||
f.write(template.format(**context))
|
f.write(template.format(**context))
|
||||||
|
|
||||||
|
for conn in [conn for conn in connections if conn['geometryType'] == 'line']:
|
||||||
|
|
||||||
|
template = \
|
||||||
|
'''
|
||||||
|
_F(
|
||||||
|
GROUP_MA = '{groupName}',
|
||||||
|
CARA = 'VECT_X_Y',
|
||||||
|
VALE = {localAxesXY}
|
||||||
|
),'''
|
||||||
|
|
||||||
|
context = {
|
||||||
|
'groupName': self.getGroupName(conn['ifcName']) + '_0D',
|
||||||
|
'localAxesXY': tuple(conn['orientation'][0] + conn['orientation'][1])
|
||||||
|
}
|
||||||
|
|
||||||
|
f.write(template.format(**context))
|
||||||
|
|
||||||
f.write(
|
f.write(
|
||||||
'''
|
'''
|
||||||
),'''
|
),'''
|
||||||
@@ -472,7 +531,7 @@ liaisons = AFFE_CHAR_MECA(
|
|||||||
LIAISON_DDL = ('''
|
LIAISON_DDL = ('''
|
||||||
)
|
)
|
||||||
|
|
||||||
for conn in connections:
|
for conn in [conn for conn in connections if conn['geometryType'] == 'point']:
|
||||||
if conn['appliedCondition']:
|
if conn['appliedCondition']:
|
||||||
for i in range(len(conn['liaisons']['coeffs'])):
|
for i in range(len(conn['liaisons']['coeffs'])):
|
||||||
template = \
|
template = \
|
||||||
@@ -516,6 +575,63 @@ liaisons = AFFE_CHAR_MECA(
|
|||||||
),'''
|
),'''
|
||||||
)
|
)
|
||||||
|
|
||||||
|
f.write(
|
||||||
|
'''
|
||||||
|
LIAISON_GROUP = ('''
|
||||||
|
)
|
||||||
|
|
||||||
|
for conn in [conn for conn in connections if conn['geometryType'] == 'line']:
|
||||||
|
if conn['appliedCondition']:
|
||||||
|
for i in range(len(conn['liaisons']['coeffs'])):
|
||||||
|
template = \
|
||||||
|
'''
|
||||||
|
_F(
|
||||||
|
GROUP_NO_1 = {groupName_1},
|
||||||
|
GROUP_NO_2 = {groupName_1},
|
||||||
|
DDL_1 = {dofs},
|
||||||
|
DDL_2 = {dofs},
|
||||||
|
COEF_MULT_1 = {coeffs},
|
||||||
|
COEF_MULT_2 = (0.0, 0.0, 0.0),
|
||||||
|
COEF_IMPO = 0.0
|
||||||
|
),'''
|
||||||
|
|
||||||
|
context = {
|
||||||
|
'groupName_1': tuple([conn['liaisons']['groupNames'][0]]),
|
||||||
|
'dofs': conn['liaisons']['dofs'][i],
|
||||||
|
'coeffs': conn['liaisons']['coeffs'][i]
|
||||||
|
}
|
||||||
|
|
||||||
|
f.write(template.format(**context))
|
||||||
|
|
||||||
|
for rel in conn['relatedElements']:
|
||||||
|
for i in range(len(rel['liaisons']['coeffs'])):
|
||||||
|
template = \
|
||||||
|
'''
|
||||||
|
_F(
|
||||||
|
GROUP_NO_1 = {groupName_1},
|
||||||
|
GROUP_NO_2 = {groupName_2},
|
||||||
|
DDL_1 = {dofs},
|
||||||
|
DDL_2 = {dofs},
|
||||||
|
COEF_MULT_1 = {coeffs_1},
|
||||||
|
COEF_MULT_2 = {coeffs_2},
|
||||||
|
COEF_IMPO = 0.0
|
||||||
|
),'''
|
||||||
|
|
||||||
|
context = {
|
||||||
|
'groupName_1': tuple([rel['liaisons']['groupNames'][0]]),
|
||||||
|
'groupName_2': tuple([rel['liaisons']['groupNames'][3]]),
|
||||||
|
'dofs': tuple(list(rel['liaisons']['dofs'][i])[:3]),
|
||||||
|
'coeffs_1': tuple(list(rel['liaisons']['coeffs'][i])[:3]),
|
||||||
|
'coeffs_2': tuple(list(rel['liaisons']['coeffs'][i])[3:]),
|
||||||
|
}
|
||||||
|
|
||||||
|
f.write(template.format(**context))
|
||||||
|
|
||||||
|
f.write(
|
||||||
|
'''
|
||||||
|
),'''
|
||||||
|
)
|
||||||
|
|
||||||
if unifiedConnection:
|
if unifiedConnection:
|
||||||
f.write(
|
f.write(
|
||||||
'''
|
'''
|
||||||
@@ -825,7 +941,7 @@ FIN()
|
|||||||
conn['stiffnesses'] = tuple(stiffnesses)
|
conn['stiffnesses'] = tuple(stiffnesses)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
fileNames = ['cantilever_01', 'portal_01', 'grid_of_beams']
|
fileNames = ['cantilever_01', 'portal_01', 'grid_of_beams', 'slab_01', 'structure_01']
|
||||||
files = fileNames
|
files = fileNames
|
||||||
|
|
||||||
for fileName in files:
|
for fileName in files:
|
||||||
|
|||||||
+39
-24
@@ -160,20 +160,19 @@ class MODEL:
|
|||||||
if rel['eccentricity']:
|
if rel['eccentricity']:
|
||||||
rel['index'] = len(conn['relatedElements']) + 1
|
rel['index'] = len(conn['relatedElements']) + 1
|
||||||
conn['relatedElements'].append(rel)
|
conn['relatedElements'].append(rel)
|
||||||
if conn['geometryType'] == 'point':
|
|
||||||
if not rel['eccentricity']:
|
if not rel['eccentricity']:
|
||||||
el['connObjs'][j] = self.makeObject(conn['geometry'], conn['geometryType'])
|
el['connObjs'][j] = self.makeObject(conn['geometry'], conn['geometryType'])
|
||||||
else:
|
else:
|
||||||
|
if conn['geometryType'] == 'point':
|
||||||
geometry = self.getLinkGeometry(rel['eccentricity'], el['orientation'], conn['geometry'])
|
geometry = self.getLinkGeometry(rel['eccentricity'], el['orientation'], conn['geometry'])
|
||||||
el['connObjs'][j] = self.makeObject(geometry[0], conn['geometryType'])
|
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][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['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])
|
el['linkObjs'][j] = self.geompy.MakeLineTwoPnt(el['linkPointObjs'][j][0], el['linkPointObjs'][j][1])
|
||||||
elif conn['geometryType'] == 'line':
|
else:
|
||||||
pass
|
print('Eccentricity defined for a %s geometryType' %conn['geometryType'])
|
||||||
elif conn['geometryType'] == 'surface':
|
|
||||||
pass
|
|
||||||
|
|
||||||
el['partObj'] = self.makePartition([el['elemObj']] + el['connObjs'], el['geometryType'])
|
el['partObj'] = self.makePartition([el['elemObj']] + el['connObjs'], el['geometryType'])
|
||||||
|
|
||||||
@@ -199,7 +198,15 @@ class MODEL:
|
|||||||
# geompy.addToStudy(el['partObj'], self.getGroupName(el['ifcName']))
|
# geompy.addToStudy(el['partObj'], self.getGroupName(el['ifcName']))
|
||||||
geompy.addToStudyInFather(el['partObj'], el['elemObj'], self.getGroupName(el['ifcName']))
|
geompy.addToStudyInFather(el['partObj'], el['elemObj'], self.getGroupName(el['ifcName']))
|
||||||
for j,rel in enumerate(el['connections']):
|
for j,rel in enumerate(el['connections']):
|
||||||
geompy.addToStudyInFather(el['partObj'], el['connObjs'][j], self.getGroupName(el['ifcName']) + '_0DC_' + self.getGroupName(rel['relatedConnection']))
|
conn = [c for c in connections if c['ifcName'] == rel['relatedConnection']][0]
|
||||||
|
rel['conn_string'] = None
|
||||||
|
if conn['geometryType'] == 'point':
|
||||||
|
rel['conn_string'] = '_0DC_'
|
||||||
|
if conn['geometryType'] == 'line':
|
||||||
|
rel['conn_string'] = '_1DC_'
|
||||||
|
if conn['geometryType'] == 'surface':
|
||||||
|
rel['conn_string'] = '_2DC_'
|
||||||
|
geompy.addToStudyInFather(el['partObj'], el['connObjs'][j], self.getGroupName(el['ifcName']) + rel['conn_string'] + self.getGroupName(rel['relatedConnection']))
|
||||||
if rel['eccentricity']:
|
if rel['eccentricity']:
|
||||||
pass
|
pass
|
||||||
# geompy.addToStudy(el['linkObjs'][j], self.getGroupName(el['ifcName']) + '_1DR_' + self.getGroupName(rel['relatedConnection']))
|
# geompy.addToStudy(el['linkObjs'][j], self.getGroupName(el['ifcName']) + '_1DR_' + self.getGroupName(rel['relatedConnection']))
|
||||||
@@ -240,8 +247,8 @@ class MODEL:
|
|||||||
geompy.addToStudyInFather(bldComp, el['elemObj'], self.getGroupName(el['ifcName']))
|
geompy.addToStudyInFather(bldComp, el['elemObj'], self.getGroupName(el['ifcName']))
|
||||||
|
|
||||||
for j,rel in enumerate(el['connections']):
|
for j,rel in enumerate(el['connections']):
|
||||||
geompy.addToStudyInFather(bldComp, el['connObjs'][j], self.getGroupName(el['ifcName']) + '_0DC_' + self.getGroupName(rel['relatedConnection']))
|
geompy.addToStudyInFather(bldComp, el['connObjs'][j], self.getGroupName(el['ifcName']) + rel['conn_string'] + self.getGroupName(rel['relatedConnection']))
|
||||||
if rel['eccentricity']:
|
if rel['eccentricity']: # point geometry
|
||||||
geompy.addToStudyInFather(bldComp, el['linkObjs'][j], self.getGroupName(el['ifcName']) + '_1DR_' + self.getGroupName(rel['relatedConnection']))
|
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][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'])
|
geompy.addToStudyInFather(bldComp, el['linkPointObjs'][j][1], self.getGroupName(rel['relatedConnection']) + '_0DC_%g' % rel['index'])
|
||||||
@@ -318,8 +325,8 @@ class MODEL:
|
|||||||
smesh.SetName(tempgroup, self.getGroupName(el['ifcName']))
|
smesh.SetName(tempgroup, self.getGroupName(el['ifcName']))
|
||||||
|
|
||||||
for j,rel in enumerate(el['connections']):
|
for j,rel in enumerate(el['connections']):
|
||||||
tempgroup = bldMesh.GroupOnGeom(el['connObjs'][j], self.getGroupName(el['ifcName']) + '_0DC_' + self.getGroupName(rel['relatedConnection']), SMESH.NODE)
|
tempgroup = bldMesh.GroupOnGeom(el['connObjs'][j], self.getGroupName(el['ifcName']) + rel['conn_string'] + self.getGroupName(rel['relatedConnection']), SMESH.NODE)
|
||||||
smesh.SetName(tempgroup, self.getGroupName(el['ifcName']) + '_0DC_' + self.getGroupName(rel['relatedConnection']))
|
smesh.SetName(tempgroup, self.getGroupName(el['ifcName']) + rel['conn_string'] + self.getGroupName(rel['relatedConnection']))
|
||||||
rel['node'] = (bldMesh.GetIDSource(tempgroup.GetNodeIDs(), SMESH.NODE)).GetIDs()[0]
|
rel['node'] = (bldMesh.GetIDSource(tempgroup.GetNodeIDs(), SMESH.NODE)).GetIDs()[0]
|
||||||
if rel['eccentricity']:
|
if rel['eccentricity']:
|
||||||
tempgroup = bldMesh.GroupOnGeom(el['linkObjs'][j], self.getGroupName(el['ifcName']) + '_1DR_' + self.getGroupName(rel['relatedConnection']), SMESH.EDGE)
|
tempgroup = bldMesh.GroupOnGeom(el['linkObjs'][j], self.getGroupName(el['ifcName']) + '_1DR_' + self.getGroupName(rel['relatedConnection']), SMESH.EDGE)
|
||||||
@@ -334,24 +341,32 @@ class MODEL:
|
|||||||
|
|
||||||
|
|
||||||
for conn in connections:
|
for conn in connections:
|
||||||
# if conn['appliedCondition']:
|
|
||||||
tempgroup = bldMesh.GroupOnGeom(conn['connObj'], self.getGroupName(conn['ifcName']), SMESH.NODE)
|
tempgroup = bldMesh.GroupOnGeom(conn['connObj'], self.getGroupName(conn['ifcName']), SMESH.NODE)
|
||||||
smesh.SetName(tempgroup, self.getGroupName(conn['ifcName']))
|
smesh.SetName(tempgroup, self.getGroupName(conn['ifcName']))
|
||||||
nodesId = bldMesh.GetIDSource(tempgroup.GetNodeIDs(), SMESH.NODE)
|
nodesId = bldMesh.GetIDSource(tempgroup.GetNodeIDs(), SMESH.NODE)
|
||||||
tempgroup = bldMesh.Add0DElementsToAllNodes(nodesId, self.getGroupName(conn['ifcName']))
|
tempgroup = bldMesh.Add0DElementsToAllNodes(nodesId, self.getGroupName(conn['ifcName']))
|
||||||
smesh.SetName(tempgroup, self.getGroupName(conn['ifcName']))
|
smesh.SetName(tempgroup, self.getGroupName(conn['ifcName'] + '_0D'))
|
||||||
conn['node'] = nodesId.GetIDs()[0]
|
if conn['geometryType'] == 'point':
|
||||||
|
conn['node'] = nodesId.GetIDs()[0]
|
||||||
|
if conn['geometryType'] == 'line':
|
||||||
|
tempgroup = bldMesh.GroupOnGeom(conn['connObj'], self.getGroupName(conn['ifcName']), SMESH.EDGE)
|
||||||
|
smesh.SetName(tempgroup, self.getGroupName(conn['ifcName']))
|
||||||
|
if conn['geometryType'] == 'surface':
|
||||||
|
tempgroup = bldMesh.GroupOnGeom(conn['connObj'], self.getGroupName(conn['ifcName']), SMESH.FACE)
|
||||||
|
smesh.SetName(tempgroup, self.getGroupName(conn['ifcName']))
|
||||||
|
|
||||||
# create 1D SEG2 spring elements
|
# create 1D SEG2 spring elements
|
||||||
for el in elements:
|
for el in elements:
|
||||||
for j,rel in enumerate(el['connections']):
|
for j,rel in enumerate(el['connections']):
|
||||||
grpName = bldMesh.CreateEmptyGroup(SMESH.EDGE, self.getGroupName(el['ifcName']) + '_1DS_' + self.getGroupName(rel['relatedConnection']))
|
conn = [c for c in connections if c['ifcName'] == rel['relatedConnection']][0]
|
||||||
smesh.SetName(grpName, self.getGroupName(el['ifcName']) + '_1DS_' + self.getGroupName(rel['relatedConnection']))
|
if conn['geometryType'] == 'point':
|
||||||
if not rel['eccentricity']:
|
grpName = bldMesh.CreateEmptyGroup(SMESH.EDGE, self.getGroupName(el['ifcName']) + '_1DS_' + self.getGroupName(rel['relatedConnection']))
|
||||||
conn = [conn for conn in connections if conn['ifcName'] == rel['relatedConnection']][0]
|
smesh.SetName(grpName, self.getGroupName(el['ifcName']) + '_1DS_' + self.getGroupName(rel['relatedConnection']))
|
||||||
grpName.Add([bldMesh.AddEdge([conn['node'], rel['node']])])
|
if not rel['eccentricity']:
|
||||||
else:
|
conn = [conn for conn in connections if conn['ifcName'] == rel['relatedConnection']][0]
|
||||||
grpName.Add([bldMesh.AddEdge([rel['eccNode'], rel['node']])])
|
grpName.Add([bldMesh.AddEdge([conn['node'], rel['node']])])
|
||||||
|
else:
|
||||||
|
grpName.Add([bldMesh.AddEdge([rel['eccNode'], rel['node']])])
|
||||||
|
|
||||||
self.mesh = bldMesh
|
self.mesh = bldMesh
|
||||||
self.meshNodes = bldMesh.GetNodesId()
|
self.meshNodes = bldMesh.GetNodesId()
|
||||||
@@ -385,7 +400,7 @@ class MODEL:
|
|||||||
print('ALL Operations Completed in %g sec' % (elapsed_time))
|
print('ALL Operations Completed in %g sec' % (elapsed_time))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
fileNames = ['cantilever_01']
|
fileNames = ['structure_01']
|
||||||
files = fileNames
|
files = fileNames
|
||||||
|
|
||||||
meshSize = 0.1
|
meshSize = 0.1
|
||||||
|
|||||||
Reference in New Issue
Block a user