Skip to content

Commit

Permalink
Merge pull request #1 from aaronyicongfu/cython
Browse files Browse the repository at this point in the history
Fix python code formatting
  • Loading branch information
gjkennedy authored Mar 7, 2024
2 parents 4e8eb71 + 1c787b7 commit 57482f3
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 18 deletions.
1 change: 1 addition & 0 deletions examples/egads/crm/dcel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Implementation of a DECL data structure
"""

import numpy as np


Expand Down
1 change: 1 addition & 0 deletions examples/poisson/poisson_agg_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Plot the aggregation error as a function of rho for the KS and p-norm
functionals
"""

from __future__ import print_function
import tikzplots as tkz
import numpy as np
Expand Down
1 change: 1 addition & 0 deletions examples/pygeometryloader/plate/plate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
To run the defaults: mpirun -np 2 python plate.py
"""

# imports
import os
from mpi4py import MPI
Expand Down
1 change: 1 addition & 0 deletions examples/pytacsadapt/plate/plate_adapt.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
3. run `mpirun -np 4 python plate_adapt.py --niters 10 --strategy fixed_growth --ref_factor 0.1`
4. compare the results of uniform and adaptive refinement between step 2 and 3
"""

import os
import argparse
from mpi4py import MPI
Expand Down
1 change: 1 addition & 0 deletions examples/smooth/smooth_stl.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Imports a STL file and applies a smoothing to it
"""

from __future__ import print_function

# Import the locate point code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Solve the eigenvalue-constrained optimization problem
"""

from mpi4py import MPI
from tmr import TMR, TopOptUtils
from paropt import ParOpt, ParOptEig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,9 @@ def evalObjConGrad(self, x, g, gcon):
prob.driver.opt_settings["Minor print level"] = 0

if max_iterations > 1 and step == max_iterations - 1:
prob.driver.opt_settings[
"Major iterations limit"
] = args.niter_finest
prob.driver.opt_settings["Major iterations limit"] = (
args.niter_finest
)
else:
prob.driver.opt_settings["Major iterations limit"] = args.max_iter

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
This script performs eigenvalue minimization with mass constraint
"""

import numpy as np
from mpi4py import MPI
import argparse
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Compute the base frequencies for different domains with concentrated mass
"""

from tmr import TMR, TopOptUtils
from tacs import TACS, constitutive

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,9 @@ def evalObjConGrad(self, x, g, gcon):
omprob.driver.opt_settings["Minor print level"] = 0

if args.n_mesh_refine > 1 and step == args.n_mesh_refine - 1:
omprob.driver.opt_settings[
"Major iterations limit"
] = args.niter_finest
omprob.driver.opt_settings["Major iterations limit"] = (
args.niter_finest
)
else:
omprob.driver.opt_settings["Major iterations limit"] = args.max_iter

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,9 @@ def evalObjConGrad(self, x, g, gcon):
omprob.driver.opt_settings["Minor print level"] = 0

if n_refine_steps > 1 and step == n_refine_steps - 1:
omprob.driver.opt_settings[
"Major iterations limit"
] = args.niter_finest
omprob.driver.opt_settings["Major iterations limit"] = (
args.niter_finest
)
else:
omprob.driver.opt_settings["Major iterations limit"] = args.max_iter

Expand Down
18 changes: 9 additions & 9 deletions tmr/pytacsadapt.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,9 @@ def setupModel(self, model_type, **kwargs):

# record the number of degrees of freedom for this model
nnodes = model.assembler.getNumOwnedNodes()
self.mesh_history[
model.prob_name
] = model.assembler.getVarsPerNode() * model.comm.allreduce(nnodes, op=MPI.SUM)
self.mesh_history[model.prob_name] = (
model.assembler.getVarsPerNode() * model.comm.allreduce(nnodes, op=MPI.SUM)
)
return

def solvePrimal(self, model_type, writeSolution=False, **kwargs):
Expand Down Expand Up @@ -662,9 +662,9 @@ def estimateOutputError(self, writeSolution=False):

# update histories
self.error_history[f"adapt_iter_{self.fine.refine_iter}_error"] = error_estimate
self.error_history[
f"adapt_iter_{self.fine.refine_iter}_correction"
] = output_correction
self.error_history[f"adapt_iter_{self.fine.refine_iter}_correction"] = (
output_correction
)

# write out the nodal error field
if writeSolution:
Expand Down Expand Up @@ -942,9 +942,9 @@ def writeModelHistory(self, filename=""):
for key, val in self.adaptation_history["element_errors"].items():
h5[f"adaptation_history/element_errors/{key}"] = val
if self.adapt_strategy:
h5["adaptation_history"].attrs[
"strategy"
] = self.adapt_strategy.replace("_", " ").lower()
h5["adaptation_history"].attrs["strategy"] = (
self.adapt_strategy.replace("_", " ").lower()
)
h5["adaptation_history"].attrs["error_tolerance"] = self.error_tol
h5["adaptation_history"].attrs[
"max_refine_levels"
Expand Down

0 comments on commit 57482f3

Please sign in to comment.