def run(self, config, job, data, log): cad_model = data.get('cad_model', None) # FIXME: Check for None data['nodes'] = data.get('nodes', {}) elements = [] nb_objectives = 0 for key, face in cad_model.of_type('BrepFace'): surface_geometry_key = surface_geometry = face.surface_geometry.data if surface_geometry_key not in data['nodes']: nodes = [] for x, y, z in surface_geometry.poles: nodes.append(eq.Node(x, y, z)) nodes = np.array(nodes, object) data['nodes'][surface_geometry_key] = nodes else: nodes = data['nodes'][surface_geometry_key] for r in range(surface_geometry.nb_poles_u): for s in range(surface_geometry.nb_poles_v): target_node = nodes[r * surface_geometry.nb_poles_v + s] u, v = surface_geometry.greville_point(r, s) nonzero_indices, shape_functions = surface_geometry.shape_functions_at( u, v, 0) element = POINT_NODE_COUPLING(nodes[nonzero_indices], shape_functions, target_node, self.weight) elements.append(element) nb_objectives += 1 if self.debug: cad_model.add( an.Line3D(target_node.act_location, surface_geometry.point_at(u, v)), r'{"layer": "Debug/ApplyAlphaRegularization/Connections"}' ) data['elements'] = data.get('elements', []) data['elements'].append(('AlphaRegularization', elements, self.weight)) # output log.info( f'{len(elements)} elements with {nb_objectives} new objectives')
def run(self, config, job, data, log): cad_model = data.get('cad_model', None) model_tolerance = job.model_tolerance nb_objectives = 0 # FIXME: Check for None data['nodes'] = data.get('nodes', {}) elements = [] thickness = self.thickness youngs_modulus = self.youngs_modulus poissons_ratio = self.poissons_ratio for key, face in cad_model.of_type('BrepFace'): surface_geometry_key = surface_geometry = face.surface_geometry.data if surface_geometry_key not in data['nodes']: nodes = [] for x, y, z in surface_geometry.poles: nodes.append(eq.Node(x, y, z)) nodes = np.array(nodes, object) data['nodes'][surface_geometry_key] = nodes else: nodes = data['nodes'][surface_geometry_key] for span_u, span_v, integration_points in an.integration_points_with_spans( face, model_tolerance): nonzero_indices = surface_geometry.nonzero_pole_indices_at_span( span_u, span_v) element = ELEMENT(nodes[nonzero_indices], thickness, youngs_modulus, poissons_ratio) elements.append(element) for u, v, weight in integration_points: _, shape_functions = surface_geometry.shape_functions_at( u, v, 2) element.add(shape_functions, weight) nb_objectives += 1 data['elements'] = data.get('elements', []) data['elements'].append(('IgaShell3PAD', elements, self.weight)) # output log.info( f'{len(elements)} elements with {nb_objectives} new objectives')
def element(): nodes = [] for ref_location, act_location in zip(DATA['ref_locations'], DATA['act_locations']): node = eq.Node() node.ref_location = ref_location node.act_location = act_location nodes.append(node) shape_functions = DATA['shape_functions'] target_node = nodes[DATA['target_node_index']] weight = DATA['weight'] return IgaPointNodeCouplingAD(nodes, shape_functions, target_node, weight)
def element(): nodes = [] for ref_location, act_location in zip(DATA['ref_locations'], DATA['act_locations']): node = eq.Node() node.ref_location = ref_location node.act_location = act_location nodes.append(node) shape_functions = DATA['shape_functions'] target = DATA['target'] weight = DATA['weight'] element = eq.IgaPointLocation(nodes) element.add(shape_functions, target, weight) return element
def run(self, config, job, data, log): cad_model = data.get('cad_model', None) model_tolerance = job.model_tolerance nb_objectives = 0 # FIXME: Check for None data['nodes'] = data.get('nodes', {}) elements = [] for key, face in cad_model.of_type('BrepFace'): surface_geometry_key = surface_geometry = face.surface_geometry.data if surface_geometry_key not in data['nodes']: nodes = [] for x, y, z in surface_geometry.poles: nodes.append(eq.Node(x, y, z)) nodes = np.array(nodes, object) data['nodes'][surface_geometry_key] = nodes else: nodes = data['nodes'][surface_geometry_key] for u, v, weight in an.integration_points(face, model_tolerance): nonzero_indices, shape_functions = surface_geometry.shape_functions_at(u, v, 2) element = REDUCED_SHELL_3P(nodes[nonzero_indices], self.membrane_stiffness, self.bending_stiffness) element.add(shape_functions, weight) elements.append(element) nb_objectives += 1 data['elements'] = data.get('elements', []) data['elements'].append(('ReducedIgaShell', elements, self.weight)) # output log.info(f'{len(elements)} elements with {nb_objectives} new objectives')
def run(self, config, job, data, log): model_tolerance = job.model_tolerance cad_model = data.get('cad_model', None) if isinstance(self.weight, float): weight_displacement = self.weight weight_rotation = self.weight else: weight_displacement = self.weight.get('displacement', 0) weight_rotation = self.weight.get('rotation', 0) # FIXME: Check for None nb_objectives = 0 data['nodes'] = nodes = data.get('nodes', {}) point_distance_group = [] normal_distance_group = [] for key, edge in cad_model.of_type('BrepEdge'): if edge.nb_trims != 2: continue (_, trim_a), (_, trim_b) = edge.trims nurbs_surface_key_a, nurbs_surface_a = trim_a.surface_geometry nurbs_surface_key_b, nurbs_surface_b = trim_b.surface_geometry if nurbs_surface_a not in nodes: nurbs_surface_nodes = [] for x, y, z in nurbs_surface_a.poles: nurbs_surface_nodes.append(eq.Node(x, y, z)) nurbs_surface_nodes_a = np.array(nurbs_surface_nodes, object) nodes[nurbs_surface_a] = nurbs_surface_nodes_a else: nurbs_surface_nodes_a = nodes[nurbs_surface_a] if nurbs_surface_b not in nodes: nurbs_surface_nodes = [] for x, y, z in nurbs_surface_b.poles: nurbs_surface_nodes.append(eq.Node(x, y, z)) nurbs_surface_nodes_b = np.array(nurbs_surface_nodes, object) nodes[nurbs_surface_b] = nurbs_surface_nodes_b else: nurbs_surface_nodes_b = nodes[nurbs_surface_b] integration_points_a, integration_points_b = an.integration_points(edge, tolerance=self.projection_tolerance, tessellation_tolerance=model_tolerance) for (t_a, weight), (t_b, _) in zip(integration_points_a, integration_points_b): u_a, v_a = trim_a.curve_geometry.data.point_at(t_a) u_b, v_b = trim_b.curve_geometry.data.point_at(t_b) indices_a, shape_functions_a = nurbs_surface_a.shape_functions_at(u_a, v_a, 1) indices_b, shape_functions_b = nurbs_surface_b.shape_functions_at(u_b, v_b, 1) element_nodes_a = [nurbs_surface_nodes_a[i] for i in indices_a] element_nodes_b = [nurbs_surface_nodes_b[i] for i in indices_b] if weight_displacement != 0: element = POINT_DISTANCE(element_nodes_a, element_nodes_b) element.add(shape_functions_a, shape_functions_b, weight * weight_displacement) point_distance_group.append(element) nb_objectives += 1 if weight_rotation != 0: _, axis = trim_a.curve_3d.derivatives_at(t_a, order=1) element = NORMAL_DISTANCE(element_nodes_a, element_nodes_b) element.add(shape_functions_a, shape_functions_b, axis, weight=weight * weight_rotation) normal_distance_group.append(element) nb_objectives += 1 if self.debug: point_a = nurbs_surface_a.point_at(u_a, v_a) point_b = nurbs_surface_b.point_at(u_b, v_b) cad_model.add(an.Point3D(point_a), r'{"layer": "Debug/ApplyEdgeCoupling/PointsA"}') cad_model.add(an.Point3D(point_b), r'{"layer": "Debug/ApplyEdgeCoupling/PointsB"}') if weight_rotation != 0: cad_model.add(an.Line3D(point_a, point_a + axis), r'{"layer": "Debug/ApplyEdgeCoupling/RotationAxis"}') data['elements'] = data.get('elements', []) if weight_displacement != 0: data['elements'].append(('DisplacementCoupling', point_distance_group, weight_displacement)) if weight_rotation != 0: data['elements'].append(('IgaRotationCouplingAD', normal_distance_group, weight_rotation)) # output log.info(f'{len(point_distance_group) + len(normal_distance_group)} with {nb_objectives} new objectives')
def node(): return eq.Node(1, 2, 3)
def run(self, config, job, data, log): model_tolerance = job.model_tolerance cad_model = data.get('cad_model', None) # FIXME: Check for None nb_objectives = 0 data['nodes'] = nodes = data.get('nodes', {}) group = [] for key, face in cad_model.of_type('BrepFace'): _, surface_geometry = face.surface_geometry if surface_geometry not in nodes: surface_nodes = [] for x, y, z in surface_geometry.poles: surface_nodes.append(eq.Node(x, y, z)) surface_nodes = np.array(surface_nodes, object) nodes[surface_geometry] = surface_nodes else: surface_nodes = nodes[surface_geometry] for u, span_u_a, span_u_b in _get_multiple_knots( surface_geometry.degree_u, surface_geometry.knots_u): for (span_v, v0, v1) in _nonzero_spans(surface_geometry.degree_v, surface_geometry.knots_v): for v, weight in an.integration_points( surface_geometry.degree_v + 1, an.Interval(v0, v1)): nonzero_indices_a, shape_functions_a = surface_geometry.shape_functions_at_span( u=u, v=v, span_u=span_u_a, span_v=span_v, order=1) nonzero_indices_b, shape_functions_b = surface_geometry.shape_functions_at_span( u=u, v=v, span_u=span_u_b, span_v=span_v, order=1) element_nodes_a = surface_nodes[nonzero_indices_a] element_nodes_b = surface_nodes[nonzero_indices_b] element = POINT_DISTANCE(element_nodes_a, element_nodes_b) element.add([shape_functions_a[1]], [shape_functions_b[1]], weight * self.weight) group.append(element) nb_objectives += 1 if self.debug: point = surface_geometry.point_at(u, v) cad_model.add( an.Point3D(point), r'{"layer": "Debug/ApplyMultipleKnotCoupling/PointsU"}' ) for v, span_v_a, span_v_b in _get_multiple_knots( surface_geometry.degree_v, surface_geometry.knots_v): for (span_u, u0, u1) in _nonzero_spans(surface_geometry.degree_u, surface_geometry.knots_u): for u, weight in an.integration_points( surface_geometry.degree_u + 1, an.Interval(u0, u1)): nonzero_indices_a, shape_functions_a = surface_geometry.shape_functions_at_span( u=u, v=v, span_u=span_u, span_v=span_v_a, order=1) nonzero_indices_b, shape_functions_b = surface_geometry.shape_functions_at_span( u=u, v=v, span_u=span_u, span_v=span_v_b, order=1) element_nodes_a = surface_nodes[nonzero_indices_a] element_nodes_b = surface_nodes[nonzero_indices_b] element = POINT_DISTANCE(element_nodes_a, element_nodes_b) element.add([shape_functions_a[2]], [shape_functions_b[2]], weight * self.weight) group.append(element) nb_objectives += 1 if self.debug: point = surface_geometry.point_at(u, v) cad_model.add( an.Point3D(point), r'{"layer": "Debug/ApplyMultipleKnotCoupling/PointsV"}' ) data['elements'] = data.get('elements', []) data['elements'].append(('DisplacementCoupling', group, self.weight)) # output log.info(f'{len(group)} elements with {nb_objectives} new objectives')
def run(self, config, job, data, log): cad_model = data.get('cad_model', None) vertices = data.get('vertices', None) displacements = data.get('displacements', None) faces = data.get('faces', None) model_tolerance = job.model_tolerance max_distance = model_tolerance * 2 if self.max_distance <= 0 else self.max_distance nb_objectives = 0 # FIXME: Check for None data['nodes'] = data.get('nodes', {}) elements = [] mapper = an.MeshMapper3D(vertices, faces) projection_failed = 0 for i, (key, face) in enumerate(cad_model.of_type('BrepFace')): surface_geometry_key = surface_geometry = face.surface_geometry.data if surface_geometry_key not in data['nodes']: nodes = [] for x, y, z in surface_geometry.poles: nodes.append(eq.Node(x, y, z)) nodes = np.array(nodes, object) data['nodes'][surface_geometry_key] = nodes else: nodes = data['nodes'][surface_geometry_key] for span_u, span_v, integration_points in an.integration_points_with_spans(face, model_tolerance): nonzero_indices = surface_geometry.nonzero_pole_indices_at_span(span_u, span_v) element = ELEMENT(nodes[nonzero_indices]) elements.append(element) for u, v, weight in integration_points: location = surface_geometry.point_at(u, v) if self.debug: cad_model.add(an.Point3D(location), r'{"layer": "Debug/ApplyMeshDisplacement/IntegrationPoints"}') success, min_location, (min_face, min_parameter), _ = mapper.map(location, max_distance) if not success: cad_model.add(an.Point3D(location), r'{"layer": "Debug/ApplyMeshDisplacement/Failed"}') projection_failed += 1 continue abc = faces[min_face] dabc = displacements[abc] displacement = np.dot(min_parameter, dabc) n, shape_functions = surface_geometry.shape_functions_at(u, v, 0) location_source = min_location location_target = min_location + displacement if self.debug: cad_model.add(an.Point3D(location_source), r'{"layer": "Debug/ApplyMeshDisplacement/Source"}') cad_model.add(an.Point3D(location_target), r'{"layer": "Debug/ApplyMeshDisplacement/Target"}') cad_model.add(an.Line3D(location_source, location_target), r'{"layer": "Debug/ApplyMeshDisplacement/DisplacementField"}') cad_model.add(an.Line3D(location, location_source), r'{"layer": "Debug/ApplyMeshDisplacement/Projection"}') element.add(shape_functions, location_target, weight * self.weight) nb_objectives += 1 data['elements'] = data.get('elements', []) data['elements'].append(('MeshDisplacement', elements, self.weight)) # output if projection_failed > 0: log.warning(f'Projection failed for {projection_failed} points') log.info(f'{len(elements)} elements with {nb_objectives} new objectives')