Hi,
I wrote a python-script, which choose randomly elements of a region and in a second steps their neighbors in this region a determined via a for loop (see python-code below, second for-loop). Unfortunately, for high element-number, this algorithm is extremely slow and inefficient.
Thus my question is:
Is there a way to get the neighbor-elements of an element directly without iterating over the region?
Best regards
Andreas
design_domain_faces = cubit.parse_cubit_list('face', 'in volume 2')
design_domain = [cubit.get_quad_global_element_id(face_id) for face_id in design_domain_faces]
design_ind = [random.choice(design_domain)]
for i in range(random.choice(range(1, len(design_domain)))):
feasible_elements = []
node_ind = self.get_nodes(random.choice(design_ind))
for element in set(design_domain).difference(set(design_ind)):
node_design = self.get_nodes(element)
if len(node_design.intersection(node_ind)) == 2:
feasible_elements.append(element)
if len(feasible_elements) != 0:
design_ind.append(random.choice(feasible_elements))
design_air = list(set(design_domain).difference(set(design_ind)))