Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions engibench/problems/airfoil/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def _identify_segments(connectivities: npt.NDArray[np.int32]) -> tuple[list[int]
prev_id = 0
segment_ids = np.zeros(len(connectivities), dtype=np.float32)
seg_id = 0
j = -1 # Ensure j is always defined

for j in range(len(connectivities)):
if connectivities[j][0] - 1 != prev_id:
Expand Down
11 changes: 6 additions & 5 deletions engibench/problems/airfoil/v0.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,15 +506,16 @@ def optimize(
# post process -- extract the shape and objective values
optisteps_history = []
history = History(self.__local_study_dir + "/output/opt.hst")
iters = list(map(int, history.getCallCounters()[:]))
call_counters = history.getCallCounters()
iters = list(map(int, call_counters)) if call_counters is not None else []

for i in range(len(iters)):
vals = history.read(int(iters[i]))
if vals is not None and "funcs" in vals and "obj" in vals["funcs"] and not vals["fail"]:
objective = history.getValues(names=["obj"], callCounters=[i], allowSens=False, major=False, scale=True)[
"obj"
]
optisteps_history.append(OptiStep(obj_values=np.array(objective), step=vals["iter"]))
values = history.getValues(names=["obj"], callCounters=[i], allowSens=False, major=False, scale=True)
if values is not None and "obj" in values:
objective = values["obj"]
optisteps_history.append(OptiStep(obj_values=np.array(objective), step=vals["iter"]))

history.close()

Expand Down
5 changes: 4 additions & 1 deletion engibench/problems/beams2d/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ def calc_sensitivity(design: npt.NDArray, st: State, cfg: dict[str, Any] | None
"""
cfg = cfg or {}
sK = ((st.KE.flatten()[np.newaxis]).T * (st.Emin + design ** cfg["penal"] * (st.Emax - st.Emin))).flatten(order="F")
K = coo_matrix((sK, (st.iK, st.jK)), shape=(st.ndof, st.ndof)).tocsc()
K: csc_array = coo_matrix((sK, (st.iK, st.jK)), shape=(st.ndof, st.ndof)).tocsc()
assert K.shape is not None
m = K.shape[0]
keep = np.delete(np.arange(0, m), st.fixed)
K = K[keep, :]
Expand Down Expand Up @@ -295,6 +296,8 @@ def inner_opt(
l1, l2, move = (0.0, 1e9, 0.2)
# reshape to perform vector operations
xnew = np.zeros(cfg["nelx"] * cfg["nely"])
xPhys = np.zeros(cfg["nelx"] * cfg["nely"])
xPrint = np.zeros(cfg["nelx"] * cfg["nely"])

while l1 + l2 > 0 and (l2 - l1) / (l1 + l2) > st.min_ratio:
lmid = 0.5 * (l2 + l1)
Expand Down
3 changes: 3 additions & 0 deletions engibench/problems/thermoelastic2d/model/fea_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ def run(self, bcs: dict[str, Any], x_init: np.ndarray | None = None) -> dict[str
change_evol = []
obj = []

f0valm = 0.0
f0valt = 0.0

while change > UPDATE_THRESHOLD or iterr < MIN_ITERATIONS:
iterr += 1
s_time = time.time()
Expand Down
9 changes: 5 additions & 4 deletions engibench/problems/thermoelastic2d/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ def plot_multi_physics( # noqa: PLR0913, PLR0915
y_elements = nely + 1

# Get even and odd Fp elements
if _fp is None:
_fp = np.zeros((x_elements * y_elements * 2,))
fp_x = _fp[::2] # 8450 / 2 = 4225 = 65 * 65
fp_y = _fp[1::2]
_fp_array: npt.NDArray[np.float64] = (
np.zeros((x_elements * y_elements * 2,)) if _fp is None else np.asarray(_fp)
) # makes sure _fp is a numpy array
fp_x = _fp_array[::2] # 8450 / 2 = 4225 = 65 * 65
fp_y = _fp_array[1::2]

if _um is None:
_um = np.zeros((x_elements * y_elements * 2,))
Expand Down
14 changes: 1 addition & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -233,19 +233,7 @@ enableTypeIgnoreComments = true
# This is required as the CI pre-commit does not download the module (i.e. numpy, pygame)
# Therefore, we have to ignore missing imports
reportMissingImports = "none"
# Some modules are missing type stubs, which is an issue when running pyright locally
reportMissingTypeStubs = false
# For warning and error, will raise an error when
reportInvalidTypeVarUse = "none"
reportOptionalSubscript = "none"

reportGeneralTypeIssues = "none" # -> commented out raises 489 errors
# reportUntypedFunctionDecorator = "none" # -> pytest.mark.parameterize issues

# reportOptionalMemberAccess = "none" # -> commented out raises warnings
reportPrivateImportUsage = "warning" # ->

reportPrivateUsage = "warning"
reportGeneralTypeIssues = "none" # -> commented out raises a lot of errors
reportUnboundVariable = "warning"

[tool.mypy]
Expand Down
Loading