Skip to content

Commit

Permalink
Merge pull request #20 from gjkennedy/cython
Browse files Browse the repository at this point in the history
fixed cython interface
  • Loading branch information
gjkennedy authored Mar 7, 2024
2 parents bdfc486 + c818b17 commit ac1b0c8
Show file tree
Hide file tree
Showing 20 changed files with 829 additions and 764 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ default:
echo "making $@ in $$subdir"; \
echo; (cd $$subdir && $(MAKE) TMR_DIR=${TMR_DIR}) || exit 1; \
done
${CXX} ${SO_LINK_FLAGS} ${TMR_OBJS} ${TMR_EXTERN_LIBS} -o ${TMR_DIR}/lib/libtmr.${SO_EXT}
${CXX} ${SO_LINK_FLAGS} ${TMR_OBJS} ${TMR_EXTERN_LIBS} -o ${TMR_DIR}/lib/libtmr.${SO_EXT}

debug:
echo "Building Real TMR"
Expand All @@ -24,7 +24,7 @@ debug:
${CXX} ${SO_LINK_FLAGS} ${TMR_OBJS} ${TMR_EXTERN_LIBS} -o ${TMR_DIR}/lib/libtmr.${SO_EXT}

interface:
${PYTHON} setup.py build_ext --inplace
pip install -e .

clean:
${RM} lib/*.a lib/*.so
Expand Down
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
12 changes: 7 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
from subprocess import check_output
import sys

# Numpy/mpi4py must be installed prior to installing TACS
# Numpy/mpi4py must be installed prior to installing
import numpy
import mpi4py

# Import distutils
from setuptools import setup
from setuptools import setup, find_packages
from distutils.core import Extension as Ext
from Cython.Build import cythonize
from Cython.Compiler import Options

Options.embedsignature = True
Options.docstrings = True


Expand Down Expand Up @@ -77,6 +76,7 @@ def get_mpi_flags():
if "tacs" in sys.modules:
inc_dirs.extend(tacs.get_include())
inc_dirs.extend(tacs.get_cython_include())
inc_dirs.append(os.path.split(tacs.get_cython_include()[0])[0])
tacs_lib_dirs, tacs_libs = tacs.get_libraries()
lib_dirs.extend(tacs_lib_dirs)
libs.extend(tacs_libs)
Expand All @@ -88,6 +88,7 @@ def get_mpi_flags():
if "paropt" in sys.modules:
inc_dirs.extend(paropt.get_include())
inc_dirs.extend(paropt.get_cython_include())
inc_dirs.append(os.path.split(paropt.get_cython_include()[0])[0])
paropt_lib_dirs, paropt_libs = paropt.get_libraries()
lib_dirs.extend(paropt_lib_dirs)
libs.extend(paropt_libs)
Expand All @@ -99,6 +100,7 @@ def get_mpi_flags():
if "egads4py" in sys.modules:
inc_dirs.extend(egads4py.get_include())
inc_dirs.extend(egads4py.get_cython_include())
inc_dirs.append(os.path.split(egads4py.get_cython_include()[0])[0])
egads4py_lib_dirs, egads4py_libs = egads4py.get_libraries()
lib_dirs.extend(egads4py_lib_dirs)
libs.extend(egads4py_libs)
Expand Down Expand Up @@ -127,16 +129,16 @@ def get_mpi_flags():

for e in exts:
e.cython_directives = {
"language_level": "3",
"embedsignature": True,
"binding": True,
}

setup(
name="tmr",
version=0.1,
version=1.0,
description="Parallel mesh generation utilities",
author="Graeme J. Kennedy",
author_email="graeme.kennedy@ae.gatech.edu",
packages=find_packages(include=["tmr*"]),
ext_modules=cythonize(exts, include_path=inc_dirs),
)
Loading

0 comments on commit ac1b0c8

Please sign in to comment.