Skip to content

Commit d55303a

Browse files
committed
all examples working
1 parent 28667c9 commit d55303a

File tree

5 files changed

+21
-14
lines changed

5 files changed

+21
-14
lines changed

src/compas_fea2/model/elements.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def __init__(self, nodes, section, frame, implementation=None, rigid=False, **kw
210210
self._frame = frame
211211
self._curve = Line(nodes[0].point, nodes[-1].point)
212212
# self._shape = Brep.from_extrusion(curve=self.section._shape, vector=Vector.from_start_end(nodes[0].point, nodes[-1].point))
213-
self._shape = Box(self.length, self.section._w, self.section._h, frame=Frame(self.nodes[0].point, [1,0,0], [0,1,0]))
213+
self._shape = section._shape #Box(self.length, self.section._w, self.section._h, frame=Frame(self.nodes[0].point, [1,0,0], [0,1,0]))
214214

215215
@property
216216
def frame(self):

src/compas_fea2/model/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ def find_nodes_by_name(self, name):
393393

394394
@get_docstring(_Part)
395395
@part_method
396-
def find_nodes_by_location(self, point, distance, plane=None):
396+
def find_nodes_around_point(self, point, distance, plane=None, single=False):
397397
pass
398398

399399
@get_docstring(_Part)

src/compas_fea2/model/parts.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def from_compas_lines(cls, lines, element_model="BeamElement", section=None, nam
266266
# nodes = [Node(n) for n in set([list(p) for l in lines for p in list(l)])]
267267
for line in lines:
268268
#FIXME change tolerance
269-
nodes = [prt.find_nodes_by_location(list(p), 1, single=True) or Node(list(p)) for p in list(line)]
269+
nodes = [prt.find_nodes_around_point(list(p), 1, single=True) or Node(list(p)) for p in list(line)]
270270
prt.add_nodes(nodes)
271271
element = getattr(compas_fea2.model, element_model)(nodes=nodes, section=section)
272272
if not isinstance(element, _Element1D):
@@ -568,7 +568,7 @@ def find_nodes_by_name(self, name):
568568
"""
569569
return [node for node in self.nodes if node.name == name]
570570

571-
def find_nodes_by_location(self, point, distance, plane=None, report=False, single=False, **kwargs):
571+
def find_nodes_around_point(self, point, distance, plane=None, report=False, single=False, **kwargs):
572572
# type: (Point, float, Plane, bool, bool, bool) -> list[Node]
573573
"""Find all nodes within a distance of a given geometrical location.
574574
@@ -623,7 +623,7 @@ def find_closest_nodes_to_point(self, point, distance, number_of_nodes=1, plane=
623623
list[:class:`compas_fea2.model.Node`]
624624
625625
"""
626-
nodes = self.find_nodes_by_location(point, distance, plane, report=True)
626+
nodes = self.find_nodes_around_point(point, distance, plane, report=True)
627627
if number_of_nodes > len(nodes):
628628
number_of_nodes = len(nodes)
629629
return [k for k, v in sorted(nodes.items(), key=lambda item: item[1])][:number_of_nodes]
@@ -647,7 +647,7 @@ def find_nodes_around_node(self, node, distance, plane=None):
647647
The nodes around the given node
648648
649649
"""
650-
nodes = self.find_nodes_by_location(node.xyz, distance, plane, report=True)
650+
nodes = self.find_nodes_around_point(node.xyz, distance, plane, report=True)
651651
if node in nodes:
652652
del nodes[node]
653653
return nodes
@@ -672,7 +672,7 @@ def find_closest_nodes_to_node(self, node, distance, number_of_nodes=1, plane=No
672672
list[:class:`compas_fea2.model.Node`]
673673
674674
"""
675-
nodes = self.find_nodes_by_location(node.xyz, distance, plane, report=True)
675+
nodes = self.find_nodes_around_point(node.xyz, distance, plane, report=True)
676676
if number_of_nodes > len(nodes):
677677
number_of_nodes = len(nodes)
678678
return [k for k, v in sorted(nodes.items(), key=lambda item: item[1])][:number_of_nodes]
@@ -832,7 +832,7 @@ def add_node(self, node):
832832
return
833833

834834
if not compas_fea2.POINT_OVERLAP:
835-
if self.find_nodes_by_location(node.xyz, distance=compas_fea2.GLOBAL_TOLERANCE):
835+
if self.find_nodes_around_point(node.xyz, distance=compas_fea2.GLOBAL_TOLERANCE):
836836
if compas_fea2.VERBOSE:
837837
print("NODE SKIPPED: Part {!r} has already a node at {}.".format(self, node.xyz))
838838
return
@@ -1339,7 +1339,7 @@ def get_average_displacement_at_point(self, problem, point, distance, step=None,
13391339
13401340
"""
13411341
step = step or problem._steps_order[-1]
1342-
nodes = self.find_nodes_by_location(point=point, distance=distance, report=True)
1342+
nodes = self.find_nodes_around_point(point=point, distance=distance, report=True)
13431343
if nodes:
13441344
displacements = [getattr(Vector(*node.results[problem][step].get("U", None)), component) for node in nodes]
13451345
return point, sum(displacements) / len(displacements)

src/compas_fea2/problem/problem.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,10 @@ def show_deformed(self, step=None, scale_factor=1.0, original=0.5, opacity=0.5,
788788

789789
if original:
790790
for part in step.model.parts:
791-
v.draw_mesh(part.discretized_boundary_mesh, opacity=original)
791+
try:
792+
v.draw_mesh(part.discretized_boundary_mesh, opacity=original)
793+
except:
794+
print("No mesh found")
792795
# v.draw_nodes_field_vector(step=step, field_name='U', vector_sf=scale_factor)
793796

794797
v.draw_deformed(step, scale_factor=scale_factor, opacity=opacity)

src/compas_fea2/results/fields.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,17 @@ def get_results_at_point(self, point, distance, plane=None, steps=None):
253253
Returns
254254
-------
255255
dict
256-
Dictionary with {'part':..; 'node':..; 'vector':...}
256+
Dictionary with {step: result}
257257
258258
"""
259259
nodes = self.model.find_nodes_around_point(point, distance, plane)
260-
results = []
261-
for step in steps:
262-
results.append(self.get_results(nodes, steps)[step])
260+
if not nodes:
261+
print(f"WARNING: No nodes found at {point} within {distance}")
262+
else:
263+
results = []
264+
steps = steps or self.problem.steps
265+
results = self.get_results(nodes, steps)
266+
return results
263267

264268

265269
class DisplacementFieldResults(FieldResults):

0 commit comments

Comments
 (0)