Skip to content

Commit 25cf0aa

Browse files
committed
Clean up some nasty leftovers
1 parent 0197ffc commit 25cf0aa

File tree

6 files changed

+32
-103
lines changed

6 files changed

+32
-103
lines changed

examples/complex/airfoil/airfoil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
FILE_NAME = "naca2414.dat"
3939
ANGLE_OF_ATTACK = 20 # in degrees
4040
CHORD = 0.5 # desired chord (provided the one from points is 1)
41-
OPTIMIZE = False # Set to False to skip optimization
41+
OPTIMIZE = True # Set to False to skip optimization
4242

4343
CELL_SIZE = 0.025
4444
BL_THICKNESS = 0.001 # thickness of boundary layer cells

src/classy_blocks/grading/chop.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ def get_possible_combinations() -> List["ChopRelation"]:
4949
class ChopData:
5050
"""A collection of results from Chop.calculate()"""
5151

52-
# TODO: combine with Chop? (not the same thing, though?)
5352
length_ratio: float
5453
start_size: float
5554
c2c_expansion: float
@@ -122,24 +121,3 @@ def calculate(self, length: float) -> ChopData:
122121
calculated.add(output)
123122

124123
raise ValueError(f"Could not calculate count and grading for given parameters: {data}")
125-
126-
def copy(self, length: float) -> "Chop":
127-
"""Returns a new Chop with same count but different
128-
total_expansion, keeping the 'preserve'd value constant;
129-
'length' argument refers to the original length (not the copied-to)"""
130-
this_def = dataclasses.asdict(self)
131-
this_data = dataclasses.asdict(self.calculate(length))
132-
preserve_value = this_data[self.preserve]
133-
134-
# create a copy of this Chop with equal count but
135-
# set other parameters from current data so that
136-
# the correct start/end size or c2c is maintained"""
137-
new_args = this_data
138-
new_args["count"] = this_data["count"]
139-
140-
for arg in ["total_expansion", "c2c_expansion", "start_size", "end_size"]:
141-
new_args[arg] = None
142-
143-
new_args[this_def["preserve"]] = preserve_value
144-
145-
return Chop(**new_args)

src/classy_blocks/grading/grading.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def get_specification(self, inverted: bool) -> List[GradingSpecType]:
8686
return [data.get_specification(inverted) for data in chops]
8787

8888
@property
89-
def specification(self) -> List[GradingSpecType]: # TODO: type this
89+
def specification(self) -> List[GradingSpecType]:
9090
# a list of [length_ratio, count, total_expansion] for each chop
9191
return self.get_specification(self.inverted)
9292

src/classy_blocks/items/wires/axis.py

Lines changed: 29 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from classy_blocks.items.vertex import Vertex
77
from classy_blocks.items.wires.manager import WireManager
88
from classy_blocks.items.wires.wire import Wire
9-
from classy_blocks.types import AxisType, ChopTakeType
9+
from classy_blocks.types import AxisType
1010

1111

1212
class Axis:
@@ -47,17 +47,6 @@ def is_aligned(self, other: "Axis") -> bool:
4747

4848
raise RuntimeError("Axes are not neighbours")
4949

50-
def get_length(self, take: ChopTakeType) -> float:
51-
lengths = [wire.length for wire in self.wires]
52-
53-
if take == "max":
54-
return max(lengths)
55-
56-
if take == "min":
57-
return min(lengths)
58-
59-
return sum(lengths) / len(lengths)
60-
6150
def grade(self) -> None:
6251
if self.is_defined:
6352
return
@@ -67,37 +56,39 @@ def grade(self) -> None:
6756
self.wires.propagate_gradings()
6857
return
6958

70-
# TODO: improve
71-
if len(self.chops) > 0:
72-
# create Grading from chops, if there are any
73-
wires_by_length = list(sorted(self.wires, key=lambda w: w.length))
74-
grading = Grading(0)
75-
for chop in self.chops:
76-
grading.add_chop(chop)
59+
if len(self.chops) == 0:
60+
# nothing to work with
61+
return
7762

63+
# create Grading from chops, if there are any
64+
grading = Grading(0)
65+
for chop in self.chops:
66+
grading.add_chop(chop)
67+
68+
take = self.chops[0].take
69+
70+
if take == "avg":
71+
# make a fake grading with an average length,
72+
# calculate count from it, then copy it with the same
73+
# count to all wires
74+
avg_length = sum([w.length for w in self.wires]) / 4
75+
grading.length = avg_length
76+
for wire in self.wires:
77+
wire.grading = grading.copy(wire.length, False)
78+
else:
79+
# take a specific wire
80+
wires_by_length = list(sorted(self.wires, key=lambda w: w.length))
7881
if self.chops[0].take == "max":
7982
# chop the longest wire, then propagate
8083
wire = wires_by_length[-1]
81-
wire.grading = grading
82-
wire.update()
83-
# copy grading to all wires in this axis
84-
self.wires.propagate_gradings()
85-
elif self.chops[0].take == "min":
86-
# chop the shortest wire, then propagate
84+
else: # "min"
8785
wire = wires_by_length[0]
88-
wire.grading = grading
89-
wire.update()
90-
# copy grading to all wires in this axis
91-
self.wires.propagate_gradings()
92-
else:
93-
# make a fake grading with an average length,
94-
# calculate count from it, then copy it with the same
95-
# count to all wires
96-
avg_length = sum([w.length for w in self.wires]) / 4
97-
grading.length = avg_length
98-
for wire in self.wires:
99-
wire.grading = grading.copy(wire.length, False)
100-
wire.copy_to_coincidents()
86+
87+
wire.grading = grading
88+
wire.update()
89+
90+
# copy grading to all wires in this axis
91+
self.wires.propagate_gradings()
10192

10293
@property
10394
def is_defined(self) -> bool:

src/classy_blocks/items/wires/manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def propagate_gradings(self) -> None:
6565
if defined is None:
6666
raise UndefinedGradingsError("Can't propagate: no defined wires")
6767

68-
for wire in self.undefined:
68+
for wire in self.wires:
6969
wire.grading = defined.grading.copy(wire.length, False)
7070
wire.copy_to_coincidents()
7171

src/classy_blocks/util/chop_collector.py

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)