From 49128573760e3dd2b9485fc8dfb0c0221c395b5a Mon Sep 17 00:00:00 2001 From: Manav Bhatia Date: Wed, 9 Oct 2019 22:19:22 -0500 Subject: [PATCH 001/111] bug-fixes for sensitivity analysis of stress evaluation. (#39) --- ...ermal_stress_jacobian_scaling_function.cpp | 2 +- src/elasticity/structural_element_1d.cpp | 19 +++++--- src/elasticity/structural_element_2d.cpp | 43 ++++++++++++++----- 3 files changed, 46 insertions(+), 18 deletions(-) diff --git a/examples/structural/base/thermal_stress_jacobian_scaling_function.cpp b/examples/structural/base/thermal_stress_jacobian_scaling_function.cpp index fdefb9af..857643bd 100644 --- a/examples/structural/base/thermal_stress_jacobian_scaling_function.cpp +++ b/examples/structural/base/thermal_stress_jacobian_scaling_function.cpp @@ -89,7 +89,7 @@ MAST::Examples::ThermalJacobianScaling::operator() (Real& val) const { if (max_res > 0.) max_log = std::log10(max_res); - val = std::fmax(1.-std::exp(_accel_factor*(log-max_log)), low); + val = std::fmax(std::pow(1-res/max_res, _accel_factor), low); //libMesh::out << log << " " << max_log << " " << val << std::endl; } } diff --git a/src/elasticity/structural_element_1d.cpp b/src/elasticity/structural_element_1d.cpp index 9e647405..a790b537 100644 --- a/src/elasticity/structural_element_1d.cpp +++ b/src/elasticity/structural_element_1d.cpp @@ -247,7 +247,9 @@ MAST::StructuralElement1D::calculate_stress(bool request_derivative, strain_3D = RealVectorX::Zero(6), stress_3D = RealVectorX::Zero(6), dstrain_dp = RealVectorX::Zero(n1), - dstress_dp = RealVectorX::Zero(n1); + dstress_dp = RealVectorX::Zero(n1), + vec1 = RealVectorX::Zero(n2), + vec2 = RealVectorX::Zero(n2); MAST::FEMOperatorMatrix Bmat_mem, @@ -433,8 +435,12 @@ MAST::StructuralElement1D::calculate_stress(bool request_derivative, dstress_dX = material_mat * dstrain_dX; // copy to the 3D structure - dstress_dX_3D.row(0) = dstress_dX.row(0); - dstrain_dX_3D.row(0) = dstrain_dX.row(0); + vec1 = dstress_dX.row(0); + this->transform_vector_to_global_system(vec1, vec2); + dstress_dX_3D.row(0) = vec2; + vec1 = dstrain_dX.row(0); + this->transform_vector_to_global_system(vec1, vec2); + dstrain_dX_3D.row(0) = vec2; if (request_derivative) data->set_derivatives(dstress_dX_3D, dstrain_dX_3D); @@ -461,7 +467,7 @@ MAST::StructuralElement1D::calculate_stress(bool request_derivative, temp_func->derivative(*p, xyz[qp_loc_index], _time, dtemp); ref_temp_func->derivative(*p, xyz[qp_loc_index], _time, dref_t); alpha_func->derivative(*p, xyz[qp_loc_index], _time, dalpha); - dstrain_dp(0) -= alpha*(dtemp-dref_t) - dalpha*(temp-ref_t); + dstrain_dp(0) -= alpha*(dtemp-dref_t) + dalpha*(temp-ref_t); } // include the dependence of strain on the thickness @@ -2098,7 +2104,7 @@ MAST::StructuralElement1D::thermal_residual_sensitivity (const MAST::FunctionBas &temp_func = bc.get >("temperature"), &ref_temp_func = bc.get >("ref_temperature"); - Real t, t0, t_sens; + Real t, t0, t_sens, t0_sens; for (unsigned int qp=0; qptransform_vector_to_global_system(vec1, vec2); + dstress_dX_3D.row(0) = vec2; + // sigma-yy + vec1 = dstress_dX.row(1); + this->transform_vector_to_global_system(vec1, vec2); + dstress_dX_3D.row(1) = vec2; + // tau-xy + vec1 = dstress_dX.row(2); + this->transform_vector_to_global_system(vec1, vec2); + dstress_dX_3D.row(3) = vec2; + // epsilon-xx + vec1 = dstrain_dX.row(0); + this->transform_vector_to_global_system(vec1, vec2); + dstrain_dX_3D.row(0) = vec2; + // epsilon-yy + vec1 = dstrain_dX.row(1); + this->transform_vector_to_global_system(vec1, vec2); + dstrain_dX_3D.row(1) = vec2; + // gamma-xy + vec1 = dstrain_dX.row(2); + this->transform_vector_to_global_system(vec1, vec2); + dstrain_dX_3D.row(3) = vec2; if (request_derivative) data->set_derivatives(dstress_dX_3D, dstrain_dX_3D); @@ -559,8 +579,8 @@ MAST::StructuralElement2D::calculate_stress(bool request_derivative, temp_func->derivative(*p, xyz[qp_loc_index], _time, dtemp); ref_temp_func->derivative(*p, xyz[qp_loc_index], _time, dref_t); alpha_func->derivative(*p, xyz[qp_loc_index], _time, dalpha); - dstrain_dp(0) -= alpha*(dtemp-dref_t) - dalpha*(temp-ref_t); // epsilon-xx - dstrain_dp(1) -= alpha*(dtemp-dref_t) - dalpha*(temp-ref_t); // epsilon-yy + dstrain_dp(0) -= alpha*(dtemp-dref_t) + dalpha*(temp-ref_t); // epsilon-xx + dstrain_dp(1) -= alpha*(dtemp-dref_t) + dalpha*(temp-ref_t); // epsilon-yy } @@ -2715,7 +2735,7 @@ thermal_residual_sensitivity (const MAST::FunctionBase& p, &temp_func = bc.get >("temperature"), &ref_temp_func = bc.get >("ref_temperature"); - Real t, t0, t_sens; + Real t, t0, t_sens, t0_sens; for (unsigned int qp=0; qp Date: Sat, 2 Nov 2019 14:57:28 -0500 Subject: [PATCH 002/111] Bug-fix for restart of continuation solver (#44) The initial data of the continuation solver is stored before competing the initial residual, which may update the search direction. --- src/solver/continuation_solver_base.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/solver/continuation_solver_base.cpp b/src/solver/continuation_solver_base.cpp index ba1f01a8..1001194b 100644 --- a/src/solver/continuation_solver_base.cpp +++ b/src/solver/continuation_solver_base.cpp @@ -103,15 +103,16 @@ MAST::ContinuationSolverBase::solve() { _p0 = (*_p)(); _X0.reset(X.clone().release()); + + // save data for possible reuse if the iterations are restarted. + _save_iteration_data(); + Real norm0 = _res_norm(X, *_p), norm = norm0; bool cont = true; - - // save data for possible reuse if the iterations are restarted. - _save_iteration_data(); while (cont) { From 16ba918a7e63037c242f3474c973c7f10d6bf2bc Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Thu, 7 Nov 2019 14:31:19 -0500 Subject: [PATCH 003/111] Initial multi-libMesh version CI build. --- .travis.yml | 61 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/.travis.yml b/.travis.yml index 39b6d1da..d2faa4b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,27 +1,38 @@ language: cpp -dist: xenial + +matrix: + include: + - os: linux + dist: xenial + env: LIBMESH_VERSION=1.3.1 + - os: linux + dist: xenial + env: LIBMESH_VERSION=1.4.1 + - os: linux + dist: xenial + env: LIBMESH_VERSION=1.5.0 before_install: -- sudo apt-get -qq install -y gfortran wget m4 -- sudo apt-get -qq install -y openmpi-bin libopenmpi-dev -- sudo apt-get -qq install -y libpetsc3.6 libpetsc3.6.2-dev -- sudo apt-get -qq install -y libslepc3.6 libslepc3.6.1-dev libparpack2-dev -- sudo apt-get -qq install -y libboost-all-dev -- sudo apt-get -qq install -y libeigen3-dev -- sudo apt-get -qq install -y doxygen graphviz rsync -- sudo apt-get -qq install -y texlive-latex-base dvi2ps ghostscript + - sudo apt-get -qq install -y gfortran wget m4 + - sudo apt-get -qq install -y openmpi-bin libopenmpi-dev + - sudo apt-get -qq install -y libpetsc3.6 libpetsc3.6.2-dev + - sudo apt-get -qq install -y libslepc3.6 libslepc3.6.1-dev libparpack2-dev + - sudo apt-get -qq install -y libboost-all-dev + - sudo apt-get -qq install -y libeigen3-dev + - sudo apt-get -qq install -y doxygen graphviz rsync + - sudo apt-get -qq install -y texlive-latex-base dvi2ps ghostscript install: -- cd ${HOME} -- wget -nv https://github.com/MASTmultiphysics/mast-ci-packages/releases/download/libmesh-1.3.1-1.deb/libmesh-1.3.1-1.deb -- sudo apt install ./libmesh-1.3.1-1.deb + - cd ${HOME} + - wget -nv https://github.com/MASTmultiphysics/mast-ci-packages/releases/download/libmesh-${LIBMESH_VERSION}-1.deb/libmesh-${LIBMESH_VERSION}-1.deb + - sudo apt install ./libmesh-${LIBMESH_VERSION}-1.deb before_script: -- export MAST_INSTALL_DIR=${HOME}/mast -- cd ${TRAVIS_BUILD_DIR} -- mkdir build -- cd build -- cmake .. + - export MAST_INSTALL_DIR=${HOME}/mast + - cd ${TRAVIS_BUILD_DIR} + - mkdir build + - cd build + - cmake .. -DCMAKE_INSTALL_PREFIX=${MAST_INSTALL_DIR} -DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpic++ @@ -37,13 +48,13 @@ before_script: -DENABLE_SNOPT=OFF script: -- make -j 2 -- make -j 2 doc_doxygen -- cd ${TRAVIS_BUILD_DIR} + - make -j 2 + - make -j 2 doc_doxygen + - cd ${TRAVIS_BUILD_DIR} deploy: - provider: script - script: bash doc/deploy_docs.sh - skip_cleanup: true - on: - branch: master + provider: script + script: bash doc/deploy_docs.sh + skip_cleanup: true + on: + branch: master From 5d532760a99ddcbaf008e636d50bb3cf453ad2f3 Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Tue, 12 Nov 2019 13:19:04 -0500 Subject: [PATCH 004/111] Migrate before_install and install stages to scripts from .travis.yml. --- .gitignore | 2 +- .travis.yml | 13 ++----------- ci/build_dependencies.sh | 34 ++++++++++++++++++++++++++++++++++ ci/get_libmesh.sh | 29 +++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 12 deletions(-) create mode 100755 ci/build_dependencies.sh create mode 100755 ci/get_libmesh.sh diff --git a/.gitignore b/.gitignore index 6c8b68e0..28a96aa4 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,7 @@ doc/example_3.dox # CLion IDE files. .idea/ -cmake-build-debug/ +cmake-build-debug*/ build2 # Visual Studio Code settings. diff --git a/.travis.yml b/.travis.yml index d2faa4b3..d3a8c167 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,19 +13,10 @@ matrix: env: LIBMESH_VERSION=1.5.0 before_install: - - sudo apt-get -qq install -y gfortran wget m4 - - sudo apt-get -qq install -y openmpi-bin libopenmpi-dev - - sudo apt-get -qq install -y libpetsc3.6 libpetsc3.6.2-dev - - sudo apt-get -qq install -y libslepc3.6 libslepc3.6.1-dev libparpack2-dev - - sudo apt-get -qq install -y libboost-all-dev - - sudo apt-get -qq install -y libeigen3-dev - - sudo apt-get -qq install -y doxygen graphviz rsync - - sudo apt-get -qq install -y texlive-latex-base dvi2ps ghostscript + - ci/build_dependencies.sh install: - - cd ${HOME} - - wget -nv https://github.com/MASTmultiphysics/mast-ci-packages/releases/download/libmesh-${LIBMESH_VERSION}-1.deb/libmesh-${LIBMESH_VERSION}-1.deb - - sudo apt install ./libmesh-${LIBMESH_VERSION}-1.deb + - ci/get_libmesh.sh before_script: - export MAST_INSTALL_DIR=${HOME}/mast diff --git a/ci/build_dependencies.sh b/ci/build_dependencies.sh new file mode 100755 index 00000000..784a5f2d --- /dev/null +++ b/ci/build_dependencies.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux + + if [ "${TRAVIS_DIST}" = xenial ]; then # Ubuntu 16.04 Xenial Xerus + sudo apt-get -qq update + sudo apt-get -qq install -y gfortran wget m4 + sudo apt-get -qq install -y openmpi-bin libopenmpi-dev + sudo apt-get -qq install -y libpetsc3.6 libpetsc3.6.2-dev + sudo apt-get -qq install -y libslepc3.6 libslepc3.6.1-dev libparpack2-dev + sudo apt-get -qq install -y libboost-all-dev + sudo apt-get -qq install -y libeigen3-dev + sudo apt-get -qq install -y doxygen graphviz rsync + sudo apt-get -qq install -y texlive-latex-base dvi2ps ghostscript + + # elif [ "${TRAVIS_DIST}" = bionic ]; then # Ubuntu 18.04 Bionic Beaver + # sudo apt-get -qq update + # sudo apt-get -qq install -y gfortran wget m4 + # which gfortran + # gcc --version + # echo "Hello From BIONIC" + + else + echo "INVALID LINUX DISTRO: ${TRAVIS_DIST}" + exit 1 + fi + +elif [ "${TRAVIS_OS_NAME}" = osx ]; then # macOS 10.14, XCode + echo "Hello From OSX" + +else + echo "INVALID OS: ${TRAVIS_OS_NAME}" + exit 1 +fi \ No newline at end of file diff --git a/ci/get_libmesh.sh b/ci/get_libmesh.sh new file mode 100755 index 00000000..d7d83344 --- /dev/null +++ b/ci/get_libmesh.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +cd ${HOME} + +if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux + + if [ "${TRAVIS_DIST}" = xenial ]; then # Ubuntu 16.04 Xenial Xerus + wget -nv https://github.com/MASTmultiphysics/mast-ci-packages/releases/download/libmesh-${LIBMESH_VERSION}-1.deb/libmesh-${LIBMESH_VERSION}-1.deb + sudo apt install ./libmesh-${LIBMESH_VERSION}-1.deb + + # elif [ "${TRAVIS_DIST}" = bionic ]; then # Ubuntu 18.04 Bionic Beaver + # sudo apt-get -qq update + # sudo apt-get -qq install -y gfortran wget m4 + # which gfortran + # gcc --version + # echo "Hello From BIONIC" + + else + echo "INVALID LINUX DISTRO: ${TRAVIS_DIST}" + exit 1 + fi + +elif [ "${TRAVIS_OS_NAME}" = osx ]; then # macOS 10.14, XCode + echo "Hello From OSX" + +else + echo "INVALID OS: ${TRAVIS_OS_NAME}" + exit 1 +fi \ No newline at end of file From 63dd10846132e312f33d719863289138196fb1ac Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Tue, 12 Nov 2019 13:32:56 -0500 Subject: [PATCH 005/111] Multi-libMesh build on OSX. --- .travis.yml | 48 ++++++++++++------------------- ci/build_mast.sh | 73 +++++++++++++++++++++++++++++++++++++++++++++++ ci/get_libmesh.sh | 24 +++++++++------- 3 files changed, 105 insertions(+), 40 deletions(-) create mode 100755 ci/build_mast.sh diff --git a/.travis.yml b/.travis.yml index d3a8c167..84e4e757 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,15 +2,24 @@ language: cpp matrix: include: - - os: linux - dist: xenial +# - os: linux +# dist: xenial +# env: LIBMESH_VERSION=1.3.1 +# - os: linux +# dist: xenial +# env: LIBMESH_VERSION=1.4.1 +# - os: linux +# dist: xenial +# env: LIBMESH_VERSION=1.5.0 + - os: osx + osx_image: xcode10.2 env: LIBMESH_VERSION=1.3.1 - - os: linux - dist: xenial + - os: osx + osx_image: xcode10.2 env: LIBMESH_VERSION=1.4.1 - - os: linux - dist: xenial - env: LIBMESH_VERSION=1.5.0 + - os: osx + osx_image: xcode10.2 + env: LIBMESH_VERSION=1.5.0 before_install: - ci/build_dependencies.sh @@ -18,30 +27,9 @@ before_install: install: - ci/get_libmesh.sh -before_script: - - export MAST_INSTALL_DIR=${HOME}/mast - - cd ${TRAVIS_BUILD_DIR} - - mkdir build - - cd build - - cmake .. - -DCMAKE_INSTALL_PREFIX=${MAST_INSTALL_DIR} - -DCMAKE_C_COMPILER=mpicc - -DCMAKE_CXX_COMPILER=mpic++ - -DCMAKE_Fortran_COMPILER=mpifort - -DlibMesh_DIR=/usr/local - -DPETSc_DIR=/usr/lib/petscdir/3.6.2/x86_64-linux-gnu-real - -DSLEPc_DIR=/usr/lib/slepcdir/3.6.1/x86_64-linux-gnu-real - -DEIGEN3_ROOT=/usr/include/eigen3 - -DBOOST_ROOT=/usr - -DBUILD_DOC=ON - -DENABLE_DOT=OFF - -DENABLE_GCMMA=OFF - -DENABLE_SNOPT=OFF - script: - - make -j 2 - - make -j 2 doc_doxygen - - cd ${TRAVIS_BUILD_DIR} + - ci/build_mast.sh + - deploy: provider: script diff --git a/ci/build_mast.sh b/ci/build_mast.sh new file mode 100755 index 00000000..10f37362 --- /dev/null +++ b/ci/build_mast.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash + +# Steps common to all OS/toolchains. +export MAST_INSTALL_DIR=${HOME}/mast +cd ${TRAVIS_BUILD_DIR} +mkdir build +cd build + +if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux + + if [ "${TRAVIS_DIST}" = xenial ]; then # Ubuntu 16.04 Xenial Xerus + cmake .. \ + -DCMAKE_INSTALL_PREFIX="${MAST_INSTALL_DIR}" \ + -DCMAKE_C_COMPILER=mpicc \ + -DCMAKE_CXX_COMPILER=mpic++ \ + -DCMAKE_Fortran_COMPILER=mpifort \ + -DlibMesh_DIR=/usr/local \ + -DPETSc_DIR=/usr/lib/petscdir/3.6.2/x86_64-linux-gnu-real \ + -DSLEPc_DIR=/usr/lib/slepcdir/3.6.1/x86_64-linux-gnu-real \ + -DEIGEN3_ROOT=/usr/include/eigen3 \ + -DBOOST_ROOT=/usr \ + -DBUILD_DOC=ON \ + -DENABLE_DOT=OFF \ + -DENABLE_GCMMA=OFF \ + -DENABLE_SNOPT=OFF + make -j 2 + make install + + # elif [ "${TRAVIS_DIST}" = bionic ]; then # Ubuntu 18.04 Bionic Beaver + + else + echo "INVALID LINUX DISTRO: ${TRAVIS_DIST}" + exit 1 + fi + +elif [ "${TRAVIS_OS_NAME}" = osx ]; then # macOS 10.14, XCode 10.2 + + if [ "${LIBMESH_VERSION}" = "1.3.1" ]; then + libMesh_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/libmesh-1.3.1-gsiac4h5rvdoowg2mjfvwrvmwbbnw5yv + elif [ "${LIBMESH_VERSION}" = "1.4.1" ]; then + libMesh_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/libmesh-1.4.1-3zx2df3tra2fd6znisp5cthgawkh4zol + elif [ "${LIBMESH_VERSION}" = "1.5.0" ]; then + echo "NOT YET READY" + fi + + /Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/cmake-3.14.4-vlzpkvowre6hweutogn563ouzkb73jsq/bin/cmake .. \ + -DCMAKE_C_COMPILER=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openmpi-3.1.4-sep4omvhokkexyojwrahdckfugactovb/bin/mpicc \ + -DCMAKE_CXX_COMPILER=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openmpi-3.1.4-sep4omvhokkexyojwrahdckfugactovb/bin/mpic++ \ + -DCMAKE_Fortran_COMPILER=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openmpi-3.1.4-sep4omvhokkexyojwrahdckfugactovb/bin/mpif90 \ + -DlibMesh_DIR="${libMesh_DIR}" \ + -DPETSc_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/petsc-3.11.4-4ode2ljnkurc55362bc6k6wtlgfjpdmf \ + -DSLEPc_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/slepc-3.11.2-nts2wrpmixfsvfev7x5b5e2e4vpct6wy \ + -DBOOST_ROOT=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/boost-1.70.0-3mel532oks2cxz76mqrxvn4xrl3bg5ri \ + -DHDF5_ROOT=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/hdf5-1.10.5-kfyeqhtsenqumr7eut6b47mjev7tstom \ + -DEIGEN3_ROOT=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/eigen-3.3.7-bd2r4aqrkox7dpebj2r3gqvgpqzwuh7x \ + -DLAPACK_LIBRARIES=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openblas-0.3.7-xqeap7iegoomce3es67cd7exlnq3neue/lib/libopenblas.dylib \ + -DBLAS_LIBRARIES=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openblas-0.3.7-xqeap7iegoomce3es67cd7exlnq3neue/lib/libopenblas.dylib \ + -DENABLE_GCMMA=OFF \ + -DENABLE_DOT=OFF \ + -DENABLE_SNOPT=OFF \ + -DENABLE_NLOPT=OFF \ + -DENABLE_CYTHON=OFF \ + -DBUILD_DOC=OFF + make -j 2 + make install + +else + echo "INVALID OS: ${TRAVIS_OS_NAME}" + exit 1 +fi + + +cd ${TRAVIS_BUILD_DIR} || exit \ No newline at end of file diff --git a/ci/get_libmesh.sh b/ci/get_libmesh.sh index d7d83344..c967a6a5 100755 --- a/ci/get_libmesh.sh +++ b/ci/get_libmesh.sh @@ -1,27 +1,31 @@ #!/usr/bin/env bash -cd ${HOME} +cd "${HOME}" || exit if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux if [ "${TRAVIS_DIST}" = xenial ]; then # Ubuntu 16.04 Xenial Xerus - wget -nv https://github.com/MASTmultiphysics/mast-ci-packages/releases/download/libmesh-${LIBMESH_VERSION}-1.deb/libmesh-${LIBMESH_VERSION}-1.deb - sudo apt install ./libmesh-${LIBMESH_VERSION}-1.deb + wget -nv "https://github.com/MASTmultiphysics/mast-ci-packages/releases/download/libmesh-${LIBMESH_VERSION}-1.deb/libmesh-${LIBMESH_VERSION}-1.deb" + sudo apt install "./libmesh-${LIBMESH_VERSION}-1.deb" # elif [ "${TRAVIS_DIST}" = bionic ]; then # Ubuntu 18.04 Bionic Beaver - # sudo apt-get -qq update - # sudo apt-get -qq install -y gfortran wget m4 - # which gfortran - # gcc --version - # echo "Hello From BIONIC" else echo "INVALID LINUX DISTRO: ${TRAVIS_DIST}" exit 1 fi -elif [ "${TRAVIS_OS_NAME}" = osx ]; then # macOS 10.14, XCode - echo "Hello From OSX" +elif [ "${TRAVIS_OS_NAME}" = osx ]; then # macOS 10.14, XCode 10.2 + mkdir "Code" + mkdir "Code/spack-mstc" + mkdir "Code/spack-mstc/spack" + cd "Code/spack-mstc/spack" || exit + wget -nv https://github.com/MASTmultiphysics/mast-ci-packages/releases/download/libmesh_macos_xcode12.2/libmesh_multiple_versions_macos_xcode_10.2.zip + unzip -qq libmesh_macos_xcode10.2.zip + + #command -v opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/gcc-9.1.0-4amtftgtal2cnomzekpogzanzv6weadk/bin/gfortran + #opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/gcc-9.1.0-4amtftgtal2cnomzekpogzanzv6weadk/bin/gfortran --version + #opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/gcc-9.1.0-4amtftgtal2cnomzekpogzanzv6weadk/bin/gfortran else echo "INVALID OS: ${TRAVIS_OS_NAME}" From acd9bf03275d5c80f35053714ea446d1dda06816 Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Fri, 15 Nov 2019 11:13:37 -0500 Subject: [PATCH 006/111] Separate CI docs build from code build for efficiency. --- .travis.yml | 27 +++++++++++++++------------ ci/build_mast.sh | 23 ++++++++++++++++++----- ci/get_libmesh.sh | 2 +- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 84e4e757..8e24d711 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,24 +2,27 @@ language: cpp matrix: include: + - os: osx + osx_image: xcode10.2 + env: LIBMESH_VERSION=1.4.1 + - os: linux + dist: xenial + env: LIBMESH_VERSION=1.4.1 + - os: linux + dist: xenial + env: CI_BUILD_DOCS=true LIBMESH_VERSION=1.4.1 # - os: linux # dist: xenial # env: LIBMESH_VERSION=1.3.1 -# - os: linux -# dist: xenial -# env: LIBMESH_VERSION=1.4.1 +# - os: osx +# osx_image: xcode10.2 +# env: LIBMESH_VERSION=1.3.1 # - os: linux # dist: xenial # env: LIBMESH_VERSION=1.5.0 - - os: osx - osx_image: xcode10.2 - env: LIBMESH_VERSION=1.3.1 - - os: osx - osx_image: xcode10.2 - env: LIBMESH_VERSION=1.4.1 - - os: osx - osx_image: xcode10.2 - env: LIBMESH_VERSION=1.5.0 + - os: osx + osx_image: xcode10.2 + env: LIBMESH_VERSION=1.5.0 before_install: - ci/build_dependencies.sh diff --git a/ci/build_mast.sh b/ci/build_mast.sh index 10f37362..55903889 100755 --- a/ci/build_mast.sh +++ b/ci/build_mast.sh @@ -23,8 +23,14 @@ if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux -DENABLE_DOT=OFF \ -DENABLE_GCMMA=OFF \ -DENABLE_SNOPT=OFF - make -j 2 - make install + + # Build doxygen documentation or build MAST library/examples. + if [ ${CI_BUILD_DOCS} ]; then + make doc_doxygen + else + make -j 2 + make install + fi # elif [ "${TRAVIS_DIST}" = bionic ]; then # Ubuntu 18.04 Bionic Beaver @@ -36,20 +42,27 @@ if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux elif [ "${TRAVIS_OS_NAME}" = osx ]; then # macOS 10.14, XCode 10.2 if [ "${LIBMESH_VERSION}" = "1.3.1" ]; then + PETSc_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/petsc-3.11.4-4ode2ljnkurc55362bc6k6wtlgfjpdmf + SLEPc_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/slepc-3.11.2-nts2wrpmixfsvfev7x5b5e2e4vpct6wy libMesh_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/libmesh-1.3.1-gsiac4h5rvdoowg2mjfvwrvmwbbnw5yv elif [ "${LIBMESH_VERSION}" = "1.4.1" ]; then + PETSc_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/petsc-3.11.4-4ode2ljnkurc55362bc6k6wtlgfjpdmf + SLEPc_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/slepc-3.11.2-nts2wrpmixfsvfev7x5b5e2e4vpct6wy libMesh_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/libmesh-1.4.1-3zx2df3tra2fd6znisp5cthgawkh4zol elif [ "${LIBMESH_VERSION}" = "1.5.0" ]; then - echo "NOT YET READY" + PETSc_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/petsc-3.12.1-edmddchkkhtwckfumww3mtghyadytdxj + SLEPc_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/slepc-3.12.0-dbsf3rtgj4hoih6okdja6godorotij22 + libMesh_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/libmesh-1.5.0-dxjeof7unenkr5ivfpdekiuftgyktkeh fi /Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/cmake-3.14.4-vlzpkvowre6hweutogn563ouzkb73jsq/bin/cmake .. \ + -DCMAKE_INSTALL_PREFIX="${MAST_INSTALL_DIR}" \ -DCMAKE_C_COMPILER=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openmpi-3.1.4-sep4omvhokkexyojwrahdckfugactovb/bin/mpicc \ -DCMAKE_CXX_COMPILER=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openmpi-3.1.4-sep4omvhokkexyojwrahdckfugactovb/bin/mpic++ \ -DCMAKE_Fortran_COMPILER=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openmpi-3.1.4-sep4omvhokkexyojwrahdckfugactovb/bin/mpif90 \ -DlibMesh_DIR="${libMesh_DIR}" \ - -DPETSc_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/petsc-3.11.4-4ode2ljnkurc55362bc6k6wtlgfjpdmf \ - -DSLEPc_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/slepc-3.11.2-nts2wrpmixfsvfev7x5b5e2e4vpct6wy \ + -DPETSc_DIR="${PETSc_DIR}" \ + -DSLEPc_DIR="${SLEPc_DIR}" \ -DBOOST_ROOT=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/boost-1.70.0-3mel532oks2cxz76mqrxvn4xrl3bg5ri \ -DHDF5_ROOT=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/hdf5-1.10.5-kfyeqhtsenqumr7eut6b47mjev7tstom \ -DEIGEN3_ROOT=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/eigen-3.3.7-bd2r4aqrkox7dpebj2r3gqvgpqzwuh7x \ diff --git a/ci/get_libmesh.sh b/ci/get_libmesh.sh index c967a6a5..e5eca2e2 100755 --- a/ci/get_libmesh.sh +++ b/ci/get_libmesh.sh @@ -21,7 +21,7 @@ elif [ "${TRAVIS_OS_NAME}" = osx ]; then # macOS 10.14, XCode 10.2 mkdir "Code/spack-mstc/spack" cd "Code/spack-mstc/spack" || exit wget -nv https://github.com/MASTmultiphysics/mast-ci-packages/releases/download/libmesh_macos_xcode12.2/libmesh_multiple_versions_macos_xcode_10.2.zip - unzip -qq libmesh_macos_xcode10.2.zip + unzip -qq libmesh_multiple_versions_macos_xcode_10.2.zip #command -v opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/gcc-9.1.0-4amtftgtal2cnomzekpogzanzv6weadk/bin/gfortran #opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/gcc-9.1.0-4amtftgtal2cnomzekpogzanzv6weadk/bin/gfortran --version From c65b4b2d46c976d202ee9f66ef40665988e3c272 Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Fri, 15 Nov 2019 12:24:02 -0500 Subject: [PATCH 007/111] Added exit status to CI scripts, organized CI, added all cases. - Also updated documentation deployment conditions. --- .travis.yml | 35 ++++++++++++++++++++++------------- ci/build_dependencies.sh | 4 +++- ci/build_mast.sh | 23 +++++++++++------------ {doc => ci}/deploy_docs.sh | 0 ci/get_libmesh.sh | 14 +++++++------- 5 files changed, 43 insertions(+), 33 deletions(-) rename {doc => ci}/deploy_docs.sh (100%) diff --git a/.travis.yml b/.travis.yml index 8e24d711..9302a03e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,27 +2,35 @@ language: cpp matrix: include: + # macOS/Linux builds - libMesh version 1.5.0 - os: osx osx_image: xcode10.2 - env: LIBMESH_VERSION=1.4.1 + env: LIBMESH_VERSION=1.5.0 - os: linux dist: xenial + env: LIBMESH_VERSION=1.5.0 + + # Doxygen documentation build + # - this job also progresses to deployment when on master branch + - os: linux + dist: xenial + env: CI_BUILD_DOCS=true CI_DEPLOY_DOCS=true LIBMESH_VERSION=1.4.1 + + # macOS/Linux builds - libMesh version 1.4.1 + - os: osx + osx_image: xcode10.2 env: LIBMESH_VERSION=1.4.1 - os: linux dist: xenial - env: CI_BUILD_DOCS=true LIBMESH_VERSION=1.4.1 -# - os: linux -# dist: xenial -# env: LIBMESH_VERSION=1.3.1 -# - os: osx -# osx_image: xcode10.2 -# env: LIBMESH_VERSION=1.3.1 -# - os: linux -# dist: xenial -# env: LIBMESH_VERSION=1.5.0 + env: LIBMESH_VERSION=1.4.1 + + # macOS/Linux builds - libMesh version 1.3.1 - os: osx osx_image: xcode10.2 - env: LIBMESH_VERSION=1.5.0 + env: LIBMESH_VERSION=1.3.1 + - os: linux + dist: xenial + env: LIBMESH_VERSION=1.3.1 before_install: - ci/build_dependencies.sh @@ -36,7 +44,8 @@ script: deploy: provider: script - script: bash doc/deploy_docs.sh + script: bash ci/deploy_docs.sh skip_cleanup: true on: branch: master + condition: ${CI_DEPLOY_DOCS} = true diff --git a/ci/build_dependencies.sh b/ci/build_dependencies.sh index 784a5f2d..3f630aab 100755 --- a/ci/build_dependencies.sh +++ b/ci/build_dependencies.sh @@ -25,7 +25,9 @@ if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux exit 1 fi -elif [ "${TRAVIS_OS_NAME}" = osx ]; then # macOS 10.14, XCode +elif [ "${TRAVIS_OS_NAME}" = osx ]; then # macOS 10.14, XCode 10.2 + # Currently we don't do anything here since we get all dependencies for macOS + # from the binary download with "ci/get_libmesh.sh" in the next stage. echo "Hello From OSX" else diff --git a/ci/build_mast.sh b/ci/build_mast.sh index 55903889..e89e8a81 100755 --- a/ci/build_mast.sh +++ b/ci/build_mast.sh @@ -1,10 +1,10 @@ #!/usr/bin/env bash # Steps common to all OS/toolchains. -export MAST_INSTALL_DIR=${HOME}/mast -cd ${TRAVIS_BUILD_DIR} -mkdir build -cd build +export MAST_INSTALL_DIR=${HOME}/mast || exit +cd ${TRAVIS_BUILD_DIR} || exit +mkdir build || exit +cd build || exit if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux @@ -22,14 +22,14 @@ if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux -DBUILD_DOC=ON \ -DENABLE_DOT=OFF \ -DENABLE_GCMMA=OFF \ - -DENABLE_SNOPT=OFF + -DENABLE_SNOPT=OFF || exit # Build doxygen documentation or build MAST library/examples. if [ ${CI_BUILD_DOCS} ]; then - make doc_doxygen + make doc_doxygen || exit else - make -j 2 - make install + make -j 2 || exit + make install || exit fi # elif [ "${TRAVIS_DIST}" = bionic ]; then # Ubuntu 18.04 Bionic Beaver @@ -73,14 +73,13 @@ elif [ "${TRAVIS_OS_NAME}" = osx ]; then # macOS 10.14, XCode 10.2 -DENABLE_SNOPT=OFF \ -DENABLE_NLOPT=OFF \ -DENABLE_CYTHON=OFF \ - -DBUILD_DOC=OFF - make -j 2 - make install + -DBUILD_DOC=OFF || exit + make -j 2 || exit + make install || exit else echo "INVALID OS: ${TRAVIS_OS_NAME}" exit 1 fi - cd ${TRAVIS_BUILD_DIR} || exit \ No newline at end of file diff --git a/doc/deploy_docs.sh b/ci/deploy_docs.sh similarity index 100% rename from doc/deploy_docs.sh rename to ci/deploy_docs.sh diff --git a/ci/get_libmesh.sh b/ci/get_libmesh.sh index e5eca2e2..4905bb6e 100755 --- a/ci/get_libmesh.sh +++ b/ci/get_libmesh.sh @@ -5,8 +5,8 @@ cd "${HOME}" || exit if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux if [ "${TRAVIS_DIST}" = xenial ]; then # Ubuntu 16.04 Xenial Xerus - wget -nv "https://github.com/MASTmultiphysics/mast-ci-packages/releases/download/libmesh-${LIBMESH_VERSION}-1.deb/libmesh-${LIBMESH_VERSION}-1.deb" - sudo apt install "./libmesh-${LIBMESH_VERSION}-1.deb" + wget -nv "https://github.com/MASTmultiphysics/mast-ci-packages/releases/download/libmesh-${LIBMESH_VERSION}-1.deb/libmesh-${LIBMESH_VERSION}-1.deb" || exit + sudo apt install "./libmesh-${LIBMESH_VERSION}-1.deb" || exit # elif [ "${TRAVIS_DIST}" = bionic ]; then # Ubuntu 18.04 Bionic Beaver @@ -16,12 +16,12 @@ if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux fi elif [ "${TRAVIS_OS_NAME}" = osx ]; then # macOS 10.14, XCode 10.2 - mkdir "Code" - mkdir "Code/spack-mstc" - mkdir "Code/spack-mstc/spack" + mkdir "Code" || exit + mkdir "Code/spack-mstc" || exit + mkdir "Code/spack-mstc/spack" || exit cd "Code/spack-mstc/spack" || exit - wget -nv https://github.com/MASTmultiphysics/mast-ci-packages/releases/download/libmesh_macos_xcode12.2/libmesh_multiple_versions_macos_xcode_10.2.zip - unzip -qq libmesh_multiple_versions_macos_xcode_10.2.zip + wget -nv https://github.com/MASTmultiphysics/mast-ci-packages/releases/download/libmesh_macos_xcode12.2/libmesh_multiple_versions_macos_xcode_10.2.zip || exit + unzip -qq libmesh_multiple_versions_macos_xcode_10.2.zip || exit #command -v opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/gcc-9.1.0-4amtftgtal2cnomzekpogzanzv6weadk/bin/gfortran #opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/gcc-9.1.0-4amtftgtal2cnomzekpogzanzv6weadk/bin/gfortran --version From b47b3660bd00a1ec597a7aa58e316c4fb8fa0cb6 Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Fri, 15 Nov 2019 15:06:27 -0500 Subject: [PATCH 008/111] Added README for the Travis CI build testing updates. --- ci/README.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 ci/README.md diff --git a/ci/README.md b/ci/README.md new file mode 100644 index 00000000..ae03d5da --- /dev/null +++ b/ci/README.md @@ -0,0 +1,48 @@ +# Travis CI Testing/Deployment + +On the GitHub repository of MAST, Travis CI (https://travis-ci.com) is utilized for build testing on multiple OS's and +deployment of updated documentation online. In the future we will integrate the execution of both unit tests as well as +example problems for integration testing. + +This directory contains scripts utilized by the Travis CI process. + +## Travis CI Processes +When a commit is pushed to the MASTmultiphysics/mast-multiphysics GitHub repository, GitHub initiates the continuous +integration processes on Travis CI. What these processes do is controlled by the `.travis.yml` file in the root of the +repository. The different phases of a Travis CI are described at https://docs.travis-ci.com/user/job-lifecycle/. This +repository utilizes a relatively basic subset of the phases and overall capability of Travis CI. + +The files in this directory are utilized in the main phases of the Travis CI lifecycle: + +1. `before_install` - `build_dependencies.sh` - This script ensures that the Travis CI runner executing the current job +has the required dependencies for libMesh and building MAST. +2. `install` - `get_libmesh.sh` - This script fetches pre-built binaries of libMesh on Linux or the entire dependency +package on macOS. Travis CI jobs have a limited time for execution that is not long enough to build libMesh +(which is not available in job runners standard Linux/macOS package managers.) +3. `script` - `build_mast.sh` - Depending on the job, this script either builds the MAST library/examples or builds the +doxygen documentation. +4. `deploy` - `deploy_docs.sh` - For the job satisfying the appropriate conditions, this script pushes the documentation +website produced by doxygen to the hosting location. + +## Multiple OS's/Jobs/Environments +The `matrix` section of the `.travis.yml` file allows for the definition of multiple jobs to be run that can be done +in different environments or on different workers. Each item under `matrix/include` causes the execution of different +Travis CI worker with the specified environment. In the current setup, we utilize both Linux and macOS to test builds +against different compilers as well as different versions of the libMesh dependency, which is periodically updated by +that projects maintainers. In this setup, Travis CI allows for the specification of system environment variables that +are utilized by the scripts in the `ci` folder for distinguishing work that is specific to each environment. + +### Linux +The current Linux build environment utilizes Ubuntu 16.04. Dependencies available in the Ubuntu apt package repositories +are leveraged; however, in the future these may be updated as versions of PETSc/SLEPc are quite old. The current +compiler on Linux is GNU GCC-5.4.0. The libMesh dependencies are provided as external binaries that were built in an +identical environment and archived. + +### macOS +The macOS build on Travis CI current utilizes macOS version 10.14.4 with the default clang C/C++ compiler (Apple LLVM +version 10.0.1). Travis CI suggests utilizing Homebrew to install dependencies, which currently does not contain many of +the packages required for libMesh/MAST. To overcome this, a complete set dependencies (including multiple versions of +libMesh) is built/archived using Spack on the same environment setup (macOS version/compiler) the Travis CI utilizes. +These dependencies are fetched by the Travis CI runner and MAST is built against them. Since macOS does not provide a +Fortran compiler, GCC-9.1.0 is first built via Spack. The compiler toolchain is then macOS-provided C/C++ and +gfortran-9. \ No newline at end of file From c6f6a99330bb60a060a99ab83d2d0d56e9a73834 Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Fri, 15 Nov 2019 16:26:00 -0500 Subject: [PATCH 009/111] Setup both Debug and Release builds on Travis CI jobs. --- ci/build_mast.sh | 69 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 66 insertions(+), 3 deletions(-) diff --git a/ci/build_mast.sh b/ci/build_mast.sh index e89e8a81..6cc48a59 100755 --- a/ci/build_mast.sh +++ b/ci/build_mast.sh @@ -3,13 +3,23 @@ # Steps common to all OS/toolchains. export MAST_INSTALL_DIR=${HOME}/mast || exit cd ${TRAVIS_BUILD_DIR} || exit -mkdir build || exit -cd build || exit +# Create directories to test both Release (optimized) and Debug build. +mkdir build_rel || exit +mkdir build_dbg || exit + +# Outer if chooses Linux/macOS based on Travis CI worker. if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux + # We could test on multiple Ubuntu distributions, which by default supply different versions + # of GCC in their default repos. For now we just use 16.04. if [ "${TRAVIS_DIST}" = xenial ]; then # Ubuntu 16.04 Xenial Xerus + + # First let us build/install a Release (optimized) version of MAST (-DCMAKE_BUILD_TYPE=Release). + echo "TEST RELEASE/OPTIMIZED BUILD..." + cd build_rel || exit cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX="${MAST_INSTALL_DIR}" \ -DCMAKE_C_COMPILER=mpicc \ -DCMAKE_CXX_COMPILER=mpic++ \ @@ -24,7 +34,6 @@ if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux -DENABLE_GCMMA=OFF \ -DENABLE_SNOPT=OFF || exit - # Build doxygen documentation or build MAST library/examples. if [ ${CI_BUILD_DOCS} ]; then make doc_doxygen || exit else @@ -32,6 +41,31 @@ if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux make install || exit fi + # Now do a build/install of a Debug version (-DCMAKE_BUILD_TYPE=Debug). + echo "TEST DEBUG BUILD..." + cd ../build_dbg || exit + cmake .. \ + -DCMAKE_BUILD_TYPE=DEBUG \ + -DCMAKE_INSTALL_PREFIX="${MAST_INSTALL_DIR}" \ + -DCMAKE_C_COMPILER=mpicc \ + -DCMAKE_CXX_COMPILER=mpic++ \ + -DCMAKE_Fortran_COMPILER=mpifort \ + -DlibMesh_DIR=/usr/local \ + -DPETSc_DIR=/usr/lib/petscdir/3.6.2/x86_64-linux-gnu-real \ + -DSLEPc_DIR=/usr/lib/slepcdir/3.6.1/x86_64-linux-gnu-real \ + -DEIGEN3_ROOT=/usr/include/eigen3 \ + -DBOOST_ROOT=/usr \ + -DBUILD_DOC=ON \ + -DENABLE_DOT=OFF \ + -DENABLE_GCMMA=OFF \ + -DENABLE_SNOPT=OFF || exit + + if [ ${CI_BUILD_DOCS} ]; then + echo "No CI documentation for a Debug build." + else + make -j 2 || exit + fi + # elif [ "${TRAVIS_DIST}" = bionic ]; then # Ubuntu 18.04 Bionic Beaver else @@ -55,7 +89,11 @@ elif [ "${TRAVIS_OS_NAME}" = osx ]; then # macOS 10.14, XCode 10.2 libMesh_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/libmesh-1.5.0-dxjeof7unenkr5ivfpdekiuftgyktkeh fi + # First let us build/install a Release (optimized) version of MAST (-DCMAKE_BUILD_TYPE=Release). + echo "TEST RELEASE/OPTIMIZED BUILD..." + cd build_rel || exit /Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/cmake-3.14.4-vlzpkvowre6hweutogn563ouzkb73jsq/bin/cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX="${MAST_INSTALL_DIR}" \ -DCMAKE_C_COMPILER=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openmpi-3.1.4-sep4omvhokkexyojwrahdckfugactovb/bin/mpicc \ -DCMAKE_CXX_COMPILER=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openmpi-3.1.4-sep4omvhokkexyojwrahdckfugactovb/bin/mpic++ \ @@ -77,6 +115,31 @@ elif [ "${TRAVIS_OS_NAME}" = osx ]; then # macOS 10.14, XCode 10.2 make -j 2 || exit make install || exit + # Now do a build/install of a Debug version (-DCMAKE_BUILD_TYPE=Debug). + echo "TEST DEBUG BUILD..." + cd ../build_dbg || exit + /Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/cmake-3.14.4-vlzpkvowre6hweutogn563ouzkb73jsq/bin/cmake .. \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_INSTALL_PREFIX="${MAST_INSTALL_DIR}" \ + -DCMAKE_C_COMPILER=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openmpi-3.1.4-sep4omvhokkexyojwrahdckfugactovb/bin/mpicc \ + -DCMAKE_CXX_COMPILER=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openmpi-3.1.4-sep4omvhokkexyojwrahdckfugactovb/bin/mpic++ \ + -DCMAKE_Fortran_COMPILER=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openmpi-3.1.4-sep4omvhokkexyojwrahdckfugactovb/bin/mpif90 \ + -DlibMesh_DIR="${libMesh_DIR}" \ + -DPETSc_DIR="${PETSc_DIR}" \ + -DSLEPc_DIR="${SLEPc_DIR}" \ + -DBOOST_ROOT=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/boost-1.70.0-3mel532oks2cxz76mqrxvn4xrl3bg5ri \ + -DHDF5_ROOT=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/hdf5-1.10.5-kfyeqhtsenqumr7eut6b47mjev7tstom \ + -DEIGEN3_ROOT=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/eigen-3.3.7-bd2r4aqrkox7dpebj2r3gqvgpqzwuh7x \ + -DLAPACK_LIBRARIES=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openblas-0.3.7-xqeap7iegoomce3es67cd7exlnq3neue/lib/libopenblas.dylib \ + -DBLAS_LIBRARIES=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openblas-0.3.7-xqeap7iegoomce3es67cd7exlnq3neue/lib/libopenblas.dylib \ + -DENABLE_GCMMA=OFF \ + -DENABLE_DOT=OFF \ + -DENABLE_SNOPT=OFF \ + -DENABLE_NLOPT=OFF \ + -DENABLE_CYTHON=OFF \ + -DBUILD_DOC=OFF || exit + make -j 2 || exit + else echo "INVALID OS: ${TRAVIS_OS_NAME}" exit 1 From 82f89e4c592477e3c94d90bbb6d5679f4dd7464b Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Tue, 19 Nov 2019 11:37:08 -0500 Subject: [PATCH 010/111] Remove Debug build from Travis CI for libMesh < v1.5.0 when using GCC. - Reference https://github.com/libMesh/libmesh/issues/2337 for discussion of extra flags necessary for MAST build when using libmesh_dbg <1.5.0 - Recommendation for GCC users is to simply move to libMesh v1.5.0. --- .gitignore | 2 +- ci/build_mast.sh | 49 ++++++++++++++++++++++++++++-------------------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index 28a96aa4..454df28a 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,7 @@ doc/example_3.dox # CLion IDE files. .idea/ -cmake-build-debug*/ +cmake-build*/ build2 # Visual Studio Code settings. diff --git a/ci/build_mast.sh b/ci/build_mast.sh index 6cc48a59..980c2b2f 100755 --- a/ci/build_mast.sh +++ b/ci/build_mast.sh @@ -43,28 +43,37 @@ if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux # Now do a build/install of a Debug version (-DCMAKE_BUILD_TYPE=Debug). echo "TEST DEBUG BUILD..." - cd ../build_dbg || exit - cmake .. \ - -DCMAKE_BUILD_TYPE=DEBUG \ - -DCMAKE_INSTALL_PREFIX="${MAST_INSTALL_DIR}" \ - -DCMAKE_C_COMPILER=mpicc \ - -DCMAKE_CXX_COMPILER=mpic++ \ - -DCMAKE_Fortran_COMPILER=mpifort \ - -DlibMesh_DIR=/usr/local \ - -DPETSc_DIR=/usr/lib/petscdir/3.6.2/x86_64-linux-gnu-real \ - -DSLEPc_DIR=/usr/lib/slepcdir/3.6.1/x86_64-linux-gnu-real \ - -DEIGEN3_ROOT=/usr/include/eigen3 \ - -DBOOST_ROOT=/usr \ - -DBUILD_DOC=ON \ - -DENABLE_DOT=OFF \ - -DENABLE_GCMMA=OFF \ - -DENABLE_SNOPT=OFF || exit - if [ ${CI_BUILD_DOCS} ]; then - echo "No CI documentation for a Debug build." + if [ "${LIBMESH_VERSION}" = "1.3.1" ]; then # No Debug build for libMesh < 1.5.0 + echo "-- NO DEBUG BUILD WITH libMesh < 1.5.0" + elif [ "${LIBMESH_VERSION}" = "1.4.1" ]; then + echo "-- NO DEBUG BUILD WITH libMesh < 1.5.0" else - make -j 2 || exit - fi + + cd ../build_dbg || exit + cmake .. \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_INSTALL_PREFIX="${MAST_INSTALL_DIR}" \ + -DCMAKE_C_COMPILER=mpicc \ + -DCMAKE_CXX_COMPILER=mpic++ \ + -DCMAKE_Fortran_COMPILER=mpifort \ + -DlibMesh_DIR=/usr/local \ + -DPETSc_DIR=/usr/lib/petscdir/3.6.2/x86_64-linux-gnu-real \ + -DSLEPc_DIR=/usr/lib/slepcdir/3.6.1/x86_64-linux-gnu-real \ + -DEIGEN3_ROOT=/usr/include/eigen3 \ + -DBOOST_ROOT=/usr \ + -DBUILD_DOC=ON \ + -DENABLE_DOT=OFF \ + -DENABLE_GCMMA=OFF \ + -DENABLE_SNOPT=OFF || exit + + if [ ${CI_BUILD_DOCS} ]; then + echo "No CI documentation for a Debug build." + else + make -j 2 || exit + fi + + fi # No Debug build for libMesh < 1.5.0 # elif [ "${TRAVIS_DIST}" = bionic ]; then # Ubuntu 18.04 Bionic Beaver From a40f6017b4f58a3be6e94fb5d6e3bb5863b7e990 Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Thu, 7 Nov 2019 14:28:31 -0500 Subject: [PATCH 011/111] Updates for compatibility with libMesh release v1.5.0. - Headers were refactored in libMesh in v1.5.0, which means we needed to include some of the relevant stuff that got dropped out. https://github.com/libMesh/libmesh/pull/2219 --- ...stiffened_plate_thermally_stressed_flutter_optimization.cpp | 1 + ...e_thermally_stressed_piston_theory_flutter_optimization.cpp | 1 + examples/structural/example_1/example_1.cpp | 1 + examples/structural/example_2/example_2.cpp | 1 + examples/structural/example_6/example_6.cpp | 1 + src/base/nonlinear_system.cpp | 1 + src/elasticity/compliance_output.cpp | 2 ++ src/elasticity/ks_stress_output.cpp | 3 ++- src/elasticity/smooth_ramp_stress_output.cpp | 2 ++ src/elasticity/stress_output_base.cpp | 2 ++ src/elasticity/structural_system.cpp | 1 + src/fluid/integrated_force_output.cpp | 1 + src/level_set/level_set_perimeter_output.cpp | 1 + src/level_set/level_set_volume_output.cpp | 1 + src/solver/complex_solver_base.cpp | 1 + src/solver/multiphysics_nonlinear_solver.cpp | 1 + .../stabilized_first_order_transient_sensitivity_solver.cpp | 1 + 17 files changed, 21 insertions(+), 1 deletion(-) diff --git a/examples/old/fsi/stiffened_plate_thermally_stressed_flutter_optimization/stiffened_plate_thermally_stressed_flutter_optimization.cpp b/examples/old/fsi/stiffened_plate_thermally_stressed_flutter_optimization/stiffened_plate_thermally_stressed_flutter_optimization.cpp index 48577092..535dc740 100644 --- a/examples/old/fsi/stiffened_plate_thermally_stressed_flutter_optimization/stiffened_plate_thermally_stressed_flutter_optimization.cpp +++ b/examples/old/fsi/stiffened_plate_thermally_stressed_flutter_optimization/stiffened_plate_thermally_stressed_flutter_optimization.cpp @@ -57,6 +57,7 @@ // libMesh includes +#include "libmesh/parallel.h" #include "libmesh/parallel_mesh.h" #include "libmesh/mesh_generation.h" #include "libmesh/exodusII_io.h" diff --git a/examples/old/structural/stiffened_plate_optimization_thermally_stressed_piston_theory_flutter/stiffened_plate_thermally_stressed_piston_theory_flutter_optimization.cpp b/examples/old/structural/stiffened_plate_optimization_thermally_stressed_piston_theory_flutter/stiffened_plate_thermally_stressed_piston_theory_flutter_optimization.cpp index cff96837..c7c7d9a0 100644 --- a/examples/old/structural/stiffened_plate_optimization_thermally_stressed_piston_theory_flutter/stiffened_plate_thermally_stressed_piston_theory_flutter_optimization.cpp +++ b/examples/old/structural/stiffened_plate_optimization_thermally_stressed_piston_theory_flutter/stiffened_plate_thermally_stressed_piston_theory_flutter_optimization.cpp @@ -40,6 +40,7 @@ #include "examples/base/plot_results.h" // libMesh includes +#include "libmesh/parallel.h" #include "libmesh/parallel_mesh.h" #include "libmesh/exodusII_io.h" #include "libmesh/numeric_vector.h" diff --git a/examples/structural/example_1/example_1.cpp b/examples/structural/example_1/example_1.cpp index c76012c9..3f6bbb52 100644 --- a/examples/structural/example_1/example_1.cpp +++ b/examples/structural/example_1/example_1.cpp @@ -22,6 +22,7 @@ // libMesh includes. #include +#include #include #include #include diff --git a/examples/structural/example_2/example_2.cpp b/examples/structural/example_2/example_2.cpp index f54f03b8..7ad379ae 100644 --- a/examples/structural/example_2/example_2.cpp +++ b/examples/structural/example_2/example_2.cpp @@ -23,6 +23,7 @@ // libMesh includes. #include +#include #include #include #include diff --git a/examples/structural/example_6/example_6.cpp b/examples/structural/example_6/example_6.cpp index 9784d5d3..656f9f38 100644 --- a/examples/structural/example_6/example_6.cpp +++ b/examples/structural/example_6/example_6.cpp @@ -49,6 +49,7 @@ // libMesh includes +#include "libmesh/parallel.h" #include "libmesh/fe_type.h" #include "libmesh/serial_mesh.h" #include "libmesh/equation_systems.h" diff --git a/src/base/nonlinear_system.cpp b/src/base/nonlinear_system.cpp index b4ca1337..0144ab84 100644 --- a/src/base/nonlinear_system.cpp +++ b/src/base/nonlinear_system.cpp @@ -47,6 +47,7 @@ #include "libmesh/generic_projector.h" #include "libmesh/wrapped_functor.h" #include "libmesh/fem_context.h" +#include "libmesh/parallel.h" MAST::NonlinearSystem::NonlinearSystem(libMesh::EquationSystems& es, diff --git a/src/elasticity/compliance_output.cpp b/src/elasticity/compliance_output.cpp index 3ace0601..46b9698a 100644 --- a/src/elasticity/compliance_output.cpp +++ b/src/elasticity/compliance_output.cpp @@ -31,6 +31,8 @@ #include "level_set/level_set_intersected_elem.h" #include "mesh/geom_elem.h" +// libMesh includes +#include "libmesh/parallel.h" MAST::ComplianceOutput::ComplianceOutput(): MAST::OutputAssemblyElemOperations(), diff --git a/src/elasticity/ks_stress_output.cpp b/src/elasticity/ks_stress_output.cpp index 9388e7d9..5fa75b52 100644 --- a/src/elasticity/ks_stress_output.cpp +++ b/src/elasticity/ks_stress_output.cpp @@ -31,7 +31,8 @@ #include "level_set/level_set_intersected_elem.h" #include "mesh/geom_elem.h" - +// libMesh includes. +#include "libmesh/parallel.h" MAST::KSStressStrainOutput::KSStressStrainOutput(): MAST::StressStrainOutputBase() { diff --git a/src/elasticity/smooth_ramp_stress_output.cpp b/src/elasticity/smooth_ramp_stress_output.cpp index 6d8fa8f7..92577f85 100644 --- a/src/elasticity/smooth_ramp_stress_output.cpp +++ b/src/elasticity/smooth_ramp_stress_output.cpp @@ -31,6 +31,8 @@ #include "level_set/level_set_intersected_elem.h" #include "mesh/geom_elem.h" +// libMesh includes +#include "libmesh/parallel.h" MAST::SmoothRampStressStrainOutput::SmoothRampStressStrainOutput(): diff --git a/src/elasticity/stress_output_base.cpp b/src/elasticity/stress_output_base.cpp index 5b29c6c0..16af69ce 100644 --- a/src/elasticity/stress_output_base.cpp +++ b/src/elasticity/stress_output_base.cpp @@ -31,6 +31,8 @@ #include "level_set/level_set_intersected_elem.h" #include "mesh/geom_elem.h" +// libMesh includes +#include "libmesh/parallel.h" MAST::StressStrainOutputBase::Data::Data(const RealVectorX& stress, const RealVectorX& strain, diff --git a/src/elasticity/structural_system.cpp b/src/elasticity/structural_system.cpp index 2c50f4a4..ba06ac54 100644 --- a/src/elasticity/structural_system.cpp +++ b/src/elasticity/structural_system.cpp @@ -25,6 +25,7 @@ #include "base/parameter.h" // libMesh includes +#include "libmesh/libmesh_logging.h" #include "libmesh/numeric_vector.h" #include "libmesh/equation_systems.h" #include "libmesh/sparse_matrix.h" diff --git a/src/fluid/integrated_force_output.cpp b/src/fluid/integrated_force_output.cpp index 84eee999..82f5830d 100644 --- a/src/fluid/integrated_force_output.cpp +++ b/src/fluid/integrated_force_output.cpp @@ -30,6 +30,7 @@ // libMesh includes #include "libmesh/boundary_info.h" +#include "libmesh/parallel.h" MAST::IntegratedForceOutput::IntegratedForceOutput(const RealVectorX& nvec): diff --git a/src/level_set/level_set_perimeter_output.cpp b/src/level_set/level_set_perimeter_output.cpp index 9ae887b1..78aae29a 100644 --- a/src/level_set/level_set_perimeter_output.cpp +++ b/src/level_set/level_set_perimeter_output.cpp @@ -27,6 +27,7 @@ #include "base/assembly_base.h" #include "base/function_base.h" +#include "libmesh/parallel.h" MAST::LevelSetPerimeter::LevelSetPerimeter(MAST::LevelSetIntersection& intersection): MAST::OutputAssemblyElemOperations(), diff --git a/src/level_set/level_set_volume_output.cpp b/src/level_set/level_set_volume_output.cpp index 035c086c..549b0c3a 100644 --- a/src/level_set/level_set_volume_output.cpp +++ b/src/level_set/level_set_volume_output.cpp @@ -27,6 +27,7 @@ #include "base/assembly_base.h" #include "base/function_base.h" +#include "libmesh/parallel.h" MAST::LevelSetVolume::LevelSetVolume(MAST::LevelSetIntersection& intersection): MAST::OutputAssemblyElemOperations(), diff --git a/src/solver/complex_solver_base.cpp b/src/solver/complex_solver_base.cpp index 80984e63..20b236c9 100644 --- a/src/solver/complex_solver_base.cpp +++ b/src/solver/complex_solver_base.cpp @@ -25,6 +25,7 @@ // libMesh includes +#include "libmesh/libmesh_logging.h" #include "libmesh/numeric_vector.h" #include "libmesh/system.h" #include "libmesh/petsc_matrix.h" diff --git a/src/solver/multiphysics_nonlinear_solver.cpp b/src/solver/multiphysics_nonlinear_solver.cpp index aa93fdb3..bf53b86a 100644 --- a/src/solver/multiphysics_nonlinear_solver.cpp +++ b/src/solver/multiphysics_nonlinear_solver.cpp @@ -25,6 +25,7 @@ #include "base/nonlinear_system.h" // libMesh includes +#include "libmesh/libmesh_logging.h" #include "libmesh/dof_map.h" #include "libmesh/petsc_matrix.h" #include "libmesh/petsc_vector.h" diff --git a/src/solver/stabilized_first_order_transient_sensitivity_solver.cpp b/src/solver/stabilized_first_order_transient_sensitivity_solver.cpp index e0ea6823..163ff20a 100644 --- a/src/solver/stabilized_first_order_transient_sensitivity_solver.cpp +++ b/src/solver/stabilized_first_order_transient_sensitivity_solver.cpp @@ -29,6 +29,7 @@ #include "base/output_assembly_elem_operations.h" // libMesh includes +#include "libmesh/libmesh_logging.h" #include "libmesh/sparse_matrix.h" #include "libmesh/numeric_vector.h" #include "libmesh/linear_solver.h" From 3ce18e574a17b9a2dd49333b93309d6eca932606 Mon Sep 17 00:00:00 2001 From: David John Neiferd <13425967+JohnDN90@users.noreply.github.com> Date: Thu, 21 Nov 2019 17:58:09 -0500 Subject: [PATCH 012/111] Added support for reading in mesh from NastranBDF. Uses a cython interface to pyNastran. Modified multiple CMakeLists.txt to compile new source code with MAST. Changed required CMake version from 3.2 to 3.12, for the built-in FindPython3 module support. --- CMakeLists.txt | 3 +- src/CMakeLists.txt | 6 +- src/mesh/CMakeLists.txt | 6 +- src/mesh/NastranIO.cpp | 272 + src/mesh/NastranIO.h | 100 + src/mesh/pynastranIO.cpp | 11724 +++++++++++++++++++++++++++++++++++++ src/mesh/pynastranIO.h | 60 + src/mesh/pynastranIO.pyx | 248 + 8 files changed, 12415 insertions(+), 4 deletions(-) create mode 100644 src/mesh/NastranIO.cpp create mode 100644 src/mesh/NastranIO.h create mode 100644 src/mesh/pynastranIO.cpp create mode 100644 src/mesh/pynastranIO.h create mode 100644 src/mesh/pynastranIO.pyx diff --git a/CMakeLists.txt b/CMakeLists.txt index d21b5eeb..e8950065 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # PREAMBLE -cmake_minimum_required(VERSION 3.2) +cmake_minimum_required(VERSION 3.12) project(MAST VERSION 0.3 LANGUAGES C CXX) @@ -54,6 +54,7 @@ set(Boost_NO_BOOST_CMAKE ON) find_package(Boost COMPONENTS iostreams system filesystem unit_test_framework REQUIRED) message("-- Found Boost include: ${Boost_INCLUDE_DIRS}") # To ensure the found Boost is what user expected message("-- Found Boost libs: ${Boost_LIBRARY_DIRS}") # To ensure the found Boost is what user expected +find_package(Python3 REQUIRED COMPONENTS Development) # Find optional packages. if (ENABLE_GCMMA) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index de73d122..8ef735d5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,7 +18,8 @@ target_include_directories(mast ${libMesh_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR} ${NLOPT_INCLUDE_DIR} - ${Boost_INCLUDE_DIRS}) # Could possibly move this into src/optimization since it is closer to where Boost is actually used. + ${Boost_INCLUDE_DIRS} + ${Python3_INCLUDE_DIRS}) # Could possibly move this into src/optimization since it is closer to where Boost is actually used. # Add libraries. target_link_libraries(mast @@ -37,7 +38,8 @@ target_link_libraries(mast ${Boost_SYSTEM_LIBRARY} debug ${libMesh_dbg_LIBRARIES} optimized ${libMesh_opt_LIBRARIES} - ${LIBGFORTRAN_LIBRARIES}) + ${LIBGFORTRAN_LIBRARIES} + ${Python3_LIBRARIES}) # NOTE: Use of PUBLIC keyword above means other CMake target (like an example) # that target_link_library(XXXX mast) will inheret these properties. diff --git a/src/mesh/CMakeLists.txt b/src/mesh/CMakeLists.txt index e1ab4e60..bdd547b4 100644 --- a/src/mesh/CMakeLists.txt +++ b/src/mesh/CMakeLists.txt @@ -5,7 +5,11 @@ target_sources(mast ${CMAKE_CURRENT_LIST_DIR}/geom_elem.cpp ${CMAKE_CURRENT_LIST_DIR}/geom_elem.h ${CMAKE_CURRENT_LIST_DIR}/mesh_coupling_base.cpp - ${CMAKE_CURRENT_LIST_DIR}/mesh_coupling_base.h) + ${CMAKE_CURRENT_LIST_DIR}/mesh_coupling_base.h + ${CMAKE_CURRENT_LIST_DIR}/pynastranIO.h + ${CMAKE_CURRENT_LIST_DIR}/pynastranIO.cpp + ${CMAKE_CURRENT_LIST_DIR}/NastranIO.cpp + ${CMAKE_CURRENT_LIST_DIR}/NastranIO.h) # Install MAST headers for this directory. install(DIRECTORY ./ DESTINATION include/mesh diff --git a/src/mesh/NastranIO.cpp b/src/mesh/NastranIO.cpp new file mode 100644 index 00000000..e88b368b --- /dev/null +++ b/src/mesh/NastranIO.cpp @@ -0,0 +1,272 @@ +// C++ includes +#include +#include + +//libMesh includes +#include "libmesh/point.h" +#include "libmesh/elem.h" +#include "libmesh/string_to_enum.h" +#include "libmesh/boundary_info.h" +#include "libmesh/utility.h" +#include "libmesh/libmesh_common.h" +#include "libmesh/mesh_input.h" +#include "libmesh/elem.h" + +// Local includes +#include "mesh/NastranIO.h" +#include "Python.h" + + +void printElementMap(std::map>> elementMap) +{ + // Iterate through element types + for (const auto& item : elementMap) + { + libMesh::out << "Element Type: " << item.first << std::endl; + + // Iterate through elements + for (const auto& elem : item.second) + { + libMesh::out << "Element ID: " << elem[0] << "\tPID: " << elem[1] << "\tNodes: "; + // Iterate through nodes + for (uint j=2; j> nodes) +{ + // Iterate through nodes + for (const auto& node : nodes) + { + libMesh::out << "Node # " << node[0] << ":\t" << node[1] << "\t" << node[2] << "\t" << node[3] << "\t" << std::endl; + } +} + + +NastranIO::NastranIO (libMesh::MeshBase& mesh, const bool pythonPreinitialized): +libMesh::MeshInput (mesh), +_pythonPreinitialized(pythonPreinitialized) +{ + // Initialize Python if it hasn't already been initialized + if ((not pythonInitialized) and (not _pythonPreinitialized)) + { + initializePython(); + } +} + + +NastranIO::~NastranIO () +{ + if((pythonInitialized) and (not _pythonPreinitialized)) + { + finalizePython(); + } +} + + +std::map NastranIO::getNastran2libMeshNodeMap() +{ + return nastran2libMeshNodeMap; +} + + +std::map NastranIO::getlibMesh2NastranNodeMap() +{ + return libMesh2NastranNodeMap; +} + +std::map NastranIO::getNastran2libMeshElemMap() +{ + return nastran2libMeshElemMap; +} + + +std::map NastranIO::getlibMesh2NastranElemMap() +{ + return libMesh2NastranElemMap; +} + + +std::map> NastranIO::getPID2subdomainIDsMap() +{ + std::map> pid2SubdomainIDsMap; + for (const auto& item : pid_elemType2subdomainMap) + { + int pid = item.first.first; + int sid = item.second; + pid2SubdomainIDsMap[pid].insert(sid); + } + + return pid2SubdomainIDsMap; +} + + +std::map, int> NastranIO::getPIDElemtype2SubdomainIDMap() +{ + return pid_elemType2subdomainMap; +} + +void NastranIO::read_nodes(BDFModel* model, libMesh::MeshBase& the_mesh) +{ + // Get the nodes from the bulk data file + std::vector> nodes = getNodes(model); + + // Reserve space in the mesh for the nodes and elements + the_mesh.reserve_nodes(model->nNodes); + + // Add the nodes to the mesh + uint64_t i = 0; + for (const auto& node : nodes) + { + double x=node[1], y=node[2], z=node[3]; + uint64_t nid=node[0]; + the_mesh.add_point(libMesh::Point(x, y, z), nid); + nastran2libMeshNodeMap[nid] = the_mesh.node_ptr(nid); + libMesh2NastranNodeMap[the_mesh.node_ptr(nid)] = nid; + i++; + } + +} + + +void NastranIO::read_elements(BDFModel* model, libMesh::MeshBase& the_mesh) +{ + // Reserve space in the mesh for the nodes and elements + the_mesh.reserve_elem(model->nElems); + + // Get the elements from the bulk data file + // Map of >>, first is name of element type and + // second is vector of EID, PID, and Node_Numbers in that order. + std::map>> elements = getElements(model); + + // Loop through all the elements and add them to the mesh + uint64_t k = 0; + uint64_t z = 1; + for (const auto& item : elements) // Loop through element types on outer loop + { + // Determine the appropriate libMesh element type + libMesh::ElemType elem_type; + if (nastranToLibMeshElem.find(item.first) == nastranToLibMeshElem.end()) + { + libmesh_error_msg("ERROR: " << item.first << " not found in nastranToLibMeshElem map in NastranIO.h"); + } + else + { + elem_type = nastranToLibMeshElem[item.first]; + } + + // Loop through all elements that belong to this element type on inner loop + for (uint i=0; iset_id(k); + nastran2libMeshElemMap[eid] = the_mesh.elem_ptr(k); + libMesh2NastranElemMap[the_mesh.elem_ptr(k)] = eid; + elem->set_id(eid); + + // Determine element type and property ID + // This is used to determine the subdomain id and separates elements + // into subdomains based on property id and element type. This is + // needed because some output formats (i.e. exodus) do not support + // multiple element types in one subdomain. + const libMesh::subdomain_id_type pid = item.second[i][1]; + const int elemtype = int(elem->type()); + if (pid_elemType2subdomainMap.find({pid, elemtype}) == pid_elemType2subdomainMap.end()) + { // If the {pid, elemtype} pair is not yet defined in the map, define it. + pid_elemType2subdomainMap[{pid, elemtype}] = z; + z++; + } + + // Set the element subdomain + const libMesh::subdomain_id_type sid = pid_elemType2subdomainMap[{pid, elemtype}]; + elem->subdomain_id() = sid; + + // Set the nodes which belong to this element + for (uint j=2; j<(item.second[i].size()); j++) + { + uint node_num = item.second[i][j]; + libMesh::dof_id_type nid = nastran2libMeshNodeMap[node_num]->id(); + elem->set_node(j-2) = the_mesh.node_ptr(nid); + } + + k++; // Increment element counter + } // End for loop over elements of same type + } // End for loop over element types +} + + +void NastranIO::read (const std::string & fname) +{ + // Get a reference to the mesh we are reading + libMesh::MeshBase& the_mesh = MeshInput::mesh(); + + // Clear any existing mesh data + the_mesh.clear(); + + // Read the Nastran BDF using pyNastran + BDFModel* model = buildBDFModel(fname); + + // Set the dimensions of the mesh + the_mesh.set_mesh_dimension(model->nDims); + + // Add nodes from the model to the mesh + read_nodes(model, the_mesh); + + // Add elements from the model to the mesh + read_elements(model, the_mesh); +} + +void NastranIO::read(BDFModel* model) +{ + // Get a reference to the mesh we are reading + libMesh::MeshBase& the_mesh = MeshInput::mesh(); + + // Clear any existing mesh data + the_mesh.clear(); + + // Set the dimensions of the mesh + the_mesh.set_mesh_dimension(model->nDims); + + // Add nodes from the model to the mesh + read_nodes(model, the_mesh); + + // Add elements from the model to the mesh + read_elements(model, the_mesh); +} + + + +void NastranIO::initializePython() +{ + // StackOverFlow, "Use generated header file from Cython" + int status = PyImport_AppendInittab("pynastranIO", PyInit_pynastranIO); + if(status==1){ + libmesh_error_msg("ERROR: During Python import for pynastranIO."); + } + Py_Initialize(); + PyObject* pynastran_module = PyImport_ImportModule("pynastranIO"); + if(pynastran_module==NULL){ + Py_Finalize(); + libmesh_error_msg("ERROR: During Python initialization for pynastranIO."); + } + pythonInitialized = true; +} + + +void NastranIO::finalizePython() +{ + Py_Finalize(); + pythonInitialized = false; +} + + + + diff --git a/src/mesh/NastranIO.h b/src/mesh/NastranIO.h new file mode 100644 index 00000000..703d8e33 --- /dev/null +++ b/src/mesh/NastranIO.h @@ -0,0 +1,100 @@ +#ifndef NASTRANIO_H +#define NASTRANIO_H + + +// C++ Includes +#include +#include +#include + +// libMesh Includes +#include "libmesh/libmesh_common.h" +#include "libmesh/mesh_input.h" +#include "libmesh/elem.h" + +#include "Python.h" +#include "mesh/NastranIO.h" +#include "mesh/pynastranIO.h" + +void printElementMap(std::map>> elementMap); + +void printNodeCoords(std::vector> nodes); + + +/** + * The NastranIO class is a preliminary implementation for reading NASTRAN + * mesh files using pyNastran with BDF files as input. + */ +class NastranIO : public libMesh::MeshInput +{ +public: + explicit + NastranIO(libMesh::MeshBase& mesh, const bool pythonPreinitialized=false); + + virtual ~NastranIO (); + + virtual void read (const std::string & name) override; + virtual void read (BDFModel* model); + + std::map getNastran2libMeshNodeMap(); + std::map getlibMesh2NastranNodeMap(); + + std::map getNastran2libMeshElemMap(); + std::map getlibMesh2NastranElemMap(); + + std::map, int> getPIDElemtype2SubdomainIDMap(); + std::map> getPID2subdomainIDsMap(); + +private: + + const bool _pythonPreinitialized = false; + bool pythonInitialized = false; + + std::map nastran2libMeshNodeMap; + std::map libMesh2NastranNodeMap; + std::map nastran2libMeshElemMap; + std::map libMesh2NastranElemMap; + std::map, int> pid_elemType2subdomainMap = {}; + + void read_nodes(BDFModel* model, libMesh::MeshBase& the_mesh); + void read_elements(BDFModel* model, libMesh::MeshBase& the_mesh); + + // Map from NASTRAN Elements to Equivalent libMesh Elements + // TODO: Not yet complete, need to add all NASTRAN elements which we need support for. + std::map nastranToLibMeshElem = { + + // 0D Elements (i.e. Ground Springs) + {"CELAS1_1", libMesh::NODEELEM}, {"CELAS2_1", libMesh::NODEELEM}, + {"CELAS3_1", libMesh::NODEELEM}, {"CELAS4_1", libMesh::NODEELEM}, + {"CBUSH_1", libMesh::NODEELEM}, {"CBUSH1D_1", libMesh::NODEELEM}, + + // 1D Elements + {"CELAS1_2", libMesh::EDGE2}, {"CELAS2_2", libMesh::EDGE2}, + {"CELAS3_2", libMesh::EDGE2}, {"CELAS4_2", libMesh::EDGE2}, + {"CBUSH_2", libMesh::EDGE2}, {"CBUSH1D_2", libMesh::EDGE2}, + {"CBUSH2D_2",libMesh::EDGE2}, + {"CROD_2", libMesh::EDGE2}, {"CBAR_2", libMesh::EDGE2}, + {"CBEAM_2", libMesh::EDGE2}, {"CBEAM3_3", libMesh::EDGE3}, + + // 2D Elements + {"CTRIA3_3", libMesh::TRI3}, {"CTRIA6_6", libMesh::TRI6}, + {"CTRIAR_3", libMesh::TRI3}, + {"CQUAD4_4", libMesh::QUAD4}, {"CQUAD8_8", libMesh::QUAD8}, + {"CQUADR_4", libMesh::QUADSHELL4}, {"CQUAD_4", libMesh::QUAD4}, + {"CQUAD_8", libMesh::QUAD8}, {"CQUAD_9", libMesh::QUAD9}, + {"CQUADX_4", libMesh::QUAD4}, {"CQUADX_8", libMesh::QUAD8}, + {"CQUADX_9", libMesh::QUAD9}, + + // 3D Elements + {"CTETRA_4", libMesh::TET4}, {"CTETRA_10", libMesh::TET10}, + {"CPENTA_6", libMesh::PRISM6}, {"CPENTA_15", libMesh::PRISM15}, + {"CPYRAM_5", libMesh::PYRAMID5}, {"CPYRAM_13", libMesh::PYRAMID13}, + {"CHEXA_8", libMesh::HEX8}, {"CHEXA_20", libMesh::HEX20} + }; + + void initializePython(); + void finalizePython(); +}; + + +#endif // NASTRANIO_H diff --git a/src/mesh/pynastranIO.cpp b/src/mesh/pynastranIO.cpp new file mode 100644 index 00000000..aad96a3c --- /dev/null +++ b/src/mesh/pynastranIO.cpp @@ -0,0 +1,11724 @@ +/* Generated by Cython 0.29.12 */ + +/* BEGIN: Cython Metadata +{ + "distutils": { + "depends": [], + "language": "c++", + "name": "pynastranIO", + "sources": [ + "pynastranIO.pyx" + ] + }, + "module_name": "pynastranIO" +} +END: Cython Metadata */ + +#define PY_SSIZE_T_CLEAN +#include "Python.h" +#ifndef Py_PYTHON_H + #error Python headers needed to compile C extensions, please install development version of Python. +#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) + #error Cython requires Python 2.6+ or Python 3.3+. +#else +#define CYTHON_ABI "0_29_12" +#define CYTHON_HEX_VERSION 0x001D0CF0 +#define CYTHON_FUTURE_DIVISION 1 +#include +#ifndef offsetof + #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) +#endif +#if !defined(WIN32) && !defined(MS_WINDOWS) + #ifndef __stdcall + #define __stdcall + #endif + #ifndef __cdecl + #define __cdecl + #endif + #ifndef __fastcall + #define __fastcall + #endif +#endif +#ifndef DL_IMPORT + #define DL_IMPORT(t) t +#endif +#ifndef DL_EXPORT + #define DL_EXPORT(t) t +#endif +#define __PYX_COMMA , +#ifndef HAVE_LONG_LONG + #if PY_VERSION_HEX >= 0x02070000 + #define HAVE_LONG_LONG + #endif +#endif +#ifndef PY_LONG_LONG + #define PY_LONG_LONG LONG_LONG +#endif +#ifndef Py_HUGE_VAL + #define Py_HUGE_VAL HUGE_VAL +#endif +#ifdef PYPY_VERSION + #define CYTHON_COMPILING_IN_PYPY 1 + #define CYTHON_COMPILING_IN_PYSTON 0 + #define CYTHON_COMPILING_IN_CPYTHON 0 + #undef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 0 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #if PY_VERSION_HEX < 0x03050000 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif + #undef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 0 + #undef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 0 + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #undef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 1 + #undef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 0 + #undef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 0 + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 + #undef CYTHON_USE_DICT_VERSIONS + #define CYTHON_USE_DICT_VERSIONS 0 + #undef CYTHON_USE_EXC_INFO_STACK + #define CYTHON_USE_EXC_INFO_STACK 0 +#elif defined(PYSTON_VERSION) + #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_PYSTON 1 + #define CYTHON_COMPILING_IN_CPYTHON 0 + #ifndef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 1 + #endif + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 0 + #ifndef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 1 + #endif + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #ifndef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 0 + #endif + #ifndef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 1 + #endif + #ifndef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 1 + #endif + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 + #undef CYTHON_USE_DICT_VERSIONS + #define CYTHON_USE_DICT_VERSIONS 0 + #undef CYTHON_USE_EXC_INFO_STACK + #define CYTHON_USE_EXC_INFO_STACK 0 +#else + #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_PYSTON 0 + #define CYTHON_COMPILING_IN_CPYTHON 1 + #ifndef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 1 + #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) + #define CYTHON_USE_PYTYPE_LOOKUP 1 + #endif + #if PY_MAJOR_VERSION < 3 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #elif !defined(CYTHON_USE_PYLONG_INTERNALS) + #define CYTHON_USE_PYLONG_INTERNALS 1 + #endif + #ifndef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 1 + #endif + #ifndef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 1 + #endif + #if PY_VERSION_HEX < 0x030300F0 + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #elif !defined(CYTHON_USE_UNICODE_WRITER) + #define CYTHON_USE_UNICODE_WRITER 1 + #endif + #ifndef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 0 + #endif + #ifndef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 1 + #endif + #ifndef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 1 + #endif + #ifndef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 1 + #endif + #ifndef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 1 + #endif + #ifndef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000) + #endif + #ifndef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) + #endif + #ifndef CYTHON_USE_DICT_VERSIONS + #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1) + #endif + #ifndef CYTHON_USE_EXC_INFO_STACK + #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3) + #endif +#endif +#if !defined(CYTHON_FAST_PYCCALL) +#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) +#endif +#if CYTHON_USE_PYLONG_INTERNALS + #include "longintrepr.h" + #undef SHIFT + #undef BASE + #undef MASK + #ifdef SIZEOF_VOID_P + enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) }; + #endif +#endif +#ifndef __has_attribute + #define __has_attribute(x) 0 +#endif +#ifndef __has_cpp_attribute + #define __has_cpp_attribute(x) 0 +#endif +#ifndef CYTHON_RESTRICT + #if defined(__GNUC__) + #define CYTHON_RESTRICT __restrict__ + #elif defined(_MSC_VER) && _MSC_VER >= 1400 + #define CYTHON_RESTRICT __restrict + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_RESTRICT restrict + #else + #define CYTHON_RESTRICT + #endif +#endif +#ifndef CYTHON_UNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +#endif +#ifndef CYTHON_MAYBE_UNUSED_VAR +# if defined(__cplusplus) + template void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } +# else +# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) +# endif +#endif +#ifndef CYTHON_NCP_UNUSED +# if CYTHON_COMPILING_IN_CPYTHON +# define CYTHON_NCP_UNUSED +# else +# define CYTHON_NCP_UNUSED CYTHON_UNUSED +# endif +#endif +#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) +#ifdef _MSC_VER + #ifndef _MSC_STDINT_H_ + #if _MSC_VER < 1300 + typedef unsigned char uint8_t; + typedef unsigned int uint32_t; + #else + typedef unsigned __int8 uint8_t; + typedef unsigned __int32 uint32_t; + #endif + #endif +#else + #include +#endif +#ifndef CYTHON_FALLTHROUGH + #if defined(__cplusplus) && __cplusplus >= 201103L + #if __has_cpp_attribute(fallthrough) + #define CYTHON_FALLTHROUGH [[fallthrough]] + #elif __has_cpp_attribute(clang::fallthrough) + #define CYTHON_FALLTHROUGH [[clang::fallthrough]] + #elif __has_cpp_attribute(gnu::fallthrough) + #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] + #endif + #endif + #ifndef CYTHON_FALLTHROUGH + #if __has_attribute(fallthrough) + #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) + #else + #define CYTHON_FALLTHROUGH + #endif + #endif + #if defined(__clang__ ) && defined(__apple_build_version__) + #if __apple_build_version__ < 7000000 + #undef CYTHON_FALLTHROUGH + #define CYTHON_FALLTHROUGH + #endif + #endif +#endif + +#ifndef __cplusplus + #error "Cython files generated with the C++ option must be compiled with a C++ compiler." +#endif +#ifndef CYTHON_INLINE + #if defined(__clang__) + #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) + #else + #define CYTHON_INLINE inline + #endif +#endif +template +void __Pyx_call_destructor(T& x) { + x.~T(); +} +template +class __Pyx_FakeReference { + public: + __Pyx_FakeReference() : ptr(NULL) { } + __Pyx_FakeReference(const T& ref) : ptr(const_cast(&ref)) { } + T *operator->() { return ptr; } + T *operator&() { return ptr; } + operator T&() { return *ptr; } + template bool operator ==(U other) { return *ptr == other; } + template bool operator !=(U other) { return *ptr != other; } + private: + T *ptr; +}; + +#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) + #define Py_OptimizeFlag 0 +#endif +#define __PYX_BUILD_PY_SSIZE_T "n" +#define CYTHON_FORMAT_SSIZE_T "z" +#if PY_MAJOR_VERSION < 3 + #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ + PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) + #define __Pyx_DefaultClassType PyClass_Type +#else + #define __Pyx_BUILTIN_MODULE_NAME "builtins" +#if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2 + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ + PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) +#else + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ + PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) +#endif + #define __Pyx_DefaultClassType PyType_Type +#endif +#ifndef Py_TPFLAGS_CHECKTYPES + #define Py_TPFLAGS_CHECKTYPES 0 +#endif +#ifndef Py_TPFLAGS_HAVE_INDEX + #define Py_TPFLAGS_HAVE_INDEX 0 +#endif +#ifndef Py_TPFLAGS_HAVE_NEWBUFFER + #define Py_TPFLAGS_HAVE_NEWBUFFER 0 +#endif +#ifndef Py_TPFLAGS_HAVE_FINALIZE + #define Py_TPFLAGS_HAVE_FINALIZE 0 +#endif +#ifndef METH_STACKLESS + #define METH_STACKLESS 0 +#endif +#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL) + #ifndef METH_FASTCALL + #define METH_FASTCALL 0x80 + #endif + typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs); + typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, + Py_ssize_t nargs, PyObject *kwnames); +#else + #define __Pyx_PyCFunctionFast _PyCFunctionFast + #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords +#endif +#if CYTHON_FAST_PYCCALL +#define __Pyx_PyFastCFunction_Check(func)\ + ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))))) +#else +#define __Pyx_PyFastCFunction_Check(func) 0 +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) + #define PyObject_Malloc(s) PyMem_Malloc(s) + #define PyObject_Free(p) PyMem_Free(p) + #define PyObject_Realloc(p) PyMem_Realloc(p) +#endif +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1 + #define PyMem_RawMalloc(n) PyMem_Malloc(n) + #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n) + #define PyMem_RawFree(p) PyMem_Free(p) +#endif +#if CYTHON_COMPILING_IN_PYSTON + #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno) +#else + #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) +#endif +#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#elif PY_VERSION_HEX >= 0x03060000 + #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() +#elif PY_VERSION_HEX >= 0x03000000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#else + #define __Pyx_PyThreadState_Current _PyThreadState_Current +#endif +#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT) +#include "pythread.h" +#define Py_tss_NEEDS_INIT 0 +typedef int Py_tss_t; +static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) { + *key = PyThread_create_key(); + return 0; +} +static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) { + Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t)); + *key = Py_tss_NEEDS_INIT; + return key; +} +static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) { + PyObject_Free(key); +} +static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) { + return *key != Py_tss_NEEDS_INIT; +} +static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) { + PyThread_delete_key(*key); + *key = Py_tss_NEEDS_INIT; +} +static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) { + return PyThread_set_key_value(*key, value); +} +static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { + return PyThread_get_key_value(*key); +} +#endif +#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) +#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) +#else +#define __Pyx_PyDict_NewPresized(n) PyDict_New() +#endif +#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS +#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash) +#else +#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name) +#endif +#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) + #define CYTHON_PEP393_ENABLED 1 + #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ + 0 : _PyUnicode_Ready((PyObject *)(op))) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) + #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) + #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) + #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) + #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) + #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch) + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) +#else + #define CYTHON_PEP393_ENABLED 0 + #define PyUnicode_1BYTE_KIND 1 + #define PyUnicode_2BYTE_KIND 2 + #define PyUnicode_4BYTE_KIND 4 + #define __Pyx_PyUnicode_READY(op) (0) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) + #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111) + #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) + #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) + #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) + #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch) + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) +#endif +#if CYTHON_COMPILING_IN_PYPY + #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) +#else + #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ + PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) + #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check) + #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) + #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) +#endif +#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) +#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) +#else + #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) +#endif +#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) + #define PyObject_ASCII(o) PyObject_Repr(o) +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBaseString_Type PyUnicode_Type + #define PyStringObject PyUnicodeObject + #define PyString_Type PyUnicode_Type + #define PyString_Check PyUnicode_Check + #define PyString_CheckExact PyUnicode_CheckExact + #define PyObject_Unicode PyObject_Str +#endif +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) + #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) +#else + #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) + #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) +#endif +#ifndef PySet_CheckExact + #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) +#endif +#if CYTHON_ASSUME_SAFE_MACROS + #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq) +#else + #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq) +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyIntObject PyLongObject + #define PyInt_Type PyLong_Type + #define PyInt_Check(op) PyLong_Check(op) + #define PyInt_CheckExact(op) PyLong_CheckExact(op) + #define PyInt_FromString PyLong_FromString + #define PyInt_FromUnicode PyLong_FromUnicode + #define PyInt_FromLong PyLong_FromLong + #define PyInt_FromSize_t PyLong_FromSize_t + #define PyInt_FromSsize_t PyLong_FromSsize_t + #define PyInt_AsLong PyLong_AsLong + #define PyInt_AS_LONG PyLong_AS_LONG + #define PyInt_AsSsize_t PyLong_AsSsize_t + #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask + #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask + #define PyNumber_Int PyNumber_Long +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBoolObject PyLongObject +#endif +#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY + #ifndef PyUnicode_InternFromString + #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) + #endif +#endif +#if PY_VERSION_HEX < 0x030200A4 + typedef long Py_hash_t; + #define __Pyx_PyInt_FromHash_t PyInt_FromLong + #define __Pyx_PyInt_AsHash_t PyInt_AsLong +#else + #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t + #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t +#endif +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func)) +#else + #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) +#endif +#if CYTHON_USE_ASYNC_SLOTS + #if PY_VERSION_HEX >= 0x030500B1 + #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods + #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) + #else + #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) + #endif +#else + #define __Pyx_PyType_AsAsync(obj) NULL +#endif +#ifndef __Pyx_PyAsyncMethodsStruct + typedef struct { + unaryfunc am_await; + unaryfunc am_aiter; + unaryfunc am_anext; + } __Pyx_PyAsyncMethodsStruct; +#endif + +#if defined(WIN32) || defined(MS_WINDOWS) + #define _USE_MATH_DEFINES +#endif +#include +#ifdef NAN +#define __PYX_NAN() ((float) NAN) +#else +static CYTHON_INLINE float __PYX_NAN() { + float value; + memset(&value, 0xFF, sizeof(value)); + return value; +} +#endif +#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) +#define __Pyx_truncl trunc +#else +#define __Pyx_truncl truncl +#endif + + +#define __PYX_ERR(f_index, lineno, Ln_error) \ +{ \ + __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \ +} + +#ifndef __PYX_EXTERN_C + #ifdef __cplusplus + #define __PYX_EXTERN_C extern "C" + #else + #define __PYX_EXTERN_C extern + #endif +#endif + +#define __PYX_HAVE__pynastranIO +#define __PYX_HAVE_API__pynastranIO +/* Early includes */ +#include +#include "ios" +#include "new" +#include "stdexcept" +#include "typeinfo" +#include +#include +#include +#include +#include +#include +#include +#include "numpy/arrayobject.h" +#include "numpy/ufuncobject.h" +#ifdef _OPENMP +#include +#endif /* _OPENMP */ + +#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) +#define CYTHON_WITHOUT_ASSERTIONS +#endif + +typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; + const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; + +#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 +#define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0 +#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8) +#define __PYX_DEFAULT_STRING_ENCODING "" +#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString +#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#define __Pyx_uchar_cast(c) ((unsigned char)c) +#define __Pyx_long_cast(x) ((long)x) +#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ + (sizeof(type) < sizeof(Py_ssize_t)) ||\ + (sizeof(type) > sizeof(Py_ssize_t) &&\ + likely(v < (type)PY_SSIZE_T_MAX ||\ + v == (type)PY_SSIZE_T_MAX) &&\ + (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ + v == (type)PY_SSIZE_T_MIN))) ||\ + (sizeof(type) == sizeof(Py_ssize_t) &&\ + (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ + v == (type)PY_SSIZE_T_MAX))) ) +static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) { + return (size_t) i < (size_t) limit; +} +#if defined (__cplusplus) && __cplusplus >= 201103L + #include + #define __Pyx_sst_abs(value) std::abs(value) +#elif SIZEOF_INT >= SIZEOF_SIZE_T + #define __Pyx_sst_abs(value) abs(value) +#elif SIZEOF_LONG >= SIZEOF_SIZE_T + #define __Pyx_sst_abs(value) labs(value) +#elif defined (_MSC_VER) + #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) +#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define __Pyx_sst_abs(value) llabs(value) +#elif defined (__GNUC__) + #define __Pyx_sst_abs(value) __builtin_llabs(value) +#else + #define __Pyx_sst_abs(value) ((value<0) ? -value : value) +#endif +static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); +#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) +#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) +#define __Pyx_PyBytes_FromString PyBytes_FromString +#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); +#if PY_MAJOR_VERSION < 3 + #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#else + #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize +#endif +#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) +#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) +#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) +#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) +#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { + const Py_UNICODE *u_end = u; + while (*u_end++) ; + return (size_t)(u_end - u - 1); +} +#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) +#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode +#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode +#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) +#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) +static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); +static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*); +static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); +#define __Pyx_PySequence_Tuple(obj)\ + (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); +#if CYTHON_ASSUME_SAFE_MACROS +#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) +#else +#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) +#endif +#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) +#if PY_MAJOR_VERSION >= 3 +#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) +#else +#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) +#endif +#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x)) +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII +static int __Pyx_sys_getdefaultencoding_not_ascii; +static int __Pyx_init_sys_getdefaultencoding_params(void) { + PyObject* sys; + PyObject* default_encoding = NULL; + PyObject* ascii_chars_u = NULL; + PyObject* ascii_chars_b = NULL; + const char* default_encoding_c; + sys = PyImport_ImportModule("sys"); + if (!sys) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); + Py_DECREF(sys); + if (!default_encoding) goto bad; + default_encoding_c = PyBytes_AsString(default_encoding); + if (!default_encoding_c) goto bad; + if (strcmp(default_encoding_c, "ascii") == 0) { + __Pyx_sys_getdefaultencoding_not_ascii = 0; + } else { + char ascii_chars[128]; + int c; + for (c = 0; c < 128; c++) { + ascii_chars[c] = c; + } + __Pyx_sys_getdefaultencoding_not_ascii = 1; + ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); + if (!ascii_chars_u) goto bad; + ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); + if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { + PyErr_Format( + PyExc_ValueError, + "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", + default_encoding_c); + goto bad; + } + Py_DECREF(ascii_chars_u); + Py_DECREF(ascii_chars_b); + } + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(default_encoding); + Py_XDECREF(ascii_chars_u); + Py_XDECREF(ascii_chars_b); + return -1; +} +#endif +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) +#else +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +static char* __PYX_DEFAULT_STRING_ENCODING; +static int __Pyx_init_sys_getdefaultencoding_params(void) { + PyObject* sys; + PyObject* default_encoding = NULL; + char* default_encoding_c; + sys = PyImport_ImportModule("sys"); + if (!sys) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); + Py_DECREF(sys); + if (!default_encoding) goto bad; + default_encoding_c = PyBytes_AsString(default_encoding); + if (!default_encoding_c) goto bad; + __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1); + if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; + strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(default_encoding); + return -1; +} +#endif +#endif + + +/* Test for GCC > 2.95 */ +#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) +#else /* !__GNUC__ or GCC < 2.95 */ + #define likely(x) (x) + #define unlikely(x) (x) +#endif /* __GNUC__ */ +static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } + +static PyObject *__pyx_m = NULL; +static PyObject *__pyx_d; +static PyObject *__pyx_b; +static PyObject *__pyx_cython_runtime = NULL; +static PyObject *__pyx_empty_tuple; +static PyObject *__pyx_empty_bytes; +static PyObject *__pyx_empty_unicode; +static int __pyx_lineno; +static int __pyx_clineno = 0; +static const char * __pyx_cfilenm= __FILE__; +static const char *__pyx_filename; + +/* Header.proto */ +#if !defined(CYTHON_CCOMPLEX) + #if defined(__cplusplus) + #define CYTHON_CCOMPLEX 1 + #elif defined(_Complex_I) + #define CYTHON_CCOMPLEX 1 + #else + #define CYTHON_CCOMPLEX 0 + #endif +#endif +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + #include + #else + #include + #endif +#endif +#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__) + #undef _Complex_I + #define _Complex_I 1.0fj +#endif + + +static const char *__pyx_f[] = { + "stringsource", + "pynastranIO.pyx", + "__init__.pxd", + "type.pxd", +}; + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":776 + * # in Cython to enable them only on the right systems. + * + * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t + */ +typedef npy_int8 __pyx_t_5numpy_int8_t; + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":777 + * + * ctypedef npy_int8 int8_t + * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< + * ctypedef npy_int32 int32_t + * ctypedef npy_int64 int64_t + */ +typedef npy_int16 __pyx_t_5numpy_int16_t; + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":778 + * ctypedef npy_int8 int8_t + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< + * ctypedef npy_int64 int64_t + * #ctypedef npy_int96 int96_t + */ +typedef npy_int32 __pyx_t_5numpy_int32_t; + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":779 + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t + * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< + * #ctypedef npy_int96 int96_t + * #ctypedef npy_int128 int128_t + */ +typedef npy_int64 __pyx_t_5numpy_int64_t; + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":783 + * #ctypedef npy_int128 int128_t + * + * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t + */ +typedef npy_uint8 __pyx_t_5numpy_uint8_t; + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":784 + * + * ctypedef npy_uint8 uint8_t + * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< + * ctypedef npy_uint32 uint32_t + * ctypedef npy_uint64 uint64_t + */ +typedef npy_uint16 __pyx_t_5numpy_uint16_t; + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":785 + * ctypedef npy_uint8 uint8_t + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< + * ctypedef npy_uint64 uint64_t + * #ctypedef npy_uint96 uint96_t + */ +typedef npy_uint32 __pyx_t_5numpy_uint32_t; + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":786 + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t + * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< + * #ctypedef npy_uint96 uint96_t + * #ctypedef npy_uint128 uint128_t + */ +typedef npy_uint64 __pyx_t_5numpy_uint64_t; + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":790 + * #ctypedef npy_uint128 uint128_t + * + * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< + * ctypedef npy_float64 float64_t + * #ctypedef npy_float80 float80_t + */ +typedef npy_float32 __pyx_t_5numpy_float32_t; + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":791 + * + * ctypedef npy_float32 float32_t + * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< + * #ctypedef npy_float80 float80_t + * #ctypedef npy_float128 float128_t + */ +typedef npy_float64 __pyx_t_5numpy_float64_t; + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":800 + * # The int types are mapped a bit surprising -- + * # numpy.int corresponds to 'l' and numpy.long to 'q' + * ctypedef npy_long int_t # <<<<<<<<<<<<<< + * ctypedef npy_longlong long_t + * ctypedef npy_longlong longlong_t + */ +typedef npy_long __pyx_t_5numpy_int_t; + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 + * # numpy.int corresponds to 'l' and numpy.long to 'q' + * ctypedef npy_long int_t + * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< + * ctypedef npy_longlong longlong_t + * + */ +typedef npy_longlong __pyx_t_5numpy_long_t; + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":802 + * ctypedef npy_long int_t + * ctypedef npy_longlong long_t + * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< + * + * ctypedef npy_ulong uint_t + */ +typedef npy_longlong __pyx_t_5numpy_longlong_t; + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":804 + * ctypedef npy_longlong longlong_t + * + * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< + * ctypedef npy_ulonglong ulong_t + * ctypedef npy_ulonglong ulonglong_t + */ +typedef npy_ulong __pyx_t_5numpy_uint_t; + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":805 + * + * ctypedef npy_ulong uint_t + * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< + * ctypedef npy_ulonglong ulonglong_t + * + */ +typedef npy_ulonglong __pyx_t_5numpy_ulong_t; + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":806 + * ctypedef npy_ulong uint_t + * ctypedef npy_ulonglong ulong_t + * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< + * + * ctypedef npy_intp intp_t + */ +typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":808 + * ctypedef npy_ulonglong ulonglong_t + * + * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< + * ctypedef npy_uintp uintp_t + * + */ +typedef npy_intp __pyx_t_5numpy_intp_t; + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":809 + * + * ctypedef npy_intp intp_t + * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< + * + * ctypedef npy_double float_t + */ +typedef npy_uintp __pyx_t_5numpy_uintp_t; + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":811 + * ctypedef npy_uintp uintp_t + * + * ctypedef npy_double float_t # <<<<<<<<<<<<<< + * ctypedef npy_double double_t + * ctypedef npy_longdouble longdouble_t + */ +typedef npy_double __pyx_t_5numpy_float_t; + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":812 + * + * ctypedef npy_double float_t + * ctypedef npy_double double_t # <<<<<<<<<<<<<< + * ctypedef npy_longdouble longdouble_t + * + */ +typedef npy_double __pyx_t_5numpy_double_t; + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":813 + * ctypedef npy_double float_t + * ctypedef npy_double double_t + * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< + * + * ctypedef npy_cfloat cfloat_t + */ +typedef npy_longdouble __pyx_t_5numpy_longdouble_t; + +/* "pynastranIO.pyx":30 + * cimport numpy as np + * DTYPE = np.float + * ctypedef np.float_t DTYPE_t # <<<<<<<<<<<<<< + * + * + */ +typedef __pyx_t_5numpy_float_t __pyx_t_11pynastranIO_DTYPE_t; +/* Declarations.proto */ +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + typedef ::std::complex< float > __pyx_t_float_complex; + #else + typedef float _Complex __pyx_t_float_complex; + #endif +#else + typedef struct { float real, imag; } __pyx_t_float_complex; +#endif +static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float); + +/* Declarations.proto */ +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + typedef ::std::complex< double > __pyx_t_double_complex; + #else + typedef double _Complex __pyx_t_double_complex; + #endif +#else + typedef struct { double real, imag; } __pyx_t_double_complex; +#endif +static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double); + + +/*--- Type declarations ---*/ +struct BDFModel; + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":815 + * ctypedef npy_longdouble longdouble_t + * + * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< + * ctypedef npy_cdouble cdouble_t + * ctypedef npy_clongdouble clongdouble_t + */ +typedef npy_cfloat __pyx_t_5numpy_cfloat_t; + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":816 + * + * ctypedef npy_cfloat cfloat_t + * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< + * ctypedef npy_clongdouble clongdouble_t + * + */ +typedef npy_cdouble __pyx_t_5numpy_cdouble_t; + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":817 + * ctypedef npy_cfloat cfloat_t + * ctypedef npy_cdouble cdouble_t + * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< + * + * ctypedef npy_cdouble complex_t + */ +typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":819 + * ctypedef npy_clongdouble clongdouble_t + * + * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew1(a): + */ +typedef npy_cdouble __pyx_t_5numpy_complex_t; + +/* "pynastranIO.pyx":33 + * + * + * cdef public class BDFModel[object BDFModel, type BDFModelType]: # <<<<<<<<<<<<<< + * cdef: + * string bdfPath + */ +struct BDFModel { + PyObject_HEAD + std::string bdfPath; + int nDims; + int nNodes; + int nElems; + int nMaterials; + int nProperties; + std::map nElemTypes; + PyObject *myBDF; +}; + +__PYX_EXTERN_C DL_EXPORT(PyTypeObject) BDFModelType; + +/* --- Runtime support code (head) --- */ +/* Refnanny.proto */ +#ifndef CYTHON_REFNANNY + #define CYTHON_REFNANNY 0 +#endif +#if CYTHON_REFNANNY + typedef struct { + void (*INCREF)(void*, PyObject*, int); + void (*DECREF)(void*, PyObject*, int); + void (*GOTREF)(void*, PyObject*, int); + void (*GIVEREF)(void*, PyObject*, int); + void* (*SetupContext)(const char*, int, const char*); + void (*FinishContext)(void**); + } __Pyx_RefNannyAPIStruct; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); + #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; +#ifdef WITH_THREAD + #define __Pyx_RefNannySetupContext(name, acquire_gil)\ + if (acquire_gil) {\ + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ + PyGILState_Release(__pyx_gilstate_save);\ + } else {\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ + } +#else + #define __Pyx_RefNannySetupContext(name, acquire_gil)\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) +#endif + #define __Pyx_RefNannyFinishContext()\ + __Pyx_RefNanny->FinishContext(&__pyx_refnanny) + #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) + #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) + #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) + #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) +#else + #define __Pyx_RefNannyDeclarations + #define __Pyx_RefNannySetupContext(name, acquire_gil) + #define __Pyx_RefNannyFinishContext() + #define __Pyx_INCREF(r) Py_INCREF(r) + #define __Pyx_DECREF(r) Py_DECREF(r) + #define __Pyx_GOTREF(r) + #define __Pyx_GIVEREF(r) + #define __Pyx_XINCREF(r) Py_XINCREF(r) + #define __Pyx_XDECREF(r) Py_XDECREF(r) + #define __Pyx_XGOTREF(r) + #define __Pyx_XGIVEREF(r) +#endif +#define __Pyx_XDECREF_SET(r, v) do {\ + PyObject *tmp = (PyObject *) r;\ + r = v; __Pyx_XDECREF(tmp);\ + } while (0) +#define __Pyx_DECREF_SET(r, v) do {\ + PyObject *tmp = (PyObject *) r;\ + r = v; __Pyx_DECREF(tmp);\ + } while (0) +#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) +#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) + +/* PyObjectGetAttrStr.proto */ +#if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name); +#else +#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) +#endif + +/* GetBuiltinName.proto */ +static PyObject *__Pyx_GetBuiltinName(PyObject *name); + +/* RaiseDoubleKeywords.proto */ +static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); + +/* ParseKeywords.proto */ +static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ + PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ + const char* function_name); + +/* RaiseArgTupleInvalid.proto */ +static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, + Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); + +/* PyDictVersioning.proto */ +#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS +#define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1) +#define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag) +#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\ + (version_var) = __PYX_GET_DICT_VERSION(dict);\ + (cache_var) = (value); +#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\ + static PY_UINT64_T __pyx_dict_version = 0;\ + static PyObject *__pyx_dict_cached_value = NULL;\ + if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\ + (VAR) = __pyx_dict_cached_value;\ + } else {\ + (VAR) = __pyx_dict_cached_value = (LOOKUP);\ + __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\ + }\ +} +static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj); +static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj); +static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version); +#else +#define __PYX_GET_DICT_VERSION(dict) (0) +#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var) +#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP); +#endif + +/* GetModuleGlobalName.proto */ +#if CYTHON_USE_DICT_VERSIONS +#define __Pyx_GetModuleGlobalName(var, name) {\ + static PY_UINT64_T __pyx_dict_version = 0;\ + static PyObject *__pyx_dict_cached_value = NULL;\ + (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\ + (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\ + __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ +} +#define __Pyx_GetModuleGlobalNameUncached(var, name) {\ + PY_UINT64_T __pyx_dict_version;\ + PyObject *__pyx_dict_cached_value;\ + (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ +} +static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value); +#else +#define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name) +#define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name) +static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name); +#endif + +/* PyFunctionFastCall.proto */ +#if CYTHON_FAST_PYCALL +#define __Pyx_PyFunction_FastCall(func, args, nargs)\ + __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) +#if 1 || PY_VERSION_HEX < 0x030600B1 +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs); +#else +#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) +#endif +#define __Pyx_BUILD_ASSERT_EXPR(cond)\ + (sizeof(char [1 - 2*!(cond)]) - 1) +#ifndef Py_MEMBER_SIZE +#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member) +#endif + static size_t __pyx_pyframe_localsplus_offset = 0; + #include "frameobject.h" + #define __Pxy_PyFrame_Initialize_Offsets()\ + ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\ + (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus))) + #define __Pyx_PyFrame_GetLocalsplus(frame)\ + (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset)) +#endif + +/* PyObjectCall.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); +#else +#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) +#endif + +/* PyObjectCallMethO.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); +#endif + +/* PyObjectCallNoArg.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); +#else +#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) +#endif + +/* PyCFunctionFastCall.proto */ +#if CYTHON_FAST_PYCCALL +static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); +#else +#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) +#endif + +/* PyObjectCallOneArg.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); + +/* IncludeCppStringH.proto */ +#include + +/* decode_c_string_utf16.proto */ +static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) { + int byteorder = 0; + return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); +} +static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) { + int byteorder = -1; + return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); +} +static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) { + int byteorder = 1; + return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); +} + +/* decode_c_bytes.proto */ +static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes( + const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop, + const char* encoding, const char* errors, + PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)); + +/* decode_cpp_string.proto */ +static CYTHON_INLINE PyObject* __Pyx_decode_cpp_string( + std::string cppstring, Py_ssize_t start, Py_ssize_t stop, + const char* encoding, const char* errors, + PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) { + return __Pyx_decode_c_bytes( + cppstring.data(), cppstring.size(), start, stop, encoding, errors, decode_func); +} + +/* PyObjectCall2Args.proto */ +static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2); + +/* PyThreadStateGet.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; +#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; +#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type +#else +#define __Pyx_PyThreadState_declare +#define __Pyx_PyThreadState_assign +#define __Pyx_PyErr_Occurred() PyErr_Occurred() +#endif + +/* PyErrFetchRestore.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) +#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) +#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) +#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) +#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); +static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) +#else +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#endif +#else +#define __Pyx_PyErr_Clear() PyErr_Clear() +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) +#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb) +#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) +#endif + +/* RaiseException.proto */ +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); + +/* WriteUnraisableException.proto */ +static void __Pyx_WriteUnraisable(const char *name, int clineno, + int lineno, const char *filename, + int full_traceback, int nogil); + +/* GetItemInt.proto */ +#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ + (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ + __Pyx_GetItemInt_Generic(o, to_py_func(i)))) +#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ + (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ + (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, + int is_list, int wraparound, int boundscheck); + +/* ObjectGetItem.proto */ +#if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key); +#else +#define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key) +#endif + +/* PyFloatBinop.proto */ +#if !CYTHON_COMPILING_IN_PYPY +static PyObject* __Pyx_PyFloat_NeObjC(PyObject *op1, PyObject *op2, double floatval, int inplace, int zerodivision_check); +#else +#define __Pyx_PyFloat_NeObjC(op1, op2, floatval, inplace, zerodivision_check)\ + (PyObject_RichCompare(op1, op2, Py_NE)) + #endif + +/* IterFinish.proto */ +static CYTHON_INLINE int __Pyx_IterFinish(void); + +/* PyObjectGetMethod.proto */ +static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method); + +/* PyObjectCallMethod0.proto */ +static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name); + +/* RaiseNeedMoreValuesToUnpack.proto */ +static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); + +/* RaiseTooManyValuesToUnpack.proto */ +static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); + +/* UnpackItemEndCheck.proto */ +static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); + +/* RaiseNoneIterError.proto */ +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); + +/* UnpackTupleError.proto */ +static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index); + +/* UnpackTuple2.proto */ +#define __Pyx_unpack_tuple2(tuple, value1, value2, is_tuple, has_known_size, decref_tuple)\ + (likely(is_tuple || PyTuple_Check(tuple)) ?\ + (likely(has_known_size || PyTuple_GET_SIZE(tuple) == 2) ?\ + __Pyx_unpack_tuple2_exact(tuple, value1, value2, decref_tuple) :\ + (__Pyx_UnpackTupleError(tuple, 2), -1)) :\ + __Pyx_unpack_tuple2_generic(tuple, value1, value2, has_known_size, decref_tuple)) +static CYTHON_INLINE int __Pyx_unpack_tuple2_exact( + PyObject* tuple, PyObject** value1, PyObject** value2, int decref_tuple); +static int __Pyx_unpack_tuple2_generic( + PyObject* tuple, PyObject** value1, PyObject** value2, int has_known_size, int decref_tuple); + +/* dict_iter.proto */ +static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* dict, int is_dict, PyObject* method_name, + Py_ssize_t* p_orig_length, int* p_is_dict); +static CYTHON_INLINE int __Pyx_dict_iter_next(PyObject* dict_or_iter, Py_ssize_t orig_length, Py_ssize_t* ppos, + PyObject** pkey, PyObject** pvalue, PyObject** pitem, int is_dict); + +/* PySequenceContains.proto */ +static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) { + int result = PySequence_Contains(seq, item); + return unlikely(result < 0) ? result : (result == (eq == Py_EQ)); +} + +/* PyIntCompare.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_NeObjC(PyObject *op1, PyObject *op2, long intval, long inplace); + +/* ListAppend.proto */ +#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS +static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { + PyListObject* L = (PyListObject*) list; + Py_ssize_t len = Py_SIZE(list); + if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) { + Py_INCREF(x); + PyList_SET_ITEM(list, len, x); + Py_SIZE(list) = len+1; + return 0; + } + return PyList_Append(list, x); +} +#else +#define __Pyx_PyList_Append(L,x) PyList_Append(L,x) +#endif + +/* DictGetItem.proto */ +#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY +static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key); +#define __Pyx_PyObject_Dict_GetItem(obj, name)\ + (likely(PyDict_CheckExact(obj)) ?\ + __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name)) +#else +#define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) +#define __Pyx_PyObject_Dict_GetItem(obj, name) PyObject_GetItem(obj, name) +#endif + +/* py_abs.proto */ +#if CYTHON_USE_PYLONG_INTERNALS +static PyObject *__Pyx_PyLong_AbsNeg(PyObject *num); +#define __Pyx_PyNumber_Absolute(x)\ + ((likely(PyLong_CheckExact(x))) ?\ + (likely(Py_SIZE(x) >= 0) ? (Py_INCREF(x), (x)) : __Pyx_PyLong_AbsNeg(x)) :\ + PyNumber_Absolute(x)) +#else +#define __Pyx_PyNumber_Absolute(x) PyNumber_Absolute(x) +#endif + +/* PyObjectSetAttrStr.proto */ +#if CYTHON_USE_TYPE_SLOTS +#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL) +static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value); +#else +#define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n) +#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v) +#endif + +/* ExtTypeTest.proto */ +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); + +/* GetTopmostException.proto */ +#if CYTHON_USE_EXC_INFO_STACK +static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate); +#endif + +/* SaveResetException.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); +#else +#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) +#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) +#endif + +/* PyErrExceptionMatches.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) +static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); +#else +#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err) +#endif + +/* GetException.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb) +static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#else +static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); +#endif + +/* PyObject_GenericGetAttrNoDict.proto */ +#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 +static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name); +#else +#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr +#endif + +/* PyObject_GenericGetAttr.proto */ +#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 +static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name); +#else +#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr +#endif + +/* SetupReduce.proto */ +static int __Pyx_setup_reduce(PyObject* type_obj); + +/* TypeImport.proto */ +#ifndef __PYX_HAVE_RT_ImportType_proto +#define __PYX_HAVE_RT_ImportType_proto +enum __Pyx_ImportType_CheckSize { + __Pyx_ImportType_CheckSize_Error = 0, + __Pyx_ImportType_CheckSize_Warn = 1, + __Pyx_ImportType_CheckSize_Ignore = 2 +}; +static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size); +#endif + +/* Import.proto */ +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); + +/* ImportFrom.proto */ +static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); + +/* CLineInTraceback.proto */ +#ifdef CYTHON_CLINE_IN_TRACEBACK +#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) +#else +static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); +#endif + +/* CodeObjectCache.proto */ +typedef struct { + PyCodeObject* code_object; + int code_line; +} __Pyx_CodeObjectCacheEntry; +struct __Pyx_CodeObjectCache { + int count; + int max_count; + __Pyx_CodeObjectCacheEntry* entries; +}; +static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; +static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); +static PyCodeObject *__pyx_find_code_object(int code_line); +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); + +/* AddTraceback.proto */ +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename); + +/* None.proto */ +#include + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); + +/* CppExceptionConversion.proto */ +#ifndef __Pyx_CppExn2PyErr +#include +#include +#include +#include +static void __Pyx_CppExn2PyErr() { + try { + if (PyErr_Occurred()) + ; // let the latest Python exn pass through and ignore the current one + else + throw; + } catch (const std::bad_alloc& exn) { + PyErr_SetString(PyExc_MemoryError, exn.what()); + } catch (const std::bad_cast& exn) { + PyErr_SetString(PyExc_TypeError, exn.what()); + } catch (const std::bad_typeid& exn) { + PyErr_SetString(PyExc_TypeError, exn.what()); + } catch (const std::domain_error& exn) { + PyErr_SetString(PyExc_ValueError, exn.what()); + } catch (const std::invalid_argument& exn) { + PyErr_SetString(PyExc_ValueError, exn.what()); + } catch (const std::ios_base::failure& exn) { + PyErr_SetString(PyExc_IOError, exn.what()); + } catch (const std::out_of_range& exn) { + PyErr_SetString(PyExc_IndexError, exn.what()); + } catch (const std::overflow_error& exn) { + PyErr_SetString(PyExc_OverflowError, exn.what()); + } catch (const std::range_error& exn) { + PyErr_SetString(PyExc_ArithmeticError, exn.what()); + } catch (const std::underflow_error& exn) { + PyErr_SetString(PyExc_ArithmeticError, exn.what()); + } catch (const std::exception& exn) { + PyErr_SetString(PyExc_RuntimeError, exn.what()); + } + catch (...) + { + PyErr_SetString(PyExc_RuntimeError, "Unknown exception"); + } +} +#endif + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); + +/* RealImag.proto */ +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + #define __Pyx_CREAL(z) ((z).real()) + #define __Pyx_CIMAG(z) ((z).imag()) + #else + #define __Pyx_CREAL(z) (__real__(z)) + #define __Pyx_CIMAG(z) (__imag__(z)) + #endif +#else + #define __Pyx_CREAL(z) ((z).real) + #define __Pyx_CIMAG(z) ((z).imag) +#endif +#if defined(__cplusplus) && CYTHON_CCOMPLEX\ + && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103) + #define __Pyx_SET_CREAL(z,x) ((z).real(x)) + #define __Pyx_SET_CIMAG(z,y) ((z).imag(y)) +#else + #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x) + #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y) +#endif + +/* Arithmetic.proto */ +#if CYTHON_CCOMPLEX + #define __Pyx_c_eq_float(a, b) ((a)==(b)) + #define __Pyx_c_sum_float(a, b) ((a)+(b)) + #define __Pyx_c_diff_float(a, b) ((a)-(b)) + #define __Pyx_c_prod_float(a, b) ((a)*(b)) + #define __Pyx_c_quot_float(a, b) ((a)/(b)) + #define __Pyx_c_neg_float(a) (-(a)) + #ifdef __cplusplus + #define __Pyx_c_is_zero_float(z) ((z)==(float)0) + #define __Pyx_c_conj_float(z) (::std::conj(z)) + #if 1 + #define __Pyx_c_abs_float(z) (::std::abs(z)) + #define __Pyx_c_pow_float(a, b) (::std::pow(a, b)) + #endif + #else + #define __Pyx_c_is_zero_float(z) ((z)==0) + #define __Pyx_c_conj_float(z) (conjf(z)) + #if 1 + #define __Pyx_c_abs_float(z) (cabsf(z)) + #define __Pyx_c_pow_float(a, b) (cpowf(a, b)) + #endif + #endif +#else + static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex); + static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex); + #if 1 + static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex, __pyx_t_float_complex); + #endif +#endif + +/* Arithmetic.proto */ +#if CYTHON_CCOMPLEX + #define __Pyx_c_eq_double(a, b) ((a)==(b)) + #define __Pyx_c_sum_double(a, b) ((a)+(b)) + #define __Pyx_c_diff_double(a, b) ((a)-(b)) + #define __Pyx_c_prod_double(a, b) ((a)*(b)) + #define __Pyx_c_quot_double(a, b) ((a)/(b)) + #define __Pyx_c_neg_double(a) (-(a)) + #ifdef __cplusplus + #define __Pyx_c_is_zero_double(z) ((z)==(double)0) + #define __Pyx_c_conj_double(z) (::std::conj(z)) + #if 1 + #define __Pyx_c_abs_double(z) (::std::abs(z)) + #define __Pyx_c_pow_double(a, b) (::std::pow(a, b)) + #endif + #else + #define __Pyx_c_is_zero_double(z) ((z)==0) + #define __Pyx_c_conj_double(z) (conj(z)) + #if 1 + #define __Pyx_c_abs_double(z) (cabs(z)) + #define __Pyx_c_pow_double(a, b) (cpow(a, b)) + #endif + #endif +#else + static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex); + static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex); + #if 1 + static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex); + #endif +#endif + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value); + +/* CIntFromPy.proto */ +static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); + +/* CIntFromPy.proto */ +static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); + +/* FastTypeChecks.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); +#else +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) +#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) +#endif +#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) + +/* CheckBinaryVersion.proto */ +static int __Pyx_check_binary_version(void); + +/* InitStrings.proto */ +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); + + +/* Module declarations from 'libc.string' */ + +/* Module declarations from 'libcpp.string' */ + +/* Module declarations from 'libcpp.vector' */ + +/* Module declarations from 'libcpp.utility' */ + +/* Module declarations from 'libcpp.map' */ + +/* Module declarations from 'libcpp' */ + +/* Module declarations from 'libcpp.list' */ + +/* Module declarations from 'libcpp.set' */ + +/* Module declarations from 'cpython.buffer' */ + +/* Module declarations from 'libc.stdio' */ + +/* Module declarations from '__builtin__' */ + +/* Module declarations from 'cpython.type' */ +static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0; + +/* Module declarations from 'cpython' */ + +/* Module declarations from 'cpython.object' */ + +/* Module declarations from 'cpython.ref' */ + +/* Module declarations from 'cpython.mem' */ + +/* Module declarations from 'numpy' */ + +/* Module declarations from 'numpy' */ +static PyTypeObject *__pyx_ptype_5numpy_dtype = 0; +static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0; +static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0; +static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0; +static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0; +static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/ + +/* Module declarations from 'pynastranIO' */ +static PyTypeObject *__pyx_ptype_11pynastranIO_BDFModel = 0; +__PYX_EXTERN_C struct BDFModel *buildBDFModel(std::string); /*proto*/ +__PYX_EXTERN_C void printBDFStats(struct BDFModel *); /*proto*/ +__PYX_EXTERN_C std::vector > getNodes(struct BDFModel *); /*proto*/ +__PYX_EXTERN_C std::map > > getElements(struct BDFModel *); /*proto*/ +__PYX_EXTERN_C std::map getNumberOfElementTypes(struct BDFModel *); /*proto*/ +static PyObject *__pyx_f_11pynastranIO_perturbZeroLengthBushings(struct BDFModel *); /*proto*/ +static std::string __pyx_convert_string_from_py_std__in_string(PyObject *); /*proto*/ +static CYTHON_INLINE PyObject *__pyx_convert_PyObject_string_to_py_std__in_string(std::string const &); /*proto*/ +static CYTHON_INLINE PyObject *__pyx_convert_PyUnicode_string_to_py_std__in_string(std::string const &); /*proto*/ +static CYTHON_INLINE PyObject *__pyx_convert_PyStr_string_to_py_std__in_string(std::string const &); /*proto*/ +static CYTHON_INLINE PyObject *__pyx_convert_PyBytes_string_to_py_std__in_string(std::string const &); /*proto*/ +static CYTHON_INLINE PyObject *__pyx_convert_PyByteArray_string_to_py_std__in_string(std::string const &); /*proto*/ +static PyObject *__pyx_convert_map_to_py_std_3a__3a_string____int(std::map const &); /*proto*/ +#define __Pyx_MODULE_NAME "pynastranIO" +extern int __pyx_module_is_main_pynastranIO; +int __pyx_module_is_main_pynastranIO = 0; + +/* Implementation of 'pynastranIO' */ +static PyObject *__pyx_builtin_TypeError; +static PyObject *__pyx_builtin_print; +static PyObject *__pyx_builtin_NotImplementedError; +static PyObject *__pyx_builtin_range; +static PyObject *__pyx_builtin_ValueError; +static PyObject *__pyx_builtin_RuntimeError; +static PyObject *__pyx_builtin_ImportError; +static const char __pyx_k_i[] = "_%i"; +static const char __pyx_k_j[] = "j"; +static const char __pyx_k_x[] = "x"; +static const char __pyx_k__3[] = "_"; +static const char __pyx_k__4[] = "'"; +static const char __pyx_k_np[] = "np"; +static const char __pyx_k_BDF[] = "BDF"; +static const char __pyx_k_eid[] = "eid"; +static const char __pyx_k_i_2[] = "i"; +static const char __pyx_k_min[] = "min"; +static const char __pyx_k_nid[] = "nid"; +static const char __pyx_k_pid[] = "pid"; +static const char __pyx_k_xyz[] = "xyz"; +static const char __pyx_k_keys[] = "keys"; +static const char __pyx_k_main[] = "__main__"; +static const char __pyx_k_name[] = "__name__"; +static const char __pyx_k_norm[] = "norm"; +static const char __pyx_k_test[] = "__test__"; +static const char __pyx_k_type[] = "type"; +static const char __pyx_k_warn[] = "warn"; +static const char __pyx_k_CBUSH[] = "CBUSH"; +static const char __pyx_k_DTYPE[] = "DTYPE"; +static const char __pyx_k_float[] = "float"; +static const char __pyx_k_items[] = "items"; +static const char __pyx_k_nodes[] = "nodes"; +static const char __pyx_k_numpy[] = "numpy"; +static const char __pyx_k_print[] = "print"; +static const char __pyx_k_range[] = "range"; +static const char __pyx_k_strip[] = "strip"; +static const char __pyx_k_utf_8[] = "utf-8"; +static const char __pyx_k_encode[] = "encode"; +static const char __pyx_k_import[] = "__import__"; +static const char __pyx_k_linalg[] = "linalg"; +static const char __pyx_k_nnodes[] = "nnodes"; +static const char __pyx_k_offset[] = "offset"; +static const char __pyx_k_reduce[] = "__reduce__"; +static const char __pyx_k_tolist[] = "tolist"; +static const char __pyx_k_CBUSH1D[] = "CBUSH1D"; +static const char __pyx_k_CBUSH2D[] = "CBUSH2D"; +static const char __pyx_k_cid_ref[] = "cid_ref"; +static const char __pyx_k_zoffset[] = "zoffset"; +static const char __pyx_k_BDFModel[] = "BDFModel"; +static const char __pyx_k_bdf_path[] = "bdf_path"; +static const char __pyx_k_elements[] = "elements"; +static const char __pyx_k_getstate[] = "__getstate__"; +static const char __pyx_k_read_bdf[] = "read_bdf"; +static const char __pyx_k_setstate[] = "__setstate__"; +static const char __pyx_k_warnings[] = "warnings"; +static const char __pyx_k_TypeError[] = "TypeError"; +static const char __pyx_k_nelements[] = "nelements"; +static const char __pyx_k_nodes_ref[] = "nodes_ref"; +static const char __pyx_k_reduce_ex[] = "__reduce_ex__"; +static const char __pyx_k_ValueError[] = "ValueError"; +static const char __pyx_k_card_count[] = "card_count"; +static const char __pyx_k_nmaterials[] = "nmaterials"; +static const char __pyx_k_ImportError[] = "ImportError"; +static const char __pyx_k_nproperties[] = "nproperties"; +static const char __pyx_k_RuntimeError[] = "RuntimeError"; +static const char __pyx_k_card_count_s[] = "card_count = %s\n"; +static const char __pyx_k_reject_count[] = "reject_count"; +static const char __pyx_k_get_bdf_stats[] = "get_bdf_stats"; +static const char __pyx_k_reduce_cython[] = "__reduce_cython__"; +static const char __pyx_k_reject_count_s[] = "reject_count = %s\n"; +static const char __pyx_k_setstate_cython[] = "__setstate_cython__"; +static const char __pyx_k_object_attributes[] = "object_attributes"; +static const char __pyx_k_pyNastran_bdf_bdf[] = "pyNastran.bdf.bdf"; +static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; +static const char __pyx_k_NotImplementedError[] = "NotImplementedError"; +static const char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous"; +static const char __pyx_k_Support_of_non_zero_offsets_not[] = "Support of non-zero offsets not yet implemented!"; +static const char __pyx_k_numpy_core_multiarray_failed_to[] = "numpy.core.multiarray failed to import"; +static const char __pyx_k_pyNASTRAN_Notes_Dependencies_cp[] = "\npyNASTRAN Notes\n---------------\nDependencies: cpylog, scipy, numpy\n"; +static const char __pyx_k_unknown_dtype_code_in_numpy_pxd[] = "unknown dtype code in numpy.pxd (%d)"; +static const char __pyx_k_Format_string_allocated_too_shor[] = "Format string allocated too short, see comment in numpy.pxd"; +static const char __pyx_k_Non_native_byte_order_not_suppor[] = "Non-native byte order not supported"; +static const char __pyx_k_Perturbing_GRID_i_by_s_to_define[] = "Perturbing GRID %i by %s to define x-axis of zero-length element."; +static const char __pyx_k_Support_of_non_zero_offets_not_y[] = "Support of non-zero offets not yet implemented!"; +static const char __pyx_k_get_elements_properties_nodes_by[] = "get_elements_properties_nodes_by_element_type"; +static const char __pyx_k_ndarray_is_not_Fortran_contiguou[] = "ndarray is not Fortran contiguous"; +static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__"; +static const char __pyx_k_numpy_core_umath_failed_to_impor[] = "numpy.core.umath failed to import"; +static const char __pyx_k_Format_string_allocated_too_shor_2[] = "Format string allocated too short."; +static PyObject *__pyx_n_s_BDF; +static PyObject *__pyx_n_s_BDFModel; +static PyObject *__pyx_n_u_CBUSH; +static PyObject *__pyx_n_u_CBUSH1D; +static PyObject *__pyx_n_u_CBUSH2D; +static PyObject *__pyx_n_s_DTYPE; +static PyObject *__pyx_kp_u_Format_string_allocated_too_shor; +static PyObject *__pyx_kp_u_Format_string_allocated_too_shor_2; +static PyObject *__pyx_n_s_ImportError; +static PyObject *__pyx_kp_u_Non_native_byte_order_not_suppor; +static PyObject *__pyx_n_s_NotImplementedError; +static PyObject *__pyx_kp_u_Perturbing_GRID_i_by_s_to_define; +static PyObject *__pyx_n_s_RuntimeError; +static PyObject *__pyx_kp_u_Support_of_non_zero_offets_not_y; +static PyObject *__pyx_kp_u_Support_of_non_zero_offsets_not; +static PyObject *__pyx_n_s_TypeError; +static PyObject *__pyx_n_s_ValueError; +static PyObject *__pyx_n_u__3; +static PyObject *__pyx_kp_u__4; +static PyObject *__pyx_n_s_bdf_path; +static PyObject *__pyx_n_s_card_count; +static PyObject *__pyx_kp_u_card_count_s; +static PyObject *__pyx_n_s_cid_ref; +static PyObject *__pyx_n_s_cline_in_traceback; +static PyObject *__pyx_n_s_eid; +static PyObject *__pyx_n_s_elements; +static PyObject *__pyx_n_s_encode; +static PyObject *__pyx_n_s_float; +static PyObject *__pyx_n_s_get_bdf_stats; +static PyObject *__pyx_n_s_get_elements_properties_nodes_by; +static PyObject *__pyx_n_s_getstate; +static PyObject *__pyx_kp_u_i; +static PyObject *__pyx_n_s_i_2; +static PyObject *__pyx_n_s_import; +static PyObject *__pyx_n_s_items; +static PyObject *__pyx_n_s_j; +static PyObject *__pyx_n_s_keys; +static PyObject *__pyx_n_s_linalg; +static PyObject *__pyx_n_s_main; +static PyObject *__pyx_n_s_min; +static PyObject *__pyx_n_s_name; +static PyObject *__pyx_kp_u_ndarray_is_not_C_contiguous; +static PyObject *__pyx_kp_u_ndarray_is_not_Fortran_contiguou; +static PyObject *__pyx_n_s_nelements; +static PyObject *__pyx_n_s_nid; +static PyObject *__pyx_n_s_nmaterials; +static PyObject *__pyx_n_s_nnodes; +static PyObject *__pyx_kp_s_no_default___reduce___due_to_non; +static PyObject *__pyx_n_s_nodes; +static PyObject *__pyx_n_s_nodes_ref; +static PyObject *__pyx_n_s_norm; +static PyObject *__pyx_n_s_np; +static PyObject *__pyx_n_s_nproperties; +static PyObject *__pyx_n_s_numpy; +static PyObject *__pyx_kp_u_numpy_core_multiarray_failed_to; +static PyObject *__pyx_kp_u_numpy_core_umath_failed_to_impor; +static PyObject *__pyx_n_s_object_attributes; +static PyObject *__pyx_n_s_offset; +static PyObject *__pyx_n_u_offset; +static PyObject *__pyx_n_s_pid; +static PyObject *__pyx_n_s_print; +static PyObject *__pyx_n_s_pyNastran_bdf_bdf; +static PyObject *__pyx_n_s_range; +static PyObject *__pyx_n_s_read_bdf; +static PyObject *__pyx_n_s_reduce; +static PyObject *__pyx_n_s_reduce_cython; +static PyObject *__pyx_n_s_reduce_ex; +static PyObject *__pyx_n_s_reject_count; +static PyObject *__pyx_kp_u_reject_count_s; +static PyObject *__pyx_n_s_setstate; +static PyObject *__pyx_n_s_setstate_cython; +static PyObject *__pyx_n_s_strip; +static PyObject *__pyx_n_s_test; +static PyObject *__pyx_n_s_tolist; +static PyObject *__pyx_n_s_type; +static PyObject *__pyx_kp_u_unknown_dtype_code_in_numpy_pxd; +static PyObject *__pyx_kp_u_utf_8; +static PyObject *__pyx_n_s_warn; +static PyObject *__pyx_n_s_warnings; +static PyObject *__pyx_n_s_x; +static PyObject *__pyx_n_s_xyz; +static PyObject *__pyx_n_s_zoffset; +static PyObject *__pyx_n_u_zoffset; +static int __pyx_pf_11pynastranIO_8BDFModel___cinit__(struct BDFModel *__pyx_v_self, std::string __pyx_v_bdf_path); /* proto */ +static PyObject *__pyx_pf_11pynastranIO_8BDFModel_5nDims___get__(struct BDFModel *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_11pynastranIO_8BDFModel_6nNodes___get__(struct BDFModel *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_11pynastranIO_8BDFModel_6nElems___get__(struct BDFModel *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_11pynastranIO_8BDFModel_10nMaterials___get__(struct BDFModel *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_11pynastranIO_8BDFModel_11nProperties___get__(struct BDFModel *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_11pynastranIO_8BDFModel_10nElemTypes___get__(struct BDFModel *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_11pynastranIO_8BDFModel_2__reduce_cython__(CYTHON_UNUSED struct BDFModel *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_11pynastranIO_8BDFModel_4__setstate_cython__(CYTHON_UNUSED struct BDFModel *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ +static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ +static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ +static PyObject *__pyx_tp_new_11pynastranIO_BDFModel(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_float_0_0; +static PyObject *__pyx_int_0; +static PyObject *__pyx_tuple_; +static PyObject *__pyx_tuple__2; +static PyObject *__pyx_tuple__5; +static PyObject *__pyx_tuple__6; +static PyObject *__pyx_tuple__7; +static PyObject *__pyx_tuple__8; +static PyObject *__pyx_tuple__9; +static PyObject *__pyx_tuple__10; +static PyObject *__pyx_tuple__11; +static PyObject *__pyx_tuple__12; +static PyObject *__pyx_tuple__13; +/* Late includes */ + +/* "pynastranIO.pyx":50 + * cdef myBDF + * + * def __cinit__(self, string bdf_path): # <<<<<<<<<<<<<< + * self.bdfPath = bdf_path + * self.myBDF = BDF() + */ + +/* Python wrapper */ +static int __pyx_pw_11pynastranIO_8BDFModel_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_11pynastranIO_8BDFModel_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + std::string __pyx_v_bdf_path; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_bdf_path,0}; + PyObject* values[1] = {0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bdf_path)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(1, 50, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + } + __pyx_v_bdf_path = __pyx_convert_string_from_py_std__in_string(values[0]); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 50, __pyx_L3_error) + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 50, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("pynastranIO.BDFModel.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_11pynastranIO_8BDFModel___cinit__(((struct BDFModel *)__pyx_v_self), __pyx_v_bdf_path); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_11pynastranIO_8BDFModel___cinit__(struct BDFModel *__pyx_v_self, std::string __pyx_v_bdf_path) { + PyObject *__pyx_v_nm = NULL; + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + __Pyx_RefNannySetupContext("__cinit__", 0); + + /* "pynastranIO.pyx":51 + * + * def __cinit__(self, string bdf_path): + * self.bdfPath = bdf_path # <<<<<<<<<<<<<< + * self.myBDF = BDF() + * nm = bdf_path.decode("UTF-8") + */ + __pyx_v_self->bdfPath = __pyx_v_bdf_path; + + /* "pynastranIO.pyx":52 + * def __cinit__(self, string bdf_path): + * self.bdfPath = bdf_path + * self.myBDF = BDF() # <<<<<<<<<<<<<< + * nm = bdf_path.decode("UTF-8") + * self.myBDF.read_bdf(nm) + */ + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_BDF); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 52, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 52, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->myBDF); + __Pyx_DECREF(__pyx_v_self->myBDF); + __pyx_v_self->myBDF = __pyx_t_1; + __pyx_t_1 = 0; + + /* "pynastranIO.pyx":53 + * self.bdfPath = bdf_path + * self.myBDF = BDF() + * nm = bdf_path.decode("UTF-8") # <<<<<<<<<<<<<< + * self.myBDF.read_bdf(nm) + * self.nNodes = self.myBDF.nnodes + */ + __pyx_t_1 = __Pyx_decode_cpp_string(__pyx_v_bdf_path, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeUTF8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 53, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_nm = __pyx_t_1; + __pyx_t_1 = 0; + + /* "pynastranIO.pyx":54 + * self.myBDF = BDF() + * nm = bdf_path.decode("UTF-8") + * self.myBDF.read_bdf(nm) # <<<<<<<<<<<<<< + * self.nNodes = self.myBDF.nnodes + * self.nElems = self.myBDF.nelements + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->myBDF, __pyx_n_s_read_bdf); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 54, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_nm) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_nm); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 54, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "pynastranIO.pyx":55 + * nm = bdf_path.decode("UTF-8") + * self.myBDF.read_bdf(nm) + * self.nNodes = self.myBDF.nnodes # <<<<<<<<<<<<<< + * self.nElems = self.myBDF.nelements + * self.nMaterials = self.myBDF.nmaterials + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->myBDF, __pyx_n_s_nnodes); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 55, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 55, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->nNodes = __pyx_t_4; + + /* "pynastranIO.pyx":56 + * self.myBDF.read_bdf(nm) + * self.nNodes = self.myBDF.nnodes + * self.nElems = self.myBDF.nelements # <<<<<<<<<<<<<< + * self.nMaterials = self.myBDF.nmaterials + * self.nProperties = self.myBDF.nproperties + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->myBDF, __pyx_n_s_nelements); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 56, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 56, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->nElems = __pyx_t_4; + + /* "pynastranIO.pyx":57 + * self.nNodes = self.myBDF.nnodes + * self.nElems = self.myBDF.nelements + * self.nMaterials = self.myBDF.nmaterials # <<<<<<<<<<<<<< + * self.nProperties = self.myBDF.nproperties + * # self.temperatures = None + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->myBDF, __pyx_n_s_nmaterials); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 57, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 57, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->nMaterials = __pyx_t_4; + + /* "pynastranIO.pyx":58 + * self.nElems = self.myBDF.nelements + * self.nMaterials = self.myBDF.nmaterials + * self.nProperties = self.myBDF.nproperties # <<<<<<<<<<<<<< + * # self.temperatures = None + * + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->myBDF, __pyx_n_s_nproperties); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 58, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 58, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_self->nProperties = __pyx_t_4; + + /* "pynastranIO.pyx":63 + * # Perturb the nodes of zero-length vectors, this is a hack to make zero-length + * # elements work in MAST. + * perturbZeroLengthBushings(self) # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_1 = __pyx_f_11pynastranIO_perturbZeroLengthBushings(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 63, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "pynastranIO.pyx":50 + * cdef myBDF + * + * def __cinit__(self, string bdf_path): # <<<<<<<<<<<<<< + * self.bdfPath = bdf_path + * self.myBDF = BDF() + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("pynastranIO.BDFModel.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_nm); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "pynastranIO.pyx":39 + * # The readonly specifier allows C/C++ code to still access these variables, but prevents them from changing it. + * cdef readonly : + * int nDims # <<<<<<<<<<<<<< + * int nNodes + * int nElems + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_11pynastranIO_8BDFModel_5nDims_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_11pynastranIO_8BDFModel_5nDims_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_11pynastranIO_8BDFModel_5nDims___get__(((struct BDFModel *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_11pynastranIO_8BDFModel_5nDims___get__(struct BDFModel *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->nDims); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 39, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("pynastranIO.BDFModel.nDims.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "pynastranIO.pyx":40 + * cdef readonly : + * int nDims + * int nNodes # <<<<<<<<<<<<<< + * int nElems + * int nMaterials + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_11pynastranIO_8BDFModel_6nNodes_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_11pynastranIO_8BDFModel_6nNodes_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_11pynastranIO_8BDFModel_6nNodes___get__(((struct BDFModel *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_11pynastranIO_8BDFModel_6nNodes___get__(struct BDFModel *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->nNodes); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 40, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("pynastranIO.BDFModel.nNodes.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "pynastranIO.pyx":41 + * int nDims + * int nNodes + * int nElems # <<<<<<<<<<<<<< + * int nMaterials + * int nProperties + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_11pynastranIO_8BDFModel_6nElems_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_11pynastranIO_8BDFModel_6nElems_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_11pynastranIO_8BDFModel_6nElems___get__(((struct BDFModel *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_11pynastranIO_8BDFModel_6nElems___get__(struct BDFModel *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->nElems); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 41, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("pynastranIO.BDFModel.nElems.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "pynastranIO.pyx":42 + * int nNodes + * int nElems + * int nMaterials # <<<<<<<<<<<<<< + * int nProperties + * map[string, int] nElemTypes + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_11pynastranIO_8BDFModel_10nMaterials_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_11pynastranIO_8BDFModel_10nMaterials_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_11pynastranIO_8BDFModel_10nMaterials___get__(((struct BDFModel *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_11pynastranIO_8BDFModel_10nMaterials___get__(struct BDFModel *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->nMaterials); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 42, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("pynastranIO.BDFModel.nMaterials.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "pynastranIO.pyx":43 + * int nElems + * int nMaterials + * int nProperties # <<<<<<<<<<<<<< + * map[string, int] nElemTypes + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_11pynastranIO_8BDFModel_11nProperties_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_11pynastranIO_8BDFModel_11nProperties_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_11pynastranIO_8BDFModel_11nProperties___get__(((struct BDFModel *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_11pynastranIO_8BDFModel_11nProperties___get__(struct BDFModel *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->nProperties); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 43, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("pynastranIO.BDFModel.nProperties.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "pynastranIO.pyx":44 + * int nMaterials + * int nProperties + * map[string, int] nElemTypes # <<<<<<<<<<<<<< + * + * # Need to declare this here, even without a type specifier. Otherwise, + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_11pynastranIO_8BDFModel_10nElemTypes_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_11pynastranIO_8BDFModel_10nElemTypes_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_11pynastranIO_8BDFModel_10nElemTypes___get__(((struct BDFModel *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_11pynastranIO_8BDFModel_10nElemTypes___get__(struct BDFModel *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_convert_map_to_py_std_3a__3a_string____int(__pyx_v_self->nElemTypes); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 44, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("pynastranIO.BDFModel.nElemTypes.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_11pynastranIO_8BDFModel_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_11pynastranIO_8BDFModel_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf_11pynastranIO_8BDFModel_2__reduce_cython__(((struct BDFModel *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_11pynastranIO_8BDFModel_2__reduce_cython__(CYTHON_UNUSED struct BDFModel *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__reduce_cython__", 0); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(0, 2, __pyx_L1_error) + + /* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("pynastranIO.BDFModel.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_11pynastranIO_8BDFModel_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ +static PyObject *__pyx_pw_11pynastranIO_8BDFModel_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf_11pynastranIO_8BDFModel_4__setstate_cython__(((struct BDFModel *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_11pynastranIO_8BDFModel_4__setstate_cython__(CYTHON_UNUSED struct BDFModel *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__setstate_cython__", 0); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(0, 4, __pyx_L1_error) + + /* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("pynastranIO.BDFModel.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "pynastranIO.pyx":66 + * + * + * cdef public BDFModel buildBDFModel(string bdf_path): # <<<<<<<<<<<<<< + * """ + * Acts as the constructor for the BDFModel class. + */ + +struct BDFModel *buildBDFModel(std::string __pyx_v_bdf_path) { + struct BDFModel *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannySetupContext("buildBDFModel", 0); + + /* "pynastranIO.pyx":70 + * Acts as the constructor for the BDFModel class. + * """ + * return BDFModel(bdf_path) # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(((PyObject *)__pyx_r)); + __pyx_t_1 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_bdf_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 70, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_11pynastranIO_BDFModel), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 70, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_r = ((struct BDFModel *)__pyx_t_2); + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "pynastranIO.pyx":66 + * + * + * cdef public BDFModel buildBDFModel(string bdf_path): # <<<<<<<<<<<<<< + * """ + * Acts as the constructor for the BDFModel class. + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("pynastranIO.buildBDFModel", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF((PyObject *)__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "pynastranIO.pyx":73 + * + * + * cdef public void printBDFStats(BDFModel model): # <<<<<<<<<<<<<< + * print(model.myBDF.get_bdf_stats()) + * print("card_count = %s\n"%model.myBDF.card_count) + */ + +void printBDFStats(struct BDFModel *__pyx_v_model) { + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __Pyx_RefNannySetupContext("printBDFStats", 0); + + /* "pynastranIO.pyx":74 + * + * cdef public void printBDFStats(BDFModel model): + * print(model.myBDF.get_bdf_stats()) # <<<<<<<<<<<<<< + * print("card_count = %s\n"%model.myBDF.card_count) + * print("reject_count = %s\n"%model.myBDF.reject_count) + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_model->myBDF, __pyx_n_s_get_bdf_stats); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 74, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 74, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 74, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "pynastranIO.pyx":75 + * cdef public void printBDFStats(BDFModel model): + * print(model.myBDF.get_bdf_stats()) + * print("card_count = %s\n"%model.myBDF.card_count) # <<<<<<<<<<<<<< + * print("reject_count = %s\n"%model.myBDF.reject_count) + * + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_model->myBDF, __pyx_n_s_card_count); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 75, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_card_count_s, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 75, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 75, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "pynastranIO.pyx":76 + * print(model.myBDF.get_bdf_stats()) + * print("card_count = %s\n"%model.myBDF.card_count) + * print("reject_count = %s\n"%model.myBDF.reject_count) # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_model->myBDF, __pyx_n_s_reject_count); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 76, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_reject_count_s, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 76, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 76, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "pynastranIO.pyx":73 + * + * + * cdef public void printBDFStats(BDFModel model): # <<<<<<<<<<<<<< + * print(model.myBDF.get_bdf_stats()) + * print("card_count = %s\n"%model.myBDF.card_count) + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_WriteUnraisable("pynastranIO.printBDFStats", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); + __pyx_L0:; + __Pyx_RefNannyFinishContext(); +} + +/* "pynastranIO.pyx":79 + * + * + * cdef public vector[vector[double]] getNodes(BDFModel model): # <<<<<<<<<<<<<< + * """ + * Creates a vector of vectors where each row is the node id and coordinates of + */ + +std::vector > getNodes(struct BDFModel *__pyx_v_model) { + int __pyx_v_n; + int __pyx_v_m; + std::vector __pyx_v_node_vec; + std::vector > __pyx_v_nodes; + bool __pyx_v_anyZ; + bool __pyx_v_anyY; + bool __pyx_v_anyX; + int __pyx_v_i; + PyObject *__pyx_v_key = NULL; + PyObject *__pyx_v_node = NULL; + std::vector > __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + std::vector __pyx_t_2; + std::vector > __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + Py_ssize_t __pyx_t_6; + PyObject *(*__pyx_t_7)(PyObject *); + PyObject *__pyx_t_8 = NULL; + double __pyx_t_9; + int __pyx_t_10; + __Pyx_RefNannySetupContext("getNodes", 0); + + /* "pynastranIO.pyx":95 + * """ + * # Get the number of rows and columns + * cdef int n = model.nNodes # Number of Nodes # <<<<<<<<<<<<<< + * cdef int m = 4 # node number + 3 dimensions = 4 + * + */ + __pyx_t_1 = __pyx_v_model->nNodes; + __pyx_v_n = __pyx_t_1; + + /* "pynastranIO.pyx":96 + * # Get the number of rows and columns + * cdef int n = model.nNodes # Number of Nodes + * cdef int m = 4 # node number + 3 dimensions = 4 # <<<<<<<<<<<<<< + * + * # Create a 2D vector (vector of vectors) to store node numbers and coords + */ + __pyx_v_m = 4; + + /* "pynastranIO.pyx":101 + * cdef vector[double] node_vec + * cdef vector[vector[double]] nodes + * node_vec = vector[double](m) # <<<<<<<<<<<<<< + * nodes = vector[vector[double]](n, node_vec) + * + */ + try { + __pyx_t_2 = std::vector (__pyx_v_m); + } catch(...) { + __Pyx_CppExn2PyErr(); + __PYX_ERR(1, 101, __pyx_L1_error) + } + __pyx_v_node_vec = __pyx_t_2; + + /* "pynastranIO.pyx":102 + * cdef vector[vector[double]] nodes + * node_vec = vector[double](m) + * nodes = vector[vector[double]](n, node_vec) # <<<<<<<<<<<<<< + * + * # Iterate over all nodes and all them to the 2D vector + */ + try { + __pyx_t_3 = std::vector > (__pyx_v_n, __pyx_v_node_vec); + } catch(...) { + __Pyx_CppExn2PyErr(); + __PYX_ERR(1, 102, __pyx_L1_error) + } + __pyx_v_nodes = __pyx_t_3; + + /* "pynastranIO.pyx":105 + * + * # Iterate over all nodes and all them to the 2D vector + * cdef bool anyZ = False # <<<<<<<<<<<<<< + * cdef bool anyY = False + * cdef bool anyX = False + */ + __pyx_v_anyZ = 0; + + /* "pynastranIO.pyx":106 + * # Iterate over all nodes and all them to the 2D vector + * cdef bool anyZ = False + * cdef bool anyY = False # <<<<<<<<<<<<<< + * cdef bool anyX = False + * cdef int i = 0 + */ + __pyx_v_anyY = 0; + + /* "pynastranIO.pyx":107 + * cdef bool anyZ = False + * cdef bool anyY = False + * cdef bool anyX = False # <<<<<<<<<<<<<< + * cdef int i = 0 + * for key in model.myBDF.nodes: + */ + __pyx_v_anyX = 0; + + /* "pynastranIO.pyx":108 + * cdef bool anyY = False + * cdef bool anyX = False + * cdef int i = 0 # <<<<<<<<<<<<<< + * for key in model.myBDF.nodes: + * node = model.myBDF.nodes[key] + */ + __pyx_v_i = 0; + + /* "pynastranIO.pyx":109 + * cdef bool anyX = False + * cdef int i = 0 + * for key in model.myBDF.nodes: # <<<<<<<<<<<<<< + * node = model.myBDF.nodes[key] + * nodes[i][0] = node.nid + */ + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_model->myBDF, __pyx_n_s_nodes); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 109, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) { + __pyx_t_5 = __pyx_t_4; __Pyx_INCREF(__pyx_t_5); __pyx_t_6 = 0; + __pyx_t_7 = NULL; + } else { + __pyx_t_6 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 109, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_7 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 109, __pyx_L1_error) + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + for (;;) { + if (likely(!__pyx_t_7)) { + if (likely(PyList_CheckExact(__pyx_t_5))) { + if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(1, 109, __pyx_L1_error) + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 109, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + #endif + } else { + if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_5)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(1, 109, __pyx_L1_error) + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 109, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + #endif + } + } else { + __pyx_t_4 = __pyx_t_7(__pyx_t_5); + if (unlikely(!__pyx_t_4)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(1, 109, __pyx_L1_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_4); + } + __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_4); + __pyx_t_4 = 0; + + /* "pynastranIO.pyx":110 + * cdef int i = 0 + * for key in model.myBDF.nodes: + * node = model.myBDF.nodes[key] # <<<<<<<<<<<<<< + * nodes[i][0] = node.nid + * nodes[i][1] = node.xyz[0] + */ + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_model->myBDF, __pyx_n_s_nodes); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 110, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_8 = __Pyx_PyObject_GetItem(__pyx_t_4, __pyx_v_key); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 110, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_XDECREF_SET(__pyx_v_node, __pyx_t_8); + __pyx_t_8 = 0; + + /* "pynastranIO.pyx":111 + * for key in model.myBDF.nodes: + * node = model.myBDF.nodes[key] + * nodes[i][0] = node.nid # <<<<<<<<<<<<<< + * nodes[i][1] = node.xyz[0] + * nodes[i][2] = node.xyz[1] + */ + __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_node, __pyx_n_s_nid); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 111, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_t_8); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(1, 111, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + ((__pyx_v_nodes[__pyx_v_i])[0]) = __pyx_t_9; + + /* "pynastranIO.pyx":112 + * node = model.myBDF.nodes[key] + * nodes[i][0] = node.nid + * nodes[i][1] = node.xyz[0] # <<<<<<<<<<<<<< + * nodes[i][2] = node.xyz[1] + * nodes[i][3] = node.xyz[2] + */ + __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_node, __pyx_n_s_xyz); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 112, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_8, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 112, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(1, 112, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + ((__pyx_v_nodes[__pyx_v_i])[1]) = __pyx_t_9; + + /* "pynastranIO.pyx":113 + * nodes[i][0] = node.nid + * nodes[i][1] = node.xyz[0] + * nodes[i][2] = node.xyz[1] # <<<<<<<<<<<<<< + * nodes[i][3] = node.xyz[2] + * if node.xyz[0]!=0.0: + */ + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_node, __pyx_n_s_xyz); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 113, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_4, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 113, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_t_8); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(1, 113, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + ((__pyx_v_nodes[__pyx_v_i])[2]) = __pyx_t_9; + + /* "pynastranIO.pyx":114 + * nodes[i][1] = node.xyz[0] + * nodes[i][2] = node.xyz[1] + * nodes[i][3] = node.xyz[2] # <<<<<<<<<<<<<< + * if node.xyz[0]!=0.0: + * anyX = True + */ + __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_node, __pyx_n_s_xyz); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 114, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_8, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 114, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(1, 114, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + ((__pyx_v_nodes[__pyx_v_i])[3]) = __pyx_t_9; + + /* "pynastranIO.pyx":115 + * nodes[i][2] = node.xyz[1] + * nodes[i][3] = node.xyz[2] + * if node.xyz[0]!=0.0: # <<<<<<<<<<<<<< + * anyX = True + * if node.xyz[1]!=0.0: + */ + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_node, __pyx_n_s_xyz); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 115, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 115, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyFloat_NeObjC(__pyx_t_8, __pyx_float_0_0, 0.0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 115, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(1, 115, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_10) { + + /* "pynastranIO.pyx":116 + * nodes[i][3] = node.xyz[2] + * if node.xyz[0]!=0.0: + * anyX = True # <<<<<<<<<<<<<< + * if node.xyz[1]!=0.0: + * anyY = True + */ + __pyx_v_anyX = 1; + + /* "pynastranIO.pyx":115 + * nodes[i][2] = node.xyz[1] + * nodes[i][3] = node.xyz[2] + * if node.xyz[0]!=0.0: # <<<<<<<<<<<<<< + * anyX = True + * if node.xyz[1]!=0.0: + */ + } + + /* "pynastranIO.pyx":117 + * if node.xyz[0]!=0.0: + * anyX = True + * if node.xyz[1]!=0.0: # <<<<<<<<<<<<<< + * anyY = True + * if node.xyz[2]!=0.0: + */ + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_node, __pyx_n_s_xyz); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 117, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_4, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 117, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyFloat_NeObjC(__pyx_t_8, __pyx_float_0_0, 0.0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 117, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(1, 117, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_10) { + + /* "pynastranIO.pyx":118 + * anyX = True + * if node.xyz[1]!=0.0: + * anyY = True # <<<<<<<<<<<<<< + * if node.xyz[2]!=0.0: + * anyZ = True + */ + __pyx_v_anyY = 1; + + /* "pynastranIO.pyx":117 + * if node.xyz[0]!=0.0: + * anyX = True + * if node.xyz[1]!=0.0: # <<<<<<<<<<<<<< + * anyY = True + * if node.xyz[2]!=0.0: + */ + } + + /* "pynastranIO.pyx":119 + * if node.xyz[1]!=0.0: + * anyY = True + * if node.xyz[2]!=0.0: # <<<<<<<<<<<<<< + * anyZ = True + * i += 1 + */ + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_node, __pyx_n_s_xyz); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 119, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_4, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 119, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyFloat_NeObjC(__pyx_t_8, __pyx_float_0_0, 0.0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 119, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(1, 119, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_10) { + + /* "pynastranIO.pyx":120 + * anyY = True + * if node.xyz[2]!=0.0: + * anyZ = True # <<<<<<<<<<<<<< + * i += 1 + * + */ + __pyx_v_anyZ = 1; + + /* "pynastranIO.pyx":119 + * if node.xyz[1]!=0.0: + * anyY = True + * if node.xyz[2]!=0.0: # <<<<<<<<<<<<<< + * anyZ = True + * i += 1 + */ + } + + /* "pynastranIO.pyx":121 + * if node.xyz[2]!=0.0: + * anyZ = True + * i += 1 # <<<<<<<<<<<<<< + * + * if anyZ: + */ + __pyx_v_i = (__pyx_v_i + 1); + + /* "pynastranIO.pyx":109 + * cdef bool anyX = False + * cdef int i = 0 + * for key in model.myBDF.nodes: # <<<<<<<<<<<<<< + * node = model.myBDF.nodes[key] + * nodes[i][0] = node.nid + */ + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + + /* "pynastranIO.pyx":123 + * i += 1 + * + * if anyZ: # <<<<<<<<<<<<<< + * model.nDims = 3 + * elif anyY: + */ + __pyx_t_10 = (__pyx_v_anyZ != 0); + if (__pyx_t_10) { + + /* "pynastranIO.pyx":124 + * + * if anyZ: + * model.nDims = 3 # <<<<<<<<<<<<<< + * elif anyY: + * model.nDims = 2 + */ + __pyx_v_model->nDims = 3; + + /* "pynastranIO.pyx":123 + * i += 1 + * + * if anyZ: # <<<<<<<<<<<<<< + * model.nDims = 3 + * elif anyY: + */ + goto __pyx_L8; + } + + /* "pynastranIO.pyx":125 + * if anyZ: + * model.nDims = 3 + * elif anyY: # <<<<<<<<<<<<<< + * model.nDims = 2 + * elif anyX: + */ + __pyx_t_10 = (__pyx_v_anyY != 0); + if (__pyx_t_10) { + + /* "pynastranIO.pyx":126 + * model.nDims = 3 + * elif anyY: + * model.nDims = 2 # <<<<<<<<<<<<<< + * elif anyX: + * model.nDims = 1 + */ + __pyx_v_model->nDims = 2; + + /* "pynastranIO.pyx":125 + * if anyZ: + * model.nDims = 3 + * elif anyY: # <<<<<<<<<<<<<< + * model.nDims = 2 + * elif anyX: + */ + goto __pyx_L8; + } + + /* "pynastranIO.pyx":127 + * elif anyY: + * model.nDims = 2 + * elif anyX: # <<<<<<<<<<<<<< + * model.nDims = 1 + * else: + */ + __pyx_t_10 = (__pyx_v_anyX != 0); + if (__pyx_t_10) { + + /* "pynastranIO.pyx":128 + * model.nDims = 2 + * elif anyX: + * model.nDims = 1 # <<<<<<<<<<<<<< + * else: + * model.nDims = 0 + */ + __pyx_v_model->nDims = 1; + + /* "pynastranIO.pyx":127 + * elif anyY: + * model.nDims = 2 + * elif anyX: # <<<<<<<<<<<<<< + * model.nDims = 1 + * else: + */ + goto __pyx_L8; + } + + /* "pynastranIO.pyx":130 + * model.nDims = 1 + * else: + * model.nDims = 0 # <<<<<<<<<<<<<< + * + * return nodes + */ + /*else*/ { + __pyx_v_model->nDims = 0; + } + __pyx_L8:; + + /* "pynastranIO.pyx":132 + * model.nDims = 0 + * + * return nodes # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __pyx_v_nodes; + goto __pyx_L0; + + /* "pynastranIO.pyx":79 + * + * + * cdef public vector[vector[double]] getNodes(BDFModel model): # <<<<<<<<<<<<<< + * """ + * Creates a vector of vectors where each row is the node id and coordinates of + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_WriteUnraisable("pynastranIO.getNodes", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); + __Pyx_pretend_to_initialize(&__pyx_r); + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_key); + __Pyx_XDECREF(__pyx_v_node); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "pynastranIO.pyx":135 + * + * + * cdef public map[string, vector[vector[int]]] getElements(BDFModel model): # <<<<<<<<<<<<<< + * """ + * Creates a map of the elements contained in the model. The keys of the map are the element type and the values + */ + +std::map > > getElements(struct BDFModel *__pyx_v_model) { + CYTHON_UNUSED int __pyx_v_n; + std::map > > __pyx_v_elementMap; + std::map __pyx_v_elemTypes; + std::map __pyx_v_i_counter; + std::map ::iterator __pyx_v_it; + std::vector __pyx_v_elem_vec; + int __pyx_v_m; + int __pyx_v_nElemNodes; + PyObject *__pyx_v_elemType = NULL; + int __pyx_v_nElemTypes; + CYTHON_UNUSED PyObject *__pyx_v_mapKeys = NULL; + int __pyx_v_i; + int __pyx_v_j; + CYTHON_UNUSED PyObject *__pyx_v_key = NULL; + PyObject *__pyx_v_element = NULL; + std::map > > __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + std::vector __pyx_t_6; + std::vector > __pyx_t_7; + std::string __pyx_t_8; + Py_ssize_t __pyx_t_9; + Py_ssize_t __pyx_t_10; + int __pyx_t_11; + PyObject *__pyx_t_12 = NULL; + int __pyx_t_13; + Py_ssize_t __pyx_t_14; + PyObject *__pyx_t_15 = NULL; + int __pyx_t_16; + int __pyx_t_17; + int __pyx_t_18; + std::string __pyx_t_19; + __Pyx_RefNannySetupContext("getElements", 0); + + /* "pynastranIO.pyx":140 + * of the map is a 2D vector (vector of vector) which stores element ID, property ID, and node numbers. + * """ + * cdef int n = model.nElems # Number of elements # <<<<<<<<<<<<<< + * + * cdef map[string, vector[vector[int]]] elementMap; + */ + __pyx_t_1 = __pyx_v_model->nElems; + __pyx_v_n = __pyx_t_1; + + /* "pynastranIO.pyx":145 + * + * # Pre-allocate space to store the element information + * cdef map[string, int] elemTypes = getNumberOfElementTypes(model) # <<<<<<<<<<<<<< + * cdef map[string, int] i_counter + * cdef map[string, int].iterator it = elemTypes.begin() + */ + __pyx_v_elemTypes = getNumberOfElementTypes(__pyx_v_model); + + /* "pynastranIO.pyx":147 + * cdef map[string, int] elemTypes = getNumberOfElementTypes(model) + * cdef map[string, int] i_counter + * cdef map[string, int].iterator it = elemTypes.begin() # <<<<<<<<<<<<<< + * cdef vector[int] elem_vec + * cdef vector[vector[int]] elements + */ + __pyx_v_it = __pyx_v_elemTypes.begin(); + + /* "pynastranIO.pyx":151 + * cdef vector[vector[int]] elements + * cdef int m, nElemNodes + * while(it != elemTypes.end()): # <<<<<<<<<<<<<< + * # print(dereference(it).first) # print the key + * # print(dereference(it).second) # print the associated value + */ + while (1) { + __pyx_t_2 = ((__pyx_v_it != __pyx_v_elemTypes.end()) != 0); + if (!__pyx_t_2) break; + + /* "pynastranIO.pyx":154 + * # print(dereference(it).first) # print the key + * # print(dereference(it).second) # print the associated value + * elemType = dereference(it).first # <<<<<<<<<<<<<< + * nElemTypes = dereference(it).second + * nElemNodes = int(str(elemType).split("_")[-1].strip("'")) + */ + __pyx_t_3 = __pyx_convert_PyBytes_string_to_py_std__in_string((*__pyx_v_it).first); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 154, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_XDECREF_SET(__pyx_v_elemType, __pyx_t_3); + __pyx_t_3 = 0; + + /* "pynastranIO.pyx":155 + * # print(dereference(it).second) # print the associated value + * elemType = dereference(it).first + * nElemTypes = dereference(it).second # <<<<<<<<<<<<<< + * nElemNodes = int(str(elemType).split("_")[-1].strip("'")) + * m = nElemNodes+2 + */ + __pyx_t_1 = (*__pyx_v_it).second; + __pyx_v_nElemTypes = __pyx_t_1; + + /* "pynastranIO.pyx":156 + * elemType = dereference(it).first + * nElemTypes = dereference(it).second + * nElemNodes = int(str(elemType).split("_")[-1].strip("'")) # <<<<<<<<<<<<<< + * m = nElemNodes+2 + * + */ + __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_v_elemType); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 156, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyUnicode_Split(((PyObject*)__pyx_t_4), __pyx_n_u__3, -1L); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 156, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetItemInt_List(__pyx_t_5, -1L, long, 1, __Pyx_PyInt_From_long, 1, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 156, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_strip); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 156, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_5, function); + } + } + __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_4, __pyx_kp_u__4) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_kp_u__4); + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 156, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyNumber_Int(__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 156, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 156, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_v_nElemNodes = __pyx_t_1; + + /* "pynastranIO.pyx":157 + * nElemTypes = dereference(it).second + * nElemNodes = int(str(elemType).split("_")[-1].strip("'")) + * m = nElemNodes+2 # <<<<<<<<<<<<<< + * + * elem_vec = vector[int](m) + */ + __pyx_v_m = (__pyx_v_nElemNodes + 2); + + /* "pynastranIO.pyx":159 + * m = nElemNodes+2 + * + * elem_vec = vector[int](m) # <<<<<<<<<<<<<< + * elementMap[elemType] = vector[vector[int]](nElemTypes, elem_vec) + * + */ + try { + __pyx_t_6 = std::vector (__pyx_v_m); + } catch(...) { + __Pyx_CppExn2PyErr(); + __PYX_ERR(1, 159, __pyx_L1_error) + } + __pyx_v_elem_vec = __pyx_t_6; + + /* "pynastranIO.pyx":160 + * + * elem_vec = vector[int](m) + * elementMap[elemType] = vector[vector[int]](nElemTypes, elem_vec) # <<<<<<<<<<<<<< + * + * i_counter[elemType] = 0 + */ + try { + __pyx_t_7 = std::vector > (__pyx_v_nElemTypes, __pyx_v_elem_vec); + } catch(...) { + __Pyx_CppExn2PyErr(); + __PYX_ERR(1, 160, __pyx_L1_error) + } + __pyx_t_8 = __pyx_convert_string_from_py_std__in_string(__pyx_v_elemType); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 160, __pyx_L1_error) + (__pyx_v_elementMap[__pyx_t_8]) = __pyx_t_7; + + /* "pynastranIO.pyx":162 + * elementMap[elemType] = vector[vector[int]](nElemTypes, elem_vec) + * + * i_counter[elemType] = 0 # <<<<<<<<<<<<<< + * + * postincrement(it) # Increment the iterator to the net element + */ + __pyx_t_8 = __pyx_convert_string_from_py_std__in_string(__pyx_v_elemType); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 162, __pyx_L1_error) + (__pyx_v_i_counter[__pyx_t_8]) = 0; + + /* "pynastranIO.pyx":164 + * i_counter[elemType] = 0 + * + * postincrement(it) # Increment the iterator to the net element # <<<<<<<<<<<<<< + * mapKeys = [] + * + */ + (void)((__pyx_v_it++)); + } + + /* "pynastranIO.pyx":165 + * + * postincrement(it) # Increment the iterator to the net element + * mapKeys = [] # <<<<<<<<<<<<<< + * + * # Loop through the elements in the BDF and all the to element map + */ + __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 165, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_v_mapKeys = ((PyObject*)__pyx_t_5); + __pyx_t_5 = 0; + + /* "pynastranIO.pyx":170 + * cdef int i + * cdef int j + * for key,element in model.myBDF.elements.items(): # <<<<<<<<<<<<<< + * if "offset" in element.object_attributes(): + * if element.offset!=0: + */ + __pyx_t_9 = 0; + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_model->myBDF, __pyx_n_s_elements); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 170, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + if (unlikely(__pyx_t_3 == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); + __PYX_ERR(1, 170, __pyx_L1_error) + } + __pyx_t_4 = __Pyx_dict_iterator(__pyx_t_3, 0, __pyx_n_s_items, (&__pyx_t_10), (&__pyx_t_1)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 170, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_XDECREF(__pyx_t_5); + __pyx_t_5 = __pyx_t_4; + __pyx_t_4 = 0; + while (1) { + __pyx_t_11 = __Pyx_dict_iter_next(__pyx_t_5, __pyx_t_10, &__pyx_t_9, &__pyx_t_4, &__pyx_t_3, NULL, __pyx_t_1); + if (unlikely(__pyx_t_11 == 0)) break; + if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(1, 170, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GOTREF(__pyx_t_3); + __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_4); + __pyx_t_4 = 0; + __Pyx_XDECREF_SET(__pyx_v_element, __pyx_t_3); + __pyx_t_3 = 0; + + /* "pynastranIO.pyx":171 + * cdef int j + * for key,element in model.myBDF.elements.items(): + * if "offset" in element.object_attributes(): # <<<<<<<<<<<<<< + * if element.offset!=0: + * raise NotImplementedError("Support of non-zero offsets not yet implemented!") + */ + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_element, __pyx_n_s_object_attributes); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 171, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_12 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_12)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_12); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + __pyx_t_3 = (__pyx_t_12) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_12) : __Pyx_PyObject_CallNoArg(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; + if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 171, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_n_u_offset, __pyx_t_3, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 171, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_13 = (__pyx_t_2 != 0); + if (__pyx_t_13) { + + /* "pynastranIO.pyx":172 + * for key,element in model.myBDF.elements.items(): + * if "offset" in element.object_attributes(): + * if element.offset!=0: # <<<<<<<<<<<<<< + * raise NotImplementedError("Support of non-zero offsets not yet implemented!") + * if "zoffset" in element.object_attributes(): + */ + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_element, __pyx_n_s_offset); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 172, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyInt_NeObjC(__pyx_t_3, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 172, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(1, 172, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(__pyx_t_13)) { + + /* "pynastranIO.pyx":173 + * if "offset" in element.object_attributes(): + * if element.offset!=0: + * raise NotImplementedError("Support of non-zero offsets not yet implemented!") # <<<<<<<<<<<<<< + * if "zoffset" in element.object_attributes(): + * if element.zoffset!=0: + */ + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 173, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __PYX_ERR(1, 173, __pyx_L1_error) + + /* "pynastranIO.pyx":172 + * for key,element in model.myBDF.elements.items(): + * if "offset" in element.object_attributes(): + * if element.offset!=0: # <<<<<<<<<<<<<< + * raise NotImplementedError("Support of non-zero offsets not yet implemented!") + * if "zoffset" in element.object_attributes(): + */ + } + + /* "pynastranIO.pyx":171 + * cdef int j + * for key,element in model.myBDF.elements.items(): + * if "offset" in element.object_attributes(): # <<<<<<<<<<<<<< + * if element.offset!=0: + * raise NotImplementedError("Support of non-zero offsets not yet implemented!") + */ + } + + /* "pynastranIO.pyx":174 + * if element.offset!=0: + * raise NotImplementedError("Support of non-zero offsets not yet implemented!") + * if "zoffset" in element.object_attributes(): # <<<<<<<<<<<<<< + * if element.zoffset!=0: + * raise NotImplementedError("Support of non-zero offets not yet implemented!") + */ + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_element, __pyx_n_s_object_attributes); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 174, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_12 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_12)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_12); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + __pyx_t_4 = (__pyx_t_12) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_12) : __Pyx_PyObject_CallNoArg(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; + if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 174, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_13 = (__Pyx_PySequence_ContainsTF(__pyx_n_u_zoffset, __pyx_t_4, Py_EQ)); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(1, 174, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_2 = (__pyx_t_13 != 0); + if (__pyx_t_2) { + + /* "pynastranIO.pyx":175 + * raise NotImplementedError("Support of non-zero offsets not yet implemented!") + * if "zoffset" in element.object_attributes(): + * if element.zoffset!=0: # <<<<<<<<<<<<<< + * raise NotImplementedError("Support of non-zero offets not yet implemented!") + * nElemNodes = len(element.nodes) + */ + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_element, __pyx_n_s_zoffset); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 175, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = __Pyx_PyInt_NeObjC(__pyx_t_4, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 175, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 175, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(__pyx_t_2)) { + + /* "pynastranIO.pyx":176 + * if "zoffset" in element.object_attributes(): + * if element.zoffset!=0: + * raise NotImplementedError("Support of non-zero offets not yet implemented!") # <<<<<<<<<<<<<< + * nElemNodes = len(element.nodes) + * elemType = (element.type + "_%i"%(nElemNodes)).encode('utf-8') + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 176, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 176, __pyx_L1_error) + + /* "pynastranIO.pyx":175 + * raise NotImplementedError("Support of non-zero offsets not yet implemented!") + * if "zoffset" in element.object_attributes(): + * if element.zoffset!=0: # <<<<<<<<<<<<<< + * raise NotImplementedError("Support of non-zero offets not yet implemented!") + * nElemNodes = len(element.nodes) + */ + } + + /* "pynastranIO.pyx":174 + * if element.offset!=0: + * raise NotImplementedError("Support of non-zero offsets not yet implemented!") + * if "zoffset" in element.object_attributes(): # <<<<<<<<<<<<<< + * if element.zoffset!=0: + * raise NotImplementedError("Support of non-zero offets not yet implemented!") + */ + } + + /* "pynastranIO.pyx":177 + * if element.zoffset!=0: + * raise NotImplementedError("Support of non-zero offets not yet implemented!") + * nElemNodes = len(element.nodes) # <<<<<<<<<<<<<< + * elemType = (element.type + "_%i"%(nElemNodes)).encode('utf-8') + * i = i_counter[elemType] + */ + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_element, __pyx_n_s_nodes); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 177, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_14 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_14 == ((Py_ssize_t)-1))) __PYX_ERR(1, 177, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_nElemNodes = __pyx_t_14; + + /* "pynastranIO.pyx":178 + * raise NotImplementedError("Support of non-zero offets not yet implemented!") + * nElemNodes = len(element.nodes) + * elemType = (element.type + "_%i"%(nElemNodes)).encode('utf-8') # <<<<<<<<<<<<<< + * i = i_counter[elemType] + * elementMap[elemType][i][0] = element.eid + */ + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_element, __pyx_n_s_type); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 178, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_nElemNodes); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 178, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_15 = PyUnicode_Format(__pyx_kp_u_i, __pyx_t_12); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 178, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = PyNumber_Add(__pyx_t_4, __pyx_t_15); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 178, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_encode); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 178, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_15))) { + __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_15); + if (likely(__pyx_t_12)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15); + __Pyx_INCREF(__pyx_t_12); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_15, function); + } + } + __pyx_t_3 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_15, __pyx_t_12, __pyx_kp_u_utf_8) : __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_kp_u_utf_8); + __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; + if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 178, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __Pyx_XDECREF_SET(__pyx_v_elemType, __pyx_t_3); + __pyx_t_3 = 0; + + /* "pynastranIO.pyx":179 + * nElemNodes = len(element.nodes) + * elemType = (element.type + "_%i"%(nElemNodes)).encode('utf-8') + * i = i_counter[elemType] # <<<<<<<<<<<<<< + * elementMap[elemType][i][0] = element.eid + * elementMap[elemType][i][1] = element.pid + */ + __pyx_t_8 = __pyx_convert_string_from_py_std__in_string(__pyx_v_elemType); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 179, __pyx_L1_error) + __pyx_v_i = (__pyx_v_i_counter[__pyx_t_8]); + + /* "pynastranIO.pyx":180 + * elemType = (element.type + "_%i"%(nElemNodes)).encode('utf-8') + * i = i_counter[elemType] + * elementMap[elemType][i][0] = element.eid # <<<<<<<<<<<<<< + * elementMap[elemType][i][1] = element.pid + * for j in range(nElemNodes): + */ + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_element, __pyx_n_s_eid); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 180, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 180, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_8 = __pyx_convert_string_from_py_std__in_string(__pyx_v_elemType); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 180, __pyx_L1_error) + (((__pyx_v_elementMap[__pyx_t_8])[__pyx_v_i])[0]) = __pyx_t_11; + + /* "pynastranIO.pyx":181 + * i = i_counter[elemType] + * elementMap[elemType][i][0] = element.eid + * elementMap[elemType][i][1] = element.pid # <<<<<<<<<<<<<< + * for j in range(nElemNodes): + * elementMap[elemType][i][j+2] = element.nodes[j] + */ + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_element, __pyx_n_s_pid); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 181, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 181, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_8 = __pyx_convert_string_from_py_std__in_string(__pyx_v_elemType); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 181, __pyx_L1_error) + (((__pyx_v_elementMap[__pyx_t_8])[__pyx_v_i])[1]) = __pyx_t_11; + + /* "pynastranIO.pyx":182 + * elementMap[elemType][i][0] = element.eid + * elementMap[elemType][i][1] = element.pid + * for j in range(nElemNodes): # <<<<<<<<<<<<<< + * elementMap[elemType][i][j+2] = element.nodes[j] + * i_counter[elemType] = i_counter[elemType]+1 + */ + __pyx_t_11 = __pyx_v_nElemNodes; + __pyx_t_16 = __pyx_t_11; + for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) { + __pyx_v_j = __pyx_t_17; + + /* "pynastranIO.pyx":183 + * elementMap[elemType][i][1] = element.pid + * for j in range(nElemNodes): + * elementMap[elemType][i][j+2] = element.nodes[j] # <<<<<<<<<<<<<< + * i_counter[elemType] = i_counter[elemType]+1 + * + */ + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_element, __pyx_n_s_nodes); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 183, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_15 = __Pyx_GetItemInt(__pyx_t_3, __pyx_v_j, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 183, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_18 = __Pyx_PyInt_As_int(__pyx_t_15); if (unlikely((__pyx_t_18 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 183, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __pyx_t_8 = __pyx_convert_string_from_py_std__in_string(__pyx_v_elemType); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 183, __pyx_L1_error) + (((__pyx_v_elementMap[__pyx_t_8])[__pyx_v_i])[(__pyx_v_j + 2)]) = __pyx_t_18; + } + + /* "pynastranIO.pyx":184 + * for j in range(nElemNodes): + * elementMap[elemType][i][j+2] = element.nodes[j] + * i_counter[elemType] = i_counter[elemType]+1 # <<<<<<<<<<<<<< + * + * return elementMap + */ + __pyx_t_8 = __pyx_convert_string_from_py_std__in_string(__pyx_v_elemType); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 184, __pyx_L1_error) + __pyx_t_19 = __pyx_convert_string_from_py_std__in_string(__pyx_v_elemType); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 184, __pyx_L1_error) + (__pyx_v_i_counter[__pyx_t_19]) = ((__pyx_v_i_counter[__pyx_t_8]) + 1); + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + + /* "pynastranIO.pyx":186 + * i_counter[elemType] = i_counter[elemType]+1 + * + * return elementMap # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __pyx_v_elementMap; + goto __pyx_L0; + + /* "pynastranIO.pyx":135 + * + * + * cdef public map[string, vector[vector[int]]] getElements(BDFModel model): # <<<<<<<<<<<<<< + * """ + * Creates a map of the elements contained in the model. The keys of the map are the element type and the values + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_12); + __Pyx_XDECREF(__pyx_t_15); + __Pyx_WriteUnraisable("pynastranIO.getElements", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); + __Pyx_pretend_to_initialize(&__pyx_r); + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_elemType); + __Pyx_XDECREF(__pyx_v_mapKeys); + __Pyx_XDECREF(__pyx_v_key); + __Pyx_XDECREF(__pyx_v_element); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "pynastranIO.pyx":189 + * + * + * cdef public map[string, int] getNumberOfElementTypes(BDFModel model): # <<<<<<<<<<<<<< + * """ + * Gets a map of the different element types and the number of each element type in the model. Useful for + */ + +std::map getNumberOfElementTypes(struct BDFModel *__pyx_v_model) { + std::map __pyx_v_elementTypes; + PyObject *__pyx_v_elemTypeList = NULL; + CYTHON_UNUSED PyObject *__pyx_v_key = NULL; + PyObject *__pyx_v_element = NULL; + PyObject *__pyx_v_elemType = NULL; + std::map __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; + Py_ssize_t __pyx_t_3; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + PyObject *__pyx_t_8 = NULL; + Py_ssize_t __pyx_t_9; + PyObject *__pyx_t_10 = NULL; + int __pyx_t_11; + int __pyx_t_12; + int __pyx_t_13; + std::string __pyx_t_14; + __Pyx_RefNannySetupContext("getNumberOfElementTypes", 0); + + /* "pynastranIO.pyx":195 + * """ + * cdef map[string, int] elementTypes + * elemTypeList = [] # <<<<<<<<<<<<<< + * for key, element in model.myBDF.elements.items(): + * elemType = (element.type + "_%i"%(len(element.nodes))).encode("utf-8") + */ + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 195, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_elemTypeList = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "pynastranIO.pyx":196 + * cdef map[string, int] elementTypes + * elemTypeList = [] + * for key, element in model.myBDF.elements.items(): # <<<<<<<<<<<<<< + * elemType = (element.type + "_%i"%(len(element.nodes))).encode("utf-8") + * if elemType not in elemTypeList: + */ + __pyx_t_2 = 0; + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_model->myBDF, __pyx_n_s_elements); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 196, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + if (unlikely(__pyx_t_5 == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); + __PYX_ERR(1, 196, __pyx_L1_error) + } + __pyx_t_6 = __Pyx_dict_iterator(__pyx_t_5, 0, __pyx_n_s_items, (&__pyx_t_3), (&__pyx_t_4)); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 196, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_XDECREF(__pyx_t_1); + __pyx_t_1 = __pyx_t_6; + __pyx_t_6 = 0; + while (1) { + __pyx_t_7 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_3, &__pyx_t_2, &__pyx_t_6, &__pyx_t_5, NULL, __pyx_t_4); + if (unlikely(__pyx_t_7 == 0)) break; + if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(1, 196, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GOTREF(__pyx_t_5); + __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_6); + __pyx_t_6 = 0; + __Pyx_XDECREF_SET(__pyx_v_element, __pyx_t_5); + __pyx_t_5 = 0; + + /* "pynastranIO.pyx":197 + * elemTypeList = [] + * for key, element in model.myBDF.elements.items(): + * elemType = (element.type + "_%i"%(len(element.nodes))).encode("utf-8") # <<<<<<<<<<<<<< + * if elemType not in elemTypeList: + * elemTypeList.append(elemType) + */ + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_element, __pyx_n_s_type); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 197, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_element, __pyx_n_s_nodes); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 197, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_9 = PyObject_Length(__pyx_t_8); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(1, 197, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = PyInt_FromSsize_t(__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 197, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_10 = PyUnicode_Format(__pyx_kp_u_i, __pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 197, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = PyNumber_Add(__pyx_t_6, __pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 197, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_encode); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 197, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) { + __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_10); + if (likely(__pyx_t_8)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); + __Pyx_INCREF(__pyx_t_8); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_10, function); + } + } + __pyx_t_5 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_8, __pyx_kp_u_utf_8) : __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_kp_u_utf_8); + __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; + if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 197, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_XDECREF_SET(__pyx_v_elemType, __pyx_t_5); + __pyx_t_5 = 0; + + /* "pynastranIO.pyx":198 + * for key, element in model.myBDF.elements.items(): + * elemType = (element.type + "_%i"%(len(element.nodes))).encode("utf-8") + * if elemType not in elemTypeList: # <<<<<<<<<<<<<< + * elemTypeList.append(elemType) + * elementTypes[elemType] = 1 + */ + __pyx_t_11 = (__Pyx_PySequence_ContainsTF(__pyx_v_elemType, __pyx_v_elemTypeList, Py_NE)); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(1, 198, __pyx_L1_error) + __pyx_t_12 = (__pyx_t_11 != 0); + if (__pyx_t_12) { + + /* "pynastranIO.pyx":199 + * elemType = (element.type + "_%i"%(len(element.nodes))).encode("utf-8") + * if elemType not in elemTypeList: + * elemTypeList.append(elemType) # <<<<<<<<<<<<<< + * elementTypes[elemType] = 1 + * else: + */ + __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_elemTypeList, __pyx_v_elemType); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(1, 199, __pyx_L1_error) + + /* "pynastranIO.pyx":200 + * if elemType not in elemTypeList: + * elemTypeList.append(elemType) + * elementTypes[elemType] = 1 # <<<<<<<<<<<<<< + * else: + * elementTypes[elemType] += 1 + */ + __pyx_t_14 = __pyx_convert_string_from_py_std__in_string(__pyx_v_elemType); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 200, __pyx_L1_error) + (__pyx_v_elementTypes[__pyx_t_14]) = 1; + + /* "pynastranIO.pyx":198 + * for key, element in model.myBDF.elements.items(): + * elemType = (element.type + "_%i"%(len(element.nodes))).encode("utf-8") + * if elemType not in elemTypeList: # <<<<<<<<<<<<<< + * elemTypeList.append(elemType) + * elementTypes[elemType] = 1 + */ + goto __pyx_L5; + } + + /* "pynastranIO.pyx":202 + * elementTypes[elemType] = 1 + * else: + * elementTypes[elemType] += 1 # <<<<<<<<<<<<<< + * + * model.nElemTypes = elementTypes + */ + /*else*/ { + __pyx_t_14 = __pyx_convert_string_from_py_std__in_string(__pyx_v_elemType); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 202, __pyx_L1_error) + (__pyx_v_elementTypes[__pyx_t_14]) = ((__pyx_v_elementTypes[__pyx_t_14]) + 1); + } + __pyx_L5:; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "pynastranIO.pyx":204 + * elementTypes[elemType] += 1 + * + * model.nElemTypes = elementTypes # <<<<<<<<<<<<<< + * return elementTypes + * + */ + __pyx_v_model->nElemTypes = __pyx_v_elementTypes; + + /* "pynastranIO.pyx":205 + * + * model.nElemTypes = elementTypes + * return elementTypes # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __pyx_v_elementTypes; + goto __pyx_L0; + + /* "pynastranIO.pyx":189 + * + * + * cdef public map[string, int] getNumberOfElementTypes(BDFModel model): # <<<<<<<<<<<<<< + * """ + * Gets a map of the different element types and the number of each element type in the model. Useful for + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_WriteUnraisable("pynastranIO.getNumberOfElementTypes", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); + __Pyx_pretend_to_initialize(&__pyx_r); + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_elemTypeList); + __Pyx_XDECREF(__pyx_v_key); + __Pyx_XDECREF(__pyx_v_element); + __Pyx_XDECREF(__pyx_v_elemType); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "pynastranIO.pyx":208 + * + * + * cdef perturbZeroLengthBushings(BDFModel model): # <<<<<<<<<<<<<< + * """ + * As of November 18, 2019, MAST does not support the specification of the elemental x-axis which is required when + */ + +static PyObject *__pyx_f_11pynastranIO_perturbZeroLengthBushings(struct BDFModel *__pyx_v_model) { + int __pyx_v_k; + double __pyx_v_eps; + double __pyx_v_nzero; + double __pyx_v_L; + PyObject *__pyx_v_data = NULL; + PyObject *__pyx_v_eids = NULL; + PyObject *__pyx_v_eid = NULL; + PyObject *__pyx_v_bushing = NULL; + PyObject *__pyx_v_i = NULL; + PyObject *__pyx_v_di = NULL; + PyObject *__pyx_v_absmindi = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + int __pyx_t_5; + Py_ssize_t __pyx_t_6; + Py_ssize_t __pyx_t_7; + int __pyx_t_8; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + double __pyx_t_11; + __Pyx_RefNannySetupContext("perturbZeroLengthBushings", 0); + + /* "pynastranIO.pyx":219 + * cdef int k + * cdef double eps, nzero, L + * eps=1.4901161193847656e-08 # <<<<<<<<<<<<<< + * nzero=1e-08 + * + */ + __pyx_v_eps = 1.4901161193847656e-08; + + /* "pynastranIO.pyx":220 + * cdef double eps, nzero, L + * eps=1.4901161193847656e-08 + * nzero=1e-08 # <<<<<<<<<<<<<< + * + * # Get element IDs of bushing elements + */ + __pyx_v_nzero = 1e-08; + + /* "pynastranIO.pyx":223 + * + * # Get element IDs of bushing elements + * data = model.myBDF.get_elements_properties_nodes_by_element_type() # <<<<<<<<<<<<<< + * eids = [] + * if "CBUSH" in data.keys(): + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_model->myBDF, __pyx_n_s_get_elements_properties_nodes_by); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 223, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 223, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_v_data = __pyx_t_1; + __pyx_t_1 = 0; + + /* "pynastranIO.pyx":224 + * # Get element IDs of bushing elements + * data = model.myBDF.get_elements_properties_nodes_by_element_type() + * eids = [] # <<<<<<<<<<<<<< + * if "CBUSH" in data.keys(): + * eids += (data["CBUSH"][0]).tolist() + */ + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 224, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_eids = __pyx_t_1; + __pyx_t_1 = 0; + + /* "pynastranIO.pyx":225 + * data = model.myBDF.get_elements_properties_nodes_by_element_type() + * eids = [] + * if "CBUSH" in data.keys(): # <<<<<<<<<<<<<< + * eids += (data["CBUSH"][0]).tolist() + * if "CBUSH1D" in data.keys(): + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_keys); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 225, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 225, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_n_u_CBUSH, __pyx_t_1, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(1, 225, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_5 = (__pyx_t_4 != 0); + if (__pyx_t_5) { + + /* "pynastranIO.pyx":226 + * eids = [] + * if "CBUSH" in data.keys(): + * eids += (data["CBUSH"][0]).tolist() # <<<<<<<<<<<<<< + * if "CBUSH1D" in data.keys(): + * eids += (data["CBUSH1D"][0]).tolist() + */ + __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_CBUSH); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 226, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 226, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_tolist); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 226, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 226, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_eids, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 226, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF_SET(__pyx_v_eids, __pyx_t_2); + __pyx_t_2 = 0; + + /* "pynastranIO.pyx":225 + * data = model.myBDF.get_elements_properties_nodes_by_element_type() + * eids = [] + * if "CBUSH" in data.keys(): # <<<<<<<<<<<<<< + * eids += (data["CBUSH"][0]).tolist() + * if "CBUSH1D" in data.keys(): + */ + } + + /* "pynastranIO.pyx":227 + * if "CBUSH" in data.keys(): + * eids += (data["CBUSH"][0]).tolist() + * if "CBUSH1D" in data.keys(): # <<<<<<<<<<<<<< + * eids += (data["CBUSH1D"][0]).tolist() + * if "CBUSH2D" in data.keys(): + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_keys); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 227, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); + } + } + __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 227, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_5 = (__Pyx_PySequence_ContainsTF(__pyx_n_u_CBUSH1D, __pyx_t_2, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(1, 227, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_4 = (__pyx_t_5 != 0); + if (__pyx_t_4) { + + /* "pynastranIO.pyx":228 + * eids += (data["CBUSH"][0]).tolist() + * if "CBUSH1D" in data.keys(): + * eids += (data["CBUSH1D"][0]).tolist() # <<<<<<<<<<<<<< + * if "CBUSH2D" in data.keys(): + * eids += (data["CBUSH2D"][0]).tolist() + */ + __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_CBUSH1D); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 228, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 228, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_tolist); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 228, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); + } + } + __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 228, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_eids, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 228, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF_SET(__pyx_v_eids, __pyx_t_1); + __pyx_t_1 = 0; + + /* "pynastranIO.pyx":227 + * if "CBUSH" in data.keys(): + * eids += (data["CBUSH"][0]).tolist() + * if "CBUSH1D" in data.keys(): # <<<<<<<<<<<<<< + * eids += (data["CBUSH1D"][0]).tolist() + * if "CBUSH2D" in data.keys(): + */ + } + + /* "pynastranIO.pyx":229 + * if "CBUSH1D" in data.keys(): + * eids += (data["CBUSH1D"][0]).tolist() + * if "CBUSH2D" in data.keys(): # <<<<<<<<<<<<<< + * eids += (data["CBUSH2D"][0]).tolist() + * + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_keys); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 229, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 229, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_n_u_CBUSH2D, __pyx_t_1, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(1, 229, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_5 = (__pyx_t_4 != 0); + if (__pyx_t_5) { + + /* "pynastranIO.pyx":230 + * eids += (data["CBUSH1D"][0]).tolist() + * if "CBUSH2D" in data.keys(): + * eids += (data["CBUSH2D"][0]).tolist() # <<<<<<<<<<<<<< + * + * # Loop through all bushing elements + */ + __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_CBUSH2D); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 230, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 230, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_tolist); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 230, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 230, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_eids, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 230, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF_SET(__pyx_v_eids, __pyx_t_2); + __pyx_t_2 = 0; + + /* "pynastranIO.pyx":229 + * if "CBUSH1D" in data.keys(): + * eids += (data["CBUSH1D"][0]).tolist() + * if "CBUSH2D" in data.keys(): # <<<<<<<<<<<<<< + * eids += (data["CBUSH2D"][0]).tolist() + * + */ + } + + /* "pynastranIO.pyx":233 + * + * # Loop through all bushing elements + * for k in range(len(eids)): # <<<<<<<<<<<<<< + * eid = eids[k] + * bushing = model.myBDF.elements[eid] + */ + __pyx_t_6 = PyObject_Length(__pyx_v_eids); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(1, 233, __pyx_L1_error) + __pyx_t_7 = __pyx_t_6; + for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { + __pyx_v_k = __pyx_t_8; + + /* "pynastranIO.pyx":234 + * # Loop through all bushing elements + * for k in range(len(eids)): + * eid = eids[k] # <<<<<<<<<<<<<< + * bushing = model.myBDF.elements[eid] + * L = np.linalg.norm(bushing.nodes_ref[1].xyz - bushing.nodes_ref[0].xyz) + */ + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_eids, __pyx_v_k, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 234, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_XDECREF_SET(__pyx_v_eid, __pyx_t_2); + __pyx_t_2 = 0; + + /* "pynastranIO.pyx":235 + * for k in range(len(eids)): + * eid = eids[k] + * bushing = model.myBDF.elements[eid] # <<<<<<<<<<<<<< + * L = np.linalg.norm(bushing.nodes_ref[1].xyz - bushing.nodes_ref[0].xyz) + * if abs(L)myBDF, __pyx_n_s_elements); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 235, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_v_eid); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 235, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF_SET(__pyx_v_bushing, __pyx_t_1); + __pyx_t_1 = 0; + + /* "pynastranIO.pyx":236 + * eid = eids[k] + * bushing = model.myBDF.elements[eid] + * L = np.linalg.norm(bushing.nodes_ref[1].xyz - bushing.nodes_ref[0].xyz) # <<<<<<<<<<<<<< + * if abs(L)0 and an x-axis can be defined by the geometry + */ + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 236, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_linalg); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 236, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_norm); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 236, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_bushing, __pyx_n_s_nodes_ref); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 236, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_9 = __Pyx_GetItemInt(__pyx_t_3, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 236, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_xyz); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 236, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_bushing, __pyx_n_s_nodes_ref); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 236, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_10 = __Pyx_GetItemInt(__pyx_t_9, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 236, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_xyz); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 236, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = PyNumber_Subtract(__pyx_t_3, __pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 236, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_9)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_9, __pyx_t_10) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_10); + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 236, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) __PYX_ERR(1, 236, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_L = __pyx_t_11; + + /* "pynastranIO.pyx":237 + * bushing = model.myBDF.elements[eid] + * L = np.linalg.norm(bushing.nodes_ref[1].xyz - bushing.nodes_ref[0].xyz) + * if abs(L)0 and an x-axis can be defined by the geometry + * i = bushing.cid_ref.i + */ + __pyx_t_5 = ((fabs(__pyx_v_L) < __pyx_v_nzero) != 0); + if (__pyx_t_5) { + + /* "pynastranIO.pyx":239 + * if abs(L)0 and an x-axis can be defined by the geometry + * i = bushing.cid_ref.i # <<<<<<<<<<<<<< + * di = eps*i + * absmindi = abs(di).min() + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_bushing, __pyx_n_s_cid_ref); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 239, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_i_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 239, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_2); + __pyx_t_2 = 0; + + /* "pynastranIO.pyx":240 + * # Slightly perturb the second node so that L>0 and an x-axis can be defined by the geometry + * i = bushing.cid_ref.i + * di = eps*i # <<<<<<<<<<<<<< + * absmindi = abs(di).min() + * if absmindimyBDF, __pyx_n_s_nodes); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 244, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_bushing, __pyx_n_s_nodes); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 244, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 244, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_t_10, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 244, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_xyz); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 244, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_10 = PyNumber_InPlaceAdd(__pyx_t_2, __pyx_v_di); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 244, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (__Pyx_PyObject_SetAttrStr(__pyx_t_1, __pyx_n_s_xyz, __pyx_t_10) < 0) __PYX_ERR(1, 244, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "pynastranIO.pyx":245 + * di *= (eps/absmindi) + * model.myBDF.nodes[bushing.nodes[1]].xyz += di + * print("Perturbing GRID %i by %s to define x-axis of zero-length element."%(bushing.nodes[1], di)) # <<<<<<<<<<<<<< + * + * # Define the orientation of the bushing + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_bushing, __pyx_n_s_nodes); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 245, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_10 = __Pyx_GetItemInt(__pyx_t_1, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 245, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 245, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_10); + __Pyx_INCREF(__pyx_v_di); + __Pyx_GIVEREF(__pyx_v_di); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_di); + __pyx_t_10 = 0; + __pyx_t_10 = PyUnicode_Format(__pyx_kp_u_Perturbing_GRID_i_by_s_to_define, __pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 245, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 245, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "pynastranIO.pyx":248 + * + * # Define the orientation of the bushing + * bushing.x = bushing.cid_ref.j.tolist() # <<<<<<<<<<<<<< + */ + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_bushing, __pyx_n_s_cid_ref); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 248, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_j); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 248, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tolist); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 248, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) { + __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_10); + if (likely(__pyx_t_2)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); + __Pyx_INCREF(__pyx_t_2); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_10, function); + } + } + __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_10); + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 248, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + if (__Pyx_PyObject_SetAttrStr(__pyx_v_bushing, __pyx_n_s_x, __pyx_t_1) < 0) __PYX_ERR(1, 248, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "pynastranIO.pyx":237 + * bushing = model.myBDF.elements[eid] + * L = np.linalg.norm(bushing.nodes_ref[1].xyz - bushing.nodes_ref[0].xyz) + * if abs(L)0 and an x-axis can be defined by the geometry + * i = bushing.cid_ref.i + */ + } + } + + /* "pynastranIO.pyx":208 + * + * + * cdef perturbZeroLengthBushings(BDFModel model): # <<<<<<<<<<<<<< + * """ + * As of November 18, 2019, MAST does not support the specification of the elemental x-axis which is required when + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_AddTraceback("pynastranIO.perturbZeroLengthBushings", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_data); + __Pyx_XDECREF(__pyx_v_eids); + __Pyx_XDECREF(__pyx_v_eid); + __Pyx_XDECREF(__pyx_v_bushing); + __Pyx_XDECREF(__pyx_v_i); + __Pyx_XDECREF(__pyx_v_di); + __Pyx_XDECREF(__pyx_v_absmindi); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":258 + * # experimental exception made for __getbuffer__ and __releasebuffer__ + * # -- the details of this may change. + * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< + * # This implementation of getbuffer is geared towards Cython + * # requirements, and does not yet fulfill the PEP. + */ + +/* Python wrapper */ +static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ +static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); + __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_v_i; + int __pyx_v_ndim; + int __pyx_v_endian_detector; + int __pyx_v_little_endian; + int __pyx_v_t; + char *__pyx_v_f; + PyArray_Descr *__pyx_v_descr = 0; + int __pyx_v_offset; + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + PyArray_Descr *__pyx_t_7; + PyObject *__pyx_t_8 = NULL; + char *__pyx_t_9; + if (__pyx_v_info == NULL) { + PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete"); + return -1; + } + __Pyx_RefNannySetupContext("__getbuffer__", 0); + __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(__pyx_v_info->obj); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":265 + * + * cdef int i, ndim + * cdef int endian_detector = 1 # <<<<<<<<<<<<<< + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * + */ + __pyx_v_endian_detector = 1; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":266 + * cdef int i, ndim + * cdef int endian_detector = 1 + * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< + * + * ndim = PyArray_NDIM(self) + */ + __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":268 + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * + * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + */ + __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 + * ndim = PyArray_NDIM(self) + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") + */ + __pyx_t_2 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L4_bool_binop_done; + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":271 + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< + * raise ValueError(u"ndarray is not C contiguous") + * + */ + __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_ARRAY_C_CONTIGUOUS) != 0)) != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L4_bool_binop_done:; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 + * ndim = PyArray_NDIM(self) + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") + */ + if (unlikely(__pyx_t_1)) { + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":272 + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 272, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(2, 272, __pyx_L1_error) + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 + * ndim = PyArray_NDIM(self) + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") + */ + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 + * raise ValueError(u"ndarray is not C contiguous") + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") + */ + __pyx_t_2 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L7_bool_binop_done; + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":275 + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< + * raise ValueError(u"ndarray is not Fortran contiguous") + * + */ + __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_ARRAY_F_CONTIGUOUS) != 0)) != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L7_bool_binop_done:; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 + * raise ValueError(u"ndarray is not C contiguous") + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") + */ + if (unlikely(__pyx_t_1)) { + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":276 + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< + * + * info.buf = PyArray_DATA(self) + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 276, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(2, 276, __pyx_L1_error) + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 + * raise ValueError(u"ndarray is not C contiguous") + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") + */ + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":278 + * raise ValueError(u"ndarray is not Fortran contiguous") + * + * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< + * info.ndim = ndim + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + */ + __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":279 + * + * info.buf = PyArray_DATA(self) + * info.ndim = ndim # <<<<<<<<<<<<<< + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * # Allocate new buffer for strides and shape info. + */ + __pyx_v_info->ndim = __pyx_v_ndim; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":280 + * info.buf = PyArray_DATA(self) + * info.ndim = ndim + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. + */ + __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); + if (__pyx_t_1) { + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":283 + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. + * info.strides = PyObject_Malloc(sizeof(Py_ssize_t) * 2 * ndim) # <<<<<<<<<<<<<< + * info.shape = info.strides + ndim + * for i in range(ndim): + */ + __pyx_v_info->strides = ((Py_ssize_t *)PyObject_Malloc((((sizeof(Py_ssize_t)) * 2) * ((size_t)__pyx_v_ndim)))); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":284 + * # This is allocated as one block, strides first. + * info.strides = PyObject_Malloc(sizeof(Py_ssize_t) * 2 * ndim) + * info.shape = info.strides + ndim # <<<<<<<<<<<<<< + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] + */ + __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":285 + * info.strides = PyObject_Malloc(sizeof(Py_ssize_t) * 2 * ndim) + * info.shape = info.strides + ndim + * for i in range(ndim): # <<<<<<<<<<<<<< + * info.strides[i] = PyArray_STRIDES(self)[i] + * info.shape[i] = PyArray_DIMS(self)[i] + */ + __pyx_t_4 = __pyx_v_ndim; + __pyx_t_5 = __pyx_t_4; + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_v_i = __pyx_t_6; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":286 + * info.shape = info.strides + ndim + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< + * info.shape[i] = PyArray_DIMS(self)[i] + * else: + */ + (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":287 + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] + * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< + * else: + * info.strides = PyArray_STRIDES(self) + */ + (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]); + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":280 + * info.buf = PyArray_DATA(self) + * info.ndim = ndim + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. + */ + goto __pyx_L9; + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":289 + * info.shape[i] = PyArray_DIMS(self)[i] + * else: + * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL + */ + /*else*/ { + __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":290 + * else: + * info.strides = PyArray_STRIDES(self) + * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) + */ + __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self)); + } + __pyx_L9:; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":291 + * info.strides = PyArray_STRIDES(self) + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL # <<<<<<<<<<<<<< + * info.itemsize = PyArray_ITEMSIZE(self) + * info.readonly = not PyArray_ISWRITEABLE(self) + */ + __pyx_v_info->suboffsets = NULL; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":292 + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< + * info.readonly = not PyArray_ISWRITEABLE(self) + * + */ + __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":293 + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) + * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< + * + * cdef int t + */ + __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0)); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":296 + * + * cdef int t + * cdef char* f = NULL # <<<<<<<<<<<<<< + * cdef dtype descr = PyArray_DESCR(self) + * cdef int offset + */ + __pyx_v_f = NULL; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":297 + * cdef int t + * cdef char* f = NULL + * cdef dtype descr = PyArray_DESCR(self) # <<<<<<<<<<<<<< + * cdef int offset + * + */ + __pyx_t_7 = PyArray_DESCR(__pyx_v_self); + __pyx_t_3 = ((PyObject *)__pyx_t_7); + __Pyx_INCREF(__pyx_t_3); + __pyx_v_descr = ((PyArray_Descr *)__pyx_t_3); + __pyx_t_3 = 0; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":300 + * cdef int offset + * + * info.obj = self # <<<<<<<<<<<<<< + * + * if not PyDataType_HASFIELDS(descr): + */ + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = ((PyObject *)__pyx_v_self); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":302 + * info.obj = self + * + * if not PyDataType_HASFIELDS(descr): # <<<<<<<<<<<<<< + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or + */ + __pyx_t_1 = ((!(PyDataType_HASFIELDS(__pyx_v_descr) != 0)) != 0); + if (__pyx_t_1) { + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":303 + * + * if not PyDataType_HASFIELDS(descr): + * t = descr.type_num # <<<<<<<<<<<<<< + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + */ + __pyx_t_4 = __pyx_v_descr->type_num; + __pyx_v_t = __pyx_t_4; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":304 + * if not PyDataType_HASFIELDS(descr): + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + __pyx_t_2 = ((__pyx_v_descr->byteorder == '>') != 0); + if (!__pyx_t_2) { + goto __pyx_L15_next_or; + } else { + } + __pyx_t_2 = (__pyx_v_little_endian != 0); + if (!__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L14_bool_binop_done; + } + __pyx_L15_next_or:; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":305 + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" + */ + __pyx_t_2 = ((__pyx_v_descr->byteorder == '<') != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L14_bool_binop_done; + } + __pyx_t_2 = ((!(__pyx_v_little_endian != 0)) != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L14_bool_binop_done:; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":304 + * if not PyDataType_HASFIELDS(descr): + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + if (unlikely(__pyx_t_1)) { + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":306 + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 306, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(2, 306, __pyx_L1_error) + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":304 + * if not PyDataType_HASFIELDS(descr): + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":307 + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" + */ + switch (__pyx_v_t) { + case NPY_BYTE: + __pyx_v_f = ((char *)"b"); + break; + case NPY_UBYTE: + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":308 + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" + */ + __pyx_v_f = ((char *)"B"); + break; + case NPY_SHORT: + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":309 + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" + */ + __pyx_v_f = ((char *)"h"); + break; + case NPY_USHORT: + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":310 + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" + */ + __pyx_v_f = ((char *)"H"); + break; + case NPY_INT: + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":311 + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" + */ + __pyx_v_f = ((char *)"i"); + break; + case NPY_UINT: + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":312 + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" + */ + __pyx_v_f = ((char *)"I"); + break; + case NPY_LONG: + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":313 + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" + */ + __pyx_v_f = ((char *)"l"); + break; + case NPY_ULONG: + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":314 + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" + */ + __pyx_v_f = ((char *)"L"); + break; + case NPY_LONGLONG: + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":315 + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" + */ + __pyx_v_f = ((char *)"q"); + break; + case NPY_ULONGLONG: + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":316 + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" + */ + __pyx_v_f = ((char *)"Q"); + break; + case NPY_FLOAT: + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":317 + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" + */ + __pyx_v_f = ((char *)"f"); + break; + case NPY_DOUBLE: + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":318 + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" + */ + __pyx_v_f = ((char *)"d"); + break; + case NPY_LONGDOUBLE: + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":319 + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" + */ + __pyx_v_f = ((char *)"g"); + break; + case NPY_CFLOAT: + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":320 + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<< + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" + */ + __pyx_v_f = ((char *)"Zf"); + break; + case NPY_CDOUBLE: + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":321 + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<< + * elif t == NPY_CLONGDOUBLE: f = "Zg" + * elif t == NPY_OBJECT: f = "O" + */ + __pyx_v_f = ((char *)"Zd"); + break; + case NPY_CLONGDOUBLE: + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":322 + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<< + * elif t == NPY_OBJECT: f = "O" + * else: + */ + __pyx_v_f = ((char *)"Zg"); + break; + case NPY_OBJECT: + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":323 + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" + * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + */ + __pyx_v_f = ((char *)"O"); + break; + default: + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":325 + * elif t == NPY_OBJECT: f = "O" + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< + * info.format = f + * return + */ + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 325, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_8 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 325, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 325, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(2, 325, __pyx_L1_error) + break; + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":326 + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * info.format = f # <<<<<<<<<<<<<< + * return + * else: + */ + __pyx_v_info->format = __pyx_v_f; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":327 + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * info.format = f + * return # <<<<<<<<<<<<<< + * else: + * info.format = PyObject_Malloc(_buffer_format_string_len) + */ + __pyx_r = 0; + goto __pyx_L0; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":302 + * info.obj = self + * + * if not PyDataType_HASFIELDS(descr): # <<<<<<<<<<<<<< + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or + */ + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":329 + * return + * else: + * info.format = PyObject_Malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 + */ + /*else*/ { + __pyx_v_info->format = ((char *)PyObject_Malloc(0xFF)); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":330 + * else: + * info.format = PyObject_Malloc(_buffer_format_string_len) + * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<< + * offset = 0 + * f = _util_dtypestring(descr, info.format + 1, + */ + (__pyx_v_info->format[0]) = '^'; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":331 + * info.format = PyObject_Malloc(_buffer_format_string_len) + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 # <<<<<<<<<<<<<< + * f = _util_dtypestring(descr, info.format + 1, + * info.format + _buffer_format_string_len, + */ + __pyx_v_offset = 0; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":332 + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 + * f = _util_dtypestring(descr, info.format + 1, # <<<<<<<<<<<<<< + * info.format + _buffer_format_string_len, + * &offset) + */ + __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 0xFF), (&__pyx_v_offset)); if (unlikely(__pyx_t_9 == ((char *)NULL))) __PYX_ERR(2, 332, __pyx_L1_error) + __pyx_v_f = __pyx_t_9; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":335 + * info.format + _buffer_format_string_len, + * &offset) + * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<< + * + * def __releasebuffer__(ndarray self, Py_buffer* info): + */ + (__pyx_v_f[0]) = '\x00'; + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":258 + * # experimental exception made for __getbuffer__ and __releasebuffer__ + * # -- the details of this may change. + * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< + * # This implementation of getbuffer is geared towards Cython + * # requirements, and does not yet fulfill the PEP. + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + if (__pyx_v_info->obj != NULL) { + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0; + } + goto __pyx_L2; + __pyx_L0:; + if (__pyx_v_info->obj == Py_None) { + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0; + } + __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_descr); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":337 + * f[0] = c'\0' # Terminate format string + * + * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< + * if PyArray_HASFIELDS(self): + * PyObject_Free(info.format) + */ + +/* Python wrapper */ +static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/ +static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0); + __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) { + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("__releasebuffer__", 0); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":338 + * + * def __releasebuffer__(ndarray self, Py_buffer* info): + * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< + * PyObject_Free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + */ + __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0); + if (__pyx_t_1) { + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":339 + * def __releasebuffer__(ndarray self, Py_buffer* info): + * if PyArray_HASFIELDS(self): + * PyObject_Free(info.format) # <<<<<<<<<<<<<< + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * PyObject_Free(info.strides) + */ + PyObject_Free(__pyx_v_info->format); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":338 + * + * def __releasebuffer__(ndarray self, Py_buffer* info): + * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< + * PyObject_Free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + */ + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":340 + * if PyArray_HASFIELDS(self): + * PyObject_Free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * PyObject_Free(info.strides) + * # info.shape was stored after info.strides in the same block + */ + __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); + if (__pyx_t_1) { + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":341 + * PyObject_Free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * PyObject_Free(info.strides) # <<<<<<<<<<<<<< + * # info.shape was stored after info.strides in the same block + * + */ + PyObject_Free(__pyx_v_info->strides); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":340 + * if PyArray_HASFIELDS(self): + * PyObject_Free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * PyObject_Free(info.strides) + * # info.shape was stored after info.strides in the same block + */ + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":337 + * f[0] = c'\0' # Terminate format string + * + * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< + * if PyArray_HASFIELDS(self): + * PyObject_Free(info.format) + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":821 + * ctypedef npy_cdouble complex_t + * + * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(1, a) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":822 + * + * cdef inline object PyArray_MultiIterNew1(a): + * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew2(a, b): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 822, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":821 + * ctypedef npy_cdouble complex_t + * + * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(1, a) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":824 + * return PyArray_MultiIterNew(1, a) + * + * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(2, a, b) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":825 + * + * cdef inline object PyArray_MultiIterNew2(a, b): + * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 825, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":824 + * return PyArray_MultiIterNew(1, a) + * + * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(2, a, b) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":827 + * return PyArray_MultiIterNew(2, a, b) + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(3, a, b, c) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":828 + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): + * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 828, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":827 + * return PyArray_MultiIterNew(2, a, b) + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(3, a, b, c) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":830 + * return PyArray_MultiIterNew(3, a, b, c) + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(4, a, b, c, d) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":831 + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): + * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 831, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":830 + * return PyArray_MultiIterNew(3, a, b, c) + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(4, a, b, c, d) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":833 + * return PyArray_MultiIterNew(4, a, b, c, d) + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":834 + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): + * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< + * + * cdef inline tuple PyDataType_SHAPE(dtype d): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 834, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":833 + * return PyArray_MultiIterNew(4, a, b, c, d) + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":836 + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< + * if PyDataType_HASSUBARRAY(d): + * return d.subarray.shape + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__pyx_v_d) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("PyDataType_SHAPE", 0); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":837 + * + * cdef inline tuple PyDataType_SHAPE(dtype d): + * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< + * return d.subarray.shape + * else: + */ + __pyx_t_1 = (PyDataType_HASSUBARRAY(__pyx_v_d) != 0); + if (__pyx_t_1) { + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":838 + * cdef inline tuple PyDataType_SHAPE(dtype d): + * if PyDataType_HASSUBARRAY(d): + * return d.subarray.shape # <<<<<<<<<<<<<< + * else: + * return () + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject*)__pyx_v_d->subarray->shape)); + __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape); + goto __pyx_L0; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":837 + * + * cdef inline tuple PyDataType_SHAPE(dtype d): + * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< + * return d.subarray.shape + * else: + */ + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":840 + * return d.subarray.shape + * else: + * return () # <<<<<<<<<<<<<< + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: + */ + /*else*/ { + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_empty_tuple); + __pyx_r = __pyx_empty_tuple; + goto __pyx_L0; + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":836 + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< + * if PyDataType_HASSUBARRAY(d): + * return d.subarray.shape + */ + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":842 + * return () + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< + * # Recursive utility function used in __getbuffer__ to get format + * # string. The new location in the format string is returned. + */ + +static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) { + PyArray_Descr *__pyx_v_child = 0; + int __pyx_v_endian_detector; + int __pyx_v_little_endian; + PyObject *__pyx_v_fields = 0; + PyObject *__pyx_v_childname = NULL; + PyObject *__pyx_v_new_offset = NULL; + PyObject *__pyx_v_t = NULL; + char *__pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + long __pyx_t_8; + char *__pyx_t_9; + __Pyx_RefNannySetupContext("_util_dtypestring", 0); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":847 + * + * cdef dtype child + * cdef int endian_detector = 1 # <<<<<<<<<<<<<< + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * cdef tuple fields + */ + __pyx_v_endian_detector = 1; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":848 + * cdef dtype child + * cdef int endian_detector = 1 + * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< + * cdef tuple fields + * + */ + __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":851 + * cdef tuple fields + * + * for childname in descr.names: # <<<<<<<<<<<<<< + * fields = descr.fields[childname] + * child, new_offset = fields + */ + if (unlikely(__pyx_v_descr->names == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); + __PYX_ERR(2, 851, __pyx_L1_error) + } + __pyx_t_1 = __pyx_v_descr->names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; + for (;;) { + if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(2, 851, __pyx_L1_error) + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 851, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + #endif + __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3); + __pyx_t_3 = 0; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":852 + * + * for childname in descr.names: + * fields = descr.fields[childname] # <<<<<<<<<<<<<< + * child, new_offset = fields + * + */ + if (unlikely(__pyx_v_descr->fields == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + __PYX_ERR(2, 852, __pyx_L1_error) + } + __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 852, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) __PYX_ERR(2, 852, __pyx_L1_error) + __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3)); + __pyx_t_3 = 0; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":853 + * for childname in descr.names: + * fields = descr.fields[childname] + * child, new_offset = fields # <<<<<<<<<<<<<< + * + * if (end - f) - (new_offset - offset[0]) < 15: + */ + if (likely(__pyx_v_fields != Py_None)) { + PyObject* sequence = __pyx_v_fields; + Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + __PYX_ERR(2, 853, __pyx_L1_error) + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + #else + __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 853, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 853, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + #endif + } else { + __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(2, 853, __pyx_L1_error) + } + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) __PYX_ERR(2, 853, __pyx_L1_error) + __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3)); + __pyx_t_3 = 0; + __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4); + __pyx_t_4 = 0; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":855 + * child, new_offset = fields + * + * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + */ + __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 855, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 855, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 855, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0); + if (unlikely(__pyx_t_6)) { + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":856 + * + * if (end - f) - (new_offset - offset[0]) < 15: + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< + * + * if ((child.byteorder == c'>' and little_endian) or + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 856, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(2, 856, __pyx_L1_error) + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":855 + * child, new_offset = fields + * + * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + */ + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":858 + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0); + if (!__pyx_t_7) { + goto __pyx_L8_next_or; + } else { + } + __pyx_t_7 = (__pyx_v_little_endian != 0); + if (!__pyx_t_7) { + } else { + __pyx_t_6 = __pyx_t_7; + goto __pyx_L7_bool_binop_done; + } + __pyx_L8_next_or:; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":859 + * + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< + * raise ValueError(u"Non-native byte order not supported") + * # One could encode it in the format string and have Cython + */ + __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0); + if (__pyx_t_7) { + } else { + __pyx_t_6 = __pyx_t_7; + goto __pyx_L7_bool_binop_done; + } + __pyx_t_7 = ((!(__pyx_v_little_endian != 0)) != 0); + __pyx_t_6 = __pyx_t_7; + __pyx_L7_bool_binop_done:; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":858 + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + if (unlikely(__pyx_t_6)) { + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":860 + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * # One could encode it in the format string and have Cython + * # complain instead, BUT: < and > in format strings also imply + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 860, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(2, 860, __pyx_L1_error) + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":858 + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":870 + * + * # Output padding bytes + * while offset[0] < new_offset: # <<<<<<<<<<<<<< + * f[0] = 120 # "x"; pad byte + * f += 1 + */ + while (1) { + __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 870, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 870, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 870, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (!__pyx_t_6) break; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":871 + * # Output padding bytes + * while offset[0] < new_offset: + * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< + * f += 1 + * offset[0] += 1 + */ + (__pyx_v_f[0]) = 0x78; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":872 + * while offset[0] < new_offset: + * f[0] = 120 # "x"; pad byte + * f += 1 # <<<<<<<<<<<<<< + * offset[0] += 1 + * + */ + __pyx_v_f = (__pyx_v_f + 1); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":873 + * f[0] = 120 # "x"; pad byte + * f += 1 + * offset[0] += 1 # <<<<<<<<<<<<<< + * + * offset[0] += child.itemsize + */ + __pyx_t_8 = 0; + (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1); + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":875 + * offset[0] += 1 + * + * offset[0] += child.itemsize # <<<<<<<<<<<<<< + * + * if not PyDataType_HASFIELDS(child): + */ + __pyx_t_8 = 0; + (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":877 + * offset[0] += child.itemsize + * + * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< + * t = child.type_num + * if end - f < 5: + */ + __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0); + if (__pyx_t_6) { + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":878 + * + * if not PyDataType_HASFIELDS(child): + * t = child.type_num # <<<<<<<<<<<<<< + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") + */ + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 878, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4); + __pyx_t_4 = 0; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":879 + * if not PyDataType_HASFIELDS(child): + * t = child.type_num + * if end - f < 5: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short.") + * + */ + __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0); + if (unlikely(__pyx_t_6)) { + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":880 + * t = child.type_num + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< + * + * # Until ticket #99 is fixed, use integers to avoid warnings + */ + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 880, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __PYX_ERR(2, 880, __pyx_L1_error) + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":879 + * if not PyDataType_HASFIELDS(child): + * t = child.type_num + * if end - f < 5: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short.") + * + */ + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":883 + * + * # Until ticket #99 is fixed, use integers to avoid warnings + * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_BYTE); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 883, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 883, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 883, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 98; + goto __pyx_L15; + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":884 + * # Until ticket #99 is fixed, use integers to avoid warnings + * if t == NPY_BYTE: f[0] = 98 #"b" + * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UBYTE); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 884, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 884, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 884, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 66; + goto __pyx_L15; + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":885 + * if t == NPY_BYTE: f[0] = 98 #"b" + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_SHORT); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 885, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 885, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 885, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x68; + goto __pyx_L15; + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":886 + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_USHORT); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 886, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 886, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 886, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 72; + goto __pyx_L15; + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":887 + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_INT); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 887, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 887, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 887, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x69; + goto __pyx_L15; + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":888 + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_UINT); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 888, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 888, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 888, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 73; + goto __pyx_L15; + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":889 + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 889, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 889, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 889, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x6C; + goto __pyx_L15; + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":890 + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 890, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 890, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 890, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 76; + goto __pyx_L15; + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":891 + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 891, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 891, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 891, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x71; + goto __pyx_L15; + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":892 + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 892, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 892, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 892, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 81; + goto __pyx_L15; + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":893 + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_FLOAT); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 893, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 893, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 893, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x66; + goto __pyx_L15; + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":894 + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 894, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 894, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 894, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x64; + goto __pyx_L15; + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":895 + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 895, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 895, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 895, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 0x67; + goto __pyx_L15; + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":896 + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 896, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 896, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 896, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 0x66; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L15; + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":897 + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + * elif t == NPY_OBJECT: f[0] = 79 #"O" + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 897, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 897, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 897, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 0x64; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L15; + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":898 + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< + * elif t == NPY_OBJECT: f[0] = 79 #"O" + * else: + */ + __pyx_t_3 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 898, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 898, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 898, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 0x67; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L15; + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":899 + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + */ + __pyx_t_4 = __Pyx_PyInt_From_enum__NPY_TYPES(NPY_OBJECT); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 899, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 899, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(2, 899, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (likely(__pyx_t_6)) { + (__pyx_v_f[0]) = 79; + goto __pyx_L15; + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":901 + * elif t == NPY_OBJECT: f[0] = 79 #"O" + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< + * f += 1 + * else: + */ + /*else*/ { + __pyx_t_3 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 901, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 901, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __PYX_ERR(2, 901, __pyx_L1_error) + } + __pyx_L15:; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":902 + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * f += 1 # <<<<<<<<<<<<<< + * else: + * # Cython ignores struct boundary information ("T{...}"), + */ + __pyx_v_f = (__pyx_v_f + 1); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":877 + * offset[0] += child.itemsize + * + * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< + * t = child.type_num + * if end - f < 5: + */ + goto __pyx_L13; + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":906 + * # Cython ignores struct boundary information ("T{...}"), + * # so don't output it + * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< + * return f + * + */ + /*else*/ { + __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_9 == ((char *)NULL))) __PYX_ERR(2, 906, __pyx_L1_error) + __pyx_v_f = __pyx_t_9; + } + __pyx_L13:; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":851 + * cdef tuple fields + * + * for childname in descr.names: # <<<<<<<<<<<<<< + * fields = descr.fields[childname] + * child, new_offset = fields + */ + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":907 + * # so don't output it + * f = _util_dtypestring(child, f, end, offset) + * return f # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __pyx_v_f; + goto __pyx_L0; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":842 + * return () + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< + * # Recursive utility function used in __getbuffer__ to get format + * # string. The new location in the format string is returned. + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_child); + __Pyx_XDECREF(__pyx_v_fields); + __Pyx_XDECREF(__pyx_v_childname); + __Pyx_XDECREF(__pyx_v_new_offset); + __Pyx_XDECREF(__pyx_v_t); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1022 + * int _import_umath() except -1 + * + * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< + * Py_INCREF(base) # important to do this before stealing the reference below! + * PyArray_SetBaseObject(arr, base) + */ + +static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("set_array_base", 0); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1023 + * + * cdef inline void set_array_base(ndarray arr, object base): + * Py_INCREF(base) # important to do this before stealing the reference below! # <<<<<<<<<<<<<< + * PyArray_SetBaseObject(arr, base) + * + */ + Py_INCREF(__pyx_v_base); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1024 + * cdef inline void set_array_base(ndarray arr, object base): + * Py_INCREF(base) # important to do this before stealing the reference below! + * PyArray_SetBaseObject(arr, base) # <<<<<<<<<<<<<< + * + * cdef inline object get_array_base(ndarray arr): + */ + (void)(PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_base)); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1022 + * int _import_umath() except -1 + * + * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< + * Py_INCREF(base) # important to do this before stealing the reference below! + * PyArray_SetBaseObject(arr, base) + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1026 + * PyArray_SetBaseObject(arr, base) + * + * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< + * base = PyArray_BASE(arr) + * if base is NULL: + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) { + PyObject *__pyx_v_base; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("get_array_base", 0); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1027 + * + * cdef inline object get_array_base(ndarray arr): + * base = PyArray_BASE(arr) # <<<<<<<<<<<<<< + * if base is NULL: + * return None + */ + __pyx_v_base = PyArray_BASE(__pyx_v_arr); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1028 + * cdef inline object get_array_base(ndarray arr): + * base = PyArray_BASE(arr) + * if base is NULL: # <<<<<<<<<<<<<< + * return None + * return base + */ + __pyx_t_1 = ((__pyx_v_base == NULL) != 0); + if (__pyx_t_1) { + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1029 + * base = PyArray_BASE(arr) + * if base is NULL: + * return None # <<<<<<<<<<<<<< + * return base + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1028 + * cdef inline object get_array_base(ndarray arr): + * base = PyArray_BASE(arr) + * if base is NULL: # <<<<<<<<<<<<<< + * return None + * return base + */ + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1030 + * if base is NULL: + * return None + * return base # <<<<<<<<<<<<<< + * + * # Versions of the import_* functions which are more suitable for + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_base)); + __pyx_r = ((PyObject *)__pyx_v_base); + goto __pyx_L0; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1026 + * PyArray_SetBaseObject(arr, base) + * + * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< + * base = PyArray_BASE(arr) + * if base is NULL: + */ + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1034 + * # Versions of the import_* functions which are more suitable for + * # Cython code. + * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< + * try: + * _import_array() + */ + +static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + __Pyx_RefNannySetupContext("import_array", 0); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1035 + * # Cython code. + * cdef inline int import_array() except -1: + * try: # <<<<<<<<<<<<<< + * _import_array() + * except Exception: + */ + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); + __Pyx_XGOTREF(__pyx_t_1); + __Pyx_XGOTREF(__pyx_t_2); + __Pyx_XGOTREF(__pyx_t_3); + /*try:*/ { + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1036 + * cdef inline int import_array() except -1: + * try: + * _import_array() # <<<<<<<<<<<<<< + * except Exception: + * raise ImportError("numpy.core.multiarray failed to import") + */ + __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 1036, __pyx_L3_error) + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1035 + * # Cython code. + * cdef inline int import_array() except -1: + * try: # <<<<<<<<<<<<<< + * _import_array() + * except Exception: + */ + } + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L8_try_end; + __pyx_L3_error:; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1037 + * try: + * _import_array() + * except Exception: # <<<<<<<<<<<<<< + * raise ImportError("numpy.core.multiarray failed to import") + * + */ + __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); + if (__pyx_t_4) { + __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 1037, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GOTREF(__pyx_t_7); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1038 + * _import_array() + * except Exception: + * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< + * + * cdef inline int import_umath() except -1: + */ + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 1038, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_Raise(__pyx_t_8, 0, 0, 0); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __PYX_ERR(2, 1038, __pyx_L5_except_error) + } + goto __pyx_L5_except_error; + __pyx_L5_except_error:; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1035 + * # Cython code. + * cdef inline int import_array() except -1: + * try: # <<<<<<<<<<<<<< + * _import_array() + * except Exception: + */ + __Pyx_XGIVEREF(__pyx_t_1); + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); + goto __pyx_L1_error; + __pyx_L8_try_end:; + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1034 + * # Versions of the import_* functions which are more suitable for + * # Cython code. + * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< + * try: + * _import_array() + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1040 + * raise ImportError("numpy.core.multiarray failed to import") + * + * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< + * try: + * _import_umath() + */ + +static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + __Pyx_RefNannySetupContext("import_umath", 0); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1041 + * + * cdef inline int import_umath() except -1: + * try: # <<<<<<<<<<<<<< + * _import_umath() + * except Exception: + */ + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); + __Pyx_XGOTREF(__pyx_t_1); + __Pyx_XGOTREF(__pyx_t_2); + __Pyx_XGOTREF(__pyx_t_3); + /*try:*/ { + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1042 + * cdef inline int import_umath() except -1: + * try: + * _import_umath() # <<<<<<<<<<<<<< + * except Exception: + * raise ImportError("numpy.core.umath failed to import") + */ + __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 1042, __pyx_L3_error) + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1041 + * + * cdef inline int import_umath() except -1: + * try: # <<<<<<<<<<<<<< + * _import_umath() + * except Exception: + */ + } + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L8_try_end; + __pyx_L3_error:; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1043 + * try: + * _import_umath() + * except Exception: # <<<<<<<<<<<<<< + * raise ImportError("numpy.core.umath failed to import") + * + */ + __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); + if (__pyx_t_4) { + __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 1043, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GOTREF(__pyx_t_7); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1044 + * _import_umath() + * except Exception: + * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< + * + * cdef inline int import_ufunc() except -1: + */ + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 1044, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_Raise(__pyx_t_8, 0, 0, 0); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __PYX_ERR(2, 1044, __pyx_L5_except_error) + } + goto __pyx_L5_except_error; + __pyx_L5_except_error:; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1041 + * + * cdef inline int import_umath() except -1: + * try: # <<<<<<<<<<<<<< + * _import_umath() + * except Exception: + */ + __Pyx_XGIVEREF(__pyx_t_1); + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); + goto __pyx_L1_error; + __pyx_L8_try_end:; + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1040 + * raise ImportError("numpy.core.multiarray failed to import") + * + * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< + * try: + * _import_umath() + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1046 + * raise ImportError("numpy.core.umath failed to import") + * + * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< + * try: + * _import_umath() + */ + +static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + __Pyx_RefNannySetupContext("import_ufunc", 0); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1047 + * + * cdef inline int import_ufunc() except -1: + * try: # <<<<<<<<<<<<<< + * _import_umath() + * except Exception: + */ + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); + __Pyx_XGOTREF(__pyx_t_1); + __Pyx_XGOTREF(__pyx_t_2); + __Pyx_XGOTREF(__pyx_t_3); + /*try:*/ { + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1048 + * cdef inline int import_ufunc() except -1: + * try: + * _import_umath() # <<<<<<<<<<<<<< + * except Exception: + * raise ImportError("numpy.core.umath failed to import") + */ + __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 1048, __pyx_L3_error) + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1047 + * + * cdef inline int import_ufunc() except -1: + * try: # <<<<<<<<<<<<<< + * _import_umath() + * except Exception: + */ + } + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L8_try_end; + __pyx_L3_error:; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1049 + * try: + * _import_umath() + * except Exception: # <<<<<<<<<<<<<< + * raise ImportError("numpy.core.umath failed to import") + */ + __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); + if (__pyx_t_4) { + __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(2, 1049, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GOTREF(__pyx_t_7); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1050 + * _import_umath() + * except Exception: + * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< + */ + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 1050, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_Raise(__pyx_t_8, 0, 0, 0); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __PYX_ERR(2, 1050, __pyx_L5_except_error) + } + goto __pyx_L5_except_error; + __pyx_L5_except_error:; + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1047 + * + * cdef inline int import_ufunc() except -1: + * try: # <<<<<<<<<<<<<< + * _import_umath() + * except Exception: + */ + __Pyx_XGIVEREF(__pyx_t_1); + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); + goto __pyx_L1_error; + __pyx_L8_try_end:; + } + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1046 + * raise ImportError("numpy.core.umath failed to import") + * + * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< + * try: + * _import_umath() + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "string.from_py":13 + * + * @cname("__pyx_convert_string_from_py_std__in_string") + * cdef string __pyx_convert_string_from_py_std__in_string(object o) except *: # <<<<<<<<<<<<<< + * cdef Py_ssize_t length + * cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length) + */ + +static std::string __pyx_convert_string_from_py_std__in_string(PyObject *__pyx_v_o) { + Py_ssize_t __pyx_v_length; + char const *__pyx_v_data; + std::string __pyx_r; + __Pyx_RefNannyDeclarations + char const *__pyx_t_1; + __Pyx_RefNannySetupContext("__pyx_convert_string_from_py_std__in_string", 0); + + /* "string.from_py":15 + * cdef string __pyx_convert_string_from_py_std__in_string(object o) except *: + * cdef Py_ssize_t length + * cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length) # <<<<<<<<<<<<<< + * return string(data, length) + * + */ + __pyx_t_1 = __Pyx_PyObject_AsStringAndSize(__pyx_v_o, (&__pyx_v_length)); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(0, 15, __pyx_L1_error) + __pyx_v_data = __pyx_t_1; + + /* "string.from_py":16 + * cdef Py_ssize_t length + * cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length) + * return string(data, length) # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = std::string(__pyx_v_data, __pyx_v_length); + goto __pyx_L0; + + /* "string.from_py":13 + * + * @cname("__pyx_convert_string_from_py_std__in_string") + * cdef string __pyx_convert_string_from_py_std__in_string(object o) except *: # <<<<<<<<<<<<<< + * cdef Py_ssize_t length + * cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length) + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_AddTraceback("string.from_py.__pyx_convert_string_from_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_pretend_to_initialize(&__pyx_r); + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "string.to_py":31 + * + * @cname("__pyx_convert_PyObject_string_to_py_std__in_string") + * cdef inline object __pyx_convert_PyObject_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< + * return __Pyx_PyObject_FromStringAndSize(s.data(), s.size()) + * cdef extern from *: + */ + +static CYTHON_INLINE PyObject *__pyx_convert_PyObject_string_to_py_std__in_string(std::string const &__pyx_v_s) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__pyx_convert_PyObject_string_to_py_std__in_string", 0); + + /* "string.to_py":32 + * @cname("__pyx_convert_PyObject_string_to_py_std__in_string") + * cdef inline object __pyx_convert_PyObject_string_to_py_std__in_string(const string& s): + * return __Pyx_PyObject_FromStringAndSize(s.data(), s.size()) # <<<<<<<<<<<<<< + * cdef extern from *: + * cdef object __Pyx_PyUnicode_FromStringAndSize(const char*, size_t) + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "string.to_py":31 + * + * @cname("__pyx_convert_PyObject_string_to_py_std__in_string") + * cdef inline object __pyx_convert_PyObject_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< + * return __Pyx_PyObject_FromStringAndSize(s.data(), s.size()) + * cdef extern from *: + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("string.to_py.__pyx_convert_PyObject_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "string.to_py":37 + * + * @cname("__pyx_convert_PyUnicode_string_to_py_std__in_string") + * cdef inline object __pyx_convert_PyUnicode_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< + * return __Pyx_PyUnicode_FromStringAndSize(s.data(), s.size()) + * cdef extern from *: + */ + +static CYTHON_INLINE PyObject *__pyx_convert_PyUnicode_string_to_py_std__in_string(std::string const &__pyx_v_s) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__pyx_convert_PyUnicode_string_to_py_std__in_string", 0); + + /* "string.to_py":38 + * @cname("__pyx_convert_PyUnicode_string_to_py_std__in_string") + * cdef inline object __pyx_convert_PyUnicode_string_to_py_std__in_string(const string& s): + * return __Pyx_PyUnicode_FromStringAndSize(s.data(), s.size()) # <<<<<<<<<<<<<< + * cdef extern from *: + * cdef object __Pyx_PyStr_FromStringAndSize(const char*, size_t) + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyUnicode_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "string.to_py":37 + * + * @cname("__pyx_convert_PyUnicode_string_to_py_std__in_string") + * cdef inline object __pyx_convert_PyUnicode_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< + * return __Pyx_PyUnicode_FromStringAndSize(s.data(), s.size()) + * cdef extern from *: + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("string.to_py.__pyx_convert_PyUnicode_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "string.to_py":43 + * + * @cname("__pyx_convert_PyStr_string_to_py_std__in_string") + * cdef inline object __pyx_convert_PyStr_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< + * return __Pyx_PyStr_FromStringAndSize(s.data(), s.size()) + * cdef extern from *: + */ + +static CYTHON_INLINE PyObject *__pyx_convert_PyStr_string_to_py_std__in_string(std::string const &__pyx_v_s) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__pyx_convert_PyStr_string_to_py_std__in_string", 0); + + /* "string.to_py":44 + * @cname("__pyx_convert_PyStr_string_to_py_std__in_string") + * cdef inline object __pyx_convert_PyStr_string_to_py_std__in_string(const string& s): + * return __Pyx_PyStr_FromStringAndSize(s.data(), s.size()) # <<<<<<<<<<<<<< + * cdef extern from *: + * cdef object __Pyx_PyBytes_FromStringAndSize(const char*, size_t) + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyStr_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "string.to_py":43 + * + * @cname("__pyx_convert_PyStr_string_to_py_std__in_string") + * cdef inline object __pyx_convert_PyStr_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< + * return __Pyx_PyStr_FromStringAndSize(s.data(), s.size()) + * cdef extern from *: + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("string.to_py.__pyx_convert_PyStr_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "string.to_py":49 + * + * @cname("__pyx_convert_PyBytes_string_to_py_std__in_string") + * cdef inline object __pyx_convert_PyBytes_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< + * return __Pyx_PyBytes_FromStringAndSize(s.data(), s.size()) + * cdef extern from *: + */ + +static CYTHON_INLINE PyObject *__pyx_convert_PyBytes_string_to_py_std__in_string(std::string const &__pyx_v_s) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__pyx_convert_PyBytes_string_to_py_std__in_string", 0); + + /* "string.to_py":50 + * @cname("__pyx_convert_PyBytes_string_to_py_std__in_string") + * cdef inline object __pyx_convert_PyBytes_string_to_py_std__in_string(const string& s): + * return __Pyx_PyBytes_FromStringAndSize(s.data(), s.size()) # <<<<<<<<<<<<<< + * cdef extern from *: + * cdef object __Pyx_PyByteArray_FromStringAndSize(const char*, size_t) + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "string.to_py":49 + * + * @cname("__pyx_convert_PyBytes_string_to_py_std__in_string") + * cdef inline object __pyx_convert_PyBytes_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< + * return __Pyx_PyBytes_FromStringAndSize(s.data(), s.size()) + * cdef extern from *: + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("string.to_py.__pyx_convert_PyBytes_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "string.to_py":55 + * + * @cname("__pyx_convert_PyByteArray_string_to_py_std__in_string") + * cdef inline object __pyx_convert_PyByteArray_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< + * return __Pyx_PyByteArray_FromStringAndSize(s.data(), s.size()) + * + */ + +static CYTHON_INLINE PyObject *__pyx_convert_PyByteArray_string_to_py_std__in_string(std::string const &__pyx_v_s) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__pyx_convert_PyByteArray_string_to_py_std__in_string", 0); + + /* "string.to_py":56 + * @cname("__pyx_convert_PyByteArray_string_to_py_std__in_string") + * cdef inline object __pyx_convert_PyByteArray_string_to_py_std__in_string(const string& s): + * return __Pyx_PyByteArray_FromStringAndSize(s.data(), s.size()) # <<<<<<<<<<<<<< + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyByteArray_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "string.to_py":55 + * + * @cname("__pyx_convert_PyByteArray_string_to_py_std__in_string") + * cdef inline object __pyx_convert_PyByteArray_string_to_py_std__in_string(const string& s): # <<<<<<<<<<<<<< + * return __Pyx_PyByteArray_FromStringAndSize(s.data(), s.size()) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("string.to_py.__pyx_convert_PyByteArray_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "map.to_py":201 + * + * @cname("__pyx_convert_map_to_py_std_3a__3a_string____int") + * cdef object __pyx_convert_map_to_py_std_3a__3a_string____int(const map[X,Y]& s): # <<<<<<<<<<<<<< + * o = {} + * cdef const map[X,Y].value_type *key_value + */ + +static PyObject *__pyx_convert_map_to_py_std_3a__3a_string____int(std::map const &__pyx_v_s) { + PyObject *__pyx_v_o = NULL; + std::map ::value_type const *__pyx_v_key_value; + std::map ::const_iterator __pyx_v_iter; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + __Pyx_RefNannySetupContext("__pyx_convert_map_to_py_std_3a__3a_string____int", 0); + + /* "map.to_py":202 + * @cname("__pyx_convert_map_to_py_std_3a__3a_string____int") + * cdef object __pyx_convert_map_to_py_std_3a__3a_string____int(const map[X,Y]& s): + * o = {} # <<<<<<<<<<<<<< + * cdef const map[X,Y].value_type *key_value + * cdef map[X,Y].const_iterator iter = s.begin() + */ + __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 202, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_o = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "map.to_py":204 + * o = {} + * cdef const map[X,Y].value_type *key_value + * cdef map[X,Y].const_iterator iter = s.begin() # <<<<<<<<<<<<<< + * while iter != s.end(): + * key_value = &cython.operator.dereference(iter) + */ + __pyx_v_iter = __pyx_v_s.begin(); + + /* "map.to_py":205 + * cdef const map[X,Y].value_type *key_value + * cdef map[X,Y].const_iterator iter = s.begin() + * while iter != s.end(): # <<<<<<<<<<<<<< + * key_value = &cython.operator.dereference(iter) + * o[key_value.first] = key_value.second + */ + while (1) { + __pyx_t_2 = ((__pyx_v_iter != __pyx_v_s.end()) != 0); + if (!__pyx_t_2) break; + + /* "map.to_py":206 + * cdef map[X,Y].const_iterator iter = s.begin() + * while iter != s.end(): + * key_value = &cython.operator.dereference(iter) # <<<<<<<<<<<<<< + * o[key_value.first] = key_value.second + * cython.operator.preincrement(iter) + */ + __pyx_v_key_value = (&(*__pyx_v_iter)); + + /* "map.to_py":207 + * while iter != s.end(): + * key_value = &cython.operator.dereference(iter) + * o[key_value.first] = key_value.second # <<<<<<<<<<<<<< + * cython.operator.preincrement(iter) + * return o + */ + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_key_value->second); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 207, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_key_value->first); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 207, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + if (unlikely(PyDict_SetItem(__pyx_v_o, __pyx_t_3, __pyx_t_1) < 0)) __PYX_ERR(0, 207, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "map.to_py":208 + * key_value = &cython.operator.dereference(iter) + * o[key_value.first] = key_value.second + * cython.operator.preincrement(iter) # <<<<<<<<<<<<<< + * return o + * + */ + (void)((++__pyx_v_iter)); + } + + /* "map.to_py":209 + * o[key_value.first] = key_value.second + * cython.operator.preincrement(iter) + * return o # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_o); + __pyx_r = __pyx_v_o; + goto __pyx_L0; + + /* "map.to_py":201 + * + * @cname("__pyx_convert_map_to_py_std_3a__3a_string____int") + * cdef object __pyx_convert_map_to_py_std_3a__3a_string____int(const map[X,Y]& s): # <<<<<<<<<<<<<< + * o = {} + * cdef const map[X,Y].value_type *key_value + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("map.to_py.__pyx_convert_map_to_py_std_3a__3a_string____int", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_o); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_tp_new_11pynastranIO_BDFModel(PyTypeObject *t, PyObject *a, PyObject *k) { + struct BDFModel *p; + PyObject *o; + if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { + o = (*t->tp_alloc)(t, 0); + } else { + o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); + } + if (unlikely(!o)) return 0; + p = ((struct BDFModel *)o); + new((void*)&(p->bdfPath)) std::string(); + new((void*)&(p->nElemTypes)) std::map (); + p->myBDF = Py_None; Py_INCREF(Py_None); + if (unlikely(__pyx_pw_11pynastranIO_8BDFModel_1__cinit__(o, a, k) < 0)) goto bad; + return o; + bad: + Py_DECREF(o); o = 0; + return NULL; +} + +static void __pyx_tp_dealloc_11pynastranIO_BDFModel(PyObject *o) { + struct BDFModel *p = (struct BDFModel *)o; + #if CYTHON_USE_TP_FINALIZE + if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + __Pyx_call_destructor(p->bdfPath); + __Pyx_call_destructor(p->nElemTypes); + Py_CLEAR(p->myBDF); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_11pynastranIO_BDFModel(PyObject *o, visitproc v, void *a) { + int e; + struct BDFModel *p = (struct BDFModel *)o; + if (p->myBDF) { + e = (*v)(p->myBDF, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_11pynastranIO_BDFModel(PyObject *o) { + PyObject* tmp; + struct BDFModel *p = (struct BDFModel *)o; + tmp = ((PyObject*)p->myBDF); + p->myBDF = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyObject *__pyx_getprop_11pynastranIO_8BDFModel_nDims(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_11pynastranIO_8BDFModel_5nDims_1__get__(o); +} + +static PyObject *__pyx_getprop_11pynastranIO_8BDFModel_nNodes(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_11pynastranIO_8BDFModel_6nNodes_1__get__(o); +} + +static PyObject *__pyx_getprop_11pynastranIO_8BDFModel_nElems(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_11pynastranIO_8BDFModel_6nElems_1__get__(o); +} + +static PyObject *__pyx_getprop_11pynastranIO_8BDFModel_nMaterials(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_11pynastranIO_8BDFModel_10nMaterials_1__get__(o); +} + +static PyObject *__pyx_getprop_11pynastranIO_8BDFModel_nProperties(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_11pynastranIO_8BDFModel_11nProperties_1__get__(o); +} + +static PyObject *__pyx_getprop_11pynastranIO_8BDFModel_nElemTypes(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_11pynastranIO_8BDFModel_10nElemTypes_1__get__(o); +} + +static PyMethodDef __pyx_methods_11pynastranIO_BDFModel[] = { + {"__reduce_cython__", (PyCFunction)__pyx_pw_11pynastranIO_8BDFModel_3__reduce_cython__, METH_NOARGS, 0}, + {"__setstate_cython__", (PyCFunction)__pyx_pw_11pynastranIO_8BDFModel_5__setstate_cython__, METH_O, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_11pynastranIO_BDFModel[] = { + {(char *)"nDims", __pyx_getprop_11pynastranIO_8BDFModel_nDims, 0, (char *)0, 0}, + {(char *)"nNodes", __pyx_getprop_11pynastranIO_8BDFModel_nNodes, 0, (char *)0, 0}, + {(char *)"nElems", __pyx_getprop_11pynastranIO_8BDFModel_nElems, 0, (char *)0, 0}, + {(char *)"nMaterials", __pyx_getprop_11pynastranIO_8BDFModel_nMaterials, 0, (char *)0, 0}, + {(char *)"nProperties", __pyx_getprop_11pynastranIO_8BDFModel_nProperties, 0, (char *)0, 0}, + {(char *)"nElemTypes", __pyx_getprop_11pynastranIO_8BDFModel_nElemTypes, 0, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +DL_EXPORT(PyTypeObject) BDFModelType = { + PyVarObject_HEAD_INIT(0, 0) + "pynastranIO.BDFModel", /*tp_name*/ + sizeof(struct BDFModel), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_11pynastranIO_BDFModel, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_11pynastranIO_BDFModel, /*tp_traverse*/ + __pyx_tp_clear_11pynastranIO_BDFModel, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_11pynastranIO_BDFModel, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_11pynastranIO_BDFModel, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_11pynastranIO_BDFModel, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif + #if PY_VERSION_HEX >= 0x030800b1 + 0, /*tp_vectorcall*/ + #endif +}; + +static PyMethodDef __pyx_methods[] = { + {0, 0, 0, 0} +}; + +#if PY_MAJOR_VERSION >= 3 +#if CYTHON_PEP489_MULTI_PHASE_INIT +static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ +static int __pyx_pymod_exec_pynastranIO(PyObject* module); /*proto*/ +static PyModuleDef_Slot __pyx_moduledef_slots[] = { + {Py_mod_create, (void*)__pyx_pymod_create}, + {Py_mod_exec, (void*)__pyx_pymod_exec_pynastranIO}, + {0, NULL} +}; +#endif + +static struct PyModuleDef __pyx_moduledef = { + PyModuleDef_HEAD_INIT, + "pynastranIO", + __pyx_k_pyNASTRAN_Notes_Dependencies_cp, /* m_doc */ + #if CYTHON_PEP489_MULTI_PHASE_INIT + 0, /* m_size */ + #else + -1, /* m_size */ + #endif + __pyx_methods /* m_methods */, + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_moduledef_slots, /* m_slots */ + #else + NULL, /* m_reload */ + #endif + NULL, /* m_traverse */ + NULL, /* m_clear */ + NULL /* m_free */ +}; +#endif +#ifndef CYTHON_SMALL_CODE +#if defined(__clang__) + #define CYTHON_SMALL_CODE +#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) + #define CYTHON_SMALL_CODE __attribute__((cold)) +#else + #define CYTHON_SMALL_CODE +#endif +#endif + +static __Pyx_StringTabEntry __pyx_string_tab[] = { + {&__pyx_n_s_BDF, __pyx_k_BDF, sizeof(__pyx_k_BDF), 0, 0, 1, 1}, + {&__pyx_n_s_BDFModel, __pyx_k_BDFModel, sizeof(__pyx_k_BDFModel), 0, 0, 1, 1}, + {&__pyx_n_u_CBUSH, __pyx_k_CBUSH, sizeof(__pyx_k_CBUSH), 0, 1, 0, 1}, + {&__pyx_n_u_CBUSH1D, __pyx_k_CBUSH1D, sizeof(__pyx_k_CBUSH1D), 0, 1, 0, 1}, + {&__pyx_n_u_CBUSH2D, __pyx_k_CBUSH2D, sizeof(__pyx_k_CBUSH2D), 0, 1, 0, 1}, + {&__pyx_n_s_DTYPE, __pyx_k_DTYPE, sizeof(__pyx_k_DTYPE), 0, 0, 1, 1}, + {&__pyx_kp_u_Format_string_allocated_too_shor, __pyx_k_Format_string_allocated_too_shor, sizeof(__pyx_k_Format_string_allocated_too_shor), 0, 1, 0, 0}, + {&__pyx_kp_u_Format_string_allocated_too_shor_2, __pyx_k_Format_string_allocated_too_shor_2, sizeof(__pyx_k_Format_string_allocated_too_shor_2), 0, 1, 0, 0}, + {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1}, + {&__pyx_kp_u_Non_native_byte_order_not_suppor, __pyx_k_Non_native_byte_order_not_suppor, sizeof(__pyx_k_Non_native_byte_order_not_suppor), 0, 1, 0, 0}, + {&__pyx_n_s_NotImplementedError, __pyx_k_NotImplementedError, sizeof(__pyx_k_NotImplementedError), 0, 0, 1, 1}, + {&__pyx_kp_u_Perturbing_GRID_i_by_s_to_define, __pyx_k_Perturbing_GRID_i_by_s_to_define, sizeof(__pyx_k_Perturbing_GRID_i_by_s_to_define), 0, 1, 0, 0}, + {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1}, + {&__pyx_kp_u_Support_of_non_zero_offets_not_y, __pyx_k_Support_of_non_zero_offets_not_y, sizeof(__pyx_k_Support_of_non_zero_offets_not_y), 0, 1, 0, 0}, + {&__pyx_kp_u_Support_of_non_zero_offsets_not, __pyx_k_Support_of_non_zero_offsets_not, sizeof(__pyx_k_Support_of_non_zero_offsets_not), 0, 1, 0, 0}, + {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, + {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, + {&__pyx_n_u__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 1, 0, 1}, + {&__pyx_kp_u__4, __pyx_k__4, sizeof(__pyx_k__4), 0, 1, 0, 0}, + {&__pyx_n_s_bdf_path, __pyx_k_bdf_path, sizeof(__pyx_k_bdf_path), 0, 0, 1, 1}, + {&__pyx_n_s_card_count, __pyx_k_card_count, sizeof(__pyx_k_card_count), 0, 0, 1, 1}, + {&__pyx_kp_u_card_count_s, __pyx_k_card_count_s, sizeof(__pyx_k_card_count_s), 0, 1, 0, 0}, + {&__pyx_n_s_cid_ref, __pyx_k_cid_ref, sizeof(__pyx_k_cid_ref), 0, 0, 1, 1}, + {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, + {&__pyx_n_s_eid, __pyx_k_eid, sizeof(__pyx_k_eid), 0, 0, 1, 1}, + {&__pyx_n_s_elements, __pyx_k_elements, sizeof(__pyx_k_elements), 0, 0, 1, 1}, + {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1}, + {&__pyx_n_s_float, __pyx_k_float, sizeof(__pyx_k_float), 0, 0, 1, 1}, + {&__pyx_n_s_get_bdf_stats, __pyx_k_get_bdf_stats, sizeof(__pyx_k_get_bdf_stats), 0, 0, 1, 1}, + {&__pyx_n_s_get_elements_properties_nodes_by, __pyx_k_get_elements_properties_nodes_by, sizeof(__pyx_k_get_elements_properties_nodes_by), 0, 0, 1, 1}, + {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1}, + {&__pyx_kp_u_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 1, 0, 0}, + {&__pyx_n_s_i_2, __pyx_k_i_2, sizeof(__pyx_k_i_2), 0, 0, 1, 1}, + {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, + {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1}, + {&__pyx_n_s_j, __pyx_k_j, sizeof(__pyx_k_j), 0, 0, 1, 1}, + {&__pyx_n_s_keys, __pyx_k_keys, sizeof(__pyx_k_keys), 0, 0, 1, 1}, + {&__pyx_n_s_linalg, __pyx_k_linalg, sizeof(__pyx_k_linalg), 0, 0, 1, 1}, + {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, + {&__pyx_n_s_min, __pyx_k_min, sizeof(__pyx_k_min), 0, 0, 1, 1}, + {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, + {&__pyx_kp_u_ndarray_is_not_C_contiguous, __pyx_k_ndarray_is_not_C_contiguous, sizeof(__pyx_k_ndarray_is_not_C_contiguous), 0, 1, 0, 0}, + {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou, __pyx_k_ndarray_is_not_Fortran_contiguou, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou), 0, 1, 0, 0}, + {&__pyx_n_s_nelements, __pyx_k_nelements, sizeof(__pyx_k_nelements), 0, 0, 1, 1}, + {&__pyx_n_s_nid, __pyx_k_nid, sizeof(__pyx_k_nid), 0, 0, 1, 1}, + {&__pyx_n_s_nmaterials, __pyx_k_nmaterials, sizeof(__pyx_k_nmaterials), 0, 0, 1, 1}, + {&__pyx_n_s_nnodes, __pyx_k_nnodes, sizeof(__pyx_k_nnodes), 0, 0, 1, 1}, + {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0}, + {&__pyx_n_s_nodes, __pyx_k_nodes, sizeof(__pyx_k_nodes), 0, 0, 1, 1}, + {&__pyx_n_s_nodes_ref, __pyx_k_nodes_ref, sizeof(__pyx_k_nodes_ref), 0, 0, 1, 1}, + {&__pyx_n_s_norm, __pyx_k_norm, sizeof(__pyx_k_norm), 0, 0, 1, 1}, + {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, + {&__pyx_n_s_nproperties, __pyx_k_nproperties, sizeof(__pyx_k_nproperties), 0, 0, 1, 1}, + {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1}, + {&__pyx_kp_u_numpy_core_multiarray_failed_to, __pyx_k_numpy_core_multiarray_failed_to, sizeof(__pyx_k_numpy_core_multiarray_failed_to), 0, 1, 0, 0}, + {&__pyx_kp_u_numpy_core_umath_failed_to_impor, __pyx_k_numpy_core_umath_failed_to_impor, sizeof(__pyx_k_numpy_core_umath_failed_to_impor), 0, 1, 0, 0}, + {&__pyx_n_s_object_attributes, __pyx_k_object_attributes, sizeof(__pyx_k_object_attributes), 0, 0, 1, 1}, + {&__pyx_n_s_offset, __pyx_k_offset, sizeof(__pyx_k_offset), 0, 0, 1, 1}, + {&__pyx_n_u_offset, __pyx_k_offset, sizeof(__pyx_k_offset), 0, 1, 0, 1}, + {&__pyx_n_s_pid, __pyx_k_pid, sizeof(__pyx_k_pid), 0, 0, 1, 1}, + {&__pyx_n_s_print, __pyx_k_print, sizeof(__pyx_k_print), 0, 0, 1, 1}, + {&__pyx_n_s_pyNastran_bdf_bdf, __pyx_k_pyNastran_bdf_bdf, sizeof(__pyx_k_pyNastran_bdf_bdf), 0, 0, 1, 1}, + {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, + {&__pyx_n_s_read_bdf, __pyx_k_read_bdf, sizeof(__pyx_k_read_bdf), 0, 0, 1, 1}, + {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1}, + {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1}, + {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1}, + {&__pyx_n_s_reject_count, __pyx_k_reject_count, sizeof(__pyx_k_reject_count), 0, 0, 1, 1}, + {&__pyx_kp_u_reject_count_s, __pyx_k_reject_count_s, sizeof(__pyx_k_reject_count_s), 0, 1, 0, 0}, + {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1}, + {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1}, + {&__pyx_n_s_strip, __pyx_k_strip, sizeof(__pyx_k_strip), 0, 0, 1, 1}, + {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, + {&__pyx_n_s_tolist, __pyx_k_tolist, sizeof(__pyx_k_tolist), 0, 0, 1, 1}, + {&__pyx_n_s_type, __pyx_k_type, sizeof(__pyx_k_type), 0, 0, 1, 1}, + {&__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_k_unknown_dtype_code_in_numpy_pxd, sizeof(__pyx_k_unknown_dtype_code_in_numpy_pxd), 0, 1, 0, 0}, + {&__pyx_kp_u_utf_8, __pyx_k_utf_8, sizeof(__pyx_k_utf_8), 0, 1, 0, 0}, + {&__pyx_n_s_warn, __pyx_k_warn, sizeof(__pyx_k_warn), 0, 0, 1, 1}, + {&__pyx_n_s_warnings, __pyx_k_warnings, sizeof(__pyx_k_warnings), 0, 0, 1, 1}, + {&__pyx_n_s_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 0, 1, 1}, + {&__pyx_n_s_xyz, __pyx_k_xyz, sizeof(__pyx_k_xyz), 0, 0, 1, 1}, + {&__pyx_n_s_zoffset, __pyx_k_zoffset, sizeof(__pyx_k_zoffset), 0, 0, 1, 1}, + {&__pyx_n_u_zoffset, __pyx_k_zoffset, sizeof(__pyx_k_zoffset), 0, 1, 0, 1}, + {0, 0, 0, 0, 0, 0, 0} +}; +static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) { + __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 2, __pyx_L1_error) + __pyx_builtin_print = __Pyx_GetBuiltinName(__pyx_n_s_print); if (!__pyx_builtin_print) __PYX_ERR(1, 74, __pyx_L1_error) + __pyx_builtin_NotImplementedError = __Pyx_GetBuiltinName(__pyx_n_s_NotImplementedError); if (!__pyx_builtin_NotImplementedError) __PYX_ERR(1, 173, __pyx_L1_error) + __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(1, 182, __pyx_L1_error) + __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(2, 272, __pyx_L1_error) + __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(2, 856, __pyx_L1_error) + __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(2, 1038, __pyx_L1_error) + return 0; + __pyx_L1_error:; + return -1; +} + +static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple_); + __Pyx_GIVEREF(__pyx_tuple_); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__2); + __Pyx_GIVEREF(__pyx_tuple__2); + + /* "pynastranIO.pyx":173 + * if "offset" in element.object_attributes(): + * if element.offset!=0: + * raise NotImplementedError("Support of non-zero offsets not yet implemented!") # <<<<<<<<<<<<<< + * if "zoffset" in element.object_attributes(): + * if element.zoffset!=0: + */ + __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_Support_of_non_zero_offsets_not); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 173, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__5); + __Pyx_GIVEREF(__pyx_tuple__5); + + /* "pynastranIO.pyx":176 + * if "zoffset" in element.object_attributes(): + * if element.zoffset!=0: + * raise NotImplementedError("Support of non-zero offets not yet implemented!") # <<<<<<<<<<<<<< + * nElemNodes = len(element.nodes) + * elemType = (element.type + "_%i"%(nElemNodes)).encode('utf-8') + */ + __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_Support_of_non_zero_offets_not_y); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 176, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__6); + __Pyx_GIVEREF(__pyx_tuple__6); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":272 + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + */ + __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(2, 272, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__7); + __Pyx_GIVEREF(__pyx_tuple__7); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":276 + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< + * + * info.buf = PyArray_DATA(self) + */ + __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(2, 276, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__8); + __Pyx_GIVEREF(__pyx_tuple__8); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":306 + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + */ + __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(2, 306, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__9); + __Pyx_GIVEREF(__pyx_tuple__9); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":856 + * + * if (end - f) - (new_offset - offset[0]) < 15: + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< + * + * if ((child.byteorder == c'>' and little_endian) or + */ + __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(2, 856, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__10); + __Pyx_GIVEREF(__pyx_tuple__10); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":880 + * t = child.type_num + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< + * + * # Until ticket #99 is fixed, use integers to avoid warnings + */ + __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(2, 880, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__11); + __Pyx_GIVEREF(__pyx_tuple__11); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1038 + * _import_array() + * except Exception: + * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< + * + * cdef inline int import_umath() except -1: + */ + __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_u_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(2, 1038, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__12); + __Pyx_GIVEREF(__pyx_tuple__12); + + /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1044 + * _import_umath() + * except Exception: + * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< + * + * cdef inline int import_ufunc() except -1: + */ + __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_u_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(2, 1044, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__13); + __Pyx_GIVEREF(__pyx_tuple__13); + __Pyx_RefNannyFinishContext(); + return 0; + __pyx_L1_error:; + __Pyx_RefNannyFinishContext(); + return -1; +} + +static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) { + if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(1, 1, __pyx_L1_error); + __pyx_float_0_0 = PyFloat_FromDouble(0.0); if (unlikely(!__pyx_float_0_0)) __PYX_ERR(1, 1, __pyx_L1_error) + __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(1, 1, __pyx_L1_error) + return 0; + __pyx_L1_error:; + return -1; +} + +static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/ + +static int __Pyx_modinit_global_init_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0); + /*--- Global init code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_variable_export_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0); + /*--- Variable export code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_function_export_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0); + /*--- Function export code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_type_init_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); + /*--- Type init code ---*/ + if (PyType_Ready(&BDFModelType) < 0) __PYX_ERR(1, 33, __pyx_L1_error) + #if PY_VERSION_HEX < 0x030800B1 + BDFModelType.tp_print = 0; + #endif + if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!BDFModelType.tp_dictoffset && BDFModelType.tp_getattro == PyObject_GenericGetAttr)) { + BDFModelType.tp_getattro = __Pyx_PyObject_GenericGetAttr; + } + if (PyObject_SetAttr(__pyx_m, __pyx_n_s_BDFModel, (PyObject *)&BDFModelType) < 0) __PYX_ERR(1, 33, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject*)&BDFModelType) < 0) __PYX_ERR(1, 33, __pyx_L1_error) + __pyx_ptype_11pynastranIO_BDFModel = &BDFModelType; + __Pyx_RefNannyFinishContext(); + return 0; + __pyx_L1_error:; + __Pyx_RefNannyFinishContext(); + return -1; +} + +static int __Pyx_modinit_type_import_code(void) { + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0); + /*--- Type import code ---*/ + __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 9, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type", + #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000 + sizeof(PyTypeObject), + #else + sizeof(PyHeapTypeObject), + #endif + __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(3, 9, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyImport_ImportModule("numpy"); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 206, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_ptype_5numpy_dtype = __Pyx_ImportType(__pyx_t_1, "numpy", "dtype", sizeof(PyArray_Descr), __Pyx_ImportType_CheckSize_Ignore); + if (!__pyx_ptype_5numpy_dtype) __PYX_ERR(2, 206, __pyx_L1_error) + __pyx_ptype_5numpy_flatiter = __Pyx_ImportType(__pyx_t_1, "numpy", "flatiter", sizeof(PyArrayIterObject), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_5numpy_flatiter) __PYX_ERR(2, 229, __pyx_L1_error) + __pyx_ptype_5numpy_broadcast = __Pyx_ImportType(__pyx_t_1, "numpy", "broadcast", sizeof(PyArrayMultiIterObject), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_5numpy_broadcast) __PYX_ERR(2, 233, __pyx_L1_error) + __pyx_ptype_5numpy_ndarray = __Pyx_ImportType(__pyx_t_1, "numpy", "ndarray", sizeof(PyArrayObject), __Pyx_ImportType_CheckSize_Ignore); + if (!__pyx_ptype_5numpy_ndarray) __PYX_ERR(2, 242, __pyx_L1_error) + __pyx_ptype_5numpy_ufunc = __Pyx_ImportType(__pyx_t_1, "numpy", "ufunc", sizeof(PyUFuncObject), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_5numpy_ufunc) __PYX_ERR(2, 918, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_RefNannyFinishContext(); + return 0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_RefNannyFinishContext(); + return -1; +} + +static int __Pyx_modinit_variable_import_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0); + /*--- Variable import code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_function_import_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0); + /*--- Function import code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + + +#if PY_MAJOR_VERSION < 3 +#ifdef CYTHON_NO_PYINIT_EXPORT +#define __Pyx_PyMODINIT_FUNC void +#else +#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC +#endif +#else +#ifdef CYTHON_NO_PYINIT_EXPORT +#define __Pyx_PyMODINIT_FUNC PyObject * +#else +#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC +#endif +#endif + + +#if PY_MAJOR_VERSION < 3 +__Pyx_PyMODINIT_FUNC initpynastranIO(void) CYTHON_SMALL_CODE; /*proto*/ +__Pyx_PyMODINIT_FUNC initpynastranIO(void) +#else +__Pyx_PyMODINIT_FUNC PyInit_pynastranIO(void) CYTHON_SMALL_CODE; /*proto*/ +__Pyx_PyMODINIT_FUNC PyInit_pynastranIO(void) +#if CYTHON_PEP489_MULTI_PHASE_INIT +{ + return PyModuleDef_Init(&__pyx_moduledef); +} +static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) { + #if PY_VERSION_HEX >= 0x030700A1 + static PY_INT64_T main_interpreter_id = -1; + PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp); + if (main_interpreter_id == -1) { + main_interpreter_id = current_id; + return (unlikely(current_id == -1)) ? -1 : 0; + } else if (unlikely(main_interpreter_id != current_id)) + #else + static PyInterpreterState *main_interpreter = NULL; + PyInterpreterState *current_interpreter = PyThreadState_Get()->interp; + if (!main_interpreter) { + main_interpreter = current_interpreter; + } else if (unlikely(main_interpreter != current_interpreter)) + #endif + { + PyErr_SetString( + PyExc_ImportError, + "Interpreter change detected - this module can only be loaded into one interpreter per process."); + return -1; + } + return 0; +} +static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) { + PyObject *value = PyObject_GetAttrString(spec, from_name); + int result = 0; + if (likely(value)) { + if (allow_none || value != Py_None) { + result = PyDict_SetItemString(moddict, to_name, value); + } + Py_DECREF(value); + } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Clear(); + } else { + result = -1; + } + return result; +} +static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { + PyObject *module = NULL, *moddict, *modname; + if (__Pyx_check_single_interpreter()) + return NULL; + if (__pyx_m) + return __Pyx_NewRef(__pyx_m); + modname = PyObject_GetAttrString(spec, "name"); + if (unlikely(!modname)) goto bad; + module = PyModule_NewObject(modname); + Py_DECREF(modname); + if (unlikely(!module)) goto bad; + moddict = PyModule_GetDict(module); + if (unlikely(!moddict)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad; + return module; +bad: + Py_XDECREF(module); + return NULL; +} + + +static CYTHON_SMALL_CODE int __pyx_pymod_exec_pynastranIO(PyObject *__pyx_pyinit_module) +#endif +#endif +{ + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + __Pyx_RefNannyDeclarations + #if CYTHON_PEP489_MULTI_PHASE_INIT + if (__pyx_m) { + if (__pyx_m == __pyx_pyinit_module) return 0; + PyErr_SetString(PyExc_RuntimeError, "Module 'pynastranIO' has already been imported. Re-initialisation is not supported."); + return -1; + } + #elif PY_MAJOR_VERSION >= 3 + if (__pyx_m) return __Pyx_NewRef(__pyx_m); + #endif + #if CYTHON_REFNANNY +__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); +if (!__Pyx_RefNanny) { + PyErr_Clear(); + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); + if (!__Pyx_RefNanny) + Py_FatalError("failed to import 'refnanny' module"); +} +#endif + __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_pynastranIO(void)", 0); + if (__Pyx_check_binary_version() < 0) __PYX_ERR(1, 1, __pyx_L1_error) + #ifdef __Pxy_PyFrame_Initialize_Offsets + __Pxy_PyFrame_Initialize_Offsets(); + #endif + __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(1, 1, __pyx_L1_error) + __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(1, 1, __pyx_L1_error) + __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(1, 1, __pyx_L1_error) + #ifdef __Pyx_CyFunction_USED + if (__pyx_CyFunction_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_FusedFunction_USED + if (__pyx_FusedFunction_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_Coroutine_USED + if (__pyx_Coroutine_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_Generator_USED + if (__pyx_Generator_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_AsyncGen_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_StopAsyncIteration_USED + if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error) + #endif + /*--- Library function declarations ---*/ + /*--- Threads initialization code ---*/ + #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS + #ifdef WITH_THREAD /* Python build with threading support? */ + PyEval_InitThreads(); + #endif + #endif + /*--- Module creation code ---*/ + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_m = __pyx_pyinit_module; + Py_INCREF(__pyx_m); + #else + #if PY_MAJOR_VERSION < 3 + __pyx_m = Py_InitModule4("pynastranIO", __pyx_methods, __pyx_k_pyNASTRAN_Notes_Dependencies_cp, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); + #else + __pyx_m = PyModule_Create(&__pyx_moduledef); + #endif + if (unlikely(!__pyx_m)) __PYX_ERR(1, 1, __pyx_L1_error) + #endif + __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(1, 1, __pyx_L1_error) + Py_INCREF(__pyx_d); + __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(1, 1, __pyx_L1_error) + Py_INCREF(__pyx_b); + __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(1, 1, __pyx_L1_error) + Py_INCREF(__pyx_cython_runtime); + if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(1, 1, __pyx_L1_error); + /*--- Initialize various global constants etc. ---*/ + if (__Pyx_InitGlobals() < 0) __PYX_ERR(1, 1, __pyx_L1_error) + #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) + if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(1, 1, __pyx_L1_error) + #endif + if (__pyx_module_is_main_pynastranIO) { + if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(1, 1, __pyx_L1_error) + } + #if PY_MAJOR_VERSION >= 3 + { + PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(1, 1, __pyx_L1_error) + if (!PyDict_GetItemString(modules, "pynastranIO")) { + if (unlikely(PyDict_SetItemString(modules, "pynastranIO", __pyx_m) < 0)) __PYX_ERR(1, 1, __pyx_L1_error) + } + } + #endif + /*--- Builtin init code ---*/ + if (__Pyx_InitCachedBuiltins() < 0) goto __pyx_L1_error; + /*--- Constants init code ---*/ + if (__Pyx_InitCachedConstants() < 0) goto __pyx_L1_error; + /*--- Global type/function init code ---*/ + (void)__Pyx_modinit_global_init_code(); + (void)__Pyx_modinit_variable_export_code(); + (void)__Pyx_modinit_function_export_code(); + if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error; + if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error; + (void)__Pyx_modinit_variable_import_code(); + (void)__Pyx_modinit_function_import_code(); + /*--- Execution code ---*/ + #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) + if (__Pyx_patch_abc() < 0) __PYX_ERR(1, 1, __pyx_L1_error) + #endif + + /* "pynastranIO.pyx":12 + * + * # pyNastran Imports + * from pyNastran.bdf.bdf import BDF # <<<<<<<<<<<<<< + * + * # Standard C++ Imports + */ + __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_n_s_BDF); + __Pyx_GIVEREF(__pyx_n_s_BDF); + PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_BDF); + __pyx_t_2 = __Pyx_Import(__pyx_n_s_pyNastran_bdf_bdf, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 12, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_BDF); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_BDF, __pyx_t_1) < 0) __PYX_ERR(1, 12, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "pynastranIO.pyx":24 + * # Cython Imports + * from cython.operator import dereference, postincrement + * from warnings import warn # <<<<<<<<<<<<<< + * + * # Setup Numpy Usage + */ + __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 24, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_n_s_warn); + __Pyx_GIVEREF(__pyx_n_s_warn); + PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_warn); + __pyx_t_1 = __Pyx_Import(__pyx_n_s_warnings, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 24, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_warn); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 24, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_warn, __pyx_t_2) < 0) __PYX_ERR(1, 24, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "pynastranIO.pyx":27 + * + * # Setup Numpy Usage + * import numpy as np # <<<<<<<<<<<<<< + * cimport numpy as np + * DTYPE = np.float + */ + __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 27, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(1, 27, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "pynastranIO.pyx":29 + * import numpy as np + * cimport numpy as np + * DTYPE = np.float # <<<<<<<<<<<<<< + * ctypedef np.float_t DTYPE_t + * + */ + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 29, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_float); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 29, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (PyDict_SetItem(__pyx_d, __pyx_n_s_DTYPE, __pyx_t_2) < 0) __PYX_ERR(1, 29, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "pynastranIO.pyx":1 + * # distutils: language = c++ # <<<<<<<<<<<<<< + * # ^^^ This line above is read by setup.py and lets it know to compile the + * # program as C++ instead of the default, C. + */ + __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(1, 1, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "map.to_py":201 + * + * @cname("__pyx_convert_map_to_py_std_3a__3a_string____int") + * cdef object __pyx_convert_map_to_py_std_3a__3a_string____int(const map[X,Y]& s): # <<<<<<<<<<<<<< + * o = {} + * cdef const map[X,Y].value_type *key_value + */ + + /*--- Wrapped vars code ---*/ + + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + if (__pyx_m) { + if (__pyx_d) { + __Pyx_AddTraceback("init pynastranIO", __pyx_clineno, __pyx_lineno, __pyx_filename); + } + Py_CLEAR(__pyx_m); + } else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_ImportError, "init pynastranIO"); + } + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + #if CYTHON_PEP489_MULTI_PHASE_INIT + return (__pyx_m != NULL) ? 0 : -1; + #elif PY_MAJOR_VERSION >= 3 + return __pyx_m; + #else + return; + #endif +} + +/* --- Runtime support code --- */ +/* Refnanny */ +#if CYTHON_REFNANNY +static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { + PyObject *m = NULL, *p = NULL; + void *r = NULL; + m = PyImport_ImportModule(modname); + if (!m) goto end; + p = PyObject_GetAttrString(m, "RefNannyAPI"); + if (!p) goto end; + r = PyLong_AsVoidPtr(p); +end: + Py_XDECREF(p); + Py_XDECREF(m); + return (__Pyx_RefNannyAPIStruct *)r; +} +#endif + +/* PyObjectGetAttrStr */ +#if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_getattro)) + return tp->tp_getattro(obj, attr_name); +#if PY_MAJOR_VERSION < 3 + if (likely(tp->tp_getattr)) + return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); +#endif + return PyObject_GetAttr(obj, attr_name); +} +#endif + +/* GetBuiltinName */ +static PyObject *__Pyx_GetBuiltinName(PyObject *name) { + PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); + if (unlikely(!result)) { + PyErr_Format(PyExc_NameError, +#if PY_MAJOR_VERSION >= 3 + "name '%U' is not defined", name); +#else + "name '%.200s' is not defined", PyString_AS_STRING(name)); +#endif + } + return result; +} + +/* RaiseDoubleKeywords */ +static void __Pyx_RaiseDoubleKeywordsError( + const char* func_name, + PyObject* kw_name) +{ + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION >= 3 + "%s() got multiple values for keyword argument '%U'", func_name, kw_name); + #else + "%s() got multiple values for keyword argument '%s'", func_name, + PyString_AsString(kw_name)); + #endif +} + +/* ParseKeywords */ +static int __Pyx_ParseOptionalKeywords( + PyObject *kwds, + PyObject **argnames[], + PyObject *kwds2, + PyObject *values[], + Py_ssize_t num_pos_args, + const char* function_name) +{ + PyObject *key = 0, *value = 0; + Py_ssize_t pos = 0; + PyObject*** name; + PyObject*** first_kw_arg = argnames + num_pos_args; + while (PyDict_Next(kwds, &pos, &key, &value)) { + name = first_kw_arg; + while (*name && (**name != key)) name++; + if (*name) { + values[name-argnames] = value; + continue; + } + name = first_kw_arg; + #if PY_MAJOR_VERSION < 3 + if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { + while (*name) { + if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) + && _PyString_Eq(**name, key)) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + if ((**argname == key) || ( + (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) + && _PyString_Eq(**argname, key))) { + goto arg_passed_twice; + } + argname++; + } + } + } else + #endif + if (likely(PyUnicode_Check(key))) { + while (*name) { + int cmp = (**name == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**name, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + int cmp = (**argname == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**argname, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) goto arg_passed_twice; + argname++; + } + } + } else + goto invalid_keyword_type; + if (kwds2) { + if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; + } else { + goto invalid_keyword; + } + } + return 0; +arg_passed_twice: + __Pyx_RaiseDoubleKeywordsError(function_name, key); + goto bad; +invalid_keyword_type: + PyErr_Format(PyExc_TypeError, + "%.200s() keywords must be strings", function_name); + goto bad; +invalid_keyword: + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION < 3 + "%.200s() got an unexpected keyword argument '%.200s'", + function_name, PyString_AsString(key)); + #else + "%s() got an unexpected keyword argument '%U'", + function_name, key); + #endif +bad: + return -1; +} + +/* RaiseArgTupleInvalid */ +static void __Pyx_RaiseArgtupleInvalid( + const char* func_name, + int exact, + Py_ssize_t num_min, + Py_ssize_t num_max, + Py_ssize_t num_found) +{ + Py_ssize_t num_expected; + const char *more_or_less; + if (num_found < num_min) { + num_expected = num_min; + more_or_less = "at least"; + } else { + num_expected = num_max; + more_or_less = "at most"; + } + if (exact) { + more_or_less = "exactly"; + } + PyErr_Format(PyExc_TypeError, + "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", + func_name, more_or_less, num_expected, + (num_expected == 1) ? "" : "s", num_found); +} + +/* PyDictVersioning */ +#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) { + PyObject *dict = Py_TYPE(obj)->tp_dict; + return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0; +} +static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) { + PyObject **dictptr = NULL; + Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset; + if (offset) { +#if CYTHON_COMPILING_IN_CPYTHON + dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj); +#else + dictptr = _PyObject_GetDictPtr(obj); +#endif + } + return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0; +} +static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) { + PyObject *dict = Py_TYPE(obj)->tp_dict; + if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict))) + return 0; + return obj_dict_version == __Pyx_get_object_dict_version(obj); +} +#endif + +/* GetModuleGlobalName */ +#if CYTHON_USE_DICT_VERSIONS +static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value) +#else +static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name) +#endif +{ + PyObject *result; +#if !CYTHON_AVOID_BORROWED_REFS +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 + result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash); + __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) + if (likely(result)) { + return __Pyx_NewRef(result); + } else if (unlikely(PyErr_Occurred())) { + return NULL; + } +#else + result = PyDict_GetItem(__pyx_d, name); + __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) + if (likely(result)) { + return __Pyx_NewRef(result); + } +#endif +#else + result = PyObject_GetItem(__pyx_d, name); + __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) + if (likely(result)) { + return __Pyx_NewRef(result); + } + PyErr_Clear(); +#endif + return __Pyx_GetBuiltinName(name); +} + +/* PyFunctionFastCall */ +#if CYTHON_FAST_PYCALL +static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, + PyObject *globals) { + PyFrameObject *f; + PyThreadState *tstate = __Pyx_PyThreadState_Current; + PyObject **fastlocals; + Py_ssize_t i; + PyObject *result; + assert(globals != NULL); + /* XXX Perhaps we should create a specialized + PyFrame_New() that doesn't take locals, but does + take builtins without sanity checking them. + */ + assert(tstate != NULL); + f = PyFrame_New(tstate, co, globals, NULL); + if (f == NULL) { + return NULL; + } + fastlocals = __Pyx_PyFrame_GetLocalsplus(f); + for (i = 0; i < na; i++) { + Py_INCREF(*args); + fastlocals[i] = *args++; + } + result = PyEval_EvalFrameEx(f,0); + ++tstate->recursion_depth; + Py_DECREF(f); + --tstate->recursion_depth; + return result; +} +#if 1 || PY_VERSION_HEX < 0x030600B1 +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) { + PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); + PyObject *globals = PyFunction_GET_GLOBALS(func); + PyObject *argdefs = PyFunction_GET_DEFAULTS(func); + PyObject *closure; +#if PY_MAJOR_VERSION >= 3 + PyObject *kwdefs; +#endif + PyObject *kwtuple, **k; + PyObject **d; + Py_ssize_t nd; + Py_ssize_t nk; + PyObject *result; + assert(kwargs == NULL || PyDict_Check(kwargs)); + nk = kwargs ? PyDict_Size(kwargs) : 0; + if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { + return NULL; + } + if ( +#if PY_MAJOR_VERSION >= 3 + co->co_kwonlyargcount == 0 && +#endif + likely(kwargs == NULL || nk == 0) && + co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { + if (argdefs == NULL && co->co_argcount == nargs) { + result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); + goto done; + } + else if (nargs == 0 && argdefs != NULL + && co->co_argcount == Py_SIZE(argdefs)) { + /* function called with no arguments, but all parameters have + a default value: use default values as arguments .*/ + args = &PyTuple_GET_ITEM(argdefs, 0); + result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); + goto done; + } + } + if (kwargs != NULL) { + Py_ssize_t pos, i; + kwtuple = PyTuple_New(2 * nk); + if (kwtuple == NULL) { + result = NULL; + goto done; + } + k = &PyTuple_GET_ITEM(kwtuple, 0); + pos = i = 0; + while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { + Py_INCREF(k[i]); + Py_INCREF(k[i+1]); + i += 2; + } + nk = i / 2; + } + else { + kwtuple = NULL; + k = NULL; + } + closure = PyFunction_GET_CLOSURE(func); +#if PY_MAJOR_VERSION >= 3 + kwdefs = PyFunction_GET_KW_DEFAULTS(func); +#endif + if (argdefs != NULL) { + d = &PyTuple_GET_ITEM(argdefs, 0); + nd = Py_SIZE(argdefs); + } + else { + d = NULL; + nd = 0; + } +#if PY_MAJOR_VERSION >= 3 + result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, + args, (int)nargs, + k, (int)nk, + d, (int)nd, kwdefs, closure); +#else + result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, + args, (int)nargs, + k, (int)nk, + d, (int)nd, closure); +#endif + Py_XDECREF(kwtuple); +done: + Py_LeaveRecursiveCall(); + return result; +} +#endif +#endif + +/* PyObjectCall */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { + PyObject *result; + ternaryfunc call = func->ob_type->tp_call; + if (unlikely(!call)) + return PyObject_Call(func, arg, kw); + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) + return NULL; + result = (*call)(func, arg, kw); + Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); + } + return result; +} +#endif + +/* PyObjectCallMethO */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { + PyObject *self, *result; + PyCFunction cfunc; + cfunc = PyCFunction_GET_FUNCTION(func); + self = PyCFunction_GET_SELF(func); + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) + return NULL; + result = cfunc(self, arg); + Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); + } + return result; +} +#endif + +/* PyObjectCallNoArg */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { +#if CYTHON_FAST_PYCALL + if (PyFunction_Check(func)) { + return __Pyx_PyFunction_FastCall(func, NULL, 0); + } +#endif +#ifdef __Pyx_CyFunction_USED + if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func))) +#else + if (likely(PyCFunction_Check(func))) +#endif + { + if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { + return __Pyx_PyObject_CallMethO(func, NULL); + } + } + return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL); +} +#endif + +/* PyCFunctionFastCall */ +#if CYTHON_FAST_PYCCALL +static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { + PyCFunctionObject *func = (PyCFunctionObject*)func_obj; + PyCFunction meth = PyCFunction_GET_FUNCTION(func); + PyObject *self = PyCFunction_GET_SELF(func); + int flags = PyCFunction_GET_FLAGS(func); + assert(PyCFunction_Check(func)); + assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))); + assert(nargs >= 0); + assert(nargs == 0 || args != NULL); + /* _PyCFunction_FastCallDict() must not be called with an exception set, + because it may clear it (directly or indirectly) and so the + caller loses its exception */ + assert(!PyErr_Occurred()); + if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) { + return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL); + } else { + return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs); + } +} +#endif + +/* PyObjectCallOneArg */ +#if CYTHON_COMPILING_IN_CPYTHON +static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject *result; + PyObject *args = PyTuple_New(1); + if (unlikely(!args)) return NULL; + Py_INCREF(arg); + PyTuple_SET_ITEM(args, 0, arg); + result = __Pyx_PyObject_Call(func, args, NULL); + Py_DECREF(args); + return result; +} +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { +#if CYTHON_FAST_PYCALL + if (PyFunction_Check(func)) { + return __Pyx_PyFunction_FastCall(func, &arg, 1); + } +#endif + if (likely(PyCFunction_Check(func))) { + if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { + return __Pyx_PyObject_CallMethO(func, arg); +#if CYTHON_FAST_PYCCALL + } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) { + return __Pyx_PyCFunction_FastCall(func, &arg, 1); +#endif + } + } + return __Pyx__PyObject_CallOneArg(func, arg); +} +#else +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject *result; + PyObject *args = PyTuple_Pack(1, arg); + if (unlikely(!args)) return NULL; + result = __Pyx_PyObject_Call(func, args, NULL); + Py_DECREF(args); + return result; +} +#endif + +/* decode_c_bytes */ +static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes( + const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop, + const char* encoding, const char* errors, + PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) { + if (unlikely((start < 0) | (stop < 0))) { + if (start < 0) { + start += length; + if (start < 0) + start = 0; + } + if (stop < 0) + stop += length; + } + if (stop > length) + stop = length; + length = stop - start; + if (unlikely(length <= 0)) + return PyUnicode_FromUnicode(NULL, 0); + cstring += start; + if (decode_func) { + return decode_func(cstring, length, errors); + } else { + return PyUnicode_Decode(cstring, length, encoding, errors); + } +} + +/* PyObjectCall2Args */ +static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) { + PyObject *args, *result = NULL; + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(function)) { + PyObject *args[2] = {arg1, arg2}; + return __Pyx_PyFunction_FastCall(function, args, 2); + } + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(function)) { + PyObject *args[2] = {arg1, arg2}; + return __Pyx_PyCFunction_FastCall(function, args, 2); + } + #endif + args = PyTuple_New(2); + if (unlikely(!args)) goto done; + Py_INCREF(arg1); + PyTuple_SET_ITEM(args, 0, arg1); + Py_INCREF(arg2); + PyTuple_SET_ITEM(args, 1, arg2); + Py_INCREF(function); + result = __Pyx_PyObject_Call(function, args, NULL); + Py_DECREF(args); + Py_DECREF(function); +done: + return result; +} + +/* PyErrFetchRestore */ +#if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + tmp_type = tstate->curexc_type; + tmp_value = tstate->curexc_value; + tmp_tb = tstate->curexc_traceback; + tstate->curexc_type = type; + tstate->curexc_value = value; + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +} +static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + *type = tstate->curexc_type; + *value = tstate->curexc_value; + *tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +} +#endif + +/* RaiseException */ +#if PY_MAJOR_VERSION < 3 +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, + CYTHON_UNUSED PyObject *cause) { + __Pyx_PyThreadState_declare + Py_XINCREF(type); + if (!value || value == Py_None) + value = NULL; + else + Py_INCREF(value); + if (!tb || tb == Py_None) + tb = NULL; + else { + Py_INCREF(tb); + if (!PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto raise_error; + } + } + if (PyType_Check(type)) { +#if CYTHON_COMPILING_IN_PYPY + if (!value) { + Py_INCREF(Py_None); + value = Py_None; + } +#endif + PyErr_NormalizeException(&type, &value, &tb); + } else { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto raise_error; + } + value = type; + type = (PyObject*) Py_TYPE(type); + Py_INCREF(type); + if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto raise_error; + } + } + __Pyx_PyThreadState_assign + __Pyx_ErrRestore(type, value, tb); + return; +raise_error: + Py_XDECREF(value); + Py_XDECREF(type); + Py_XDECREF(tb); + return; +} +#else +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { + PyObject* owned_instance = NULL; + if (tb == Py_None) { + tb = 0; + } else if (tb && !PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto bad; + } + if (value == Py_None) + value = 0; + if (PyExceptionInstance_Check(type)) { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto bad; + } + value = type; + type = (PyObject*) Py_TYPE(value); + } else if (PyExceptionClass_Check(type)) { + PyObject *instance_class = NULL; + if (value && PyExceptionInstance_Check(value)) { + instance_class = (PyObject*) Py_TYPE(value); + if (instance_class != type) { + int is_subclass = PyObject_IsSubclass(instance_class, type); + if (!is_subclass) { + instance_class = NULL; + } else if (unlikely(is_subclass == -1)) { + goto bad; + } else { + type = instance_class; + } + } + } + if (!instance_class) { + PyObject *args; + if (!value) + args = PyTuple_New(0); + else if (PyTuple_Check(value)) { + Py_INCREF(value); + args = value; + } else + args = PyTuple_Pack(1, value); + if (!args) + goto bad; + owned_instance = PyObject_Call(type, args, NULL); + Py_DECREF(args); + if (!owned_instance) + goto bad; + value = owned_instance; + if (!PyExceptionInstance_Check(value)) { + PyErr_Format(PyExc_TypeError, + "calling %R should have returned an instance of " + "BaseException, not %R", + type, Py_TYPE(value)); + goto bad; + } + } + } else { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto bad; + } + if (cause) { + PyObject *fixed_cause; + if (cause == Py_None) { + fixed_cause = NULL; + } else if (PyExceptionClass_Check(cause)) { + fixed_cause = PyObject_CallObject(cause, NULL); + if (fixed_cause == NULL) + goto bad; + } else if (PyExceptionInstance_Check(cause)) { + fixed_cause = cause; + Py_INCREF(fixed_cause); + } else { + PyErr_SetString(PyExc_TypeError, + "exception causes must derive from " + "BaseException"); + goto bad; + } + PyException_SetCause(value, fixed_cause); + } + PyErr_SetObject(type, value); + if (tb) { +#if CYTHON_COMPILING_IN_PYPY + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); + Py_INCREF(tb); + PyErr_Restore(tmp_type, tmp_value, tb); + Py_XDECREF(tmp_tb); +#else + PyThreadState *tstate = __Pyx_PyThreadState_Current; + PyObject* tmp_tb = tstate->curexc_traceback; + if (tb != tmp_tb) { + Py_INCREF(tb); + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_tb); + } +#endif + } +bad: + Py_XDECREF(owned_instance); + return; +} +#endif + +/* WriteUnraisableException */ +static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, + CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, + int full_traceback, CYTHON_UNUSED int nogil) { + PyObject *old_exc, *old_val, *old_tb; + PyObject *ctx; + __Pyx_PyThreadState_declare +#ifdef WITH_THREAD + PyGILState_STATE state; + if (nogil) + state = PyGILState_Ensure(); +#ifdef _MSC_VER + else state = (PyGILState_STATE)-1; +#endif +#endif + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); + if (full_traceback) { + Py_XINCREF(old_exc); + Py_XINCREF(old_val); + Py_XINCREF(old_tb); + __Pyx_ErrRestore(old_exc, old_val, old_tb); + PyErr_PrintEx(1); + } + #if PY_MAJOR_VERSION < 3 + ctx = PyString_FromString(name); + #else + ctx = PyUnicode_FromString(name); + #endif + __Pyx_ErrRestore(old_exc, old_val, old_tb); + if (!ctx) { + PyErr_WriteUnraisable(Py_None); + } else { + PyErr_WriteUnraisable(ctx); + Py_DECREF(ctx); + } +#ifdef WITH_THREAD + if (nogil) + PyGILState_Release(state); +#endif +} + +/* GetItemInt */ +static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { + PyObject *r; + if (!j) return NULL; + r = PyObject_GetItem(o, j); + Py_DECREF(j); + return r; +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + Py_ssize_t wrapped_i = i; + if (wraparound & unlikely(i < 0)) { + wrapped_i += PyList_GET_SIZE(o); + } + if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) { + PyObject *r = PyList_GET_ITEM(o, wrapped_i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + Py_ssize_t wrapped_i = i; + if (wraparound & unlikely(i < 0)) { + wrapped_i += PyTuple_GET_SIZE(o); + } + if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, wrapped_i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS + if (is_list || PyList_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); + if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) { + PyObject *r = PyList_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } + else if (PyTuple_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); + if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } else { + PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; + if (likely(m && m->sq_item)) { + if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { + Py_ssize_t l = m->sq_length(o); + if (likely(l >= 0)) { + i += l; + } else { + if (!PyErr_ExceptionMatches(PyExc_OverflowError)) + return NULL; + PyErr_Clear(); + } + } + return m->sq_item(o, i); + } + } +#else + if (is_list || PySequence_Check(o)) { + return PySequence_GetItem(o, i); + } +#endif + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +} + +/* ObjectGetItem */ +#if CYTHON_USE_TYPE_SLOTS +static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) { + PyObject *runerr; + Py_ssize_t key_value; + PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence; + if (unlikely(!(m && m->sq_item))) { + PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name); + return NULL; + } + key_value = __Pyx_PyIndex_AsSsize_t(index); + if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) { + return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1); + } + if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) { + PyErr_Clear(); + PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name); + } + return NULL; +} +static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) { + PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping; + if (likely(m && m->mp_subscript)) { + return m->mp_subscript(obj, key); + } + return __Pyx_PyObject_GetIndex(obj, key); +} +#endif + +/* PyFloatBinop */ +#if !CYTHON_COMPILING_IN_PYPY +static PyObject* __Pyx_PyFloat_NeObjC(PyObject *op1, PyObject *op2, double floatval, int inplace, int zerodivision_check) { + const double b = floatval; + double a; + (void)inplace; + (void)zerodivision_check; + if (op1 == op2) { + Py_RETURN_FALSE; + } + if (likely(PyFloat_CheckExact(op1))) { + a = PyFloat_AS_DOUBLE(op1); + + } else + #if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact(op1))) { + a = (double) PyInt_AS_LONG(op1); + + } else + #endif + if (likely(PyLong_CheckExact(op1))) { + #if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)op1)->ob_digit; + const Py_ssize_t size = Py_SIZE(op1); + switch (size) { + case 0: a = 0.0; break; + case -1: a = -(double) digits[0]; break; + case 1: a = (double) digits[0]; break; + case -2: + case 2: + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (1 * PyLong_SHIFT < 53))) { + a = (double) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + if ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53) || (a < (double) ((PY_LONG_LONG)1 << 53))) { + if (size == -2) + a = -a; + break; + } + } + CYTHON_FALLTHROUGH; + case -3: + case 3: + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53))) { + a = (double) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + if ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53) || (a < (double) ((PY_LONG_LONG)1 << 53))) { + if (size == -3) + a = -a; + break; + } + } + CYTHON_FALLTHROUGH; + case -4: + case 4: + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53))) { + a = (double) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + if ((8 * sizeof(unsigned long) < 53) || (4 * PyLong_SHIFT < 53) || (a < (double) ((PY_LONG_LONG)1 << 53))) { + if (size == -4) + a = -a; + break; + } + } + CYTHON_FALLTHROUGH; + default: + #else + { + #endif + return ( + PyFloat_Type.tp_richcompare(op2, op1, Py_NE)); + } + } else { + return ( + PyObject_RichCompare(op1, op2, Py_NE)); + } + if (a != b) { + Py_RETURN_TRUE; + } else { + Py_RETURN_FALSE; + } +} +#endif + +/* IterFinish */ + static CYTHON_INLINE int __Pyx_IterFinish(void) { +#if CYTHON_FAST_THREAD_STATE + PyThreadState *tstate = __Pyx_PyThreadState_Current; + PyObject* exc_type = tstate->curexc_type; + if (unlikely(exc_type)) { + if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) { + PyObject *exc_value, *exc_tb; + exc_value = tstate->curexc_value; + exc_tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; + Py_DECREF(exc_type); + Py_XDECREF(exc_value); + Py_XDECREF(exc_tb); + return 0; + } else { + return -1; + } + } + return 0; +#else + if (unlikely(PyErr_Occurred())) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) { + PyErr_Clear(); + return 0; + } else { + return -1; + } + } + return 0; +#endif +} + +/* PyObjectGetMethod */ + static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) { + PyObject *attr; +#if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP + PyTypeObject *tp = Py_TYPE(obj); + PyObject *descr; + descrgetfunc f = NULL; + PyObject **dictptr, *dict; + int meth_found = 0; + assert (*method == NULL); + if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) { + attr = __Pyx_PyObject_GetAttrStr(obj, name); + goto try_unpack; + } + if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) { + return 0; + } + descr = _PyType_Lookup(tp, name); + if (likely(descr != NULL)) { + Py_INCREF(descr); +#if PY_MAJOR_VERSION >= 3 + #ifdef __Pyx_CyFunction_USED + if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr))) + #else + if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type))) + #endif +#else + #ifdef __Pyx_CyFunction_USED + if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr))) + #else + if (likely(PyFunction_Check(descr))) + #endif +#endif + { + meth_found = 1; + } else { + f = Py_TYPE(descr)->tp_descr_get; + if (f != NULL && PyDescr_IsData(descr)) { + attr = f(descr, obj, (PyObject *)Py_TYPE(obj)); + Py_DECREF(descr); + goto try_unpack; + } + } + } + dictptr = _PyObject_GetDictPtr(obj); + if (dictptr != NULL && (dict = *dictptr) != NULL) { + Py_INCREF(dict); + attr = __Pyx_PyDict_GetItemStr(dict, name); + if (attr != NULL) { + Py_INCREF(attr); + Py_DECREF(dict); + Py_XDECREF(descr); + goto try_unpack; + } + Py_DECREF(dict); + } + if (meth_found) { + *method = descr; + return 1; + } + if (f != NULL) { + attr = f(descr, obj, (PyObject *)Py_TYPE(obj)); + Py_DECREF(descr); + goto try_unpack; + } + if (descr != NULL) { + *method = descr; + return 0; + } + PyErr_Format(PyExc_AttributeError, +#if PY_MAJOR_VERSION >= 3 + "'%.50s' object has no attribute '%U'", + tp->tp_name, name); +#else + "'%.50s' object has no attribute '%.400s'", + tp->tp_name, PyString_AS_STRING(name)); +#endif + return 0; +#else + attr = __Pyx_PyObject_GetAttrStr(obj, name); + goto try_unpack; +#endif +try_unpack: +#if CYTHON_UNPACK_METHODS + if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) { + PyObject *function = PyMethod_GET_FUNCTION(attr); + Py_INCREF(function); + Py_DECREF(attr); + *method = function; + return 1; + } +#endif + *method = attr; + return 0; +} + +/* PyObjectCallMethod0 */ + static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) { + PyObject *method = NULL, *result = NULL; + int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method); + if (likely(is_method)) { + result = __Pyx_PyObject_CallOneArg(method, obj); + Py_DECREF(method); + return result; + } + if (unlikely(!method)) goto bad; + result = __Pyx_PyObject_CallNoArg(method); + Py_DECREF(method); +bad: + return result; +} + +/* RaiseNeedMoreValuesToUnpack */ + static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { + PyErr_Format(PyExc_ValueError, + "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", + index, (index == 1) ? "" : "s"); +} + +/* RaiseTooManyValuesToUnpack */ + static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { + PyErr_Format(PyExc_ValueError, + "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); +} + +/* UnpackItemEndCheck */ + static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { + if (unlikely(retval)) { + Py_DECREF(retval); + __Pyx_RaiseTooManyValuesError(expected); + return -1; + } else { + return __Pyx_IterFinish(); + } + return 0; +} + +/* RaiseNoneIterError */ + static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); +} + +/* UnpackTupleError */ + static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) { + if (t == Py_None) { + __Pyx_RaiseNoneNotIterableError(); + } else if (PyTuple_GET_SIZE(t) < index) { + __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(t)); + } else { + __Pyx_RaiseTooManyValuesError(index); + } +} + +/* UnpackTuple2 */ + static CYTHON_INLINE int __Pyx_unpack_tuple2_exact( + PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2, int decref_tuple) { + PyObject *value1 = NULL, *value2 = NULL; +#if CYTHON_COMPILING_IN_PYPY + value1 = PySequence_ITEM(tuple, 0); if (unlikely(!value1)) goto bad; + value2 = PySequence_ITEM(tuple, 1); if (unlikely(!value2)) goto bad; +#else + value1 = PyTuple_GET_ITEM(tuple, 0); Py_INCREF(value1); + value2 = PyTuple_GET_ITEM(tuple, 1); Py_INCREF(value2); +#endif + if (decref_tuple) { + Py_DECREF(tuple); + } + *pvalue1 = value1; + *pvalue2 = value2; + return 0; +#if CYTHON_COMPILING_IN_PYPY +bad: + Py_XDECREF(value1); + Py_XDECREF(value2); + if (decref_tuple) { Py_XDECREF(tuple); } + return -1; +#endif +} +static int __Pyx_unpack_tuple2_generic(PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2, + int has_known_size, int decref_tuple) { + Py_ssize_t index; + PyObject *value1 = NULL, *value2 = NULL, *iter = NULL; + iternextfunc iternext; + iter = PyObject_GetIter(tuple); + if (unlikely(!iter)) goto bad; + if (decref_tuple) { Py_DECREF(tuple); tuple = NULL; } + iternext = Py_TYPE(iter)->tp_iternext; + value1 = iternext(iter); if (unlikely(!value1)) { index = 0; goto unpacking_failed; } + value2 = iternext(iter); if (unlikely(!value2)) { index = 1; goto unpacking_failed; } + if (!has_known_size && unlikely(__Pyx_IternextUnpackEndCheck(iternext(iter), 2))) goto bad; + Py_DECREF(iter); + *pvalue1 = value1; + *pvalue2 = value2; + return 0; +unpacking_failed: + if (!has_known_size && __Pyx_IterFinish() == 0) + __Pyx_RaiseNeedMoreValuesError(index); +bad: + Py_XDECREF(iter); + Py_XDECREF(value1); + Py_XDECREF(value2); + if (decref_tuple) { Py_XDECREF(tuple); } + return -1; +} + +/* dict_iter */ + static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_dict, PyObject* method_name, + Py_ssize_t* p_orig_length, int* p_source_is_dict) { + is_dict = is_dict || likely(PyDict_CheckExact(iterable)); + *p_source_is_dict = is_dict; + if (is_dict) { +#if !CYTHON_COMPILING_IN_PYPY + *p_orig_length = PyDict_Size(iterable); + Py_INCREF(iterable); + return iterable; +#elif PY_MAJOR_VERSION >= 3 + static PyObject *py_items = NULL, *py_keys = NULL, *py_values = NULL; + PyObject **pp = NULL; + if (method_name) { + const char *name = PyUnicode_AsUTF8(method_name); + if (strcmp(name, "iteritems") == 0) pp = &py_items; + else if (strcmp(name, "iterkeys") == 0) pp = &py_keys; + else if (strcmp(name, "itervalues") == 0) pp = &py_values; + if (pp) { + if (!*pp) { + *pp = PyUnicode_FromString(name + 4); + if (!*pp) + return NULL; + } + method_name = *pp; + } + } +#endif + } + *p_orig_length = 0; + if (method_name) { + PyObject* iter; + iterable = __Pyx_PyObject_CallMethod0(iterable, method_name); + if (!iterable) + return NULL; +#if !CYTHON_COMPILING_IN_PYPY + if (PyTuple_CheckExact(iterable) || PyList_CheckExact(iterable)) + return iterable; +#endif + iter = PyObject_GetIter(iterable); + Py_DECREF(iterable); + return iter; + } + return PyObject_GetIter(iterable); +} +static CYTHON_INLINE int __Pyx_dict_iter_next( + PyObject* iter_obj, CYTHON_NCP_UNUSED Py_ssize_t orig_length, CYTHON_NCP_UNUSED Py_ssize_t* ppos, + PyObject** pkey, PyObject** pvalue, PyObject** pitem, int source_is_dict) { + PyObject* next_item; +#if !CYTHON_COMPILING_IN_PYPY + if (source_is_dict) { + PyObject *key, *value; + if (unlikely(orig_length != PyDict_Size(iter_obj))) { + PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration"); + return -1; + } + if (unlikely(!PyDict_Next(iter_obj, ppos, &key, &value))) { + return 0; + } + if (pitem) { + PyObject* tuple = PyTuple_New(2); + if (unlikely(!tuple)) { + return -1; + } + Py_INCREF(key); + Py_INCREF(value); + PyTuple_SET_ITEM(tuple, 0, key); + PyTuple_SET_ITEM(tuple, 1, value); + *pitem = tuple; + } else { + if (pkey) { + Py_INCREF(key); + *pkey = key; + } + if (pvalue) { + Py_INCREF(value); + *pvalue = value; + } + } + return 1; + } else if (PyTuple_CheckExact(iter_obj)) { + Py_ssize_t pos = *ppos; + if (unlikely(pos >= PyTuple_GET_SIZE(iter_obj))) return 0; + *ppos = pos + 1; + next_item = PyTuple_GET_ITEM(iter_obj, pos); + Py_INCREF(next_item); + } else if (PyList_CheckExact(iter_obj)) { + Py_ssize_t pos = *ppos; + if (unlikely(pos >= PyList_GET_SIZE(iter_obj))) return 0; + *ppos = pos + 1; + next_item = PyList_GET_ITEM(iter_obj, pos); + Py_INCREF(next_item); + } else +#endif + { + next_item = PyIter_Next(iter_obj); + if (unlikely(!next_item)) { + return __Pyx_IterFinish(); + } + } + if (pitem) { + *pitem = next_item; + } else if (pkey && pvalue) { + if (__Pyx_unpack_tuple2(next_item, pkey, pvalue, source_is_dict, source_is_dict, 1)) + return -1; + } else if (pkey) { + *pkey = next_item; + } else { + *pvalue = next_item; + } + return 1; +} + +/* PyIntCompare */ + static CYTHON_INLINE PyObject* __Pyx_PyInt_NeObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED long inplace) { + if (op1 == op2) { + Py_RETURN_FALSE; + } + #if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact(op1))) { + const long b = intval; + long a = PyInt_AS_LONG(op1); + if (a != b) Py_RETURN_TRUE; else Py_RETURN_FALSE; + } + #endif + #if CYTHON_USE_PYLONG_INTERNALS + if (likely(PyLong_CheckExact(op1))) { + int unequal; + unsigned long uintval; + Py_ssize_t size = Py_SIZE(op1); + const digit* digits = ((PyLongObject*)op1)->ob_digit; + if (intval == 0) { + if (size != 0) Py_RETURN_TRUE; else Py_RETURN_FALSE; + } else if (intval < 0) { + if (size >= 0) + Py_RETURN_TRUE; + intval = -intval; + size = -size; + } else { + if (size <= 0) + Py_RETURN_TRUE; + } + uintval = (unsigned long) intval; +#if PyLong_SHIFT * 4 < SIZEOF_LONG*8 + if (uintval >> (PyLong_SHIFT * 4)) { + unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK)) + | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)); + } else +#endif +#if PyLong_SHIFT * 3 < SIZEOF_LONG*8 + if (uintval >> (PyLong_SHIFT * 3)) { + unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK)) + | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)); + } else +#endif +#if PyLong_SHIFT * 2 < SIZEOF_LONG*8 + if (uintval >> (PyLong_SHIFT * 2)) { + unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK)) + | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)); + } else +#endif +#if PyLong_SHIFT * 1 < SIZEOF_LONG*8 + if (uintval >> (PyLong_SHIFT * 1)) { + unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK)) + | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)); + } else +#endif + unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK)); + if (unequal != 0) Py_RETURN_TRUE; else Py_RETURN_FALSE; + } + #endif + if (PyFloat_CheckExact(op1)) { + const long b = intval; + double a = PyFloat_AS_DOUBLE(op1); + if ((double)a != (double)b) Py_RETURN_TRUE; else Py_RETURN_FALSE; + } + return ( + PyObject_RichCompare(op1, op2, Py_NE)); +} + +/* DictGetItem */ + #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY +static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { + PyObject *value; + value = PyDict_GetItemWithError(d, key); + if (unlikely(!value)) { + if (!PyErr_Occurred()) { + if (unlikely(PyTuple_Check(key))) { + PyObject* args = PyTuple_Pack(1, key); + if (likely(args)) { + PyErr_SetObject(PyExc_KeyError, args); + Py_DECREF(args); + } + } else { + PyErr_SetObject(PyExc_KeyError, key); + } + } + return NULL; + } + Py_INCREF(value); + return value; +} +#endif + +/* py_abs */ + #if CYTHON_USE_PYLONG_INTERNALS +static PyObject *__Pyx_PyLong_AbsNeg(PyObject *n) { + if (likely(Py_SIZE(n) == -1)) { + return PyLong_FromLong(((PyLongObject*)n)->ob_digit[0]); + } +#if CYTHON_COMPILING_IN_CPYTHON + { + PyObject *copy = _PyLong_Copy((PyLongObject*)n); + if (likely(copy)) { + Py_SIZE(copy) = -(Py_SIZE(copy)); + } + return copy; + } +#else + return PyNumber_Negative(n); +#endif +} +#endif + +/* PyObjectSetAttrStr */ + #if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) { + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_setattro)) + return tp->tp_setattro(obj, attr_name, value); +#if PY_MAJOR_VERSION < 3 + if (likely(tp->tp_setattr)) + return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value); +#endif + return PyObject_SetAttr(obj, attr_name, value); +} +#endif + +/* ExtTypeTest */ + static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { + if (unlikely(!type)) { + PyErr_SetString(PyExc_SystemError, "Missing type object"); + return 0; + } + if (likely(__Pyx_TypeCheck(obj, type))) + return 1; + PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", + Py_TYPE(obj)->tp_name, type->tp_name); + return 0; +} + +/* GetTopmostException */ + #if CYTHON_USE_EXC_INFO_STACK +static _PyErr_StackItem * +__Pyx_PyErr_GetTopmostException(PyThreadState *tstate) +{ + _PyErr_StackItem *exc_info = tstate->exc_info; + while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) && + exc_info->previous_item != NULL) + { + exc_info = exc_info->previous_item; + } + return exc_info; +} +#endif + +/* SaveResetException */ + #if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + #if CYTHON_USE_EXC_INFO_STACK + _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate); + *type = exc_info->exc_type; + *value = exc_info->exc_value; + *tb = exc_info->exc_traceback; + #else + *type = tstate->exc_type; + *value = tstate->exc_value; + *tb = tstate->exc_traceback; + #endif + Py_XINCREF(*type); + Py_XINCREF(*value); + Py_XINCREF(*tb); +} +static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + #if CYTHON_USE_EXC_INFO_STACK + _PyErr_StackItem *exc_info = tstate->exc_info; + tmp_type = exc_info->exc_type; + tmp_value = exc_info->exc_value; + tmp_tb = exc_info->exc_traceback; + exc_info->exc_type = type; + exc_info->exc_value = value; + exc_info->exc_traceback = tb; + #else + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = type; + tstate->exc_value = value; + tstate->exc_traceback = tb; + #endif + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +} +#endif + +/* PyErrExceptionMatches */ + #if CYTHON_FAST_THREAD_STATE +static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(tuple); +#if PY_MAJOR_VERSION >= 3 + for (i=0; icurexc_type; + if (exc_type == err) return 1; + if (unlikely(!exc_type)) return 0; + if (unlikely(PyTuple_Check(err))) + return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); + return __Pyx_PyErr_GivenExceptionMatches(exc_type, err); +} +#endif + +/* GetException */ + #if CYTHON_FAST_THREAD_STATE +static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) +#else +static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) +#endif +{ + PyObject *local_type, *local_value, *local_tb; +#if CYTHON_FAST_THREAD_STATE + PyObject *tmp_type, *tmp_value, *tmp_tb; + local_type = tstate->curexc_type; + local_value = tstate->curexc_value; + local_tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +#else + PyErr_Fetch(&local_type, &local_value, &local_tb); +#endif + PyErr_NormalizeException(&local_type, &local_value, &local_tb); +#if CYTHON_FAST_THREAD_STATE + if (unlikely(tstate->curexc_type)) +#else + if (unlikely(PyErr_Occurred())) +#endif + goto bad; + #if PY_MAJOR_VERSION >= 3 + if (local_tb) { + if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) + goto bad; + } + #endif + Py_XINCREF(local_tb); + Py_XINCREF(local_type); + Py_XINCREF(local_value); + *type = local_type; + *value = local_value; + *tb = local_tb; +#if CYTHON_FAST_THREAD_STATE + #if CYTHON_USE_EXC_INFO_STACK + { + _PyErr_StackItem *exc_info = tstate->exc_info; + tmp_type = exc_info->exc_type; + tmp_value = exc_info->exc_value; + tmp_tb = exc_info->exc_traceback; + exc_info->exc_type = local_type; + exc_info->exc_value = local_value; + exc_info->exc_traceback = local_tb; + } + #else + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = local_type; + tstate->exc_value = local_value; + tstate->exc_traceback = local_tb; + #endif + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +#else + PyErr_SetExcInfo(local_type, local_value, local_tb); +#endif + return 0; +bad: + *type = 0; + *value = 0; + *tb = 0; + Py_XDECREF(local_type); + Py_XDECREF(local_value); + Py_XDECREF(local_tb); + return -1; +} + +/* PyObject_GenericGetAttrNoDict */ + #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 +static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) { + PyErr_Format(PyExc_AttributeError, +#if PY_MAJOR_VERSION >= 3 + "'%.50s' object has no attribute '%U'", + tp->tp_name, attr_name); +#else + "'%.50s' object has no attribute '%.400s'", + tp->tp_name, PyString_AS_STRING(attr_name)); +#endif + return NULL; +} +static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) { + PyObject *descr; + PyTypeObject *tp = Py_TYPE(obj); + if (unlikely(!PyString_Check(attr_name))) { + return PyObject_GenericGetAttr(obj, attr_name); + } + assert(!tp->tp_dictoffset); + descr = _PyType_Lookup(tp, attr_name); + if (unlikely(!descr)) { + return __Pyx_RaiseGenericGetAttributeError(tp, attr_name); + } + Py_INCREF(descr); + #if PY_MAJOR_VERSION < 3 + if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS))) + #endif + { + descrgetfunc f = Py_TYPE(descr)->tp_descr_get; + if (unlikely(f)) { + PyObject *res = f(descr, obj, (PyObject *)tp); + Py_DECREF(descr); + return res; + } + } + return descr; +} +#endif + +/* PyObject_GenericGetAttr */ + #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 +static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) { + if (unlikely(Py_TYPE(obj)->tp_dictoffset)) { + return PyObject_GenericGetAttr(obj, attr_name); + } + return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name); +} +#endif + +/* SetupReduce */ + static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { + int ret; + PyObject *name_attr; + name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name); + if (likely(name_attr)) { + ret = PyObject_RichCompareBool(name_attr, name, Py_EQ); + } else { + ret = -1; + } + if (unlikely(ret < 0)) { + PyErr_Clear(); + ret = 0; + } + Py_XDECREF(name_attr); + return ret; +} +static int __Pyx_setup_reduce(PyObject* type_obj) { + int ret = 0; + PyObject *object_reduce = NULL; + PyObject *object_reduce_ex = NULL; + PyObject *reduce = NULL; + PyObject *reduce_ex = NULL; + PyObject *reduce_cython = NULL; + PyObject *setstate = NULL; + PyObject *setstate_cython = NULL; +#if CYTHON_USE_PYTYPE_LOOKUP + if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto GOOD; +#else + if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto GOOD; +#endif +#if CYTHON_USE_PYTYPE_LOOKUP + object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; +#else + object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; +#endif + reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto BAD; + if (reduce_ex == object_reduce_ex) { +#if CYTHON_USE_PYTYPE_LOOKUP + object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; +#else + object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; +#endif + reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto BAD; + if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { + reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto BAD; + ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto BAD; + ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto BAD; + setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate); + if (!setstate) PyErr_Clear(); + if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) { + setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto BAD; + ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto BAD; + ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto BAD; + } + PyType_Modified((PyTypeObject*)type_obj); + } + } + goto GOOD; +BAD: + if (!PyErr_Occurred()) + PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); + ret = -1; +GOOD: +#if !CYTHON_USE_PYTYPE_LOOKUP + Py_XDECREF(object_reduce); + Py_XDECREF(object_reduce_ex); +#endif + Py_XDECREF(reduce); + Py_XDECREF(reduce_ex); + Py_XDECREF(reduce_cython); + Py_XDECREF(setstate); + Py_XDECREF(setstate_cython); + return ret; +} + +/* TypeImport */ + #ifndef __PYX_HAVE_RT_ImportType +#define __PYX_HAVE_RT_ImportType +static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name, + size_t size, enum __Pyx_ImportType_CheckSize check_size) +{ + PyObject *result = 0; + char warning[200]; + Py_ssize_t basicsize; +#ifdef Py_LIMITED_API + PyObject *py_basicsize; +#endif + result = PyObject_GetAttrString(module, class_name); + if (!result) + goto bad; + if (!PyType_Check(result)) { + PyErr_Format(PyExc_TypeError, + "%.200s.%.200s is not a type object", + module_name, class_name); + goto bad; + } +#ifndef Py_LIMITED_API + basicsize = ((PyTypeObject *)result)->tp_basicsize; +#else + py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); + if (!py_basicsize) + goto bad; + basicsize = PyLong_AsSsize_t(py_basicsize); + Py_DECREF(py_basicsize); + py_basicsize = 0; + if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) + goto bad; +#endif + if ((size_t)basicsize < size) { + PyErr_Format(PyExc_ValueError, + "%.200s.%.200s size changed, may indicate binary incompatibility. " + "Expected %zd from C header, got %zd from PyObject", + module_name, class_name, size, basicsize); + goto bad; + } + if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) { + PyErr_Format(PyExc_ValueError, + "%.200s.%.200s size changed, may indicate binary incompatibility. " + "Expected %zd from C header, got %zd from PyObject", + module_name, class_name, size, basicsize); + goto bad; + } + else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) { + PyOS_snprintf(warning, sizeof(warning), + "%s.%s size changed, may indicate binary incompatibility. " + "Expected %zd from C header, got %zd from PyObject", + module_name, class_name, size, basicsize); + if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; + } + return (PyTypeObject *)result; +bad: + Py_XDECREF(result); + return NULL; +} +#endif + +/* Import */ + static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { + PyObject *empty_list = 0; + PyObject *module = 0; + PyObject *global_dict = 0; + PyObject *empty_dict = 0; + PyObject *list; + #if PY_MAJOR_VERSION < 3 + PyObject *py_import; + py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); + if (!py_import) + goto bad; + #endif + if (from_list) + list = from_list; + else { + empty_list = PyList_New(0); + if (!empty_list) + goto bad; + list = empty_list; + } + global_dict = PyModule_GetDict(__pyx_m); + if (!global_dict) + goto bad; + empty_dict = PyDict_New(); + if (!empty_dict) + goto bad; + { + #if PY_MAJOR_VERSION >= 3 + if (level == -1) { + if (strchr(__Pyx_MODULE_NAME, '.')) { + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, 1); + if (!module) { + if (!PyErr_ExceptionMatches(PyExc_ImportError)) + goto bad; + PyErr_Clear(); + } + } + level = 0; + } + #endif + if (!module) { + #if PY_MAJOR_VERSION < 3 + PyObject *py_level = PyInt_FromLong(level); + if (!py_level) + goto bad; + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, py_level, (PyObject *)NULL); + Py_DECREF(py_level); + #else + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, level); + #endif + } + } +bad: + #if PY_MAJOR_VERSION < 3 + Py_XDECREF(py_import); + #endif + Py_XDECREF(empty_list); + Py_XDECREF(empty_dict); + return module; +} + +/* ImportFrom */ + static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) { + PyObject* value = __Pyx_PyObject_GetAttrStr(module, name); + if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Format(PyExc_ImportError, + #if PY_MAJOR_VERSION < 3 + "cannot import name %.230s", PyString_AS_STRING(name)); + #else + "cannot import name %S", name); + #endif + } + return value; +} + +/* CLineInTraceback */ + #ifndef CYTHON_CLINE_IN_TRACEBACK +static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) { + PyObject *use_cline; + PyObject *ptype, *pvalue, *ptraceback; +#if CYTHON_COMPILING_IN_CPYTHON + PyObject **cython_runtime_dict; +#endif + if (unlikely(!__pyx_cython_runtime)) { + return c_line; + } + __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); +#if CYTHON_COMPILING_IN_CPYTHON + cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); + if (likely(cython_runtime_dict)) { + __PYX_PY_DICT_LOOKUP_IF_MODIFIED( + use_cline, *cython_runtime_dict, + __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback)) + } else +#endif + { + PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); + if (use_cline_obj) { + use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; + Py_DECREF(use_cline_obj); + } else { + PyErr_Clear(); + use_cline = NULL; + } + } + if (!use_cline) { + c_line = 0; + PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); + } + else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) { + c_line = 0; + } + __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); + return c_line; +} +#endif + +/* CodeObjectCache */ + static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { + int start = 0, mid = 0, end = count - 1; + if (end >= 0 && code_line > entries[end].code_line) { + return count; + } + while (start < end) { + mid = start + (end - start) / 2; + if (code_line < entries[mid].code_line) { + end = mid; + } else if (code_line > entries[mid].code_line) { + start = mid + 1; + } else { + return mid; + } + } + if (code_line <= entries[mid].code_line) { + return mid; + } else { + return mid + 1; + } +} +static PyCodeObject *__pyx_find_code_object(int code_line) { + PyCodeObject* code_object; + int pos; + if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { + return NULL; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { + return NULL; + } + code_object = __pyx_code_cache.entries[pos].code_object; + Py_INCREF(code_object); + return code_object; +} +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { + int pos, i; + __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; + if (unlikely(!code_line)) { + return; + } + if (unlikely(!entries)) { + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); + if (likely(entries)) { + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = 64; + __pyx_code_cache.count = 1; + entries[0].code_line = code_line; + entries[0].code_object = code_object; + Py_INCREF(code_object); + } + return; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { + PyCodeObject* tmp = entries[pos].code_object; + entries[pos].code_object = code_object; + Py_DECREF(tmp); + return; + } + if (__pyx_code_cache.count == __pyx_code_cache.max_count) { + int new_max = __pyx_code_cache.max_count + 64; + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( + __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry)); + if (unlikely(!entries)) { + return; + } + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = new_max; + } + for (i=__pyx_code_cache.count; i>pos; i--) { + entries[i] = entries[i-1]; + } + entries[pos].code_line = code_line; + entries[pos].code_object = code_object; + __pyx_code_cache.count++; + Py_INCREF(code_object); +} + +/* AddTraceback */ + #include "compile.h" +#include "frameobject.h" +#include "traceback.h" +static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( + const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyObject *py_srcfile = 0; + PyObject *py_funcname = 0; + #if PY_MAJOR_VERSION < 3 + py_srcfile = PyString_FromString(filename); + #else + py_srcfile = PyUnicode_FromString(filename); + #endif + if (!py_srcfile) goto bad; + if (c_line) { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #else + py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #endif + } + else { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromString(funcname); + #else + py_funcname = PyUnicode_FromString(funcname); + #endif + } + if (!py_funcname) goto bad; + py_code = __Pyx_PyCode_New( + 0, + 0, + 0, + 0, + 0, + __pyx_empty_bytes, /*PyObject *code,*/ + __pyx_empty_tuple, /*PyObject *consts,*/ + __pyx_empty_tuple, /*PyObject *names,*/ + __pyx_empty_tuple, /*PyObject *varnames,*/ + __pyx_empty_tuple, /*PyObject *freevars,*/ + __pyx_empty_tuple, /*PyObject *cellvars,*/ + py_srcfile, /*PyObject *filename,*/ + py_funcname, /*PyObject *name,*/ + py_line, + __pyx_empty_bytes /*PyObject *lnotab*/ + ); + Py_DECREF(py_srcfile); + Py_DECREF(py_funcname); + return py_code; +bad: + Py_XDECREF(py_srcfile); + Py_XDECREF(py_funcname); + return NULL; +} +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyFrameObject *py_frame = 0; + PyThreadState *tstate = __Pyx_PyThreadState_Current; + if (c_line) { + c_line = __Pyx_CLineForTraceback(tstate, c_line); + } + py_code = __pyx_find_code_object(c_line ? -c_line : py_line); + if (!py_code) { + py_code = __Pyx_CreateCodeObjectForTraceback( + funcname, c_line, py_line, filename); + if (!py_code) goto bad; + __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); + } + py_frame = PyFrame_New( + tstate, /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ + ); + if (!py_frame) goto bad; + __Pyx_PyFrame_SetLineNumber(py_frame, py_line); + PyTraceBack_Here(py_frame); +bad: + Py_XDECREF(py_code); + Py_XDECREF(py_frame); +} + +/* CIntFromPyVerify */ + #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ + __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) +#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ + __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) +#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ + {\ + func_type value = func_value;\ + if (sizeof(target_type) < sizeof(func_type)) {\ + if (unlikely(value != (func_type) (target_type) value)) {\ + func_type zero = 0;\ + if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ + return (target_type) -1;\ + if (is_unsigned && unlikely(value < zero))\ + goto raise_neg_overflow;\ + else\ + goto raise_overflow;\ + }\ + }\ + return (target_type) value;\ + } + +/* CIntToPy */ + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { + const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(int) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(int) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(int) <= sizeof(long)) { + return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(int), + little, !is_unsigned); + } +} + +/* CIntToPy */ + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { + const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(long) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(long) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(long) <= sizeof(long)) { + return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(long), + little, !is_unsigned); + } +} + +/* Declarations */ + #if CYTHON_CCOMPLEX + #ifdef __cplusplus + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + return ::std::complex< float >(x, y); + } + #else + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + return x + y*(__pyx_t_float_complex)_Complex_I; + } + #endif +#else + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + __pyx_t_float_complex z; + z.real = x; + z.imag = y; + return z; + } +#endif + +/* Arithmetic */ + #if CYTHON_CCOMPLEX +#else + static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { + return (a.real == b.real) && (a.imag == b.imag); + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real + b.real; + z.imag = a.imag + b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real - b.real; + z.imag = a.imag - b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real * b.real - a.imag * b.imag; + z.imag = a.real * b.imag + a.imag * b.real; + return z; + } + #if 1 + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { + if (b.imag == 0) { + return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real); + } else if (fabsf(b.real) >= fabsf(b.imag)) { + if (b.real == 0 && b.imag == 0) { + return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.imag); + } else { + float r = b.imag / b.real; + float s = (float)(1.0) / (b.real + b.imag * r); + return __pyx_t_float_complex_from_parts( + (a.real + a.imag * r) * s, (a.imag - a.real * r) * s); + } + } else { + float r = b.real / b.imag; + float s = (float)(1.0) / (b.imag + b.real * r); + return __pyx_t_float_complex_from_parts( + (a.real * r + a.imag) * s, (a.imag * r - a.real) * s); + } + } + #else + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { + if (b.imag == 0) { + return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real); + } else { + float denom = b.real * b.real + b.imag * b.imag; + return __pyx_t_float_complex_from_parts( + (a.real * b.real + a.imag * b.imag) / denom, + (a.imag * b.real - a.real * b.imag) / denom); + } + } + #endif + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex a) { + __pyx_t_float_complex z; + z.real = -a.real; + z.imag = -a.imag; + return z; + } + static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex a) { + return (a.real == 0) && (a.imag == 0); + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex a) { + __pyx_t_float_complex z; + z.real = a.real; + z.imag = -a.imag; + return z; + } + #if 1 + static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex z) { + #if !defined(HAVE_HYPOT) || defined(_MSC_VER) + return sqrtf(z.real*z.real + z.imag*z.imag); + #else + return hypotf(z.real, z.imag); + #endif + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + float r, lnr, theta, z_r, z_theta; + if (b.imag == 0 && b.real == (int)b.real) { + if (b.real < 0) { + float denom = a.real * a.real + a.imag * a.imag; + a.real = a.real / denom; + a.imag = -a.imag / denom; + b.real = -b.real; + } + switch ((int)b.real) { + case 0: + z.real = 1; + z.imag = 0; + return z; + case 1: + return a; + case 2: + z = __Pyx_c_prod_float(a, a); + return __Pyx_c_prod_float(a, a); + case 3: + z = __Pyx_c_prod_float(a, a); + return __Pyx_c_prod_float(z, a); + case 4: + z = __Pyx_c_prod_float(a, a); + return __Pyx_c_prod_float(z, z); + } + } + if (a.imag == 0) { + if (a.real == 0) { + return a; + } else if (b.imag == 0) { + z.real = powf(a.real, b.real); + z.imag = 0; + return z; + } else if (a.real > 0) { + r = a.real; + theta = 0; + } else { + r = -a.real; + theta = atan2f(0.0, -1.0); + } + } else { + r = __Pyx_c_abs_float(a); + theta = atan2f(a.imag, a.real); + } + lnr = logf(r); + z_r = expf(lnr * b.real - theta * b.imag); + z_theta = theta * b.real + lnr * b.imag; + z.real = z_r * cosf(z_theta); + z.imag = z_r * sinf(z_theta); + return z; + } + #endif +#endif + +/* Declarations */ + #if CYTHON_CCOMPLEX + #ifdef __cplusplus + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + return ::std::complex< double >(x, y); + } + #else + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + return x + y*(__pyx_t_double_complex)_Complex_I; + } + #endif +#else + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + __pyx_t_double_complex z; + z.real = x; + z.imag = y; + return z; + } +#endif + +/* Arithmetic */ + #if CYTHON_CCOMPLEX +#else + static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + return (a.real == b.real) && (a.imag == b.imag); + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real + b.real; + z.imag = a.imag + b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real - b.real; + z.imag = a.imag - b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real * b.real - a.imag * b.imag; + z.imag = a.real * b.imag + a.imag * b.real; + return z; + } + #if 1 + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + if (b.imag == 0) { + return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real); + } else if (fabs(b.real) >= fabs(b.imag)) { + if (b.real == 0 && b.imag == 0) { + return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag); + } else { + double r = b.imag / b.real; + double s = (double)(1.0) / (b.real + b.imag * r); + return __pyx_t_double_complex_from_parts( + (a.real + a.imag * r) * s, (a.imag - a.real * r) * s); + } + } else { + double r = b.real / b.imag; + double s = (double)(1.0) / (b.imag + b.real * r); + return __pyx_t_double_complex_from_parts( + (a.real * r + a.imag) * s, (a.imag * r - a.real) * s); + } + } + #else + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + if (b.imag == 0) { + return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real); + } else { + double denom = b.real * b.real + b.imag * b.imag; + return __pyx_t_double_complex_from_parts( + (a.real * b.real + a.imag * b.imag) / denom, + (a.imag * b.real - a.real * b.imag) / denom); + } + } + #endif + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) { + __pyx_t_double_complex z; + z.real = -a.real; + z.imag = -a.imag; + return z; + } + static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) { + return (a.real == 0) && (a.imag == 0); + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) { + __pyx_t_double_complex z; + z.real = a.real; + z.imag = -a.imag; + return z; + } + #if 1 + static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) { + #if !defined(HAVE_HYPOT) || defined(_MSC_VER) + return sqrt(z.real*z.real + z.imag*z.imag); + #else + return hypot(z.real, z.imag); + #endif + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + double r, lnr, theta, z_r, z_theta; + if (b.imag == 0 && b.real == (int)b.real) { + if (b.real < 0) { + double denom = a.real * a.real + a.imag * a.imag; + a.real = a.real / denom; + a.imag = -a.imag / denom; + b.real = -b.real; + } + switch ((int)b.real) { + case 0: + z.real = 1; + z.imag = 0; + return z; + case 1: + return a; + case 2: + z = __Pyx_c_prod_double(a, a); + return __Pyx_c_prod_double(a, a); + case 3: + z = __Pyx_c_prod_double(a, a); + return __Pyx_c_prod_double(z, a); + case 4: + z = __Pyx_c_prod_double(a, a); + return __Pyx_c_prod_double(z, z); + } + } + if (a.imag == 0) { + if (a.real == 0) { + return a; + } else if (b.imag == 0) { + z.real = pow(a.real, b.real); + z.imag = 0; + return z; + } else if (a.real > 0) { + r = a.real; + theta = 0; + } else { + r = -a.real; + theta = atan2(0.0, -1.0); + } + } else { + r = __Pyx_c_abs_double(a); + theta = atan2(a.imag, a.real); + } + lnr = log(r); + z_r = exp(lnr * b.real - theta * b.imag); + z_theta = theta * b.real + lnr * b.imag; + z.real = z_r * cos(z_theta); + z.imag = z_r * sin(z_theta); + return z; + } + #endif +#endif + +/* CIntToPy */ + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__NPY_TYPES(enum NPY_TYPES value) { + const enum NPY_TYPES neg_one = (enum NPY_TYPES) ((enum NPY_TYPES) 0 - (enum NPY_TYPES) 1), const_zero = (enum NPY_TYPES) 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(enum NPY_TYPES) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(enum NPY_TYPES) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(enum NPY_TYPES) <= sizeof(long)) { + return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(enum NPY_TYPES) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(enum NPY_TYPES), + little, !is_unsigned); + } +} + +/* CIntFromPy */ + static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { + const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(int) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (int) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (int) 0; + case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) + case 2: + if (8 * sizeof(int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { + return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + case 3: + if (8 * sizeof(int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { + return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + case 4: + if (8 * sizeof(int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { + return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (int) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if (sizeof(int) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (int) 0; + case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) + case -2: + if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 2: + if (8 * sizeof(int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case -3: + if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 3: + if (8 * sizeof(int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case -4: + if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { + return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + } +#endif + if (sizeof(int) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + int val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (int) -1; + } + } else { + int val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (int) -1; + val = __Pyx_PyInt_As_int(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to int"); + return (int) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to int"); + return (int) -1; +} + +/* CIntFromPy */ + static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { + const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(long) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (long) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (long) 0; + case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) + case 2: + if (8 * sizeof(long) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { + return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + case 3: + if (8 * sizeof(long) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { + return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + case 4: + if (8 * sizeof(long) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { + return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (long) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if (sizeof(long) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (long) 0; + case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) + case -2: + if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 2: + if (8 * sizeof(long) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case -3: + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 3: + if (8 * sizeof(long) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case -4: + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(long) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + } +#endif + if (sizeof(long) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + long val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (long) -1; + } + } else { + long val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (long) -1; + val = __Pyx_PyInt_As_long(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to long"); + return (long) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to long"); + return (long) -1; +} + +/* FastTypeChecks */ + #if CYTHON_COMPILING_IN_CPYTHON +static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { + while (a) { + a = a->tp_base; + if (a == b) + return 1; + } + return b == &PyBaseObject_Type; +} +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { + PyObject *mro; + if (a == b) return 1; + mro = a->tp_mro; + if (likely(mro)) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(mro); + for (i = 0; i < n; i++) { + if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) + return 1; + } + return 0; + } + return __Pyx_InBases(a, b); +} +#if PY_MAJOR_VERSION == 2 +static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { + PyObject *exception, *value, *tb; + int res; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&exception, &value, &tb); + res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + if (!res) { + res = PyObject_IsSubclass(err, exc_type2); + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + } + __Pyx_ErrRestore(exception, value, tb); + return res; +} +#else +static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { + int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; + if (!res) { + res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); + } + return res; +} +#endif +static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { + Py_ssize_t i, n; + assert(PyExceptionClass_Check(exc_type)); + n = PyTuple_GET_SIZE(tuple); +#if PY_MAJOR_VERSION >= 3 + for (i=0; ip) { + #if PY_MAJOR_VERSION < 3 + if (t->is_unicode) { + *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); + } else if (t->intern) { + *t->p = PyString_InternFromString(t->s); + } else { + *t->p = PyString_FromStringAndSize(t->s, t->n - 1); + } + #else + if (t->is_unicode | t->is_str) { + if (t->intern) { + *t->p = PyUnicode_InternFromString(t->s); + } else if (t->encoding) { + *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); + } else { + *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); + } + } else { + *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); + } + #endif + if (!*t->p) + return -1; + if (PyObject_Hash(*t->p) == -1) + return -1; + ++t; + } + return 0; +} + +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { + return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); +} +static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { + Py_ssize_t ignore; + return __Pyx_PyObject_AsStringAndSize(o, &ignore); +} +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +#if !CYTHON_PEP393_ENABLED +static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; + } + } + } +#endif + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +} +#else +static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + if (likely(PyUnicode_IS_ASCII(o))) { + *length = PyUnicode_GET_LENGTH(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } +#else + return PyUnicode_AsUTF8AndSize(o, length); +#endif +} +#endif +#endif +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT + if ( +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + __Pyx_sys_getdefaultencoding_not_ascii && +#endif + PyUnicode_Check(o)) { + return __Pyx_PyUnicode_AsStringAndSize(o, length); + } else +#endif +#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) + if (PyByteArray_Check(o)) { + *length = PyByteArray_GET_SIZE(o); + return PyByteArray_AS_STRING(o); + } else +#endif + { + char* result; + int r = PyBytes_AsStringAndSize(o, &result, length); + if (unlikely(r < 0)) { + return NULL; + } else { + return result; + } + } +} +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { + int is_true = x == Py_True; + if (is_true | (x == Py_False) | (x == Py_None)) return is_true; + else return PyObject_IsTrue(x); +} +static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) { + int retval; + if (unlikely(!x)) return -1; + retval = __Pyx_PyObject_IsTrue(x); + Py_DECREF(x); + return retval; +} +static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { +#if PY_MAJOR_VERSION >= 3 + if (PyLong_Check(result)) { + if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, + "__int__ returned non-int (type %.200s). " + "The ability to return an instance of a strict subclass of int " + "is deprecated, and may be removed in a future version of Python.", + Py_TYPE(result)->tp_name)) { + Py_DECREF(result); + return NULL; + } + return result; + } +#endif + PyErr_Format(PyExc_TypeError, + "__%.4s__ returned non-%.4s (type %.200s)", + type_name, type_name, Py_TYPE(result)->tp_name); + Py_DECREF(result); + return NULL; +} +static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { +#if CYTHON_USE_TYPE_SLOTS + PyNumberMethods *m; +#endif + const char *name = NULL; + PyObject *res = NULL; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x) || PyLong_Check(x))) +#else + if (likely(PyLong_Check(x))) +#endif + return __Pyx_NewRef(x); +#if CYTHON_USE_TYPE_SLOTS + m = Py_TYPE(x)->tp_as_number; + #if PY_MAJOR_VERSION < 3 + if (m && m->nb_int) { + name = "int"; + res = m->nb_int(x); + } + else if (m && m->nb_long) { + name = "long"; + res = m->nb_long(x); + } + #else + if (likely(m && m->nb_int)) { + name = "int"; + res = m->nb_int(x); + } + #endif +#else + if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { + res = PyNumber_Int(x); + } +#endif + if (likely(res)) { +#if PY_MAJOR_VERSION < 3 + if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { +#else + if (unlikely(!PyLong_CheckExact(res))) { +#endif + return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); + } + } + else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, + "an integer is required"); + } + return res; +} +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { + Py_ssize_t ival; + PyObject *x; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact(b))) { + if (sizeof(Py_ssize_t) >= sizeof(long)) + return PyInt_AS_LONG(b); + else + return PyInt_AsSsize_t(b); + } +#endif + if (likely(PyLong_CheckExact(b))) { + #if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)b)->ob_digit; + const Py_ssize_t size = Py_SIZE(b); + if (likely(__Pyx_sst_abs(size) <= 1)) { + ival = likely(size) ? digits[0] : 0; + if (size == -1) ival = -ival; + return ival; + } else { + switch (size) { + case 2: + if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { + return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -2: + if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case 3: + if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { + return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -3: + if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case 4: + if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { + return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -4: + if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + } + } + #endif + return PyLong_AsSsize_t(b); + } + x = PyNumber_Index(b); + if (!x) return -1; + ival = PyInt_AsSsize_t(x); + Py_DECREF(x); + return ival; +} +static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { + return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False); +} +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { + return PyInt_FromSize_t(ival); +} + + +#endif /* Py_PYTHON_H */ diff --git a/src/mesh/pynastranIO.h b/src/mesh/pynastranIO.h new file mode 100644 index 00000000..530fc404 --- /dev/null +++ b/src/mesh/pynastranIO.h @@ -0,0 +1,60 @@ +/* Generated by Cython 0.29.12 */ + +#ifndef __PYX_HAVE__pynastranIO +#define __PYX_HAVE__pynastranIO + +struct BDFModel; + +/* "pynastranIO.pyx":33 + * + * + * cdef public class BDFModel[object BDFModel, type BDFModelType]: # <<<<<<<<<<<<<< + * cdef: + * string bdfPath + */ +struct BDFModel { + PyObject_HEAD + std::string bdfPath; + int nDims; + int nNodes; + int nElems; + int nMaterials; + int nProperties; + std::map nElemTypes; + PyObject *myBDF; +}; + +#ifndef __PYX_HAVE_API__pynastranIO + +#ifndef __PYX_EXTERN_C + #ifdef __cplusplus + #define __PYX_EXTERN_C extern "C" + #else + #define __PYX_EXTERN_C extern + #endif +#endif + +#ifndef DL_IMPORT + #define DL_IMPORT(_T) _T +#endif + +__PYX_EXTERN_C DL_IMPORT(PyTypeObject) BDFModelType; + +__PYX_EXTERN_C struct BDFModel *buildBDFModel(std::string); +__PYX_EXTERN_C void printBDFStats(struct BDFModel *); +__PYX_EXTERN_C std::vector > getNodes(struct BDFModel *); +__PYX_EXTERN_C std::map > > getElements(struct BDFModel *); +__PYX_EXTERN_C std::map getNumberOfElementTypes(struct BDFModel *); + +#endif /* !__PYX_HAVE_API__pynastranIO */ + +/* WARNING: the interface of the module init function changed in CPython 3.5. */ +/* It now returns a PyModuleDef instance instead of a PyModule instance. */ + +#if PY_MAJOR_VERSION < 3 +PyMODINIT_FUNC initpynastranIO(void); +#else +PyMODINIT_FUNC PyInit_pynastranIO(void); +#endif + +#endif /* !__PYX_HAVE__pynastranIO */ diff --git a/src/mesh/pynastranIO.pyx b/src/mesh/pynastranIO.pyx new file mode 100644 index 00000000..d2b1a0e1 --- /dev/null +++ b/src/mesh/pynastranIO.pyx @@ -0,0 +1,248 @@ +# distutils: language = c++ +# ^^^ This line above is read by setup.py and lets it know to compile the +# program as C++ instead of the default, C. + +""" +pyNASTRAN Notes +--------------- +Dependencies: cpylog, scipy, numpy +""" + +# pyNastran Imports +from pyNastran.bdf.bdf import BDF + +# Standard C++ Imports +from libcpp.string cimport string +from libcpp.vector cimport vector +from libcpp.map cimport map +from libcpp cimport bool +from libcpp.list cimport list as clist +from libcpp.set cimport set as cset + +# Cython Imports +from cython.operator import dereference, postincrement +from warnings import warn + +# Setup Numpy Usage +import numpy as np +cimport numpy as np +DTYPE = np.float +ctypedef np.float_t DTYPE_t + + +cdef public class BDFModel[object BDFModel, type BDFModelType]: + cdef: + string bdfPath + + # The readonly specifier allows C/C++ code to still access these variables, but prevents them from changing it. + cdef readonly : + int nDims + int nNodes + int nElems + int nMaterials + int nProperties + map[string, int] nElemTypes + + # Need to declare this here, even without a type specifier. Otherwise, + # a "Segmentation fault (core dumped)" error occurs. + cdef myBDF + + def __cinit__(self, string bdf_path): + self.bdfPath = bdf_path + self.myBDF = BDF() + nm = bdf_path.decode("UTF-8") + self.myBDF.read_bdf(nm) + self.nNodes = self.myBDF.nnodes + self.nElems = self.myBDF.nelements + self.nMaterials = self.myBDF.nmaterials + self.nProperties = self.myBDF.nproperties + # self.temperatures = None + + # Perturb the nodes of zero-length vectors, this is a hack to make zero-length + # elements work in MAST. + perturbZeroLengthBushings(self) + + +cdef public BDFModel buildBDFModel(string bdf_path): + """ + Acts as the constructor for the BDFModel class. + """ + return BDFModel(bdf_path) + + +cdef public void printBDFStats(BDFModel model): + print(model.myBDF.get_bdf_stats()) + print("card_count = %s\n"%model.myBDF.card_count) + print("reject_count = %s\n"%model.myBDF.reject_count) + + +cdef public vector[vector[double]] getNodes(BDFModel model): + """ + Creates a vector of vectors where each row is the node id and coordinates of + a single node (id, x, y, z). Also determines the dimension of the model. + + Notes + ---- + Have to manually add "#include " to the pynastran.h file for this + to work. Is there a way to tell setup.py to automatically do this? + + References + ---------- + "Cython, confusion, regarding the vector (size) constructor", StackOverflow, + Ami Tavory, Jan 16, 2016. + """ + # Get the number of rows and columns + cdef int n = model.nNodes # Number of Nodes + cdef int m = 4 # node number + 3 dimensions = 4 + + # Create a 2D vector (vector of vectors) to store node numbers and coords + cdef vector[double] node_vec + cdef vector[vector[double]] nodes + node_vec = vector[double](m) + nodes = vector[vector[double]](n, node_vec) + + # Iterate over all nodes and all them to the 2D vector + cdef bool anyZ = False + cdef bool anyY = False + cdef bool anyX = False + cdef int i = 0 + for key in model.myBDF.nodes: + node = model.myBDF.nodes[key] + nodes[i][0] = node.nid + nodes[i][1] = node.xyz[0] + nodes[i][2] = node.xyz[1] + nodes[i][3] = node.xyz[2] + if node.xyz[0]!=0.0: + anyX = True + if node.xyz[1]!=0.0: + anyY = True + if node.xyz[2]!=0.0: + anyZ = True + i += 1 + + if anyZ: + model.nDims = 3 + elif anyY: + model.nDims = 2 + elif anyX: + model.nDims = 1 + else: + model.nDims = 0 + + return nodes + + +cdef public map[string, vector[vector[int]]] getElements(BDFModel model): + """ + Creates a map of the elements contained in the model. The keys of the map are the element type and the values + of the map is a 2D vector (vector of vector) which stores element ID, property ID, and node numbers. + """ + cdef int n = model.nElems # Number of elements + + cdef map[string, vector[vector[int]]] elementMap; + + # Pre-allocate space to store the element information + cdef map[string, int] elemTypes = getNumberOfElementTypes(model) + cdef map[string, int] i_counter + cdef map[string, int].iterator it = elemTypes.begin() + cdef vector[int] elem_vec + cdef vector[vector[int]] elements + cdef int m, nElemNodes + while(it != elemTypes.end()): + # print(dereference(it).first) # print the key + # print(dereference(it).second) # print the associated value + elemType = dereference(it).first + nElemTypes = dereference(it).second + nElemNodes = int(str(elemType).split("_")[-1].strip("'")) + m = nElemNodes+2 + + elem_vec = vector[int](m) + elementMap[elemType] = vector[vector[int]](nElemTypes, elem_vec) + + i_counter[elemType] = 0 + + postincrement(it) # Increment the iterator to the net element + mapKeys = [] + + # Loop through the elements in the BDF and all the to element map + cdef int i + cdef int j + for key,element in model.myBDF.elements.items(): + if "offset" in element.object_attributes(): + if element.offset!=0: + raise NotImplementedError("Support of non-zero offsets not yet implemented!") + if "zoffset" in element.object_attributes(): + if element.zoffset!=0: + raise NotImplementedError("Support of non-zero offets not yet implemented!") + nElemNodes = len(element.nodes) + elemType = (element.type + "_%i"%(nElemNodes)).encode('utf-8') + i = i_counter[elemType] + elementMap[elemType][i][0] = element.eid + elementMap[elemType][i][1] = element.pid + for j in range(nElemNodes): + elementMap[elemType][i][j+2] = element.nodes[j] + i_counter[elemType] = i_counter[elemType]+1 + + return elementMap + + +cdef public map[string, int] getNumberOfElementTypes(BDFModel model): + """ + Gets a map of the different element types and the number of each element type in the model. Useful for + pre-allocation when importing elements. + """ + cdef map[string, int] elementTypes + elemTypeList = [] + for key, element in model.myBDF.elements.items(): + elemType = (element.type + "_%i"%(len(element.nodes))).encode("utf-8") + if elemType not in elemTypeList: + elemTypeList.append(elemType) + elementTypes[elemType] = 1 + else: + elementTypes[elemType] += 1 + + model.nElemTypes = elementTypes + return elementTypes + + +cdef perturbZeroLengthBushings(BDFModel model): + """ + As of November 18, 2019, MAST does not support the specification of the elemental x-axis which is required when + the element has a zero-length (i.e. CBUSH in Nastran) and the x-axis cannot be determined from the geometry. This + method provides a work around by getting the x-axis from the coordinate system the bushing references and then + perturbing one of the nodes by a very small distance in the direction of the x-axis. This then allows MAST to + determine the x-axis from geometry and introduces a negligible effect on the stiffness matrix of the bushing + element. + """ + cdef int k + cdef double eps, nzero, L + eps=1.4901161193847656e-08 + nzero=1e-08 + + # Get element IDs of bushing elements + data = model.myBDF.get_elements_properties_nodes_by_element_type() + eids = [] + if "CBUSH" in data.keys(): + eids += (data["CBUSH"][0]).tolist() + if "CBUSH1D" in data.keys(): + eids += (data["CBUSH1D"][0]).tolist() + if "CBUSH2D" in data.keys(): + eids += (data["CBUSH2D"][0]).tolist() + + # Loop through all bushing elements + for k in range(len(eids)): + eid = eids[k] + bushing = model.myBDF.elements[eid] + L = np.linalg.norm(bushing.nodes_ref[1].xyz - bushing.nodes_ref[0].xyz) + if abs(L)0 and an x-axis can be defined by the geometry + i = bushing.cid_ref.i + di = eps*i + absmindi = abs(di).min() + if absmindi Date: Thu, 21 Nov 2019 21:09:55 -0500 Subject: [PATCH 013/111] Make NastranIO support optional in CMake build. - NastranIO adds Python dependency not needed otherwise so we make this support optional. --- CMakeLists.txt | 27 +++++++++++++++------------ src/CMakeLists.txt | 6 ++---- src/mesh/CMakeLists.txt | 20 +++++++++++++++----- 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e8950065..c0a8b813 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,14 +14,14 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) include(GNUInstallDirs) # Build options with defaults. -option(ENABLE_GCMMA "Build with GCMMA interface" OFF) -option(ENABLE_DOT "Build with DOT interface" OFF) -option(ENABLE_SNOPT "Build with SNOPT interface" OFF) -option(ENABLE_NLOPT "Build with NLOPT interface" OFF) -option(ENABLE_CYTHON "Build with CYTHON interface" OFF) -option(BUILD_DOC "Build documentation" OFF) - -# Required dependency paths. +option(ENABLE_GCMMA "Build with GCMMA interface" OFF) +option(ENABLE_DOT "Build with DOT interface" OFF) +option(ENABLE_SNOPT "Build with SNOPT interface" OFF) +option(ENABLE_NLOPT "Build with NLOPT interface" OFF) +option(ENABLE_NASTRANIO "Build with support for reading Nastran meshes" OFF) +option(BUILD_DOC "Build documentation" OFF) + +# Dependency paths - these paths help CMake find dependencies. set(MAST_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}) set(libMesh_DIR "libMesh_DIR" CACHE PATH "Directory containing libMesh include/ and lib/") set(PETSc_DIR "PETSc_DIR" CACHE PATH "Directory containing PETSc include/ and lib/") @@ -29,9 +29,9 @@ set(PETSc_ARCH "PETSc_ARCH" CACHE STRING "Configuration/build of PETSc that sh set(SLEPc_DIR "SLEPc_DIR" CACHE PATH "Directory containing SLEPc include/ and lib/") set(SLEPc_ARCH "SLEPc_ARCH" CACHE STRING "Configuration/build of SLEPc that should be used.") set(EIGEN3_ROOT "Eigen_DIR" CACHE PATH "Directory containing eigen header files") -set(DOT_DIR "DOT_DIR" CACHE PATH "Directory containing DOT lib/") -set(SNOPT_DIR "SNOpt_DIR" CACHE PATH "Directory containing SNOPT lib/") -set(NLOPT_DIR "NLOpt_DIR" CACHE PATH "Directory containing NLOpt include/ and lib/") +set(DOT_DIR "DOT_DIR" CACHE PATH "Directory containing DOT lib/") +set(SNOPT_DIR "SNOpt_DIR" CACHE PATH "Directory containing SNOPT lib/") +set(NLOPT_DIR "NLOpt_DIR" CACHE PATH "Directory containing NLOpt include/ and lib/") # EXTERNALLY PROVIDED CONTENT # None. Use this if we pull something in during the build in the future. @@ -54,7 +54,6 @@ set(Boost_NO_BOOST_CMAKE ON) find_package(Boost COMPONENTS iostreams system filesystem unit_test_framework REQUIRED) message("-- Found Boost include: ${Boost_INCLUDE_DIRS}") # To ensure the found Boost is what user expected message("-- Found Boost libs: ${Boost_LIBRARY_DIRS}") # To ensure the found Boost is what user expected -find_package(Python3 REQUIRED COMPONENTS Development) # Find optional packages. if (ENABLE_GCMMA) @@ -84,6 +83,10 @@ else() set (MAST_ENABLE_NLOPT 0) endif() +if (ENABLE_NASTRANIO) + find_package(Python3 REQUIRED COMPONENTS Development) +endif() + # MAIN TARGETS add_subdirectory(src) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8ef735d5..de73d122 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,8 +18,7 @@ target_include_directories(mast ${libMesh_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR} ${NLOPT_INCLUDE_DIR} - ${Boost_INCLUDE_DIRS} - ${Python3_INCLUDE_DIRS}) # Could possibly move this into src/optimization since it is closer to where Boost is actually used. + ${Boost_INCLUDE_DIRS}) # Could possibly move this into src/optimization since it is closer to where Boost is actually used. # Add libraries. target_link_libraries(mast @@ -38,8 +37,7 @@ target_link_libraries(mast ${Boost_SYSTEM_LIBRARY} debug ${libMesh_dbg_LIBRARIES} optimized ${libMesh_opt_LIBRARIES} - ${LIBGFORTRAN_LIBRARIES} - ${Python3_LIBRARIES}) + ${LIBGFORTRAN_LIBRARIES}) # NOTE: Use of PUBLIC keyword above means other CMake target (like an example) # that target_link_library(XXXX mast) will inheret these properties. diff --git a/src/mesh/CMakeLists.txt b/src/mesh/CMakeLists.txt index bdd547b4..b0b25c57 100644 --- a/src/mesh/CMakeLists.txt +++ b/src/mesh/CMakeLists.txt @@ -5,11 +5,21 @@ target_sources(mast ${CMAKE_CURRENT_LIST_DIR}/geom_elem.cpp ${CMAKE_CURRENT_LIST_DIR}/geom_elem.h ${CMAKE_CURRENT_LIST_DIR}/mesh_coupling_base.cpp - ${CMAKE_CURRENT_LIST_DIR}/mesh_coupling_base.h - ${CMAKE_CURRENT_LIST_DIR}/pynastranIO.h - ${CMAKE_CURRENT_LIST_DIR}/pynastranIO.cpp - ${CMAKE_CURRENT_LIST_DIR}/NastranIO.cpp - ${CMAKE_CURRENT_LIST_DIR}/NastranIO.h) + ${CMAKE_CURRENT_LIST_DIR}/mesh_coupling_base.h) + +# Only add NastranIO sources if we are building Nastran mesh support. Also add Python includes +# and libraries to mast target. +if(ENABLE_NASTRANIO) + target_sources(mast + PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/pynastranIO.h + ${CMAKE_CURRENT_LIST_DIR}/pynastranIO.cpp + ${CMAKE_CURRENT_LIST_DIR}/NastranIO.cpp + ${CMAKE_CURRENT_LIST_DIR}/NastranIO.h) + + target_include_directories(mast PUBLIC ${Python3_INCLUDE_DIRS}) + target_link_libraries(mast PUBLIC ${Python3_LIBRARIES}) +endif() # Install MAST headers for this directory. install(DIRECTORY ./ DESTINATION include/mesh From 28a836ab8b63350ad9c73f9863f9a0369bc41e0c Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Fri, 22 Nov 2019 11:37:18 -0500 Subject: [PATCH 014/111] Check for pyNastran module dependency in CMake configure. - Increment to CMake 3.13 requirement due to improved support for adding includes/libraries to targets (3.13) and FindPython (3.12). --- CMakeLists.txt | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c0a8b813..2a60b74f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # PREAMBLE -cmake_minimum_required(VERSION 3.12) +cmake_minimum_required(VERSION 3.13) project(MAST VERSION 0.3 LANGUAGES C CXX) @@ -84,7 +84,20 @@ else() endif() if (ENABLE_NASTRANIO) - find_package(Python3 REQUIRED COMPONENTS Development) + find_package(Python3 REQUIRED COMPONENTS Development Interpreter) + message(STATUS " Python3_EXECUTABLE: ${Python3_EXECUTABLE}") + message(STATUS " Python3_INCLUDE_DIR: ${Python3_INCLUDE_DIR}") + message(STATUS " Python3_LIBRARY_RELEASE: ${Python3_LIBRARY_RELEASE}") + + execute_process(COMMAND ${Python3_EXECUTABLE} -c "import pyNastran" + RESULT_VARIABLE PYNASTRAN_ERROR) + if(PYNASTRAN_ERROR) + message(FATAL_ERROR "Error finding pyNastran package for Python3_EXECUTABLE!") + else() + message(STATUS " pyNastran package found") + endif() + +# message(STATUS " Python3_EXECUTABLE: ${Python3_EXECUTABLE}") endif() # MAIN TARGETS From 9ce5ca9b2d7aa9990cf5b6aefc95c287a7503f8f Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Fri, 22 Nov 2019 11:56:59 -0500 Subject: [PATCH 015/111] Update CMake version on Travis CI Linux build. - Reference: https://askubuntu.com/questions/355565/how-do-i-install-the-latest-version-of-cmake-from-the-command-line --- ci/build_dependencies.sh | 6 ++++++ ci/build_mast.sh | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ci/build_dependencies.sh b/ci/build_dependencies.sh index 3f630aab..67d8c807 100755 --- a/ci/build_dependencies.sh +++ b/ci/build_dependencies.sh @@ -13,6 +13,12 @@ if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux sudo apt-get -qq install -y doxygen graphviz rsync sudo apt-get -qq install -y texlive-latex-base dvi2ps ghostscript + # Update to later CMake release. + cd ${HOME} || exit + wget https://github.com/Kitware/CMake/releases/download/v3.15.5/cmake-3.15.5-Linux-x86_64.sh || exit + sudo mkdir /opt/cmake || exit + sudo sh cmake-3.15.5-Linux-x86_64.sh --prefix=/opt/cmake || exit + # elif [ "${TRAVIS_DIST}" = bionic ]; then # Ubuntu 18.04 Bionic Beaver # sudo apt-get -qq update # sudo apt-get -qq install -y gfortran wget m4 diff --git a/ci/build_mast.sh b/ci/build_mast.sh index 980c2b2f..7f13abd5 100755 --- a/ci/build_mast.sh +++ b/ci/build_mast.sh @@ -18,7 +18,7 @@ if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux # First let us build/install a Release (optimized) version of MAST (-DCMAKE_BUILD_TYPE=Release). echo "TEST RELEASE/OPTIMIZED BUILD..." cd build_rel || exit - cmake .. \ + /opt/cmake .. \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX="${MAST_INSTALL_DIR}" \ -DCMAKE_C_COMPILER=mpicc \ From ea462951907ea6f7d1cd835414cec6554657ee6d Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Fri, 22 Nov 2019 12:10:45 -0500 Subject: [PATCH 016/111] Toggle on option for pyNastran build in CI scripts. --- ci/build_mast.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ci/build_mast.sh b/ci/build_mast.sh index 7f13abd5..d13858c3 100755 --- a/ci/build_mast.sh +++ b/ci/build_mast.sh @@ -32,7 +32,8 @@ if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux -DBUILD_DOC=ON \ -DENABLE_DOT=OFF \ -DENABLE_GCMMA=OFF \ - -DENABLE_SNOPT=OFF || exit + -DENABLE_SNOPT=OFF \ + -DENABLE_NASTRANIO=ON || exit if [ ${CI_BUILD_DOCS} ]; then make doc_doxygen || exit @@ -51,7 +52,7 @@ if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux else cd ../build_dbg || exit - cmake .. \ + /opt/cmake .. \ -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_INSTALL_PREFIX="${MAST_INSTALL_DIR}" \ -DCMAKE_C_COMPILER=mpicc \ @@ -65,7 +66,8 @@ if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux -DBUILD_DOC=ON \ -DENABLE_DOT=OFF \ -DENABLE_GCMMA=OFF \ - -DENABLE_SNOPT=OFF || exit + -DENABLE_SNOPT=OFF\ + -DENABLE_NASTRANIO=ON || exit if [ ${CI_BUILD_DOCS} ]; then echo "No CI documentation for a Debug build." @@ -120,7 +122,8 @@ elif [ "${TRAVIS_OS_NAME}" = osx ]; then # macOS 10.14, XCode 10.2 -DENABLE_SNOPT=OFF \ -DENABLE_NLOPT=OFF \ -DENABLE_CYTHON=OFF \ - -DBUILD_DOC=OFF || exit + -DBUILD_DOC=OFF \ + -DENABLE_NASTRANIO=ON || exit make -j 2 || exit make install || exit @@ -146,7 +149,8 @@ elif [ "${TRAVIS_OS_NAME}" = osx ]; then # macOS 10.14, XCode 10.2 -DENABLE_SNOPT=OFF \ -DENABLE_NLOPT=OFF \ -DENABLE_CYTHON=OFF \ - -DBUILD_DOC=OFF || exit + -DBUILD_DOC=OFF \ + -DENABLE_NASTRANIO=ON || exit make -j 2 || exit else From 92ffe34a4b047f313a50dad57b03e9471dbf77f3 Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Fri, 22 Nov 2019 17:43:24 -0500 Subject: [PATCH 017/111] Custom CMake module to find Python3. - Built-in CMake still seems to have trouble finding consistent interpreter/headers/library when there are multiple options. Has been especially troublesome on macOS or when using Spack built Python. --- CMakeLists.txt | 7 +-- ci/build_dependencies.sh | 23 +++++++++- ci/build_mast.sh | 6 ++- cmake/FindPython3.cmake | 92 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 118 insertions(+), 10 deletions(-) create mode 100644 cmake/FindPython3.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a60b74f..305ed6b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,10 +84,7 @@ else() endif() if (ENABLE_NASTRANIO) - find_package(Python3 REQUIRED COMPONENTS Development Interpreter) - message(STATUS " Python3_EXECUTABLE: ${Python3_EXECUTABLE}") - message(STATUS " Python3_INCLUDE_DIR: ${Python3_INCLUDE_DIR}") - message(STATUS " Python3_LIBRARY_RELEASE: ${Python3_LIBRARY_RELEASE}") + find_package(Python3 REQUIRED)# COMPONENTS Development Interpreter) execute_process(COMMAND ${Python3_EXECUTABLE} -c "import pyNastran" RESULT_VARIABLE PYNASTRAN_ERROR) @@ -96,8 +93,6 @@ if (ENABLE_NASTRANIO) else() message(STATUS " pyNastran package found") endif() - -# message(STATUS " Python3_EXECUTABLE: ${Python3_EXECUTABLE}") endif() # MAIN TARGETS diff --git a/ci/build_dependencies.sh b/ci/build_dependencies.sh index 67d8c807..30423ffb 100755 --- a/ci/build_dependencies.sh +++ b/ci/build_dependencies.sh @@ -3,6 +3,12 @@ if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux if [ "${TRAVIS_DIST}" = xenial ]; then # Ubuntu 16.04 Xenial Xerus + cd ${HOME} || exit + + # Python 3.6 apt repository (since its not neatly included in Ubuntu 16.04) + sudo add-apt-repository -y ppa:deadsnakes/ppa + + # Regular libMesh/MAST dependencies. sudo apt-get -qq update sudo apt-get -qq install -y gfortran wget m4 sudo apt-get -qq install -y openmpi-bin libopenmpi-dev @@ -12,12 +18,25 @@ if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux sudo apt-get -qq install -y libeigen3-dev sudo apt-get -qq install -y doxygen graphviz rsync sudo apt-get -qq install -y texlive-latex-base dvi2ps ghostscript + sudo apt-get -qq install -y python3.6 python3.6-dev libpython3.6 + + wget https://bootstrap.pypa.io/get-pip.py || exit + sudo python3.6 get-pip.py || exit + + sudo which python + sudo which python3 + sudo which python3.6 + python --version + python3 --version + python3.6 --version + sudo which pip + sudo which pip3 + #sudo pip3 install numpy # Update to later CMake release. - cd ${HOME} || exit wget https://github.com/Kitware/CMake/releases/download/v3.15.5/cmake-3.15.5-Linux-x86_64.sh || exit sudo mkdir /opt/cmake || exit - sudo sh cmake-3.15.5-Linux-x86_64.sh --prefix=/opt/cmake || exit + sudo sh cmake-3.15.5-Linux-x86_64.sh --prefix=/opt/cmake --skip-license || exit # elif [ "${TRAVIS_DIST}" = bionic ]; then # Ubuntu 18.04 Bionic Beaver # sudo apt-get -qq update diff --git a/ci/build_mast.sh b/ci/build_mast.sh index d13858c3..97c9711d 100755 --- a/ci/build_mast.sh +++ b/ci/build_mast.sh @@ -18,7 +18,7 @@ if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux # First let us build/install a Release (optimized) version of MAST (-DCMAKE_BUILD_TYPE=Release). echo "TEST RELEASE/OPTIMIZED BUILD..." cd build_rel || exit - /opt/cmake .. \ + /opt/cmake/bin/cmake .. \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX="${MAST_INSTALL_DIR}" \ -DCMAKE_C_COMPILER=mpicc \ @@ -52,7 +52,7 @@ if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux else cd ../build_dbg || exit - /opt/cmake .. \ + /opt/cmake/bin/cmake .. \ -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_INSTALL_PREFIX="${MAST_INSTALL_DIR}" \ -DCMAKE_C_COMPILER=mpicc \ @@ -117,6 +117,7 @@ elif [ "${TRAVIS_OS_NAME}" = osx ]; then # macOS 10.14, XCode 10.2 -DEIGEN3_ROOT=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/eigen-3.3.7-bd2r4aqrkox7dpebj2r3gqvgpqzwuh7x \ -DLAPACK_LIBRARIES=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openblas-0.3.7-xqeap7iegoomce3es67cd7exlnq3neue/lib/libopenblas.dylib \ -DBLAS_LIBRARIES=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openblas-0.3.7-xqeap7iegoomce3es67cd7exlnq3neue/lib/libopenblas.dylib \ + -DPython3_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-wiaaasdpryqnn6l46xcmj3ekqvruyx7d \ -DENABLE_GCMMA=OFF \ -DENABLE_DOT=OFF \ -DENABLE_SNOPT=OFF \ @@ -144,6 +145,7 @@ elif [ "${TRAVIS_OS_NAME}" = osx ]; then # macOS 10.14, XCode 10.2 -DEIGEN3_ROOT=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/eigen-3.3.7-bd2r4aqrkox7dpebj2r3gqvgpqzwuh7x \ -DLAPACK_LIBRARIES=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openblas-0.3.7-xqeap7iegoomce3es67cd7exlnq3neue/lib/libopenblas.dylib \ -DBLAS_LIBRARIES=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openblas-0.3.7-xqeap7iegoomce3es67cd7exlnq3neue/lib/libopenblas.dylib \ + -DPython3_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-wiaaasdpryqnn6l46xcmj3ekqvruyx7d \ -DENABLE_GCMMA=OFF \ -DENABLE_DOT=OFF \ -DENABLE_SNOPT=OFF \ diff --git a/cmake/FindPython3.cmake b/cmake/FindPython3.cmake new file mode 100644 index 00000000..2b59a125 --- /dev/null +++ b/cmake/FindPython3.cmake @@ -0,0 +1,92 @@ +# This module relies on Python3_DIR being set. +# +# The reason that we include this module rather than the CMake provided +# FindPythonInterp, FindPythonLibs, or FindPython is that they seem to be unable +# consistently find matching Python interpreter and libraries when there +# are multiple Python distributions available (especially on macOS). +# We use a HINT in this module to try to hone in on a single Python distribution. +# +# Python3_FOUND - Python 3 required components are on the system. +# Python3_EXECUTABLE - Path to Python 3 interpreter. +# Python3_LIBRARIES - Paths to Python 3 libraries. +# Python3_INCLUDE_DIRS - Python 3 include directories (including site-packages). + +# Acceptable Python versions. +set(_PY_VERSIONS 3.8 3.7 3.6) + +# Here we ensure MacOS system provided Python distributions are found by CMake +# last because they typically don't have the functionality we want. +set(CMAKE_FIND_FRAMEWORK LAST) +set(CMAKE_FIND_APPBUNDLE LAST) + +# Build list of acceptable Python executables that we will look for. +set(_PY_NAMES "") +foreach(_PY_VER ${_PY_VERSIONS}) + list(APPEND _PY_NAMES "python${_PY_VER}") +endforeach() + +# Find path to Python interpreter. We call find_program() twice to make sure we +# search user provided Python3_DIR (CMake variable) before trying default +# system environment paths. +find_program(Python3_EXECUTABLE + NAMES ${_PY_NAMES} + HINTS + ${Python3_DIR} + PATH_SUFFIXES + "bin" + NO_DEFAULT_PATH) +find_program(Python3_EXECUTABLE + NAMES ${_PY_NAMES}) + +# Find root directory of Python distribution. Stored in Python_ROOT_DIR. +get_filename_component(Python3_BIN_DIR ${Python3_EXECUTABLE} DIRECTORY) +get_filename_component(Python3_ROOT_DIR ${Python3_BIN_DIR} DIRECTORY) +# Also, get name of Python interpreter that we actually found above. +# Stored in Python_NAME. +get_filename_component(Python3_NAME ${Python3_EXECUTABLE} NAME) + +# Find the Python headers. +# -- Currently we search relative to Python_ROOT_DIR we found above. +find_path(Python3_INCLUDE_DIR Python.h + HINTS + ${Python3_ROOT_DIR}/include/${Python3_NAME}/ + ${Python3_ROOT_DIR}/include/${Python3_NAME}m/) + +# Find the Python library. Store also library directory to help +# find modules/site-packages. +# -- Currently we search relative to Python_ROOT_DIR we found above. +find_library(Python3_LIBRARY + NAMES ${Python3_NAME} + HINTS ${Python3_ROOT_DIR}/lib) +get_filename_component(Python3_LIBRARY_DIR ${Python3_LIBRARY} DIRECTORY) + +# Find the mpi4py headers required for Cython wrapper. +# find_path(mpi4py_INCLUDE_DIR MPI.pxd +# HINTS +# ${Python_LIBRARY_DIR}/${Python_NAME}/site-packages/mpi4py) + +# find_path(Python_MODULEDIR mpi4py/MPI.pxd +# HINTS +# ${Python_LIBRARY_DIR}/${Python_NAME}/site-packages) + +# Set standard CMake variables and output status. +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Python3 + REQUIRED_VARS + Python3_EXECUTABLE + Python3_LIBRARY + Python3_INCLUDE_DIR) + # mpi4py_INCLUDE_DIR) +message(STATUS " Python3_EXECUTABLE: ${Python3_EXECUTABLE}") +message(STATUS " Python3_INCLUDE_DIR: ${Python3_INCLUDE_DIR}") +message(STATUS " Python3_LIBRARY: ${Python3_LIBRARY}") +message(STATUS " Python3 Modules: ${Python3_MODULEDIR}") +# +#message("-- mpi4py Headers: ${mpi4py_INCLUDE_DIR}") + +# Advance cache variables. +mark_as_advanced(Python3_INCLUDE_DIR Python3_LIBRARY Python3_EXECUTABLE) + +# Roll-up libraries and headers into standard CMake variables. +set(Python3_LIBRARIES ${Python3_LIBRARY}) +set(Python3_INCLUDE_DIRS ${Python3_INCLUDE_DIR})# ${mpi4py_INCLUDE_DIR}) \ No newline at end of file From c8cb2020e1ba92476d5ccef83e8aebff60dbd3a7 Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Sat, 23 Nov 2019 19:31:40 -0500 Subject: [PATCH 018/111] Configure Travis macOS to use Python with shared library. --- ci/build_mast.sh | 4 ++-- cmake/FindPython3.cmake | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/ci/build_mast.sh b/ci/build_mast.sh index 97c9711d..0a54a280 100755 --- a/ci/build_mast.sh +++ b/ci/build_mast.sh @@ -117,7 +117,7 @@ elif [ "${TRAVIS_OS_NAME}" = osx ]; then # macOS 10.14, XCode 10.2 -DEIGEN3_ROOT=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/eigen-3.3.7-bd2r4aqrkox7dpebj2r3gqvgpqzwuh7x \ -DLAPACK_LIBRARIES=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openblas-0.3.7-xqeap7iegoomce3es67cd7exlnq3neue/lib/libopenblas.dylib \ -DBLAS_LIBRARIES=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openblas-0.3.7-xqeap7iegoomce3es67cd7exlnq3neue/lib/libopenblas.dylib \ - -DPython3_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-wiaaasdpryqnn6l46xcmj3ekqvruyx7d \ + -DPython3_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk \ -DENABLE_GCMMA=OFF \ -DENABLE_DOT=OFF \ -DENABLE_SNOPT=OFF \ @@ -145,7 +145,7 @@ elif [ "${TRAVIS_OS_NAME}" = osx ]; then # macOS 10.14, XCode 10.2 -DEIGEN3_ROOT=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/eigen-3.3.7-bd2r4aqrkox7dpebj2r3gqvgpqzwuh7x \ -DLAPACK_LIBRARIES=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openblas-0.3.7-xqeap7iegoomce3es67cd7exlnq3neue/lib/libopenblas.dylib \ -DBLAS_LIBRARIES=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openblas-0.3.7-xqeap7iegoomce3es67cd7exlnq3neue/lib/libopenblas.dylib \ - -DPython3_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-wiaaasdpryqnn6l46xcmj3ekqvruyx7d \ + -DPython3_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk \ -DENABLE_GCMMA=OFF \ -DENABLE_DOT=OFF \ -DENABLE_SNOPT=OFF \ diff --git a/cmake/FindPython3.cmake b/cmake/FindPython3.cmake index 2b59a125..adee561c 100644 --- a/cmake/FindPython3.cmake +++ b/cmake/FindPython3.cmake @@ -42,7 +42,7 @@ find_program(Python3_EXECUTABLE get_filename_component(Python3_BIN_DIR ${Python3_EXECUTABLE} DIRECTORY) get_filename_component(Python3_ROOT_DIR ${Python3_BIN_DIR} DIRECTORY) # Also, get name of Python interpreter that we actually found above. -# Stored in Python_NAME. +# Stored in Python3_NAME. get_filename_component(Python3_NAME ${Python3_EXECUTABLE} NAME) # Find the Python headers. @@ -56,7 +56,7 @@ find_path(Python3_INCLUDE_DIR Python.h # find modules/site-packages. # -- Currently we search relative to Python_ROOT_DIR we found above. find_library(Python3_LIBRARY - NAMES ${Python3_NAME} + NAMES ${Python3_NAME} ${Python3_NAME}m HINTS ${Python3_ROOT_DIR}/lib) get_filename_component(Python3_LIBRARY_DIR ${Python3_LIBRARY} DIRECTORY) @@ -69,6 +69,12 @@ get_filename_component(Python3_LIBRARY_DIR ${Python3_LIBRARY} DIRECTORY) # HINTS # ${Python_LIBRARY_DIR}/${Python_NAME}/site-packages) +# Output what we found. +message(STATUS " Python3_EXECUTABLE: ${Python3_EXECUTABLE}") +message(STATUS " Python3_INCLUDE_DIR: ${Python3_INCLUDE_DIR}") +message(STATUS " Python3_LIBRARY: ${Python3_LIBRARY}") +message(STATUS " Python3 Modules: ${Python3_MODULEDIR}") + # Set standard CMake variables and output status. include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Python3 @@ -77,11 +83,6 @@ find_package_handle_standard_args(Python3 Python3_LIBRARY Python3_INCLUDE_DIR) # mpi4py_INCLUDE_DIR) -message(STATUS " Python3_EXECUTABLE: ${Python3_EXECUTABLE}") -message(STATUS " Python3_INCLUDE_DIR: ${Python3_INCLUDE_DIR}") -message(STATUS " Python3_LIBRARY: ${Python3_LIBRARY}") -message(STATUS " Python3 Modules: ${Python3_MODULEDIR}") -# #message("-- mpi4py Headers: ${mpi4py_INCLUDE_DIR}") # Advance cache variables. From 8a10c1fc9c97dcffb4d47352b3a1972fbd6bee06 Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Sat, 23 Nov 2019 21:48:02 -0500 Subject: [PATCH 019/111] Update CMake NastranIO support to find req'd Numpy header path. - CMake >3.12 able to find Numpy headers itself, but we are using custom FindPython3. --- CMakeLists.txt | 11 +++++++++++ src/mesh/CMakeLists.txt | 23 ++++++++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 305ed6b1..af426a5f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,6 +86,7 @@ endif() if (ENABLE_NASTRANIO) find_package(Python3 REQUIRED)# COMPONENTS Development Interpreter) + # Make sure Python has pyNastran. execute_process(COMMAND ${Python3_EXECUTABLE} -c "import pyNastran" RESULT_VARIABLE PYNASTRAN_ERROR) if(PYNASTRAN_ERROR) @@ -93,6 +94,16 @@ if (ENABLE_NASTRANIO) else() message(STATUS " pyNastran package found") endif() + + # Make sure Python has NumPy. + execute_process(COMMAND ${Python3_EXECUTABLE} -c "import numpy" + RESULT_VARIABLE NUMPY_ERROR) + if(NUMPY_ERROR) + message(FATAL_ERROR "Error finding pyNastran package for Python3_EXECUTABLE!") + else() + message(STATUS " Numpy package found") + endif() + endif() # MAIN TARGETS diff --git a/src/mesh/CMakeLists.txt b/src/mesh/CMakeLists.txt index b0b25c57..cbd9253e 100644 --- a/src/mesh/CMakeLists.txt +++ b/src/mesh/CMakeLists.txt @@ -7,9 +7,9 @@ target_sources(mast ${CMAKE_CURRENT_LIST_DIR}/mesh_coupling_base.cpp ${CMAKE_CURRENT_LIST_DIR}/mesh_coupling_base.h) -# Only add NastranIO sources if we are building Nastran mesh support. Also add Python includes -# and libraries to mast target. +# Only add NastranIO/Python data to mast target if we are building Nastran mesh support. if(ENABLE_NASTRANIO) + # Add sources to mast target. target_sources(mast PRIVATE ${CMAKE_CURRENT_LIST_DIR}/pynastranIO.h @@ -17,7 +17,24 @@ if(ENABLE_NASTRANIO) ${CMAKE_CURRENT_LIST_DIR}/NastranIO.cpp ${CMAKE_CURRENT_LIST_DIR}/NastranIO.h) - target_include_directories(mast PUBLIC ${Python3_INCLUDE_DIRS}) + # Find Numpy header path. + execute_process( + COMMAND "${Python3_EXECUTABLE}" -c "import numpy; print(numpy.get_include(), end='')" + RESULT_VARIABLE NUMPY_ERROR + OUTPUT_VARIABLE NUMPY_INCLUDE_PATH + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NUMPY_ERROR) + message(FATAL_ERROR "Error finding Numpy header path for Python3_EXECUTABLE!") + else() + message(STATUS " Numpy header path: ${NUMPY_INCLUDE_PATH}") + endif() + + # Add header/library to mast target. + target_include_directories(mast + PUBLIC + ${Python3_INCLUDE_DIRS} + ${NUMPY_INCLUDE_PATH}) target_link_libraries(mast PUBLIC ${Python3_LIBRARIES}) endif() From 6bc3238ac5e6e0035da21339ccaac9f8c16256cb Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Sat, 23 Nov 2019 22:31:33 -0500 Subject: [PATCH 020/111] Travis CI Linux configuration for Python 3.6 & pyNastran. --- ci/build_dependencies.sh | 11 ++--------- ci/build_mast.sh | 2 ++ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/ci/build_dependencies.sh b/ci/build_dependencies.sh index 30423ffb..20a369f4 100755 --- a/ci/build_dependencies.sh +++ b/ci/build_dependencies.sh @@ -20,18 +20,11 @@ if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux sudo apt-get -qq install -y texlive-latex-base dvi2ps ghostscript sudo apt-get -qq install -y python3.6 python3.6-dev libpython3.6 + # Get pip working with external Python 3.6. wget https://bootstrap.pypa.io/get-pip.py || exit sudo python3.6 get-pip.py || exit - sudo which python - sudo which python3 - sudo which python3.6 - python --version - python3 --version - python3.6 --version - sudo which pip - sudo which pip3 - #sudo pip3 install numpy + sudo python3.6 -m pip install numpy scipy docopt colorama pandas h5py matplotlib cpylog pyNastran # Update to later CMake release. wget https://github.com/Kitware/CMake/releases/download/v3.15.5/cmake-3.15.5-Linux-x86_64.sh || exit diff --git a/ci/build_mast.sh b/ci/build_mast.sh index 0a54a280..786c2a23 100755 --- a/ci/build_mast.sh +++ b/ci/build_mast.sh @@ -28,6 +28,7 @@ if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux -DPETSc_DIR=/usr/lib/petscdir/3.6.2/x86_64-linux-gnu-real \ -DSLEPc_DIR=/usr/lib/slepcdir/3.6.1/x86_64-linux-gnu-real \ -DEIGEN3_ROOT=/usr/include/eigen3 \ + -DPython3_DIR=/usr \ -DBOOST_ROOT=/usr \ -DBUILD_DOC=ON \ -DENABLE_DOT=OFF \ @@ -62,6 +63,7 @@ if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux -DPETSc_DIR=/usr/lib/petscdir/3.6.2/x86_64-linux-gnu-real \ -DSLEPc_DIR=/usr/lib/slepcdir/3.6.1/x86_64-linux-gnu-real \ -DEIGEN3_ROOT=/usr/include/eigen3 \ + -DPython3_DIR=/usr \ -DBOOST_ROOT=/usr \ -DBUILD_DOC=ON \ -DENABLE_DOT=OFF \ From fb0d5cc43da2aecd7a9597733a7dab726e5ba631 Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Tue, 26 Nov 2019 10:45:35 -0500 Subject: [PATCH 021/111] Added optional target to CMake build to run Cython. - Option only necessary if developing Python bindings and making changes to pyNastran interface currently. --- CMakeLists.txt | 4 +-- ci/build_dependencies.sh | 1 + ci/build_mast.sh | 14 +++++++--- cmake/FindCython.cmake | 58 ++++++++++++++++++++++++++++++++++++++++ src/mesh/CMakeLists.txt | 29 +++++++++++++++++++- 5 files changed, 99 insertions(+), 7 deletions(-) create mode 100644 cmake/FindCython.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index af426a5f..ae2904d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ option(ENABLE_DOT "Build with DOT interface" OFF) option(ENABLE_SNOPT "Build with SNOPT interface" OFF) option(ENABLE_NLOPT "Build with NLOPT interface" OFF) option(ENABLE_NASTRANIO "Build with support for reading Nastran meshes" OFF) +option(ENABLE_CYTHON "Build with support for Cython development" OFF) option(BUILD_DOC "Build documentation" OFF) # Dependency paths - these paths help CMake find dependencies. @@ -84,7 +85,7 @@ else() endif() if (ENABLE_NASTRANIO) - find_package(Python3 REQUIRED)# COMPONENTS Development Interpreter) + find_package(Python3 REQUIRED) # Make sure Python has pyNastran. execute_process(COMMAND ${Python3_EXECUTABLE} -c "import pyNastran" @@ -103,7 +104,6 @@ if (ENABLE_NASTRANIO) else() message(STATUS " Numpy package found") endif() - endif() # MAIN TARGETS diff --git a/ci/build_dependencies.sh b/ci/build_dependencies.sh index 20a369f4..1a4d97f9 100755 --- a/ci/build_dependencies.sh +++ b/ci/build_dependencies.sh @@ -25,6 +25,7 @@ if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux sudo python3.6 get-pip.py || exit sudo python3.6 -m pip install numpy scipy docopt colorama pandas h5py matplotlib cpylog pyNastran + sudo python3.6 -m pip install Cython --install-option="--no-cython-compile" # Update to later CMake release. wget https://github.com/Kitware/CMake/releases/download/v3.15.5/cmake-3.15.5-Linux-x86_64.sh || exit diff --git a/ci/build_mast.sh b/ci/build_mast.sh index 786c2a23..ab861834 100755 --- a/ci/build_mast.sh +++ b/ci/build_mast.sh @@ -34,7 +34,8 @@ if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux -DENABLE_DOT=OFF \ -DENABLE_GCMMA=OFF \ -DENABLE_SNOPT=OFF \ - -DENABLE_NASTRANIO=ON || exit + -DENABLE_NASTRANIO=ON \ + -DENABLE_CYTHON=ON || exit if [ ${CI_BUILD_DOCS} ]; then make doc_doxygen || exit @@ -69,7 +70,8 @@ if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux -DENABLE_DOT=OFF \ -DENABLE_GCMMA=OFF \ -DENABLE_SNOPT=OFF\ - -DENABLE_NASTRANIO=ON || exit + -DENABLE_NASTRANIO=ON \ + -DENABLE_CYTHON=ON || exit if [ ${CI_BUILD_DOCS} ]; then echo "No CI documentation for a Debug build." @@ -126,7 +128,9 @@ elif [ "${TRAVIS_OS_NAME}" = osx ]; then # macOS 10.14, XCode 10.2 -DENABLE_NLOPT=OFF \ -DENABLE_CYTHON=OFF \ -DBUILD_DOC=OFF \ - -DENABLE_NASTRANIO=ON || exit + -DENABLE_NASTRANIO=ON \ + -DENABLE_CYTHON=ON || exit + make -j 2 || exit make install || exit @@ -154,7 +158,9 @@ elif [ "${TRAVIS_OS_NAME}" = osx ]; then # macOS 10.14, XCode 10.2 -DENABLE_NLOPT=OFF \ -DENABLE_CYTHON=OFF \ -DBUILD_DOC=OFF \ - -DENABLE_NASTRANIO=ON || exit + -DENABLE_NASTRANIO=ON \ + -DENABLE_CYTHON=ON || exit + make -j 2 || exit else diff --git a/cmake/FindCython.cmake b/cmake/FindCython.cmake new file mode 100644 index 00000000..b8871ff1 --- /dev/null +++ b/cmake/FindCython.cmake @@ -0,0 +1,58 @@ +# Find the Cython compiler. +# +# This code sets the following variables: +# +# Cython_FOUND - Cython is available on the system. +# Cython_EXECUTABLE - Path to the Cython executable. +# +# Note this file is a modified version of that provided by Kitware online. +# --- see original Kitware copyright statement at bottom of file. + +# Use the Cython executable that lives next to the Python executable if it +# exists. If not, we will use whatever we can find on the system paths. +if(Python3_FOUND) + get_filename_component(_PYTHON_PATH ${Python3_EXECUTABLE} PATH) + find_program(Cython_EXECUTABLE + NAMES + cython + cython.bat + cython3 + HINTS ${_PYTHON_PATH}) +else() + find_program(Cython_EXECUTABLE + NAMES + cython + cython.bat + cython3) +endif() + +# Set standard CMake variables and output status. +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Cython + REQUIRED_VARS + Cython_EXECUTABLE) + +# Advance cache variables. +mark_as_advanced(Cython_EXECUTABLE) + + + + + +# Original Kitware copywrite statement. Modifications to code included +# formatting changes to utilize MAST-Interface version of FindPython.cmake. +#============================================================================= +# Copyright 2011 Kitware, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#============================================================================= \ No newline at end of file diff --git a/src/mesh/CMakeLists.txt b/src/mesh/CMakeLists.txt index cbd9253e..155a117f 100644 --- a/src/mesh/CMakeLists.txt +++ b/src/mesh/CMakeLists.txt @@ -7,8 +7,35 @@ target_sources(mast ${CMAKE_CURRENT_LIST_DIR}/mesh_coupling_base.cpp ${CMAKE_CURRENT_LIST_DIR}/mesh_coupling_base.h) -# Only add NastranIO/Python data to mast target if we are building Nastran mesh support. +# Only add NastranIO/Python data to `mast` target if we are building Nastran mesh support. if(ENABLE_NASTRANIO) + + # Cython is currently not required unless you want to make changes in pynastranIO.pyx + # and generate new pynastranIO.h/.cpp. If you want to modify pynastranIO.pyx, make sure + # to set ENABLE_CYTHON=ON and CMake will ensure Cython is executed to generate updated + # bindings prior to all `mast` target builds. + if (ENABLE_CYTHON) + + # Make sure we have the Cython compiler. + find_package(Cython REQUIRED) + + # Define the target to run Cython. + add_custom_target(cython_pynastran + DEPENDS + ${CMAKE_CURRENT_LIST_DIR}/pynastranIO.pyx + COMMAND + ${Cython_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/pynastranIO.pyx --cplus -3 -Werror #-Wextra + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + BYPRODUCTS + ${CMAKE_CURRENT_LIST_DIR}/pynastranIO.h + ${CMAKE_CURRENT_LIST_DIR}/pynastranIO.cpp + COMMENT + "Running Cython to generate pyNastran bindings.") + + # Make the MAST library target `mast` dependency on running Cython. + add_dependencies(mast cython_pynastran) + endif() + # Add sources to mast target. target_sources(mast PRIVATE From 5f6f8335bfc2b6ba6125f9c66de3809b1a77424d Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Tue, 26 Nov 2019 12:09:28 -0500 Subject: [PATCH 022/111] Renamed Nastran mesh interface files to match existing MAST style. --- src/mesh/CMakeLists.txt | 22 +- src/mesh/{NastranIO.cpp => nastran_io.cpp} | 4 +- src/mesh/{NastranIO.h => nastran_io.h} | 4 +- .../{pynastranIO.cpp => pynastran_io.cpp} | 1017 ++++++++--------- src/mesh/{pynastranIO.h => pynastran_io.h} | 18 +- .../{pynastranIO.pyx => pynastran_io.pyx} | 0 6 files changed, 521 insertions(+), 544 deletions(-) rename src/mesh/{NastranIO.cpp => nastran_io.cpp} (99%) rename src/mesh/{NastranIO.h => nastran_io.h} (98%) rename src/mesh/{pynastranIO.cpp => pynastran_io.cpp} (92%) rename src/mesh/{pynastranIO.h => pynastran_io.h} (78%) rename src/mesh/{pynastranIO.pyx => pynastran_io.pyx} (100%) diff --git a/src/mesh/CMakeLists.txt b/src/mesh/CMakeLists.txt index 155a117f..38f3a9c3 100644 --- a/src/mesh/CMakeLists.txt +++ b/src/mesh/CMakeLists.txt @@ -7,11 +7,11 @@ target_sources(mast ${CMAKE_CURRENT_LIST_DIR}/mesh_coupling_base.cpp ${CMAKE_CURRENT_LIST_DIR}/mesh_coupling_base.h) -# Only add NastranIO/Python data to `mast` target if we are building Nastran mesh support. +# Only add nastran_io/Python data to `mast` target if we are building Nastran mesh support. if(ENABLE_NASTRANIO) - # Cython is currently not required unless you want to make changes in pynastranIO.pyx - # and generate new pynastranIO.h/.cpp. If you want to modify pynastranIO.pyx, make sure + # Cython is currently not required unless you want to make changes in pynastran_io.pyx + # and generate new pynastran_io.h/.cpp. If you want to modify pynastran_io.pyx, make sure # to set ENABLE_CYTHON=ON and CMake will ensure Cython is executed to generate updated # bindings prior to all `mast` target builds. if (ENABLE_CYTHON) @@ -22,13 +22,13 @@ if(ENABLE_NASTRANIO) # Define the target to run Cython. add_custom_target(cython_pynastran DEPENDS - ${CMAKE_CURRENT_LIST_DIR}/pynastranIO.pyx + ${CMAKE_CURRENT_LIST_DIR}/pynastran_io.pyx COMMAND - ${Cython_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/pynastranIO.pyx --cplus -3 -Werror #-Wextra + ${Cython_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/pynastran_io.pyx --cplus -3 -Werror #-Wextra WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} BYPRODUCTS - ${CMAKE_CURRENT_LIST_DIR}/pynastranIO.h - ${CMAKE_CURRENT_LIST_DIR}/pynastranIO.cpp + ${CMAKE_CURRENT_LIST_DIR}/pynastran_io.h + ${CMAKE_CURRENT_LIST_DIR}/pynastran_io.cpp COMMENT "Running Cython to generate pyNastran bindings.") @@ -39,10 +39,10 @@ if(ENABLE_NASTRANIO) # Add sources to mast target. target_sources(mast PRIVATE - ${CMAKE_CURRENT_LIST_DIR}/pynastranIO.h - ${CMAKE_CURRENT_LIST_DIR}/pynastranIO.cpp - ${CMAKE_CURRENT_LIST_DIR}/NastranIO.cpp - ${CMAKE_CURRENT_LIST_DIR}/NastranIO.h) + ${CMAKE_CURRENT_LIST_DIR}/pynastran_io.h + ${CMAKE_CURRENT_LIST_DIR}/pynastran_io.cpp + ${CMAKE_CURRENT_LIST_DIR}/nastran_io.cpp + ${CMAKE_CURRENT_LIST_DIR}/nastran_io.h) # Find Numpy header path. execute_process( diff --git a/src/mesh/NastranIO.cpp b/src/mesh/nastran_io.cpp similarity index 99% rename from src/mesh/NastranIO.cpp rename to src/mesh/nastran_io.cpp index e88b368b..3961b384 100644 --- a/src/mesh/NastranIO.cpp +++ b/src/mesh/nastran_io.cpp @@ -13,7 +13,7 @@ #include "libmesh/elem.h" // Local includes -#include "mesh/NastranIO.h" +#include "mesh/nastran_io.h" #include "Python.h" @@ -247,7 +247,7 @@ void NastranIO::read(BDFModel* model) void NastranIO::initializePython() { // StackOverFlow, "Use generated header file from Cython" - int status = PyImport_AppendInittab("pynastranIO", PyInit_pynastranIO); + int status = PyImport_AppendInittab("pynastranIO", PyInit_pynastran_io); if(status==1){ libmesh_error_msg("ERROR: During Python import for pynastranIO."); } diff --git a/src/mesh/NastranIO.h b/src/mesh/nastran_io.h similarity index 98% rename from src/mesh/NastranIO.h rename to src/mesh/nastran_io.h index 703d8e33..f8d5be33 100644 --- a/src/mesh/NastranIO.h +++ b/src/mesh/nastran_io.h @@ -13,8 +13,8 @@ #include "libmesh/elem.h" #include "Python.h" -#include "mesh/NastranIO.h" -#include "mesh/pynastranIO.h" +#include "mesh/nastran_io.h" +#include "mesh/pynastran_io.h" void printElementMap(std::map>> elementMap); diff --git a/src/mesh/pynastranIO.cpp b/src/mesh/pynastran_io.cpp similarity index 92% rename from src/mesh/pynastranIO.cpp rename to src/mesh/pynastran_io.cpp index aad96a3c..f3c264c8 100644 --- a/src/mesh/pynastranIO.cpp +++ b/src/mesh/pynastran_io.cpp @@ -1,18 +1,4 @@ -/* Generated by Cython 0.29.12 */ - -/* BEGIN: Cython Metadata -{ - "distutils": { - "depends": [], - "language": "c++", - "name": "pynastranIO", - "sources": [ - "pynastranIO.pyx" - ] - }, - "module_name": "pynastranIO" -} -END: Cython Metadata */ +/* Generated by Cython 0.29.6 */ #define PY_SSIZE_T_CLEAN #include "Python.h" @@ -21,8 +7,8 @@ END: Cython Metadata */ #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) #error Cython requires Python 2.6+ or Python 3.3+. #else -#define CYTHON_ABI "0_29_12" -#define CYTHON_HEX_VERSION 0x001D0CF0 +#define CYTHON_ABI "0_29_6" +#define CYTHON_HEX_VERSION 0x001D06F0 #define CYTHON_FUTURE_DIVISION 1 #include #ifndef offsetof @@ -338,13 +324,8 @@ class __Pyx_FakeReference { #define __Pyx_DefaultClassType PyClass_Type #else #define __Pyx_BUILTIN_MODULE_NAME "builtins" -#if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2 - #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ - PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) -#else #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) -#endif #define __Pyx_DefaultClassType PyType_Type #endif #ifndef Py_TPFLAGS_CHECKTYPES @@ -618,8 +599,8 @@ static CYTHON_INLINE float __PYX_NAN() { #endif #endif -#define __PYX_HAVE__pynastranIO -#define __PYX_HAVE_API__pynastranIO +#define __PYX_HAVE__pynastran_io +#define __PYX_HAVE_API__pynastran_io /* Early includes */ #include #include "ios" @@ -866,12 +847,12 @@ static const char *__pyx_filename; static const char *__pyx_f[] = { "stringsource", - "pynastranIO.pyx", + "pynastran_io.pyx", "__init__.pxd", "type.pxd", }; -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":776 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":776 * # in Cython to enable them only on the right systems. * * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< @@ -880,7 +861,7 @@ static const char *__pyx_f[] = { */ typedef npy_int8 __pyx_t_5numpy_int8_t; -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":777 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":777 * * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< @@ -889,7 +870,7 @@ typedef npy_int8 __pyx_t_5numpy_int8_t; */ typedef npy_int16 __pyx_t_5numpy_int16_t; -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":778 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":778 * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< @@ -898,7 +879,7 @@ typedef npy_int16 __pyx_t_5numpy_int16_t; */ typedef npy_int32 __pyx_t_5numpy_int32_t; -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":779 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":779 * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< @@ -907,7 +888,7 @@ typedef npy_int32 __pyx_t_5numpy_int32_t; */ typedef npy_int64 __pyx_t_5numpy_int64_t; -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":783 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":783 * #ctypedef npy_int128 int128_t * * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< @@ -916,7 +897,7 @@ typedef npy_int64 __pyx_t_5numpy_int64_t; */ typedef npy_uint8 __pyx_t_5numpy_uint8_t; -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":784 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":784 * * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< @@ -925,7 +906,7 @@ typedef npy_uint8 __pyx_t_5numpy_uint8_t; */ typedef npy_uint16 __pyx_t_5numpy_uint16_t; -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":785 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":785 * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< @@ -934,7 +915,7 @@ typedef npy_uint16 __pyx_t_5numpy_uint16_t; */ typedef npy_uint32 __pyx_t_5numpy_uint32_t; -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":786 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":786 * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< @@ -943,7 +924,7 @@ typedef npy_uint32 __pyx_t_5numpy_uint32_t; */ typedef npy_uint64 __pyx_t_5numpy_uint64_t; -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":790 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":790 * #ctypedef npy_uint128 uint128_t * * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< @@ -952,7 +933,7 @@ typedef npy_uint64 __pyx_t_5numpy_uint64_t; */ typedef npy_float32 __pyx_t_5numpy_float32_t; -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":791 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":791 * * ctypedef npy_float32 float32_t * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< @@ -961,7 +942,7 @@ typedef npy_float32 __pyx_t_5numpy_float32_t; */ typedef npy_float64 __pyx_t_5numpy_float64_t; -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":800 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":800 * # The int types are mapped a bit surprising -- * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t # <<<<<<<<<<<<<< @@ -970,7 +951,7 @@ typedef npy_float64 __pyx_t_5numpy_float64_t; */ typedef npy_long __pyx_t_5numpy_int_t; -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< @@ -979,7 +960,7 @@ typedef npy_long __pyx_t_5numpy_int_t; */ typedef npy_longlong __pyx_t_5numpy_long_t; -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":802 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":802 * ctypedef npy_long int_t * ctypedef npy_longlong long_t * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< @@ -988,7 +969,7 @@ typedef npy_longlong __pyx_t_5numpy_long_t; */ typedef npy_longlong __pyx_t_5numpy_longlong_t; -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":804 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":804 * ctypedef npy_longlong longlong_t * * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< @@ -997,7 +978,7 @@ typedef npy_longlong __pyx_t_5numpy_longlong_t; */ typedef npy_ulong __pyx_t_5numpy_uint_t; -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":805 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":805 * * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< @@ -1006,7 +987,7 @@ typedef npy_ulong __pyx_t_5numpy_uint_t; */ typedef npy_ulonglong __pyx_t_5numpy_ulong_t; -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":806 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":806 * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< @@ -1015,7 +996,7 @@ typedef npy_ulonglong __pyx_t_5numpy_ulong_t; */ typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":808 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":808 * ctypedef npy_ulonglong ulonglong_t * * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< @@ -1024,7 +1005,7 @@ typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; */ typedef npy_intp __pyx_t_5numpy_intp_t; -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":809 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":809 * * ctypedef npy_intp intp_t * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< @@ -1033,7 +1014,7 @@ typedef npy_intp __pyx_t_5numpy_intp_t; */ typedef npy_uintp __pyx_t_5numpy_uintp_t; -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":811 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":811 * ctypedef npy_uintp uintp_t * * ctypedef npy_double float_t # <<<<<<<<<<<<<< @@ -1042,7 +1023,7 @@ typedef npy_uintp __pyx_t_5numpy_uintp_t; */ typedef npy_double __pyx_t_5numpy_float_t; -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":812 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":812 * * ctypedef npy_double float_t * ctypedef npy_double double_t # <<<<<<<<<<<<<< @@ -1051,7 +1032,7 @@ typedef npy_double __pyx_t_5numpy_float_t; */ typedef npy_double __pyx_t_5numpy_double_t; -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":813 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":813 * ctypedef npy_double float_t * ctypedef npy_double double_t * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< @@ -1060,14 +1041,14 @@ typedef npy_double __pyx_t_5numpy_double_t; */ typedef npy_longdouble __pyx_t_5numpy_longdouble_t; -/* "pynastranIO.pyx":30 +/* "pynastran_io.pyx":30 * cimport numpy as np * DTYPE = np.float * ctypedef np.float_t DTYPE_t # <<<<<<<<<<<<<< * * */ -typedef __pyx_t_5numpy_float_t __pyx_t_11pynastranIO_DTYPE_t; +typedef __pyx_t_5numpy_float_t __pyx_t_12pynastran_io_DTYPE_t; /* Declarations.proto */ #if CYTHON_CCOMPLEX #ifdef __cplusplus @@ -1096,7 +1077,7 @@ static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(do /*--- Type declarations ---*/ struct BDFModel; -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":815 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":815 * ctypedef npy_longdouble longdouble_t * * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< @@ -1105,7 +1086,7 @@ struct BDFModel; */ typedef npy_cfloat __pyx_t_5numpy_cfloat_t; -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":816 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":816 * * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< @@ -1114,7 +1095,7 @@ typedef npy_cfloat __pyx_t_5numpy_cfloat_t; */ typedef npy_cdouble __pyx_t_5numpy_cdouble_t; -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":817 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":817 * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< @@ -1123,7 +1104,7 @@ typedef npy_cdouble __pyx_t_5numpy_cdouble_t; */ typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":819 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":819 * ctypedef npy_clongdouble clongdouble_t * * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< @@ -1132,7 +1113,7 @@ typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; */ typedef npy_cdouble __pyx_t_5numpy_complex_t; -/* "pynastranIO.pyx":33 +/* "pynastran_io.pyx":33 * * * cdef public class BDFModel[object BDFModel, type BDFModelType]: # <<<<<<<<<<<<<< @@ -1291,7 +1272,7 @@ static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name); #define __Pyx_PyFunction_FastCall(func, args, nargs)\ __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) #if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs); +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs); #else #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) #endif @@ -1869,14 +1850,14 @@ static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0; static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0; static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/ -/* Module declarations from 'pynastranIO' */ -static PyTypeObject *__pyx_ptype_11pynastranIO_BDFModel = 0; +/* Module declarations from 'pynastran_io' */ +static PyTypeObject *__pyx_ptype_12pynastran_io_BDFModel = 0; __PYX_EXTERN_C struct BDFModel *buildBDFModel(std::string); /*proto*/ __PYX_EXTERN_C void printBDFStats(struct BDFModel *); /*proto*/ __PYX_EXTERN_C std::vector > getNodes(struct BDFModel *); /*proto*/ __PYX_EXTERN_C std::map > > getElements(struct BDFModel *); /*proto*/ __PYX_EXTERN_C std::map getNumberOfElementTypes(struct BDFModel *); /*proto*/ -static PyObject *__pyx_f_11pynastranIO_perturbZeroLengthBushings(struct BDFModel *); /*proto*/ +static PyObject *__pyx_f_12pynastran_io_perturbZeroLengthBushings(struct BDFModel *); /*proto*/ static std::string __pyx_convert_string_from_py_std__in_string(PyObject *); /*proto*/ static CYTHON_INLINE PyObject *__pyx_convert_PyObject_string_to_py_std__in_string(std::string const &); /*proto*/ static CYTHON_INLINE PyObject *__pyx_convert_PyUnicode_string_to_py_std__in_string(std::string const &); /*proto*/ @@ -1884,11 +1865,11 @@ static CYTHON_INLINE PyObject *__pyx_convert_PyStr_string_to_py_std__in_string(s static CYTHON_INLINE PyObject *__pyx_convert_PyBytes_string_to_py_std__in_string(std::string const &); /*proto*/ static CYTHON_INLINE PyObject *__pyx_convert_PyByteArray_string_to_py_std__in_string(std::string const &); /*proto*/ static PyObject *__pyx_convert_map_to_py_std_3a__3a_string____int(std::map const &); /*proto*/ -#define __Pyx_MODULE_NAME "pynastranIO" -extern int __pyx_module_is_main_pynastranIO; -int __pyx_module_is_main_pynastranIO = 0; +#define __Pyx_MODULE_NAME "pynastran_io" +extern int __pyx_module_is_main_pynastran_io; +int __pyx_module_is_main_pynastran_io = 0; -/* Implementation of 'pynastranIO' */ +/* Implementation of 'pynastran_io' */ static PyObject *__pyx_builtin_TypeError; static PyObject *__pyx_builtin_print; static PyObject *__pyx_builtin_NotImplementedError; @@ -2061,18 +2042,18 @@ static PyObject *__pyx_n_s_x; static PyObject *__pyx_n_s_xyz; static PyObject *__pyx_n_s_zoffset; static PyObject *__pyx_n_u_zoffset; -static int __pyx_pf_11pynastranIO_8BDFModel___cinit__(struct BDFModel *__pyx_v_self, std::string __pyx_v_bdf_path); /* proto */ -static PyObject *__pyx_pf_11pynastranIO_8BDFModel_5nDims___get__(struct BDFModel *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_11pynastranIO_8BDFModel_6nNodes___get__(struct BDFModel *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_11pynastranIO_8BDFModel_6nElems___get__(struct BDFModel *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_11pynastranIO_8BDFModel_10nMaterials___get__(struct BDFModel *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_11pynastranIO_8BDFModel_11nProperties___get__(struct BDFModel *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_11pynastranIO_8BDFModel_10nElemTypes___get__(struct BDFModel *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_11pynastranIO_8BDFModel_2__reduce_cython__(CYTHON_UNUSED struct BDFModel *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_11pynastranIO_8BDFModel_4__setstate_cython__(CYTHON_UNUSED struct BDFModel *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ +static int __pyx_pf_12pynastran_io_8BDFModel___cinit__(struct BDFModel *__pyx_v_self, std::string __pyx_v_bdf_path); /* proto */ +static PyObject *__pyx_pf_12pynastran_io_8BDFModel_5nDims___get__(struct BDFModel *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_12pynastran_io_8BDFModel_6nNodes___get__(struct BDFModel *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_12pynastran_io_8BDFModel_6nElems___get__(struct BDFModel *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_12pynastran_io_8BDFModel_10nMaterials___get__(struct BDFModel *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_12pynastran_io_8BDFModel_11nProperties___get__(struct BDFModel *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_12pynastran_io_8BDFModel_10nElemTypes___get__(struct BDFModel *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_12pynastran_io_8BDFModel_2__reduce_cython__(CYTHON_UNUSED struct BDFModel *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_12pynastran_io_8BDFModel_4__setstate_cython__(CYTHON_UNUSED struct BDFModel *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ -static PyObject *__pyx_tp_new_11pynastranIO_BDFModel(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_12pynastran_io_BDFModel(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_float_0_0; static PyObject *__pyx_int_0; static PyObject *__pyx_tuple_; @@ -2088,7 +2069,7 @@ static PyObject *__pyx_tuple__12; static PyObject *__pyx_tuple__13; /* Late includes */ -/* "pynastranIO.pyx":50 +/* "pynastran_io.pyx":50 * cdef myBDF * * def __cinit__(self, string bdf_path): # <<<<<<<<<<<<<< @@ -2097,8 +2078,8 @@ static PyObject *__pyx_tuple__13; */ /* Python wrapper */ -static int __pyx_pw_11pynastranIO_8BDFModel_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pw_11pynastranIO_8BDFModel_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static int __pyx_pw_12pynastran_io_8BDFModel_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_12pynastran_io_8BDFModel_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { std::string __pyx_v_bdf_path; int __pyx_r; __Pyx_RefNannyDeclarations @@ -2135,18 +2116,18 @@ static int __pyx_pw_11pynastranIO_8BDFModel_1__cinit__(PyObject *__pyx_v_self, P __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 50, __pyx_L3_error) __pyx_L3_error:; - __Pyx_AddTraceback("pynastranIO.BDFModel.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("pynastran_io.BDFModel.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_11pynastranIO_8BDFModel___cinit__(((struct BDFModel *)__pyx_v_self), __pyx_v_bdf_path); + __pyx_r = __pyx_pf_12pynastran_io_8BDFModel___cinit__(((struct BDFModel *)__pyx_v_self), __pyx_v_bdf_path); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static int __pyx_pf_11pynastranIO_8BDFModel___cinit__(struct BDFModel *__pyx_v_self, std::string __pyx_v_bdf_path) { +static int __pyx_pf_12pynastran_io_8BDFModel___cinit__(struct BDFModel *__pyx_v_self, std::string __pyx_v_bdf_path) { PyObject *__pyx_v_nm = NULL; int __pyx_r; __Pyx_RefNannyDeclarations @@ -2156,7 +2137,7 @@ static int __pyx_pf_11pynastranIO_8BDFModel___cinit__(struct BDFModel *__pyx_v_s int __pyx_t_4; __Pyx_RefNannySetupContext("__cinit__", 0); - /* "pynastranIO.pyx":51 + /* "pynastran_io.pyx":51 * * def __cinit__(self, string bdf_path): * self.bdfPath = bdf_path # <<<<<<<<<<<<<< @@ -2165,7 +2146,7 @@ static int __pyx_pf_11pynastranIO_8BDFModel___cinit__(struct BDFModel *__pyx_v_s */ __pyx_v_self->bdfPath = __pyx_v_bdf_path; - /* "pynastranIO.pyx":52 + /* "pynastran_io.pyx":52 * def __cinit__(self, string bdf_path): * self.bdfPath = bdf_path * self.myBDF = BDF() # <<<<<<<<<<<<<< @@ -2195,7 +2176,7 @@ static int __pyx_pf_11pynastranIO_8BDFModel___cinit__(struct BDFModel *__pyx_v_s __pyx_v_self->myBDF = __pyx_t_1; __pyx_t_1 = 0; - /* "pynastranIO.pyx":53 + /* "pynastran_io.pyx":53 * self.bdfPath = bdf_path * self.myBDF = BDF() * nm = bdf_path.decode("UTF-8") # <<<<<<<<<<<<<< @@ -2207,7 +2188,7 @@ static int __pyx_pf_11pynastranIO_8BDFModel___cinit__(struct BDFModel *__pyx_v_s __pyx_v_nm = __pyx_t_1; __pyx_t_1 = 0; - /* "pynastranIO.pyx":54 + /* "pynastran_io.pyx":54 * self.myBDF = BDF() * nm = bdf_path.decode("UTF-8") * self.myBDF.read_bdf(nm) # <<<<<<<<<<<<<< @@ -2233,7 +2214,7 @@ static int __pyx_pf_11pynastranIO_8BDFModel___cinit__(struct BDFModel *__pyx_v_s __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "pynastranIO.pyx":55 + /* "pynastran_io.pyx":55 * nm = bdf_path.decode("UTF-8") * self.myBDF.read_bdf(nm) * self.nNodes = self.myBDF.nnodes # <<<<<<<<<<<<<< @@ -2246,7 +2227,7 @@ static int __pyx_pf_11pynastranIO_8BDFModel___cinit__(struct BDFModel *__pyx_v_s __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_self->nNodes = __pyx_t_4; - /* "pynastranIO.pyx":56 + /* "pynastran_io.pyx":56 * self.myBDF.read_bdf(nm) * self.nNodes = self.myBDF.nnodes * self.nElems = self.myBDF.nelements # <<<<<<<<<<<<<< @@ -2259,7 +2240,7 @@ static int __pyx_pf_11pynastranIO_8BDFModel___cinit__(struct BDFModel *__pyx_v_s __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_self->nElems = __pyx_t_4; - /* "pynastranIO.pyx":57 + /* "pynastran_io.pyx":57 * self.nNodes = self.myBDF.nnodes * self.nElems = self.myBDF.nelements * self.nMaterials = self.myBDF.nmaterials # <<<<<<<<<<<<<< @@ -2272,7 +2253,7 @@ static int __pyx_pf_11pynastranIO_8BDFModel___cinit__(struct BDFModel *__pyx_v_s __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_self->nMaterials = __pyx_t_4; - /* "pynastranIO.pyx":58 + /* "pynastran_io.pyx":58 * self.nElems = self.myBDF.nelements * self.nMaterials = self.myBDF.nmaterials * self.nProperties = self.myBDF.nproperties # <<<<<<<<<<<<<< @@ -2285,18 +2266,18 @@ static int __pyx_pf_11pynastranIO_8BDFModel___cinit__(struct BDFModel *__pyx_v_s __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_self->nProperties = __pyx_t_4; - /* "pynastranIO.pyx":63 + /* "pynastran_io.pyx":63 * # Perturb the nodes of zero-length vectors, this is a hack to make zero-length * # elements work in MAST. * perturbZeroLengthBushings(self) # <<<<<<<<<<<<<< * * */ - __pyx_t_1 = __pyx_f_11pynastranIO_perturbZeroLengthBushings(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 63, __pyx_L1_error) + __pyx_t_1 = __pyx_f_12pynastran_io_perturbZeroLengthBushings(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 63, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "pynastranIO.pyx":50 + /* "pynastran_io.pyx":50 * cdef myBDF * * def __cinit__(self, string bdf_path): # <<<<<<<<<<<<<< @@ -2311,7 +2292,7 @@ static int __pyx_pf_11pynastranIO_8BDFModel___cinit__(struct BDFModel *__pyx_v_s __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("pynastranIO.BDFModel.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("pynastran_io.BDFModel.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_nm); @@ -2319,7 +2300,7 @@ static int __pyx_pf_11pynastranIO_8BDFModel___cinit__(struct BDFModel *__pyx_v_s return __pyx_r; } -/* "pynastranIO.pyx":39 +/* "pynastran_io.pyx":39 * # The readonly specifier allows C/C++ code to still access these variables, but prevents them from changing it. * cdef readonly : * int nDims # <<<<<<<<<<<<<< @@ -2328,19 +2309,19 @@ static int __pyx_pf_11pynastranIO_8BDFModel___cinit__(struct BDFModel *__pyx_v_s */ /* Python wrapper */ -static PyObject *__pyx_pw_11pynastranIO_8BDFModel_5nDims_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_11pynastranIO_8BDFModel_5nDims_1__get__(PyObject *__pyx_v_self) { +static PyObject *__pyx_pw_12pynastran_io_8BDFModel_5nDims_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_12pynastran_io_8BDFModel_5nDims_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_11pynastranIO_8BDFModel_5nDims___get__(((struct BDFModel *)__pyx_v_self)); + __pyx_r = __pyx_pf_12pynastran_io_8BDFModel_5nDims___get__(((struct BDFModel *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_11pynastranIO_8BDFModel_5nDims___get__(struct BDFModel *__pyx_v_self) { +static PyObject *__pyx_pf_12pynastran_io_8BDFModel_5nDims___get__(struct BDFModel *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -2355,7 +2336,7 @@ static PyObject *__pyx_pf_11pynastranIO_8BDFModel_5nDims___get__(struct BDFModel /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("pynastranIO.BDFModel.nDims.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("pynastran_io.BDFModel.nDims.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -2363,7 +2344,7 @@ static PyObject *__pyx_pf_11pynastranIO_8BDFModel_5nDims___get__(struct BDFModel return __pyx_r; } -/* "pynastranIO.pyx":40 +/* "pynastran_io.pyx":40 * cdef readonly : * int nDims * int nNodes # <<<<<<<<<<<<<< @@ -2372,19 +2353,19 @@ static PyObject *__pyx_pf_11pynastranIO_8BDFModel_5nDims___get__(struct BDFModel */ /* Python wrapper */ -static PyObject *__pyx_pw_11pynastranIO_8BDFModel_6nNodes_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_11pynastranIO_8BDFModel_6nNodes_1__get__(PyObject *__pyx_v_self) { +static PyObject *__pyx_pw_12pynastran_io_8BDFModel_6nNodes_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_12pynastran_io_8BDFModel_6nNodes_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_11pynastranIO_8BDFModel_6nNodes___get__(((struct BDFModel *)__pyx_v_self)); + __pyx_r = __pyx_pf_12pynastran_io_8BDFModel_6nNodes___get__(((struct BDFModel *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_11pynastranIO_8BDFModel_6nNodes___get__(struct BDFModel *__pyx_v_self) { +static PyObject *__pyx_pf_12pynastran_io_8BDFModel_6nNodes___get__(struct BDFModel *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -2399,7 +2380,7 @@ static PyObject *__pyx_pf_11pynastranIO_8BDFModel_6nNodes___get__(struct BDFMode /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("pynastranIO.BDFModel.nNodes.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("pynastran_io.BDFModel.nNodes.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -2407,7 +2388,7 @@ static PyObject *__pyx_pf_11pynastranIO_8BDFModel_6nNodes___get__(struct BDFMode return __pyx_r; } -/* "pynastranIO.pyx":41 +/* "pynastran_io.pyx":41 * int nDims * int nNodes * int nElems # <<<<<<<<<<<<<< @@ -2416,19 +2397,19 @@ static PyObject *__pyx_pf_11pynastranIO_8BDFModel_6nNodes___get__(struct BDFMode */ /* Python wrapper */ -static PyObject *__pyx_pw_11pynastranIO_8BDFModel_6nElems_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_11pynastranIO_8BDFModel_6nElems_1__get__(PyObject *__pyx_v_self) { +static PyObject *__pyx_pw_12pynastran_io_8BDFModel_6nElems_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_12pynastran_io_8BDFModel_6nElems_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_11pynastranIO_8BDFModel_6nElems___get__(((struct BDFModel *)__pyx_v_self)); + __pyx_r = __pyx_pf_12pynastran_io_8BDFModel_6nElems___get__(((struct BDFModel *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_11pynastranIO_8BDFModel_6nElems___get__(struct BDFModel *__pyx_v_self) { +static PyObject *__pyx_pf_12pynastran_io_8BDFModel_6nElems___get__(struct BDFModel *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -2443,7 +2424,7 @@ static PyObject *__pyx_pf_11pynastranIO_8BDFModel_6nElems___get__(struct BDFMode /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("pynastranIO.BDFModel.nElems.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("pynastran_io.BDFModel.nElems.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -2451,7 +2432,7 @@ static PyObject *__pyx_pf_11pynastranIO_8BDFModel_6nElems___get__(struct BDFMode return __pyx_r; } -/* "pynastranIO.pyx":42 +/* "pynastran_io.pyx":42 * int nNodes * int nElems * int nMaterials # <<<<<<<<<<<<<< @@ -2460,19 +2441,19 @@ static PyObject *__pyx_pf_11pynastranIO_8BDFModel_6nElems___get__(struct BDFMode */ /* Python wrapper */ -static PyObject *__pyx_pw_11pynastranIO_8BDFModel_10nMaterials_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_11pynastranIO_8BDFModel_10nMaterials_1__get__(PyObject *__pyx_v_self) { +static PyObject *__pyx_pw_12pynastran_io_8BDFModel_10nMaterials_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_12pynastran_io_8BDFModel_10nMaterials_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_11pynastranIO_8BDFModel_10nMaterials___get__(((struct BDFModel *)__pyx_v_self)); + __pyx_r = __pyx_pf_12pynastran_io_8BDFModel_10nMaterials___get__(((struct BDFModel *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_11pynastranIO_8BDFModel_10nMaterials___get__(struct BDFModel *__pyx_v_self) { +static PyObject *__pyx_pf_12pynastran_io_8BDFModel_10nMaterials___get__(struct BDFModel *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -2487,7 +2468,7 @@ static PyObject *__pyx_pf_11pynastranIO_8BDFModel_10nMaterials___get__(struct BD /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("pynastranIO.BDFModel.nMaterials.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("pynastran_io.BDFModel.nMaterials.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -2495,7 +2476,7 @@ static PyObject *__pyx_pf_11pynastranIO_8BDFModel_10nMaterials___get__(struct BD return __pyx_r; } -/* "pynastranIO.pyx":43 +/* "pynastran_io.pyx":43 * int nElems * int nMaterials * int nProperties # <<<<<<<<<<<<<< @@ -2504,19 +2485,19 @@ static PyObject *__pyx_pf_11pynastranIO_8BDFModel_10nMaterials___get__(struct BD */ /* Python wrapper */ -static PyObject *__pyx_pw_11pynastranIO_8BDFModel_11nProperties_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_11pynastranIO_8BDFModel_11nProperties_1__get__(PyObject *__pyx_v_self) { +static PyObject *__pyx_pw_12pynastran_io_8BDFModel_11nProperties_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_12pynastran_io_8BDFModel_11nProperties_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_11pynastranIO_8BDFModel_11nProperties___get__(((struct BDFModel *)__pyx_v_self)); + __pyx_r = __pyx_pf_12pynastran_io_8BDFModel_11nProperties___get__(((struct BDFModel *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_11pynastranIO_8BDFModel_11nProperties___get__(struct BDFModel *__pyx_v_self) { +static PyObject *__pyx_pf_12pynastran_io_8BDFModel_11nProperties___get__(struct BDFModel *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -2531,7 +2512,7 @@ static PyObject *__pyx_pf_11pynastranIO_8BDFModel_11nProperties___get__(struct B /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("pynastranIO.BDFModel.nProperties.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("pynastran_io.BDFModel.nProperties.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -2539,7 +2520,7 @@ static PyObject *__pyx_pf_11pynastranIO_8BDFModel_11nProperties___get__(struct B return __pyx_r; } -/* "pynastranIO.pyx":44 +/* "pynastran_io.pyx":44 * int nMaterials * int nProperties * map[string, int] nElemTypes # <<<<<<<<<<<<<< @@ -2548,19 +2529,19 @@ static PyObject *__pyx_pf_11pynastranIO_8BDFModel_11nProperties___get__(struct B */ /* Python wrapper */ -static PyObject *__pyx_pw_11pynastranIO_8BDFModel_10nElemTypes_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_11pynastranIO_8BDFModel_10nElemTypes_1__get__(PyObject *__pyx_v_self) { +static PyObject *__pyx_pw_12pynastran_io_8BDFModel_10nElemTypes_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_12pynastran_io_8BDFModel_10nElemTypes_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_11pynastranIO_8BDFModel_10nElemTypes___get__(((struct BDFModel *)__pyx_v_self)); + __pyx_r = __pyx_pf_12pynastran_io_8BDFModel_10nElemTypes___get__(((struct BDFModel *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_11pynastranIO_8BDFModel_10nElemTypes___get__(struct BDFModel *__pyx_v_self) { +static PyObject *__pyx_pf_12pynastran_io_8BDFModel_10nElemTypes___get__(struct BDFModel *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -2575,7 +2556,7 @@ static PyObject *__pyx_pf_11pynastranIO_8BDFModel_10nElemTypes___get__(struct BD /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("pynastranIO.BDFModel.nElemTypes.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("pynastran_io.BDFModel.nElemTypes.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -2590,19 +2571,19 @@ static PyObject *__pyx_pf_11pynastranIO_8BDFModel_10nElemTypes___get__(struct BD */ /* Python wrapper */ -static PyObject *__pyx_pw_11pynastranIO_8BDFModel_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_11pynastranIO_8BDFModel_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pw_12pynastran_io_8BDFModel_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_12pynastran_io_8BDFModel_3__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf_11pynastranIO_8BDFModel_2__reduce_cython__(((struct BDFModel *)__pyx_v_self)); + __pyx_r = __pyx_pf_12pynastran_io_8BDFModel_2__reduce_cython__(((struct BDFModel *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_11pynastranIO_8BDFModel_2__reduce_cython__(CYTHON_UNUSED struct BDFModel *__pyx_v_self) { +static PyObject *__pyx_pf_12pynastran_io_8BDFModel_2__reduce_cython__(CYTHON_UNUSED struct BDFModel *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -2629,7 +2610,7 @@ static PyObject *__pyx_pf_11pynastranIO_8BDFModel_2__reduce_cython__(CYTHON_UNUS /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("pynastranIO.BDFModel.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("pynastran_io.BDFModel.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); @@ -2644,19 +2625,19 @@ static PyObject *__pyx_pf_11pynastranIO_8BDFModel_2__reduce_cython__(CYTHON_UNUS */ /* Python wrapper */ -static PyObject *__pyx_pw_11pynastranIO_8BDFModel_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ -static PyObject *__pyx_pw_11pynastranIO_8BDFModel_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { +static PyObject *__pyx_pw_12pynastran_io_8BDFModel_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ +static PyObject *__pyx_pw_12pynastran_io_8BDFModel_5__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf_11pynastranIO_8BDFModel_4__setstate_cython__(((struct BDFModel *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); + __pyx_r = __pyx_pf_12pynastran_io_8BDFModel_4__setstate_cython__(((struct BDFModel *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_11pynastranIO_8BDFModel_4__setstate_cython__(CYTHON_UNUSED struct BDFModel *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { +static PyObject *__pyx_pf_12pynastran_io_8BDFModel_4__setstate_cython__(CYTHON_UNUSED struct BDFModel *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -2683,14 +2664,14 @@ static PyObject *__pyx_pf_11pynastranIO_8BDFModel_4__setstate_cython__(CYTHON_UN /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("pynastranIO.BDFModel.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("pynastran_io.BDFModel.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "pynastranIO.pyx":66 +/* "pynastran_io.pyx":66 * * * cdef public BDFModel buildBDFModel(string bdf_path): # <<<<<<<<<<<<<< @@ -2705,7 +2686,7 @@ struct BDFModel *buildBDFModel(std::string __pyx_v_bdf_path) { PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("buildBDFModel", 0); - /* "pynastranIO.pyx":70 + /* "pynastran_io.pyx":70 * Acts as the constructor for the BDFModel class. * """ * return BDFModel(bdf_path) # <<<<<<<<<<<<<< @@ -2715,14 +2696,14 @@ struct BDFModel *buildBDFModel(std::string __pyx_v_bdf_path) { __Pyx_XDECREF(((PyObject *)__pyx_r)); __pyx_t_1 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_v_bdf_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 70, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_11pynastranIO_BDFModel), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 70, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_ptype_12pynastran_io_BDFModel), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 70, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = ((struct BDFModel *)__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L0; - /* "pynastranIO.pyx":66 + /* "pynastran_io.pyx":66 * * * cdef public BDFModel buildBDFModel(string bdf_path): # <<<<<<<<<<<<<< @@ -2734,7 +2715,7 @@ struct BDFModel *buildBDFModel(std::string __pyx_v_bdf_path) { __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("pynastranIO.buildBDFModel", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("pynastran_io.buildBDFModel", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF((PyObject *)__pyx_r); @@ -2742,7 +2723,7 @@ struct BDFModel *buildBDFModel(std::string __pyx_v_bdf_path) { return __pyx_r; } -/* "pynastranIO.pyx":73 +/* "pynastran_io.pyx":73 * * * cdef public void printBDFStats(BDFModel model): # <<<<<<<<<<<<<< @@ -2757,7 +2738,7 @@ void printBDFStats(struct BDFModel *__pyx_v_model) { PyObject *__pyx_t_3 = NULL; __Pyx_RefNannySetupContext("printBDFStats", 0); - /* "pynastranIO.pyx":74 + /* "pynastran_io.pyx":74 * * cdef public void printBDFStats(BDFModel model): * print(model.myBDF.get_bdf_stats()) # <<<<<<<<<<<<<< @@ -2786,7 +2767,7 @@ void printBDFStats(struct BDFModel *__pyx_v_model) { __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "pynastranIO.pyx":75 + /* "pynastran_io.pyx":75 * cdef public void printBDFStats(BDFModel model): * print(model.myBDF.get_bdf_stats()) * print("card_count = %s\n"%model.myBDF.card_count) # <<<<<<<<<<<<<< @@ -2803,7 +2784,7 @@ void printBDFStats(struct BDFModel *__pyx_v_model) { __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "pynastranIO.pyx":76 + /* "pynastran_io.pyx":76 * print(model.myBDF.get_bdf_stats()) * print("card_count = %s\n"%model.myBDF.card_count) * print("reject_count = %s\n"%model.myBDF.reject_count) # <<<<<<<<<<<<<< @@ -2820,7 +2801,7 @@ void printBDFStats(struct BDFModel *__pyx_v_model) { __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "pynastranIO.pyx":73 + /* "pynastran_io.pyx":73 * * * cdef public void printBDFStats(BDFModel model): # <<<<<<<<<<<<<< @@ -2834,12 +2815,12 @@ void printBDFStats(struct BDFModel *__pyx_v_model) { __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); - __Pyx_WriteUnraisable("pynastranIO.printBDFStats", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); + __Pyx_WriteUnraisable("pynastran_io.printBDFStats", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } -/* "pynastranIO.pyx":79 +/* "pynastran_io.pyx":79 * * * cdef public vector[vector[double]] getNodes(BDFModel model): # <<<<<<<<<<<<<< @@ -2872,7 +2853,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { int __pyx_t_10; __Pyx_RefNannySetupContext("getNodes", 0); - /* "pynastranIO.pyx":95 + /* "pynastran_io.pyx":95 * """ * # Get the number of rows and columns * cdef int n = model.nNodes # Number of Nodes # <<<<<<<<<<<<<< @@ -2882,7 +2863,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { __pyx_t_1 = __pyx_v_model->nNodes; __pyx_v_n = __pyx_t_1; - /* "pynastranIO.pyx":96 + /* "pynastran_io.pyx":96 * # Get the number of rows and columns * cdef int n = model.nNodes # Number of Nodes * cdef int m = 4 # node number + 3 dimensions = 4 # <<<<<<<<<<<<<< @@ -2891,7 +2872,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { */ __pyx_v_m = 4; - /* "pynastranIO.pyx":101 + /* "pynastran_io.pyx":101 * cdef vector[double] node_vec * cdef vector[vector[double]] nodes * node_vec = vector[double](m) # <<<<<<<<<<<<<< @@ -2906,7 +2887,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { } __pyx_v_node_vec = __pyx_t_2; - /* "pynastranIO.pyx":102 + /* "pynastran_io.pyx":102 * cdef vector[vector[double]] nodes * node_vec = vector[double](m) * nodes = vector[vector[double]](n, node_vec) # <<<<<<<<<<<<<< @@ -2921,7 +2902,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { } __pyx_v_nodes = __pyx_t_3; - /* "pynastranIO.pyx":105 + /* "pynastran_io.pyx":105 * * # Iterate over all nodes and all them to the 2D vector * cdef bool anyZ = False # <<<<<<<<<<<<<< @@ -2930,7 +2911,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { */ __pyx_v_anyZ = 0; - /* "pynastranIO.pyx":106 + /* "pynastran_io.pyx":106 * # Iterate over all nodes and all them to the 2D vector * cdef bool anyZ = False * cdef bool anyY = False # <<<<<<<<<<<<<< @@ -2939,7 +2920,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { */ __pyx_v_anyY = 0; - /* "pynastranIO.pyx":107 + /* "pynastran_io.pyx":107 * cdef bool anyZ = False * cdef bool anyY = False * cdef bool anyX = False # <<<<<<<<<<<<<< @@ -2948,7 +2929,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { */ __pyx_v_anyX = 0; - /* "pynastranIO.pyx":108 + /* "pynastran_io.pyx":108 * cdef bool anyY = False * cdef bool anyX = False * cdef int i = 0 # <<<<<<<<<<<<<< @@ -2957,7 +2938,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { */ __pyx_v_i = 0; - /* "pynastranIO.pyx":109 + /* "pynastran_io.pyx":109 * cdef bool anyX = False * cdef int i = 0 * for key in model.myBDF.nodes: # <<<<<<<<<<<<<< @@ -3009,7 +2990,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_4); __pyx_t_4 = 0; - /* "pynastranIO.pyx":110 + /* "pynastran_io.pyx":110 * cdef int i = 0 * for key in model.myBDF.nodes: * node = model.myBDF.nodes[key] # <<<<<<<<<<<<<< @@ -3024,7 +3005,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { __Pyx_XDECREF_SET(__pyx_v_node, __pyx_t_8); __pyx_t_8 = 0; - /* "pynastranIO.pyx":111 + /* "pynastran_io.pyx":111 * for key in model.myBDF.nodes: * node = model.myBDF.nodes[key] * nodes[i][0] = node.nid # <<<<<<<<<<<<<< @@ -3037,7 +3018,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; ((__pyx_v_nodes[__pyx_v_i])[0]) = __pyx_t_9; - /* "pynastranIO.pyx":112 + /* "pynastran_io.pyx":112 * node = model.myBDF.nodes[key] * nodes[i][0] = node.nid * nodes[i][1] = node.xyz[0] # <<<<<<<<<<<<<< @@ -3053,7 +3034,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; ((__pyx_v_nodes[__pyx_v_i])[1]) = __pyx_t_9; - /* "pynastranIO.pyx":113 + /* "pynastran_io.pyx":113 * nodes[i][0] = node.nid * nodes[i][1] = node.xyz[0] * nodes[i][2] = node.xyz[1] # <<<<<<<<<<<<<< @@ -3069,7 +3050,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; ((__pyx_v_nodes[__pyx_v_i])[2]) = __pyx_t_9; - /* "pynastranIO.pyx":114 + /* "pynastran_io.pyx":114 * nodes[i][1] = node.xyz[0] * nodes[i][2] = node.xyz[1] * nodes[i][3] = node.xyz[2] # <<<<<<<<<<<<<< @@ -3085,7 +3066,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; ((__pyx_v_nodes[__pyx_v_i])[3]) = __pyx_t_9; - /* "pynastranIO.pyx":115 + /* "pynastran_io.pyx":115 * nodes[i][2] = node.xyz[1] * nodes[i][3] = node.xyz[2] * if node.xyz[0]!=0.0: # <<<<<<<<<<<<<< @@ -3104,7 +3085,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_10) { - /* "pynastranIO.pyx":116 + /* "pynastran_io.pyx":116 * nodes[i][3] = node.xyz[2] * if node.xyz[0]!=0.0: * anyX = True # <<<<<<<<<<<<<< @@ -3113,7 +3094,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { */ __pyx_v_anyX = 1; - /* "pynastranIO.pyx":115 + /* "pynastran_io.pyx":115 * nodes[i][2] = node.xyz[1] * nodes[i][3] = node.xyz[2] * if node.xyz[0]!=0.0: # <<<<<<<<<<<<<< @@ -3122,7 +3103,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { */ } - /* "pynastranIO.pyx":117 + /* "pynastran_io.pyx":117 * if node.xyz[0]!=0.0: * anyX = True * if node.xyz[1]!=0.0: # <<<<<<<<<<<<<< @@ -3141,7 +3122,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_10) { - /* "pynastranIO.pyx":118 + /* "pynastran_io.pyx":118 * anyX = True * if node.xyz[1]!=0.0: * anyY = True # <<<<<<<<<<<<<< @@ -3150,7 +3131,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { */ __pyx_v_anyY = 1; - /* "pynastranIO.pyx":117 + /* "pynastran_io.pyx":117 * if node.xyz[0]!=0.0: * anyX = True * if node.xyz[1]!=0.0: # <<<<<<<<<<<<<< @@ -3159,7 +3140,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { */ } - /* "pynastranIO.pyx":119 + /* "pynastran_io.pyx":119 * if node.xyz[1]!=0.0: * anyY = True * if node.xyz[2]!=0.0: # <<<<<<<<<<<<<< @@ -3178,7 +3159,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_10) { - /* "pynastranIO.pyx":120 + /* "pynastran_io.pyx":120 * anyY = True * if node.xyz[2]!=0.0: * anyZ = True # <<<<<<<<<<<<<< @@ -3187,7 +3168,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { */ __pyx_v_anyZ = 1; - /* "pynastranIO.pyx":119 + /* "pynastran_io.pyx":119 * if node.xyz[1]!=0.0: * anyY = True * if node.xyz[2]!=0.0: # <<<<<<<<<<<<<< @@ -3196,7 +3177,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { */ } - /* "pynastranIO.pyx":121 + /* "pynastran_io.pyx":121 * if node.xyz[2]!=0.0: * anyZ = True * i += 1 # <<<<<<<<<<<<<< @@ -3205,7 +3186,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { */ __pyx_v_i = (__pyx_v_i + 1); - /* "pynastranIO.pyx":109 + /* "pynastran_io.pyx":109 * cdef bool anyX = False * cdef int i = 0 * for key in model.myBDF.nodes: # <<<<<<<<<<<<<< @@ -3215,7 +3196,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - /* "pynastranIO.pyx":123 + /* "pynastran_io.pyx":123 * i += 1 * * if anyZ: # <<<<<<<<<<<<<< @@ -3225,7 +3206,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { __pyx_t_10 = (__pyx_v_anyZ != 0); if (__pyx_t_10) { - /* "pynastranIO.pyx":124 + /* "pynastran_io.pyx":124 * * if anyZ: * model.nDims = 3 # <<<<<<<<<<<<<< @@ -3234,7 +3215,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { */ __pyx_v_model->nDims = 3; - /* "pynastranIO.pyx":123 + /* "pynastran_io.pyx":123 * i += 1 * * if anyZ: # <<<<<<<<<<<<<< @@ -3244,7 +3225,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { goto __pyx_L8; } - /* "pynastranIO.pyx":125 + /* "pynastran_io.pyx":125 * if anyZ: * model.nDims = 3 * elif anyY: # <<<<<<<<<<<<<< @@ -3254,7 +3235,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { __pyx_t_10 = (__pyx_v_anyY != 0); if (__pyx_t_10) { - /* "pynastranIO.pyx":126 + /* "pynastran_io.pyx":126 * model.nDims = 3 * elif anyY: * model.nDims = 2 # <<<<<<<<<<<<<< @@ -3263,7 +3244,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { */ __pyx_v_model->nDims = 2; - /* "pynastranIO.pyx":125 + /* "pynastran_io.pyx":125 * if anyZ: * model.nDims = 3 * elif anyY: # <<<<<<<<<<<<<< @@ -3273,7 +3254,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { goto __pyx_L8; } - /* "pynastranIO.pyx":127 + /* "pynastran_io.pyx":127 * elif anyY: * model.nDims = 2 * elif anyX: # <<<<<<<<<<<<<< @@ -3283,7 +3264,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { __pyx_t_10 = (__pyx_v_anyX != 0); if (__pyx_t_10) { - /* "pynastranIO.pyx":128 + /* "pynastran_io.pyx":128 * model.nDims = 2 * elif anyX: * model.nDims = 1 # <<<<<<<<<<<<<< @@ -3292,7 +3273,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { */ __pyx_v_model->nDims = 1; - /* "pynastranIO.pyx":127 + /* "pynastran_io.pyx":127 * elif anyY: * model.nDims = 2 * elif anyX: # <<<<<<<<<<<<<< @@ -3302,7 +3283,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { goto __pyx_L8; } - /* "pynastranIO.pyx":130 + /* "pynastran_io.pyx":130 * model.nDims = 1 * else: * model.nDims = 0 # <<<<<<<<<<<<<< @@ -3314,7 +3295,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { } __pyx_L8:; - /* "pynastranIO.pyx":132 + /* "pynastran_io.pyx":132 * model.nDims = 0 * * return nodes # <<<<<<<<<<<<<< @@ -3324,7 +3305,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { __pyx_r = __pyx_v_nodes; goto __pyx_L0; - /* "pynastranIO.pyx":79 + /* "pynastran_io.pyx":79 * * * cdef public vector[vector[double]] getNodes(BDFModel model): # <<<<<<<<<<<<<< @@ -3337,7 +3318,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_8); - __Pyx_WriteUnraisable("pynastranIO.getNodes", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); + __Pyx_WriteUnraisable("pynastran_io.getNodes", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __Pyx_pretend_to_initialize(&__pyx_r); __pyx_L0:; __Pyx_XDECREF(__pyx_v_key); @@ -3346,7 +3327,7 @@ std::vector > getNodes(struct BDFModel *__pyx_v_model) { return __pyx_r; } -/* "pynastranIO.pyx":135 +/* "pynastran_io.pyx":135 * * * cdef public map[string, vector[vector[int]]] getElements(BDFModel model): # <<<<<<<<<<<<<< @@ -3393,7 +3374,7 @@ std::map > > getElements(struct BDFMod std::string __pyx_t_19; __Pyx_RefNannySetupContext("getElements", 0); - /* "pynastranIO.pyx":140 + /* "pynastran_io.pyx":140 * of the map is a 2D vector (vector of vector) which stores element ID, property ID, and node numbers. * """ * cdef int n = model.nElems # Number of elements # <<<<<<<<<<<<<< @@ -3403,7 +3384,7 @@ std::map > > getElements(struct BDFMod __pyx_t_1 = __pyx_v_model->nElems; __pyx_v_n = __pyx_t_1; - /* "pynastranIO.pyx":145 + /* "pynastran_io.pyx":145 * * # Pre-allocate space to store the element information * cdef map[string, int] elemTypes = getNumberOfElementTypes(model) # <<<<<<<<<<<<<< @@ -3412,7 +3393,7 @@ std::map > > getElements(struct BDFMod */ __pyx_v_elemTypes = getNumberOfElementTypes(__pyx_v_model); - /* "pynastranIO.pyx":147 + /* "pynastran_io.pyx":147 * cdef map[string, int] elemTypes = getNumberOfElementTypes(model) * cdef map[string, int] i_counter * cdef map[string, int].iterator it = elemTypes.begin() # <<<<<<<<<<<<<< @@ -3421,7 +3402,7 @@ std::map > > getElements(struct BDFMod */ __pyx_v_it = __pyx_v_elemTypes.begin(); - /* "pynastranIO.pyx":151 + /* "pynastran_io.pyx":151 * cdef vector[vector[int]] elements * cdef int m, nElemNodes * while(it != elemTypes.end()): # <<<<<<<<<<<<<< @@ -3432,7 +3413,7 @@ std::map > > getElements(struct BDFMod __pyx_t_2 = ((__pyx_v_it != __pyx_v_elemTypes.end()) != 0); if (!__pyx_t_2) break; - /* "pynastranIO.pyx":154 + /* "pynastran_io.pyx":154 * # print(dereference(it).first) # print the key * # print(dereference(it).second) # print the associated value * elemType = dereference(it).first # <<<<<<<<<<<<<< @@ -3444,7 +3425,7 @@ std::map > > getElements(struct BDFMod __Pyx_XDECREF_SET(__pyx_v_elemType, __pyx_t_3); __pyx_t_3 = 0; - /* "pynastranIO.pyx":155 + /* "pynastran_io.pyx":155 * # print(dereference(it).second) # print the associated value * elemType = dereference(it).first * nElemTypes = dereference(it).second # <<<<<<<<<<<<<< @@ -3454,7 +3435,7 @@ std::map > > getElements(struct BDFMod __pyx_t_1 = (*__pyx_v_it).second; __pyx_v_nElemTypes = __pyx_t_1; - /* "pynastranIO.pyx":156 + /* "pynastran_io.pyx":156 * elemType = dereference(it).first * nElemTypes = dereference(it).second * nElemNodes = int(str(elemType).split("_")[-1].strip("'")) # <<<<<<<<<<<<<< @@ -3494,7 +3475,7 @@ std::map > > getElements(struct BDFMod __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_nElemNodes = __pyx_t_1; - /* "pynastranIO.pyx":157 + /* "pynastran_io.pyx":157 * nElemTypes = dereference(it).second * nElemNodes = int(str(elemType).split("_")[-1].strip("'")) * m = nElemNodes+2 # <<<<<<<<<<<<<< @@ -3503,7 +3484,7 @@ std::map > > getElements(struct BDFMod */ __pyx_v_m = (__pyx_v_nElemNodes + 2); - /* "pynastranIO.pyx":159 + /* "pynastran_io.pyx":159 * m = nElemNodes+2 * * elem_vec = vector[int](m) # <<<<<<<<<<<<<< @@ -3518,7 +3499,7 @@ std::map > > getElements(struct BDFMod } __pyx_v_elem_vec = __pyx_t_6; - /* "pynastranIO.pyx":160 + /* "pynastran_io.pyx":160 * * elem_vec = vector[int](m) * elementMap[elemType] = vector[vector[int]](nElemTypes, elem_vec) # <<<<<<<<<<<<<< @@ -3534,7 +3515,7 @@ std::map > > getElements(struct BDFMod __pyx_t_8 = __pyx_convert_string_from_py_std__in_string(__pyx_v_elemType); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 160, __pyx_L1_error) (__pyx_v_elementMap[__pyx_t_8]) = __pyx_t_7; - /* "pynastranIO.pyx":162 + /* "pynastran_io.pyx":162 * elementMap[elemType] = vector[vector[int]](nElemTypes, elem_vec) * * i_counter[elemType] = 0 # <<<<<<<<<<<<<< @@ -3544,7 +3525,7 @@ std::map > > getElements(struct BDFMod __pyx_t_8 = __pyx_convert_string_from_py_std__in_string(__pyx_v_elemType); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 162, __pyx_L1_error) (__pyx_v_i_counter[__pyx_t_8]) = 0; - /* "pynastranIO.pyx":164 + /* "pynastran_io.pyx":164 * i_counter[elemType] = 0 * * postincrement(it) # Increment the iterator to the net element # <<<<<<<<<<<<<< @@ -3554,7 +3535,7 @@ std::map > > getElements(struct BDFMod (void)((__pyx_v_it++)); } - /* "pynastranIO.pyx":165 + /* "pynastran_io.pyx":165 * * postincrement(it) # Increment the iterator to the net element * mapKeys = [] # <<<<<<<<<<<<<< @@ -3566,7 +3547,7 @@ std::map > > getElements(struct BDFMod __pyx_v_mapKeys = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0; - /* "pynastranIO.pyx":170 + /* "pynastran_io.pyx":170 * cdef int i * cdef int j * for key,element in model.myBDF.elements.items(): # <<<<<<<<<<<<<< @@ -3597,7 +3578,7 @@ std::map > > getElements(struct BDFMod __Pyx_XDECREF_SET(__pyx_v_element, __pyx_t_3); __pyx_t_3 = 0; - /* "pynastranIO.pyx":171 + /* "pynastran_io.pyx":171 * cdef int j * for key,element in model.myBDF.elements.items(): * if "offset" in element.object_attributes(): # <<<<<<<<<<<<<< @@ -3626,7 +3607,7 @@ std::map > > getElements(struct BDFMod __pyx_t_13 = (__pyx_t_2 != 0); if (__pyx_t_13) { - /* "pynastranIO.pyx":172 + /* "pynastran_io.pyx":172 * for key,element in model.myBDF.elements.items(): * if "offset" in element.object_attributes(): * if element.offset!=0: # <<<<<<<<<<<<<< @@ -3642,7 +3623,7 @@ std::map > > getElements(struct BDFMod __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(__pyx_t_13)) { - /* "pynastranIO.pyx":173 + /* "pynastran_io.pyx":173 * if "offset" in element.object_attributes(): * if element.offset!=0: * raise NotImplementedError("Support of non-zero offsets not yet implemented!") # <<<<<<<<<<<<<< @@ -3655,7 +3636,7 @@ std::map > > getElements(struct BDFMod __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(1, 173, __pyx_L1_error) - /* "pynastranIO.pyx":172 + /* "pynastran_io.pyx":172 * for key,element in model.myBDF.elements.items(): * if "offset" in element.object_attributes(): * if element.offset!=0: # <<<<<<<<<<<<<< @@ -3664,7 +3645,7 @@ std::map > > getElements(struct BDFMod */ } - /* "pynastranIO.pyx":171 + /* "pynastran_io.pyx":171 * cdef int j * for key,element in model.myBDF.elements.items(): * if "offset" in element.object_attributes(): # <<<<<<<<<<<<<< @@ -3673,7 +3654,7 @@ std::map > > getElements(struct BDFMod */ } - /* "pynastranIO.pyx":174 + /* "pynastran_io.pyx":174 * if element.offset!=0: * raise NotImplementedError("Support of non-zero offsets not yet implemented!") * if "zoffset" in element.object_attributes(): # <<<<<<<<<<<<<< @@ -3702,7 +3683,7 @@ std::map > > getElements(struct BDFMod __pyx_t_2 = (__pyx_t_13 != 0); if (__pyx_t_2) { - /* "pynastranIO.pyx":175 + /* "pynastran_io.pyx":175 * raise NotImplementedError("Support of non-zero offsets not yet implemented!") * if "zoffset" in element.object_attributes(): * if element.zoffset!=0: # <<<<<<<<<<<<<< @@ -3718,7 +3699,7 @@ std::map > > getElements(struct BDFMod __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(__pyx_t_2)) { - /* "pynastranIO.pyx":176 + /* "pynastran_io.pyx":176 * if "zoffset" in element.object_attributes(): * if element.zoffset!=0: * raise NotImplementedError("Support of non-zero offets not yet implemented!") # <<<<<<<<<<<<<< @@ -3731,7 +3712,7 @@ std::map > > getElements(struct BDFMod __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(1, 176, __pyx_L1_error) - /* "pynastranIO.pyx":175 + /* "pynastran_io.pyx":175 * raise NotImplementedError("Support of non-zero offsets not yet implemented!") * if "zoffset" in element.object_attributes(): * if element.zoffset!=0: # <<<<<<<<<<<<<< @@ -3740,7 +3721,7 @@ std::map > > getElements(struct BDFMod */ } - /* "pynastranIO.pyx":174 + /* "pynastran_io.pyx":174 * if element.offset!=0: * raise NotImplementedError("Support of non-zero offsets not yet implemented!") * if "zoffset" in element.object_attributes(): # <<<<<<<<<<<<<< @@ -3749,7 +3730,7 @@ std::map > > getElements(struct BDFMod */ } - /* "pynastranIO.pyx":177 + /* "pynastran_io.pyx":177 * if element.zoffset!=0: * raise NotImplementedError("Support of non-zero offets not yet implemented!") * nElemNodes = len(element.nodes) # <<<<<<<<<<<<<< @@ -3762,7 +3743,7 @@ std::map > > getElements(struct BDFMod __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_nElemNodes = __pyx_t_14; - /* "pynastranIO.pyx":178 + /* "pynastran_io.pyx":178 * raise NotImplementedError("Support of non-zero offets not yet implemented!") * nElemNodes = len(element.nodes) * elemType = (element.type + "_%i"%(nElemNodes)).encode('utf-8') # <<<<<<<<<<<<<< @@ -3801,7 +3782,7 @@ std::map > > getElements(struct BDFMod __Pyx_XDECREF_SET(__pyx_v_elemType, __pyx_t_3); __pyx_t_3 = 0; - /* "pynastranIO.pyx":179 + /* "pynastran_io.pyx":179 * nElemNodes = len(element.nodes) * elemType = (element.type + "_%i"%(nElemNodes)).encode('utf-8') * i = i_counter[elemType] # <<<<<<<<<<<<<< @@ -3811,7 +3792,7 @@ std::map > > getElements(struct BDFMod __pyx_t_8 = __pyx_convert_string_from_py_std__in_string(__pyx_v_elemType); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 179, __pyx_L1_error) __pyx_v_i = (__pyx_v_i_counter[__pyx_t_8]); - /* "pynastranIO.pyx":180 + /* "pynastran_io.pyx":180 * elemType = (element.type + "_%i"%(nElemNodes)).encode('utf-8') * i = i_counter[elemType] * elementMap[elemType][i][0] = element.eid # <<<<<<<<<<<<<< @@ -3825,7 +3806,7 @@ std::map > > getElements(struct BDFMod __pyx_t_8 = __pyx_convert_string_from_py_std__in_string(__pyx_v_elemType); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 180, __pyx_L1_error) (((__pyx_v_elementMap[__pyx_t_8])[__pyx_v_i])[0]) = __pyx_t_11; - /* "pynastranIO.pyx":181 + /* "pynastran_io.pyx":181 * i = i_counter[elemType] * elementMap[elemType][i][0] = element.eid * elementMap[elemType][i][1] = element.pid # <<<<<<<<<<<<<< @@ -3839,7 +3820,7 @@ std::map > > getElements(struct BDFMod __pyx_t_8 = __pyx_convert_string_from_py_std__in_string(__pyx_v_elemType); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 181, __pyx_L1_error) (((__pyx_v_elementMap[__pyx_t_8])[__pyx_v_i])[1]) = __pyx_t_11; - /* "pynastranIO.pyx":182 + /* "pynastran_io.pyx":182 * elementMap[elemType][i][0] = element.eid * elementMap[elemType][i][1] = element.pid * for j in range(nElemNodes): # <<<<<<<<<<<<<< @@ -3851,7 +3832,7 @@ std::map > > getElements(struct BDFMod for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) { __pyx_v_j = __pyx_t_17; - /* "pynastranIO.pyx":183 + /* "pynastran_io.pyx":183 * elementMap[elemType][i][1] = element.pid * for j in range(nElemNodes): * elementMap[elemType][i][j+2] = element.nodes[j] # <<<<<<<<<<<<<< @@ -3869,7 +3850,7 @@ std::map > > getElements(struct BDFMod (((__pyx_v_elementMap[__pyx_t_8])[__pyx_v_i])[(__pyx_v_j + 2)]) = __pyx_t_18; } - /* "pynastranIO.pyx":184 + /* "pynastran_io.pyx":184 * for j in range(nElemNodes): * elementMap[elemType][i][j+2] = element.nodes[j] * i_counter[elemType] = i_counter[elemType]+1 # <<<<<<<<<<<<<< @@ -3882,7 +3863,7 @@ std::map > > getElements(struct BDFMod } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - /* "pynastranIO.pyx":186 + /* "pynastran_io.pyx":186 * i_counter[elemType] = i_counter[elemType]+1 * * return elementMap # <<<<<<<<<<<<<< @@ -3892,7 +3873,7 @@ std::map > > getElements(struct BDFMod __pyx_r = __pyx_v_elementMap; goto __pyx_L0; - /* "pynastranIO.pyx":135 + /* "pynastran_io.pyx":135 * * * cdef public map[string, vector[vector[int]]] getElements(BDFModel model): # <<<<<<<<<<<<<< @@ -3907,7 +3888,7 @@ std::map > > getElements(struct BDFMod __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_15); - __Pyx_WriteUnraisable("pynastranIO.getElements", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); + __Pyx_WriteUnraisable("pynastran_io.getElements", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __Pyx_pretend_to_initialize(&__pyx_r); __pyx_L0:; __Pyx_XDECREF(__pyx_v_elemType); @@ -3918,7 +3899,7 @@ std::map > > getElements(struct BDFMod return __pyx_r; } -/* "pynastranIO.pyx":189 +/* "pynastran_io.pyx":189 * * * cdef public map[string, int] getNumberOfElementTypes(BDFModel model): # <<<<<<<<<<<<<< @@ -3950,7 +3931,7 @@ std::map getNumberOfElementTypes(struct BDFModel *__pyx_v_mode std::string __pyx_t_14; __Pyx_RefNannySetupContext("getNumberOfElementTypes", 0); - /* "pynastranIO.pyx":195 + /* "pynastran_io.pyx":195 * """ * cdef map[string, int] elementTypes * elemTypeList = [] # <<<<<<<<<<<<<< @@ -3962,7 +3943,7 @@ std::map getNumberOfElementTypes(struct BDFModel *__pyx_v_mode __pyx_v_elemTypeList = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "pynastranIO.pyx":196 + /* "pynastran_io.pyx":196 * cdef map[string, int] elementTypes * elemTypeList = [] * for key, element in model.myBDF.elements.items(): # <<<<<<<<<<<<<< @@ -3993,7 +3974,7 @@ std::map getNumberOfElementTypes(struct BDFModel *__pyx_v_mode __Pyx_XDECREF_SET(__pyx_v_element, __pyx_t_5); __pyx_t_5 = 0; - /* "pynastranIO.pyx":197 + /* "pynastran_io.pyx":197 * elemTypeList = [] * for key, element in model.myBDF.elements.items(): * elemType = (element.type + "_%i"%(len(element.nodes))).encode("utf-8") # <<<<<<<<<<<<<< @@ -4036,7 +4017,7 @@ std::map getNumberOfElementTypes(struct BDFModel *__pyx_v_mode __Pyx_XDECREF_SET(__pyx_v_elemType, __pyx_t_5); __pyx_t_5 = 0; - /* "pynastranIO.pyx":198 + /* "pynastran_io.pyx":198 * for key, element in model.myBDF.elements.items(): * elemType = (element.type + "_%i"%(len(element.nodes))).encode("utf-8") * if elemType not in elemTypeList: # <<<<<<<<<<<<<< @@ -4047,7 +4028,7 @@ std::map getNumberOfElementTypes(struct BDFModel *__pyx_v_mode __pyx_t_12 = (__pyx_t_11 != 0); if (__pyx_t_12) { - /* "pynastranIO.pyx":199 + /* "pynastran_io.pyx":199 * elemType = (element.type + "_%i"%(len(element.nodes))).encode("utf-8") * if elemType not in elemTypeList: * elemTypeList.append(elemType) # <<<<<<<<<<<<<< @@ -4056,7 +4037,7 @@ std::map getNumberOfElementTypes(struct BDFModel *__pyx_v_mode */ __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_elemTypeList, __pyx_v_elemType); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(1, 199, __pyx_L1_error) - /* "pynastranIO.pyx":200 + /* "pynastran_io.pyx":200 * if elemType not in elemTypeList: * elemTypeList.append(elemType) * elementTypes[elemType] = 1 # <<<<<<<<<<<<<< @@ -4066,7 +4047,7 @@ std::map getNumberOfElementTypes(struct BDFModel *__pyx_v_mode __pyx_t_14 = __pyx_convert_string_from_py_std__in_string(__pyx_v_elemType); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 200, __pyx_L1_error) (__pyx_v_elementTypes[__pyx_t_14]) = 1; - /* "pynastranIO.pyx":198 + /* "pynastran_io.pyx":198 * for key, element in model.myBDF.elements.items(): * elemType = (element.type + "_%i"%(len(element.nodes))).encode("utf-8") * if elemType not in elemTypeList: # <<<<<<<<<<<<<< @@ -4076,7 +4057,7 @@ std::map getNumberOfElementTypes(struct BDFModel *__pyx_v_mode goto __pyx_L5; } - /* "pynastranIO.pyx":202 + /* "pynastran_io.pyx":202 * elementTypes[elemType] = 1 * else: * elementTypes[elemType] += 1 # <<<<<<<<<<<<<< @@ -4091,7 +4072,7 @@ std::map getNumberOfElementTypes(struct BDFModel *__pyx_v_mode } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "pynastranIO.pyx":204 + /* "pynastran_io.pyx":204 * elementTypes[elemType] += 1 * * model.nElemTypes = elementTypes # <<<<<<<<<<<<<< @@ -4100,7 +4081,7 @@ std::map getNumberOfElementTypes(struct BDFModel *__pyx_v_mode */ __pyx_v_model->nElemTypes = __pyx_v_elementTypes; - /* "pynastranIO.pyx":205 + /* "pynastran_io.pyx":205 * * model.nElemTypes = elementTypes * return elementTypes # <<<<<<<<<<<<<< @@ -4110,7 +4091,7 @@ std::map getNumberOfElementTypes(struct BDFModel *__pyx_v_mode __pyx_r = __pyx_v_elementTypes; goto __pyx_L0; - /* "pynastranIO.pyx":189 + /* "pynastran_io.pyx":189 * * * cdef public map[string, int] getNumberOfElementTypes(BDFModel model): # <<<<<<<<<<<<<< @@ -4125,7 +4106,7 @@ std::map getNumberOfElementTypes(struct BDFModel *__pyx_v_mode __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_10); - __Pyx_WriteUnraisable("pynastranIO.getNumberOfElementTypes", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); + __Pyx_WriteUnraisable("pynastran_io.getNumberOfElementTypes", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __Pyx_pretend_to_initialize(&__pyx_r); __pyx_L0:; __Pyx_XDECREF(__pyx_v_elemTypeList); @@ -4136,7 +4117,7 @@ std::map getNumberOfElementTypes(struct BDFModel *__pyx_v_mode return __pyx_r; } -/* "pynastranIO.pyx":208 +/* "pynastran_io.pyx":208 * * * cdef perturbZeroLengthBushings(BDFModel model): # <<<<<<<<<<<<<< @@ -4144,7 +4125,7 @@ std::map getNumberOfElementTypes(struct BDFModel *__pyx_v_mode * As of November 18, 2019, MAST does not support the specification of the elemental x-axis which is required when */ -static PyObject *__pyx_f_11pynastranIO_perturbZeroLengthBushings(struct BDFModel *__pyx_v_model) { +static PyObject *__pyx_f_12pynastran_io_perturbZeroLengthBushings(struct BDFModel *__pyx_v_model) { int __pyx_v_k; double __pyx_v_eps; double __pyx_v_nzero; @@ -4171,7 +4152,7 @@ static PyObject *__pyx_f_11pynastranIO_perturbZeroLengthBushings(struct BDFModel double __pyx_t_11; __Pyx_RefNannySetupContext("perturbZeroLengthBushings", 0); - /* "pynastranIO.pyx":219 + /* "pynastran_io.pyx":219 * cdef int k * cdef double eps, nzero, L * eps=1.4901161193847656e-08 # <<<<<<<<<<<<<< @@ -4180,7 +4161,7 @@ static PyObject *__pyx_f_11pynastranIO_perturbZeroLengthBushings(struct BDFModel */ __pyx_v_eps = 1.4901161193847656e-08; - /* "pynastranIO.pyx":220 + /* "pynastran_io.pyx":220 * cdef double eps, nzero, L * eps=1.4901161193847656e-08 * nzero=1e-08 # <<<<<<<<<<<<<< @@ -4189,7 +4170,7 @@ static PyObject *__pyx_f_11pynastranIO_perturbZeroLengthBushings(struct BDFModel */ __pyx_v_nzero = 1e-08; - /* "pynastranIO.pyx":223 + /* "pynastran_io.pyx":223 * * # Get element IDs of bushing elements * data = model.myBDF.get_elements_properties_nodes_by_element_type() # <<<<<<<<<<<<<< @@ -4216,7 +4197,7 @@ static PyObject *__pyx_f_11pynastranIO_perturbZeroLengthBushings(struct BDFModel __pyx_v_data = __pyx_t_1; __pyx_t_1 = 0; - /* "pynastranIO.pyx":224 + /* "pynastran_io.pyx":224 * # Get element IDs of bushing elements * data = model.myBDF.get_elements_properties_nodes_by_element_type() * eids = [] # <<<<<<<<<<<<<< @@ -4228,7 +4209,7 @@ static PyObject *__pyx_f_11pynastranIO_perturbZeroLengthBushings(struct BDFModel __pyx_v_eids = __pyx_t_1; __pyx_t_1 = 0; - /* "pynastranIO.pyx":225 + /* "pynastran_io.pyx":225 * data = model.myBDF.get_elements_properties_nodes_by_element_type() * eids = [] * if "CBUSH" in data.keys(): # <<<<<<<<<<<<<< @@ -4257,7 +4238,7 @@ static PyObject *__pyx_f_11pynastranIO_perturbZeroLengthBushings(struct BDFModel __pyx_t_5 = (__pyx_t_4 != 0); if (__pyx_t_5) { - /* "pynastranIO.pyx":226 + /* "pynastran_io.pyx":226 * eids = [] * if "CBUSH" in data.keys(): * eids += (data["CBUSH"][0]).tolist() # <<<<<<<<<<<<<< @@ -4293,7 +4274,7 @@ static PyObject *__pyx_f_11pynastranIO_perturbZeroLengthBushings(struct BDFModel __Pyx_DECREF_SET(__pyx_v_eids, __pyx_t_2); __pyx_t_2 = 0; - /* "pynastranIO.pyx":225 + /* "pynastran_io.pyx":225 * data = model.myBDF.get_elements_properties_nodes_by_element_type() * eids = [] * if "CBUSH" in data.keys(): # <<<<<<<<<<<<<< @@ -4302,7 +4283,7 @@ static PyObject *__pyx_f_11pynastranIO_perturbZeroLengthBushings(struct BDFModel */ } - /* "pynastranIO.pyx":227 + /* "pynastran_io.pyx":227 * if "CBUSH" in data.keys(): * eids += (data["CBUSH"][0]).tolist() * if "CBUSH1D" in data.keys(): # <<<<<<<<<<<<<< @@ -4331,7 +4312,7 @@ static PyObject *__pyx_f_11pynastranIO_perturbZeroLengthBushings(struct BDFModel __pyx_t_4 = (__pyx_t_5 != 0); if (__pyx_t_4) { - /* "pynastranIO.pyx":228 + /* "pynastran_io.pyx":228 * eids += (data["CBUSH"][0]).tolist() * if "CBUSH1D" in data.keys(): * eids += (data["CBUSH1D"][0]).tolist() # <<<<<<<<<<<<<< @@ -4367,7 +4348,7 @@ static PyObject *__pyx_f_11pynastranIO_perturbZeroLengthBushings(struct BDFModel __Pyx_DECREF_SET(__pyx_v_eids, __pyx_t_1); __pyx_t_1 = 0; - /* "pynastranIO.pyx":227 + /* "pynastran_io.pyx":227 * if "CBUSH" in data.keys(): * eids += (data["CBUSH"][0]).tolist() * if "CBUSH1D" in data.keys(): # <<<<<<<<<<<<<< @@ -4376,7 +4357,7 @@ static PyObject *__pyx_f_11pynastranIO_perturbZeroLengthBushings(struct BDFModel */ } - /* "pynastranIO.pyx":229 + /* "pynastran_io.pyx":229 * if "CBUSH1D" in data.keys(): * eids += (data["CBUSH1D"][0]).tolist() * if "CBUSH2D" in data.keys(): # <<<<<<<<<<<<<< @@ -4405,7 +4386,7 @@ static PyObject *__pyx_f_11pynastranIO_perturbZeroLengthBushings(struct BDFModel __pyx_t_5 = (__pyx_t_4 != 0); if (__pyx_t_5) { - /* "pynastranIO.pyx":230 + /* "pynastran_io.pyx":230 * eids += (data["CBUSH1D"][0]).tolist() * if "CBUSH2D" in data.keys(): * eids += (data["CBUSH2D"][0]).tolist() # <<<<<<<<<<<<<< @@ -4441,7 +4422,7 @@ static PyObject *__pyx_f_11pynastranIO_perturbZeroLengthBushings(struct BDFModel __Pyx_DECREF_SET(__pyx_v_eids, __pyx_t_2); __pyx_t_2 = 0; - /* "pynastranIO.pyx":229 + /* "pynastran_io.pyx":229 * if "CBUSH1D" in data.keys(): * eids += (data["CBUSH1D"][0]).tolist() * if "CBUSH2D" in data.keys(): # <<<<<<<<<<<<<< @@ -4450,7 +4431,7 @@ static PyObject *__pyx_f_11pynastranIO_perturbZeroLengthBushings(struct BDFModel */ } - /* "pynastranIO.pyx":233 + /* "pynastran_io.pyx":233 * * # Loop through all bushing elements * for k in range(len(eids)): # <<<<<<<<<<<<<< @@ -4462,7 +4443,7 @@ static PyObject *__pyx_f_11pynastranIO_perturbZeroLengthBushings(struct BDFModel for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { __pyx_v_k = __pyx_t_8; - /* "pynastranIO.pyx":234 + /* "pynastran_io.pyx":234 * # Loop through all bushing elements * for k in range(len(eids)): * eid = eids[k] # <<<<<<<<<<<<<< @@ -4474,7 +4455,7 @@ static PyObject *__pyx_f_11pynastranIO_perturbZeroLengthBushings(struct BDFModel __Pyx_XDECREF_SET(__pyx_v_eid, __pyx_t_2); __pyx_t_2 = 0; - /* "pynastranIO.pyx":235 + /* "pynastran_io.pyx":235 * for k in range(len(eids)): * eid = eids[k] * bushing = model.myBDF.elements[eid] # <<<<<<<<<<<<<< @@ -4489,7 +4470,7 @@ static PyObject *__pyx_f_11pynastranIO_perturbZeroLengthBushings(struct BDFModel __Pyx_XDECREF_SET(__pyx_v_bushing, __pyx_t_1); __pyx_t_1 = 0; - /* "pynastranIO.pyx":236 + /* "pynastran_io.pyx":236 * eid = eids[k] * bushing = model.myBDF.elements[eid] * L = np.linalg.norm(bushing.nodes_ref[1].xyz - bushing.nodes_ref[0].xyz) # <<<<<<<<<<<<<< @@ -4544,7 +4525,7 @@ static PyObject *__pyx_f_11pynastranIO_perturbZeroLengthBushings(struct BDFModel __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_L = __pyx_t_11; - /* "pynastranIO.pyx":237 + /* "pynastran_io.pyx":237 * bushing = model.myBDF.elements[eid] * L = np.linalg.norm(bushing.nodes_ref[1].xyz - bushing.nodes_ref[0].xyz) * if abs(L)0 and an x-axis can be defined by the geometry * i = bushing.cid_ref.i # <<<<<<<<<<<<<< @@ -4569,7 +4550,7 @@ static PyObject *__pyx_f_11pynastranIO_perturbZeroLengthBushings(struct BDFModel __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_2); __pyx_t_2 = 0; - /* "pynastranIO.pyx":240 + /* "pynastran_io.pyx":240 * # Slightly perturb the second node so that L>0 and an x-axis can be defined by the geometry * i = bushing.cid_ref.i * di = eps*i # <<<<<<<<<<<<<< @@ -4584,7 +4565,7 @@ static PyObject *__pyx_f_11pynastranIO_perturbZeroLengthBushings(struct BDFModel __Pyx_XDECREF_SET(__pyx_v_di, __pyx_t_1); __pyx_t_1 = 0; - /* "pynastranIO.pyx":241 + /* "pynastran_io.pyx":241 * i = bushing.cid_ref.i * di = eps*i * absmindi = abs(di).min() # <<<<<<<<<<<<<< @@ -4614,7 +4595,7 @@ static PyObject *__pyx_f_11pynastranIO_perturbZeroLengthBushings(struct BDFModel __Pyx_XDECREF_SET(__pyx_v_absmindi, __pyx_t_1); __pyx_t_1 = 0; - /* "pynastranIO.pyx":242 + /* "pynastran_io.pyx":242 * di = eps*i * absmindi = abs(di).min() * if absmindiobj = Py_None; __Pyx_INCREF(Py_None); __Pyx_GIVEREF(__pyx_v_info->obj); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":265 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":265 * * cdef int i, ndim * cdef int endian_detector = 1 # <<<<<<<<<<<<<< @@ -4842,7 +4823,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_endian_detector = 1; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":266 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":266 * cdef int i, ndim * cdef int endian_detector = 1 * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< @@ -4851,7 +4832,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":268 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":268 * cdef bint little_endian = ((&endian_detector)[0] != 0) * * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< @@ -4860,7 +4841,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 * ndim = PyArray_NDIM(self) * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -4874,7 +4855,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P goto __pyx_L4_bool_binop_done; } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":271 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":271 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< @@ -4885,7 +4866,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = __pyx_t_2; __pyx_L4_bool_binop_done:; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 * ndim = PyArray_NDIM(self) * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -4894,7 +4875,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ if (unlikely(__pyx_t_1)) { - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":272 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":272 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< @@ -4907,7 +4888,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(2, 272, __pyx_L1_error) - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 * ndim = PyArray_NDIM(self) * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -4916,7 +4897,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -4930,7 +4911,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P goto __pyx_L7_bool_binop_done; } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":275 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":275 * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< @@ -4941,7 +4922,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = __pyx_t_2; __pyx_L7_bool_binop_done:; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -4950,7 +4931,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ if (unlikely(__pyx_t_1)) { - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":276 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":276 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< @@ -4963,7 +4944,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(2, 276, __pyx_L1_error) - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -4972,7 +4953,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":278 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":278 * raise ValueError(u"ndarray is not Fortran contiguous") * * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< @@ -4981,7 +4962,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":279 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":279 * * info.buf = PyArray_DATA(self) * info.ndim = ndim # <<<<<<<<<<<<<< @@ -4990,7 +4971,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->ndim = __pyx_v_ndim; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":280 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":280 * info.buf = PyArray_DATA(self) * info.ndim = ndim * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< @@ -5000,7 +4981,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); if (__pyx_t_1) { - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":283 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":283 * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. * info.strides = PyObject_Malloc(sizeof(Py_ssize_t) * 2 * ndim) # <<<<<<<<<<<<<< @@ -5009,7 +4990,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->strides = ((Py_ssize_t *)PyObject_Malloc((((sizeof(Py_ssize_t)) * 2) * ((size_t)__pyx_v_ndim)))); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":284 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":284 * # This is allocated as one block, strides first. * info.strides = PyObject_Malloc(sizeof(Py_ssize_t) * 2 * ndim) * info.shape = info.strides + ndim # <<<<<<<<<<<<<< @@ -5018,7 +4999,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":285 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":285 * info.strides = PyObject_Malloc(sizeof(Py_ssize_t) * 2 * ndim) * info.shape = info.strides + ndim * for i in range(ndim): # <<<<<<<<<<<<<< @@ -5030,7 +5011,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { __pyx_v_i = __pyx_t_6; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":286 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":286 * info.shape = info.strides + ndim * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< @@ -5039,7 +5020,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":287 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":287 * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< @@ -5049,7 +5030,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]); } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":280 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":280 * info.buf = PyArray_DATA(self) * info.ndim = ndim * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< @@ -5059,7 +5040,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P goto __pyx_L9; } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":289 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":289 * info.shape[i] = PyArray_DIMS(self)[i] * else: * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< @@ -5069,7 +5050,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P /*else*/ { __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":290 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":290 * else: * info.strides = PyArray_STRIDES(self) * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< @@ -5080,7 +5061,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P } __pyx_L9:; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":291 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":291 * info.strides = PyArray_STRIDES(self) * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL # <<<<<<<<<<<<<< @@ -5089,7 +5070,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->suboffsets = NULL; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":292 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":292 * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< @@ -5098,7 +5079,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":293 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":293 * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< @@ -5107,7 +5088,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0)); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":296 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":296 * * cdef int t * cdef char* f = NULL # <<<<<<<<<<<<<< @@ -5116,7 +5097,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_f = NULL; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":297 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":297 * cdef int t * cdef char* f = NULL * cdef dtype descr = PyArray_DESCR(self) # <<<<<<<<<<<<<< @@ -5129,7 +5110,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_descr = ((PyArray_Descr *)__pyx_t_3); __pyx_t_3 = 0; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":300 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":300 * cdef int offset * * info.obj = self # <<<<<<<<<<<<<< @@ -5142,7 +5123,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = ((PyObject *)__pyx_v_self); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":302 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":302 * info.obj = self * * if not PyDataType_HASFIELDS(descr): # <<<<<<<<<<<<<< @@ -5152,7 +5133,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = ((!(PyDataType_HASFIELDS(__pyx_v_descr) != 0)) != 0); if (__pyx_t_1) { - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":303 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":303 * * if not PyDataType_HASFIELDS(descr): * t = descr.type_num # <<<<<<<<<<<<<< @@ -5162,7 +5143,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_4 = __pyx_v_descr->type_num; __pyx_v_t = __pyx_t_4; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":304 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":304 * if not PyDataType_HASFIELDS(descr): * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -5182,7 +5163,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P } __pyx_L15_next_or:; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":305 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":305 * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< @@ -5199,7 +5180,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = __pyx_t_2; __pyx_L14_bool_binop_done:; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":304 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":304 * if not PyDataType_HASFIELDS(descr): * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -5208,7 +5189,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ if (unlikely(__pyx_t_1)) { - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":306 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":306 * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< @@ -5221,7 +5202,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(2, 306, __pyx_L1_error) - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":304 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":304 * if not PyDataType_HASFIELDS(descr): * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -5230,7 +5211,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":307 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":307 * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< @@ -5243,7 +5224,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_UBYTE: - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":308 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":308 * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< @@ -5254,7 +5235,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_SHORT: - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":309 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":309 * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< @@ -5265,7 +5246,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_USHORT: - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":310 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":310 * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< @@ -5276,7 +5257,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_INT: - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":311 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":311 * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< @@ -5287,7 +5268,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_UINT: - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":312 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":312 * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< @@ -5298,7 +5279,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_LONG: - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":313 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":313 * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< @@ -5309,7 +5290,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_ULONG: - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":314 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":314 * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< @@ -5320,7 +5301,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_LONGLONG: - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":315 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":315 * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< @@ -5331,7 +5312,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_ULONGLONG: - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":316 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":316 * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< @@ -5342,7 +5323,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_FLOAT: - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":317 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":317 * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< @@ -5353,7 +5334,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_DOUBLE: - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":318 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":318 * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< @@ -5364,7 +5345,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_LONGDOUBLE: - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":319 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":319 * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< @@ -5375,7 +5356,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_CFLOAT: - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":320 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":320 * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<< @@ -5386,7 +5367,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_CDOUBLE: - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":321 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":321 * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<< @@ -5397,7 +5378,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_CLONGDOUBLE: - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":322 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":322 * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<< @@ -5408,7 +5389,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_OBJECT: - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":323 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":323 * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< @@ -5419,7 +5400,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; default: - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":325 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":325 * elif t == NPY_OBJECT: f = "O" * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< @@ -5440,7 +5421,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":326 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":326 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f # <<<<<<<<<<<<<< @@ -5449,7 +5430,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->format = __pyx_v_f; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":327 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":327 * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f * return # <<<<<<<<<<<<<< @@ -5459,7 +5440,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_r = 0; goto __pyx_L0; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":302 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":302 * info.obj = self * * if not PyDataType_HASFIELDS(descr): # <<<<<<<<<<<<<< @@ -5468,7 +5449,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":329 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":329 * return * else: * info.format = PyObject_Malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< @@ -5478,7 +5459,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P /*else*/ { __pyx_v_info->format = ((char *)PyObject_Malloc(0xFF)); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":330 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":330 * else: * info.format = PyObject_Malloc(_buffer_format_string_len) * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<< @@ -5487,7 +5468,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ (__pyx_v_info->format[0]) = '^'; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":331 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":331 * info.format = PyObject_Malloc(_buffer_format_string_len) * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 # <<<<<<<<<<<<<< @@ -5496,7 +5477,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_offset = 0; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":332 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":332 * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 * f = _util_dtypestring(descr, info.format + 1, # <<<<<<<<<<<<<< @@ -5506,7 +5487,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 0xFF), (&__pyx_v_offset)); if (unlikely(__pyx_t_9 == ((char *)NULL))) __PYX_ERR(2, 332, __pyx_L1_error) __pyx_v_f = __pyx_t_9; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":335 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":335 * info.format + _buffer_format_string_len, * &offset) * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<< @@ -5516,7 +5497,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P (__pyx_v_f[0]) = '\x00'; } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":258 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":258 * # experimental exception made for __getbuffer__ and __releasebuffer__ * # -- the details of this may change. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< @@ -5548,7 +5529,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P return __pyx_r; } -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":337 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":337 * f[0] = c'\0' # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< @@ -5572,7 +5553,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s int __pyx_t_1; __Pyx_RefNannySetupContext("__releasebuffer__", 0); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":338 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":338 * * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< @@ -5582,7 +5563,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0); if (__pyx_t_1) { - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":339 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":339 * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): * PyObject_Free(info.format) # <<<<<<<<<<<<<< @@ -5591,7 +5572,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s */ PyObject_Free(__pyx_v_info->format); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":338 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":338 * * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< @@ -5600,7 +5581,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s */ } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":340 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":340 * if PyArray_HASFIELDS(self): * PyObject_Free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< @@ -5610,7 +5591,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); if (__pyx_t_1) { - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":341 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":341 * PyObject_Free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): * PyObject_Free(info.strides) # <<<<<<<<<<<<<< @@ -5619,7 +5600,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s */ PyObject_Free(__pyx_v_info->strides); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":340 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":340 * if PyArray_HASFIELDS(self): * PyObject_Free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< @@ -5628,7 +5609,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s */ } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":337 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":337 * f[0] = c'\0' # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< @@ -5640,7 +5621,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s __Pyx_RefNannyFinishContext(); } -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":821 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":821 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< @@ -5654,7 +5635,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":822 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":822 * * cdef inline object PyArray_MultiIterNew1(a): * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< @@ -5668,7 +5649,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":821 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":821 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< @@ -5687,7 +5668,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ return __pyx_r; } -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":824 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":824 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< @@ -5701,7 +5682,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":825 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":825 * * cdef inline object PyArray_MultiIterNew2(a, b): * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< @@ -5715,7 +5696,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":824 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":824 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< @@ -5734,7 +5715,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ return __pyx_r; } -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":827 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":827 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< @@ -5748,7 +5729,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":828 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":828 * * cdef inline object PyArray_MultiIterNew3(a, b, c): * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< @@ -5762,7 +5743,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":827 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":827 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< @@ -5781,7 +5762,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ return __pyx_r; } -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":830 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":830 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< @@ -5795,7 +5776,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":831 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":831 * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< @@ -5809,7 +5790,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":830 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":830 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< @@ -5828,7 +5809,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ return __pyx_r; } -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":833 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":833 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< @@ -5842,7 +5823,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":834 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":834 * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< @@ -5856,7 +5837,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":833 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":833 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< @@ -5875,7 +5856,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ return __pyx_r; } -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":836 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":836 * return PyArray_MultiIterNew(5, a, b, c, d, e) * * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< @@ -5889,7 +5870,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ int __pyx_t_1; __Pyx_RefNannySetupContext("PyDataType_SHAPE", 0); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":837 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":837 * * cdef inline tuple PyDataType_SHAPE(dtype d): * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< @@ -5899,7 +5880,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ __pyx_t_1 = (PyDataType_HASSUBARRAY(__pyx_v_d) != 0); if (__pyx_t_1) { - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":838 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":838 * cdef inline tuple PyDataType_SHAPE(dtype d): * if PyDataType_HASSUBARRAY(d): * return d.subarray.shape # <<<<<<<<<<<<<< @@ -5911,7 +5892,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape); goto __pyx_L0; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":837 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":837 * * cdef inline tuple PyDataType_SHAPE(dtype d): * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< @@ -5920,7 +5901,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ */ } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":840 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":840 * return d.subarray.shape * else: * return () # <<<<<<<<<<<<<< @@ -5934,7 +5915,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ goto __pyx_L0; } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":836 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":836 * return PyArray_MultiIterNew(5, a, b, c, d, e) * * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< @@ -5949,7 +5930,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ return __pyx_r; } -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":842 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":842 * return () * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< @@ -5978,7 +5959,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx char *__pyx_t_9; __Pyx_RefNannySetupContext("_util_dtypestring", 0); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":847 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":847 * * cdef dtype child * cdef int endian_detector = 1 # <<<<<<<<<<<<<< @@ -5987,7 +5968,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_endian_detector = 1; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":848 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":848 * cdef dtype child * cdef int endian_detector = 1 * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< @@ -5996,7 +5977,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":851 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":851 * cdef tuple fields * * for childname in descr.names: # <<<<<<<<<<<<<< @@ -6019,7 +6000,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3); __pyx_t_3 = 0; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":852 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":852 * * for childname in descr.names: * fields = descr.fields[childname] # <<<<<<<<<<<<<< @@ -6036,7 +6017,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":853 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":853 * for childname in descr.names: * fields = descr.fields[childname] * child, new_offset = fields # <<<<<<<<<<<<<< @@ -6071,7 +6052,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4); __pyx_t_4 = 0; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":855 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":855 * child, new_offset = fields * * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< @@ -6088,7 +6069,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0); if (unlikely(__pyx_t_6)) { - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":856 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":856 * * if (end - f) - (new_offset - offset[0]) < 15: * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< @@ -6101,7 +6082,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(2, 856, __pyx_L1_error) - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":855 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":855 * child, new_offset = fields * * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< @@ -6110,7 +6091,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":858 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":858 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -6130,7 +6111,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx } __pyx_L8_next_or:; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":859 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":859 * * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< @@ -6147,7 +6128,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = __pyx_t_7; __pyx_L7_bool_binop_done:; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":858 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":858 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -6156,7 +6137,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ if (unlikely(__pyx_t_6)) { - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":860 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":860 * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< @@ -6169,7 +6150,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(2, 860, __pyx_L1_error) - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":858 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":858 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -6178,7 +6159,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":870 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":870 * * # Output padding bytes * while offset[0] < new_offset: # <<<<<<<<<<<<<< @@ -6194,7 +6175,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!__pyx_t_6) break; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":871 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":871 * # Output padding bytes * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< @@ -6203,7 +6184,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ (__pyx_v_f[0]) = 0x78; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":872 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":872 * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte * f += 1 # <<<<<<<<<<<<<< @@ -6212,7 +6193,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_f = (__pyx_v_f + 1); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":873 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":873 * f[0] = 120 # "x"; pad byte * f += 1 * offset[0] += 1 # <<<<<<<<<<<<<< @@ -6223,7 +6204,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1); } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":875 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":875 * offset[0] += 1 * * offset[0] += child.itemsize # <<<<<<<<<<<<<< @@ -6233,7 +6214,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_8 = 0; (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":877 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":877 * offset[0] += child.itemsize * * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< @@ -6243,7 +6224,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0); if (__pyx_t_6) { - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":878 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":878 * * if not PyDataType_HASFIELDS(child): * t = child.type_num # <<<<<<<<<<<<<< @@ -6255,7 +6236,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4); __pyx_t_4 = 0; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":879 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":879 * if not PyDataType_HASFIELDS(child): * t = child.type_num * if end - f < 5: # <<<<<<<<<<<<<< @@ -6265,7 +6246,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0); if (unlikely(__pyx_t_6)) { - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":880 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":880 * t = child.type_num * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< @@ -6278,7 +6259,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(2, 880, __pyx_L1_error) - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":879 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":879 * if not PyDataType_HASFIELDS(child): * t = child.type_num * if end - f < 5: # <<<<<<<<<<<<<< @@ -6287,7 +6268,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":883 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":883 * * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< @@ -6305,7 +6286,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":884 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":884 * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< @@ -6323,7 +6304,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":885 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":885 * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< @@ -6341,7 +6322,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":886 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":886 * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< @@ -6359,7 +6340,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":887 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":887 * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< @@ -6377,7 +6358,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":888 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":888 * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< @@ -6395,7 +6376,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":889 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":889 * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< @@ -6413,7 +6394,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":890 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":890 * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< @@ -6431,7 +6412,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":891 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":891 * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< @@ -6449,7 +6430,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":892 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":892 * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< @@ -6467,7 +6448,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":893 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":893 * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< @@ -6485,7 +6466,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":894 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":894 * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< @@ -6503,7 +6484,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":895 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":895 * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< @@ -6521,7 +6502,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":896 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":896 * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< @@ -6541,7 +6522,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":897 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":897 * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< @@ -6561,7 +6542,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":898 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":898 * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< @@ -6581,7 +6562,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":899 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":899 * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< @@ -6599,7 +6580,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":901 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":901 * elif t == NPY_OBJECT: f[0] = 79 #"O" * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< @@ -6618,7 +6599,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx } __pyx_L15:; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":902 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":902 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * f += 1 # <<<<<<<<<<<<<< @@ -6627,7 +6608,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_f = (__pyx_v_f + 1); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":877 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":877 * offset[0] += child.itemsize * * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< @@ -6637,7 +6618,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L13; } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":906 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":906 * # Cython ignores struct boundary information ("T{...}"), * # so don't output it * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< @@ -6650,7 +6631,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx } __pyx_L13:; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":851 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":851 * cdef tuple fields * * for childname in descr.names: # <<<<<<<<<<<<<< @@ -6660,7 +6641,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":907 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":907 * # so don't output it * f = _util_dtypestring(child, f, end, offset) * return f # <<<<<<<<<<<<<< @@ -6670,7 +6651,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_r = __pyx_v_f; goto __pyx_L0; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":842 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":842 * return () * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< @@ -6695,7 +6676,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx return __pyx_r; } -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1022 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1022 * int _import_umath() except -1 * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< @@ -6707,7 +6688,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("set_array_base", 0); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1023 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1023 * * cdef inline void set_array_base(ndarray arr, object base): * Py_INCREF(base) # important to do this before stealing the reference below! # <<<<<<<<<<<<<< @@ -6716,7 +6697,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a */ Py_INCREF(__pyx_v_base); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1024 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1024 * cdef inline void set_array_base(ndarray arr, object base): * Py_INCREF(base) # important to do this before stealing the reference below! * PyArray_SetBaseObject(arr, base) # <<<<<<<<<<<<<< @@ -6725,7 +6706,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a */ (void)(PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_base)); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1022 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1022 * int _import_umath() except -1 * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< @@ -6737,7 +6718,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a __Pyx_RefNannyFinishContext(); } -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1026 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1026 * PyArray_SetBaseObject(arr, base) * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< @@ -6752,7 +6733,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py int __pyx_t_1; __Pyx_RefNannySetupContext("get_array_base", 0); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1027 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1027 * * cdef inline object get_array_base(ndarray arr): * base = PyArray_BASE(arr) # <<<<<<<<<<<<<< @@ -6761,7 +6742,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py */ __pyx_v_base = PyArray_BASE(__pyx_v_arr); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1028 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1028 * cdef inline object get_array_base(ndarray arr): * base = PyArray_BASE(arr) * if base is NULL: # <<<<<<<<<<<<<< @@ -6771,7 +6752,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py __pyx_t_1 = ((__pyx_v_base == NULL) != 0); if (__pyx_t_1) { - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1029 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1029 * base = PyArray_BASE(arr) * if base is NULL: * return None # <<<<<<<<<<<<<< @@ -6782,7 +6763,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1028 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1028 * cdef inline object get_array_base(ndarray arr): * base = PyArray_BASE(arr) * if base is NULL: # <<<<<<<<<<<<<< @@ -6791,7 +6772,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py */ } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1030 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1030 * if base is NULL: * return None * return base # <<<<<<<<<<<<<< @@ -6803,7 +6784,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py __pyx_r = ((PyObject *)__pyx_v_base); goto __pyx_L0; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1026 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1026 * PyArray_SetBaseObject(arr, base) * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< @@ -6818,7 +6799,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py return __pyx_r; } -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1034 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1034 * # Versions of the import_* functions which are more suitable for * # Cython code. * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< @@ -6839,7 +6820,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("import_array", 0); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1035 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1035 * # Cython code. * cdef inline int import_array() except -1: * try: # <<<<<<<<<<<<<< @@ -6855,7 +6836,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1036 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1036 * cdef inline int import_array() except -1: * try: * _import_array() # <<<<<<<<<<<<<< @@ -6864,7 +6845,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { */ __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 1036, __pyx_L3_error) - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1035 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1035 * # Cython code. * cdef inline int import_array() except -1: * try: # <<<<<<<<<<<<<< @@ -6878,7 +6859,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { goto __pyx_L8_try_end; __pyx_L3_error:; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1037 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1037 * try: * _import_array() * except Exception: # <<<<<<<<<<<<<< @@ -6893,7 +6874,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_7); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1038 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1038 * _import_array() * except Exception: * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< @@ -6909,7 +6890,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { goto __pyx_L5_except_error; __pyx_L5_except_error:; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1035 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1035 * # Cython code. * cdef inline int import_array() except -1: * try: # <<<<<<<<<<<<<< @@ -6924,7 +6905,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { __pyx_L8_try_end:; } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1034 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1034 * # Versions of the import_* functions which are more suitable for * # Cython code. * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< @@ -6947,7 +6928,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { return __pyx_r; } -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1040 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1040 * raise ImportError("numpy.core.multiarray failed to import") * * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< @@ -6968,7 +6949,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("import_umath", 0); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1041 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1041 * * cdef inline int import_umath() except -1: * try: # <<<<<<<<<<<<<< @@ -6984,7 +6965,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1042 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1042 * cdef inline int import_umath() except -1: * try: * _import_umath() # <<<<<<<<<<<<<< @@ -6993,7 +6974,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { */ __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 1042, __pyx_L3_error) - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1041 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1041 * * cdef inline int import_umath() except -1: * try: # <<<<<<<<<<<<<< @@ -7007,7 +6988,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { goto __pyx_L8_try_end; __pyx_L3_error:; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1043 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1043 * try: * _import_umath() * except Exception: # <<<<<<<<<<<<<< @@ -7022,7 +7003,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_7); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1044 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1044 * _import_umath() * except Exception: * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< @@ -7038,7 +7019,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { goto __pyx_L5_except_error; __pyx_L5_except_error:; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1041 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1041 * * cdef inline int import_umath() except -1: * try: # <<<<<<<<<<<<<< @@ -7053,7 +7034,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { __pyx_L8_try_end:; } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1040 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1040 * raise ImportError("numpy.core.multiarray failed to import") * * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< @@ -7076,7 +7057,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { return __pyx_r; } -/* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1046 +/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1046 * raise ImportError("numpy.core.umath failed to import") * * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< @@ -7097,7 +7078,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("import_ufunc", 0); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1047 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1047 * * cdef inline int import_ufunc() except -1: * try: # <<<<<<<<<<<<<< @@ -7113,7 +7094,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1048 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1048 * cdef inline int import_ufunc() except -1: * try: * _import_umath() # <<<<<<<<<<<<<< @@ -7122,7 +7103,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { */ __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 1048, __pyx_L3_error) - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1047 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1047 * * cdef inline int import_ufunc() except -1: * try: # <<<<<<<<<<<<<< @@ -7136,7 +7117,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { goto __pyx_L8_try_end; __pyx_L3_error:; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1049 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1049 * try: * _import_umath() * except Exception: # <<<<<<<<<<<<<< @@ -7150,7 +7131,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_7); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1050 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1050 * _import_umath() * except Exception: * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< @@ -7164,7 +7145,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { goto __pyx_L5_except_error; __pyx_L5_except_error:; - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1047 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1047 * * cdef inline int import_ufunc() except -1: * try: # <<<<<<<<<<<<<< @@ -7179,7 +7160,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { __pyx_L8_try_end:; } - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1046 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1046 * raise ImportError("numpy.core.umath failed to import") * * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< @@ -7607,7 +7588,7 @@ static PyObject *__pyx_convert_map_to_py_std_3a__3a_string____int(std::maptp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { @@ -7620,14 +7601,14 @@ static PyObject *__pyx_tp_new_11pynastranIO_BDFModel(PyTypeObject *t, PyObject * new((void*)&(p->bdfPath)) std::string(); new((void*)&(p->nElemTypes)) std::map (); p->myBDF = Py_None; Py_INCREF(Py_None); - if (unlikely(__pyx_pw_11pynastranIO_8BDFModel_1__cinit__(o, a, k) < 0)) goto bad; + if (unlikely(__pyx_pw_12pynastran_io_8BDFModel_1__cinit__(o, a, k) < 0)) goto bad; return o; bad: Py_DECREF(o); o = 0; return NULL; } -static void __pyx_tp_dealloc_11pynastranIO_BDFModel(PyObject *o) { +static void __pyx_tp_dealloc_12pynastran_io_BDFModel(PyObject *o) { struct BDFModel *p = (struct BDFModel *)o; #if CYTHON_USE_TP_FINALIZE if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { @@ -7641,7 +7622,7 @@ static void __pyx_tp_dealloc_11pynastranIO_BDFModel(PyObject *o) { (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_11pynastranIO_BDFModel(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_12pynastran_io_BDFModel(PyObject *o, visitproc v, void *a) { int e; struct BDFModel *p = (struct BDFModel *)o; if (p->myBDF) { @@ -7650,7 +7631,7 @@ static int __pyx_tp_traverse_11pynastranIO_BDFModel(PyObject *o, visitproc v, vo return 0; } -static int __pyx_tp_clear_11pynastranIO_BDFModel(PyObject *o) { +static int __pyx_tp_clear_12pynastran_io_BDFModel(PyObject *o) { PyObject* tmp; struct BDFModel *p = (struct BDFModel *)o; tmp = ((PyObject*)p->myBDF); @@ -7659,52 +7640,52 @@ static int __pyx_tp_clear_11pynastranIO_BDFModel(PyObject *o) { return 0; } -static PyObject *__pyx_getprop_11pynastranIO_8BDFModel_nDims(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_11pynastranIO_8BDFModel_5nDims_1__get__(o); +static PyObject *__pyx_getprop_12pynastran_io_8BDFModel_nDims(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_12pynastran_io_8BDFModel_5nDims_1__get__(o); } -static PyObject *__pyx_getprop_11pynastranIO_8BDFModel_nNodes(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_11pynastranIO_8BDFModel_6nNodes_1__get__(o); +static PyObject *__pyx_getprop_12pynastran_io_8BDFModel_nNodes(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_12pynastran_io_8BDFModel_6nNodes_1__get__(o); } -static PyObject *__pyx_getprop_11pynastranIO_8BDFModel_nElems(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_11pynastranIO_8BDFModel_6nElems_1__get__(o); +static PyObject *__pyx_getprop_12pynastran_io_8BDFModel_nElems(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_12pynastran_io_8BDFModel_6nElems_1__get__(o); } -static PyObject *__pyx_getprop_11pynastranIO_8BDFModel_nMaterials(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_11pynastranIO_8BDFModel_10nMaterials_1__get__(o); +static PyObject *__pyx_getprop_12pynastran_io_8BDFModel_nMaterials(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_12pynastran_io_8BDFModel_10nMaterials_1__get__(o); } -static PyObject *__pyx_getprop_11pynastranIO_8BDFModel_nProperties(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_11pynastranIO_8BDFModel_11nProperties_1__get__(o); +static PyObject *__pyx_getprop_12pynastran_io_8BDFModel_nProperties(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_12pynastran_io_8BDFModel_11nProperties_1__get__(o); } -static PyObject *__pyx_getprop_11pynastranIO_8BDFModel_nElemTypes(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_11pynastranIO_8BDFModel_10nElemTypes_1__get__(o); +static PyObject *__pyx_getprop_12pynastran_io_8BDFModel_nElemTypes(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_12pynastran_io_8BDFModel_10nElemTypes_1__get__(o); } -static PyMethodDef __pyx_methods_11pynastranIO_BDFModel[] = { - {"__reduce_cython__", (PyCFunction)__pyx_pw_11pynastranIO_8BDFModel_3__reduce_cython__, METH_NOARGS, 0}, - {"__setstate_cython__", (PyCFunction)__pyx_pw_11pynastranIO_8BDFModel_5__setstate_cython__, METH_O, 0}, +static PyMethodDef __pyx_methods_12pynastran_io_BDFModel[] = { + {"__reduce_cython__", (PyCFunction)__pyx_pw_12pynastran_io_8BDFModel_3__reduce_cython__, METH_NOARGS, 0}, + {"__setstate_cython__", (PyCFunction)__pyx_pw_12pynastran_io_8BDFModel_5__setstate_cython__, METH_O, 0}, {0, 0, 0, 0} }; -static struct PyGetSetDef __pyx_getsets_11pynastranIO_BDFModel[] = { - {(char *)"nDims", __pyx_getprop_11pynastranIO_8BDFModel_nDims, 0, (char *)0, 0}, - {(char *)"nNodes", __pyx_getprop_11pynastranIO_8BDFModel_nNodes, 0, (char *)0, 0}, - {(char *)"nElems", __pyx_getprop_11pynastranIO_8BDFModel_nElems, 0, (char *)0, 0}, - {(char *)"nMaterials", __pyx_getprop_11pynastranIO_8BDFModel_nMaterials, 0, (char *)0, 0}, - {(char *)"nProperties", __pyx_getprop_11pynastranIO_8BDFModel_nProperties, 0, (char *)0, 0}, - {(char *)"nElemTypes", __pyx_getprop_11pynastranIO_8BDFModel_nElemTypes, 0, (char *)0, 0}, +static struct PyGetSetDef __pyx_getsets_12pynastran_io_BDFModel[] = { + {(char *)"nDims", __pyx_getprop_12pynastran_io_8BDFModel_nDims, 0, (char *)0, 0}, + {(char *)"nNodes", __pyx_getprop_12pynastran_io_8BDFModel_nNodes, 0, (char *)0, 0}, + {(char *)"nElems", __pyx_getprop_12pynastran_io_8BDFModel_nElems, 0, (char *)0, 0}, + {(char *)"nMaterials", __pyx_getprop_12pynastran_io_8BDFModel_nMaterials, 0, (char *)0, 0}, + {(char *)"nProperties", __pyx_getprop_12pynastran_io_8BDFModel_nProperties, 0, (char *)0, 0}, + {(char *)"nElemTypes", __pyx_getprop_12pynastran_io_8BDFModel_nElemTypes, 0, (char *)0, 0}, {0, 0, 0, 0, 0} }; DL_EXPORT(PyTypeObject) BDFModelType = { PyVarObject_HEAD_INIT(0, 0) - "pynastranIO.BDFModel", /*tp_name*/ + "pynastran_io.BDFModel", /*tp_name*/ sizeof(struct BDFModel), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_11pynastranIO_BDFModel, /*tp_dealloc*/ + __pyx_tp_dealloc_12pynastran_io_BDFModel, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -7726,15 +7707,15 @@ DL_EXPORT(PyTypeObject) BDFModelType = { 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - __pyx_tp_traverse_11pynastranIO_BDFModel, /*tp_traverse*/ - __pyx_tp_clear_11pynastranIO_BDFModel, /*tp_clear*/ + __pyx_tp_traverse_12pynastran_io_BDFModel, /*tp_traverse*/ + __pyx_tp_clear_12pynastran_io_BDFModel, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_11pynastranIO_BDFModel, /*tp_methods*/ + __pyx_methods_12pynastran_io_BDFModel, /*tp_methods*/ 0, /*tp_members*/ - __pyx_getsets_11pynastranIO_BDFModel, /*tp_getset*/ + __pyx_getsets_12pynastran_io_BDFModel, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ @@ -7742,7 +7723,7 @@ DL_EXPORT(PyTypeObject) BDFModelType = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_11pynastranIO_BDFModel, /*tp_new*/ + __pyx_tp_new_12pynastran_io_BDFModel, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -7755,9 +7736,6 @@ DL_EXPORT(PyTypeObject) BDFModelType = { #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif - #if PY_VERSION_HEX >= 0x030800b1 - 0, /*tp_vectorcall*/ - #endif }; static PyMethodDef __pyx_methods[] = { @@ -7767,17 +7745,17 @@ static PyMethodDef __pyx_methods[] = { #if PY_MAJOR_VERSION >= 3 #if CYTHON_PEP489_MULTI_PHASE_INIT static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ -static int __pyx_pymod_exec_pynastranIO(PyObject* module); /*proto*/ +static int __pyx_pymod_exec_pynastran_io(PyObject* module); /*proto*/ static PyModuleDef_Slot __pyx_moduledef_slots[] = { {Py_mod_create, (void*)__pyx_pymod_create}, - {Py_mod_exec, (void*)__pyx_pymod_exec_pynastranIO}, + {Py_mod_exec, (void*)__pyx_pymod_exec_pynastran_io}, {0, NULL} }; #endif static struct PyModuleDef __pyx_moduledef = { PyModuleDef_HEAD_INIT, - "pynastranIO", + "pynastran_io", __pyx_k_pyNASTRAN_Notes_Dependencies_cp, /* m_doc */ #if CYTHON_PEP489_MULTI_PHASE_INIT 0, /* m_size */ @@ -7927,7 +7905,7 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__2); __Pyx_GIVEREF(__pyx_tuple__2); - /* "pynastranIO.pyx":173 + /* "pynastran_io.pyx":173 * if "offset" in element.object_attributes(): * if element.offset!=0: * raise NotImplementedError("Support of non-zero offsets not yet implemented!") # <<<<<<<<<<<<<< @@ -7938,7 +7916,7 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__5); __Pyx_GIVEREF(__pyx_tuple__5); - /* "pynastranIO.pyx":176 + /* "pynastran_io.pyx":176 * if "zoffset" in element.object_attributes(): * if element.zoffset!=0: * raise NotImplementedError("Support of non-zero offets not yet implemented!") # <<<<<<<<<<<<<< @@ -7949,7 +7927,7 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__6); __Pyx_GIVEREF(__pyx_tuple__6); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":272 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":272 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< @@ -7960,7 +7938,7 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__7); __Pyx_GIVEREF(__pyx_tuple__7); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":276 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":276 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< @@ -7971,7 +7949,7 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__8); __Pyx_GIVEREF(__pyx_tuple__8); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":306 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":306 * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< @@ -7982,7 +7960,7 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__9); __Pyx_GIVEREF(__pyx_tuple__9); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":856 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":856 * * if (end - f) - (new_offset - offset[0]) < 15: * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< @@ -7993,7 +7971,7 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__10); __Pyx_GIVEREF(__pyx_tuple__10); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":880 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":880 * t = child.type_num * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< @@ -8004,7 +7982,7 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__11); __Pyx_GIVEREF(__pyx_tuple__11); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1038 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1038 * _import_array() * except Exception: * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< @@ -8015,7 +7993,7 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__12); __Pyx_GIVEREF(__pyx_tuple__12); - /* "../../../../Programs/anaconda3/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1044 + /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1044 * _import_umath() * except Exception: * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< @@ -8078,15 +8056,13 @@ static int __Pyx_modinit_type_init_code(void) { __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); /*--- Type init code ---*/ if (PyType_Ready(&BDFModelType) < 0) __PYX_ERR(1, 33, __pyx_L1_error) - #if PY_VERSION_HEX < 0x030800B1 BDFModelType.tp_print = 0; - #endif if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!BDFModelType.tp_dictoffset && BDFModelType.tp_getattro == PyObject_GenericGetAttr)) { BDFModelType.tp_getattro = __Pyx_PyObject_GenericGetAttr; } if (PyObject_SetAttr(__pyx_m, __pyx_n_s_BDFModel, (PyObject *)&BDFModelType) < 0) __PYX_ERR(1, 33, __pyx_L1_error) if (__Pyx_setup_reduce((PyObject*)&BDFModelType) < 0) __PYX_ERR(1, 33, __pyx_L1_error) - __pyx_ptype_11pynastranIO_BDFModel = &BDFModelType; + __pyx_ptype_12pynastran_io_BDFModel = &BDFModelType; __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -8164,11 +8140,11 @@ static int __Pyx_modinit_function_import_code(void) { #if PY_MAJOR_VERSION < 3 -__Pyx_PyMODINIT_FUNC initpynastranIO(void) CYTHON_SMALL_CODE; /*proto*/ -__Pyx_PyMODINIT_FUNC initpynastranIO(void) +__Pyx_PyMODINIT_FUNC initpynastran_io(void) CYTHON_SMALL_CODE; /*proto*/ +__Pyx_PyMODINIT_FUNC initpynastran_io(void) #else -__Pyx_PyMODINIT_FUNC PyInit_pynastranIO(void) CYTHON_SMALL_CODE; /*proto*/ -__Pyx_PyMODINIT_FUNC PyInit_pynastranIO(void) +__Pyx_PyMODINIT_FUNC PyInit_pynastran_io(void) CYTHON_SMALL_CODE; /*proto*/ +__Pyx_PyMODINIT_FUNC PyInit_pynastran_io(void) #if CYTHON_PEP489_MULTI_PHASE_INIT { return PyModuleDef_Init(&__pyx_moduledef); @@ -8235,7 +8211,7 @@ static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNU } -static CYTHON_SMALL_CODE int __pyx_pymod_exec_pynastranIO(PyObject *__pyx_pyinit_module) +static CYTHON_SMALL_CODE int __pyx_pymod_exec_pynastran_io(PyObject *__pyx_pyinit_module) #endif #endif { @@ -8245,7 +8221,7 @@ static CYTHON_SMALL_CODE int __pyx_pymod_exec_pynastranIO(PyObject *__pyx_pyinit #if CYTHON_PEP489_MULTI_PHASE_INIT if (__pyx_m) { if (__pyx_m == __pyx_pyinit_module) return 0; - PyErr_SetString(PyExc_RuntimeError, "Module 'pynastranIO' has already been imported. Re-initialisation is not supported."); + PyErr_SetString(PyExc_RuntimeError, "Module 'pynastran_io' has already been imported. Re-initialisation is not supported."); return -1; } #elif PY_MAJOR_VERSION >= 3 @@ -8260,7 +8236,7 @@ if (!__Pyx_RefNanny) { Py_FatalError("failed to import 'refnanny' module"); } #endif - __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_pynastranIO(void)", 0); + __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_pynastran_io(void)", 0); if (__Pyx_check_binary_version() < 0) __PYX_ERR(1, 1, __pyx_L1_error) #ifdef __Pxy_PyFrame_Initialize_Offsets __Pxy_PyFrame_Initialize_Offsets(); @@ -8299,7 +8275,7 @@ if (!__Pyx_RefNanny) { Py_INCREF(__pyx_m); #else #if PY_MAJOR_VERSION < 3 - __pyx_m = Py_InitModule4("pynastranIO", __pyx_methods, __pyx_k_pyNASTRAN_Notes_Dependencies_cp, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); + __pyx_m = Py_InitModule4("pynastran_io", __pyx_methods, __pyx_k_pyNASTRAN_Notes_Dependencies_cp, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif @@ -8308,30 +8284,31 @@ if (!__Pyx_RefNanny) { __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(1, 1, __pyx_L1_error) Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(1, 1, __pyx_L1_error) - Py_INCREF(__pyx_b); __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(1, 1, __pyx_L1_error) - Py_INCREF(__pyx_cython_runtime); + #if CYTHON_COMPILING_IN_PYPY + Py_INCREF(__pyx_b); + #endif if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(1, 1, __pyx_L1_error); /*--- Initialize various global constants etc. ---*/ if (__Pyx_InitGlobals() < 0) __PYX_ERR(1, 1, __pyx_L1_error) #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(1, 1, __pyx_L1_error) #endif - if (__pyx_module_is_main_pynastranIO) { + if (__pyx_module_is_main_pynastran_io) { if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(1, 1, __pyx_L1_error) } #if PY_MAJOR_VERSION >= 3 { PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(1, 1, __pyx_L1_error) - if (!PyDict_GetItemString(modules, "pynastranIO")) { - if (unlikely(PyDict_SetItemString(modules, "pynastranIO", __pyx_m) < 0)) __PYX_ERR(1, 1, __pyx_L1_error) + if (!PyDict_GetItemString(modules, "pynastran_io")) { + if (unlikely(PyDict_SetItemString(modules, "pynastran_io", __pyx_m) < 0)) __PYX_ERR(1, 1, __pyx_L1_error) } } #endif /*--- Builtin init code ---*/ - if (__Pyx_InitCachedBuiltins() < 0) goto __pyx_L1_error; + if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(1, 1, __pyx_L1_error) /*--- Constants init code ---*/ - if (__Pyx_InitCachedConstants() < 0) goto __pyx_L1_error; + if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(1, 1, __pyx_L1_error) /*--- Global type/function init code ---*/ (void)__Pyx_modinit_global_init_code(); (void)__Pyx_modinit_variable_export_code(); @@ -8345,7 +8322,7 @@ if (!__Pyx_RefNanny) { if (__Pyx_patch_abc() < 0) __PYX_ERR(1, 1, __pyx_L1_error) #endif - /* "pynastranIO.pyx":12 + /* "pynastran_io.pyx":12 * * # pyNastran Imports * from pyNastran.bdf.bdf import BDF # <<<<<<<<<<<<<< @@ -8366,7 +8343,7 @@ if (!__Pyx_RefNanny) { __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "pynastranIO.pyx":24 + /* "pynastran_io.pyx":24 * # Cython Imports * from cython.operator import dereference, postincrement * from warnings import warn # <<<<<<<<<<<<<< @@ -8387,7 +8364,7 @@ if (!__Pyx_RefNanny) { __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "pynastranIO.pyx":27 + /* "pynastran_io.pyx":27 * * # Setup Numpy Usage * import numpy as np # <<<<<<<<<<<<<< @@ -8399,7 +8376,7 @@ if (!__Pyx_RefNanny) { if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(1, 27, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "pynastranIO.pyx":29 + /* "pynastran_io.pyx":29 * import numpy as np * cimport numpy as np * DTYPE = np.float # <<<<<<<<<<<<<< @@ -8414,7 +8391,7 @@ if (!__Pyx_RefNanny) { if (PyDict_SetItem(__pyx_d, __pyx_n_s_DTYPE, __pyx_t_2) < 0) __PYX_ERR(1, 29, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "pynastranIO.pyx":1 + /* "pynastran_io.pyx":1 * # distutils: language = c++ # <<<<<<<<<<<<<< * # ^^^ This line above is read by setup.py and lets it know to compile the * # program as C++ instead of the default, C. @@ -8440,11 +8417,11 @@ if (!__Pyx_RefNanny) { __Pyx_XDECREF(__pyx_t_2); if (__pyx_m) { if (__pyx_d) { - __Pyx_AddTraceback("init pynastranIO", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("init pynastran_io", __pyx_clineno, __pyx_lineno, __pyx_filename); } Py_CLEAR(__pyx_m); } else if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_ImportError, "init pynastranIO"); + PyErr_SetString(PyExc_ImportError, "init pynastran_io"); } __pyx_L0:; __Pyx_RefNannyFinishContext(); @@ -8737,7 +8714,7 @@ static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args return result; } #if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) { +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) { PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); PyObject *globals = PyFunction_GET_GLOBALS(func); PyObject *argdefs = PyFunction_GET_DEFAULTS(func); @@ -8808,12 +8785,12 @@ static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, } #if PY_MAJOR_VERSION >= 3 result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, - args, (int)nargs, + args, nargs, k, (int)nk, d, (int)nd, kwdefs, closure); #else result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, - args, (int)nargs, + args, nargs, k, (int)nk, d, (int)nd, closure); #endif diff --git a/src/mesh/pynastranIO.h b/src/mesh/pynastran_io.h similarity index 78% rename from src/mesh/pynastranIO.h rename to src/mesh/pynastran_io.h index 530fc404..d179215b 100644 --- a/src/mesh/pynastranIO.h +++ b/src/mesh/pynastran_io.h @@ -1,11 +1,11 @@ -/* Generated by Cython 0.29.12 */ +/* Generated by Cython 0.29.6 */ -#ifndef __PYX_HAVE__pynastranIO -#define __PYX_HAVE__pynastranIO +#ifndef __PYX_HAVE__pynastran_io +#define __PYX_HAVE__pynastran_io struct BDFModel; -/* "pynastranIO.pyx":33 +/* "pynastran_io.pyx":33 * * * cdef public class BDFModel[object BDFModel, type BDFModelType]: # <<<<<<<<<<<<<< @@ -24,7 +24,7 @@ struct BDFModel { PyObject *myBDF; }; -#ifndef __PYX_HAVE_API__pynastranIO +#ifndef __PYX_HAVE_API__pynastran_io #ifndef __PYX_EXTERN_C #ifdef __cplusplus @@ -46,15 +46,15 @@ __PYX_EXTERN_C std::vector > getNodes(struct BDFModel *); __PYX_EXTERN_C std::map > > getElements(struct BDFModel *); __PYX_EXTERN_C std::map getNumberOfElementTypes(struct BDFModel *); -#endif /* !__PYX_HAVE_API__pynastranIO */ +#endif /* !__PYX_HAVE_API__pynastran_io */ /* WARNING: the interface of the module init function changed in CPython 3.5. */ /* It now returns a PyModuleDef instance instead of a PyModule instance. */ #if PY_MAJOR_VERSION < 3 -PyMODINIT_FUNC initpynastranIO(void); +PyMODINIT_FUNC initpynastran_io(void); #else -PyMODINIT_FUNC PyInit_pynastranIO(void); +PyMODINIT_FUNC PyInit_pynastran_io(void); #endif -#endif /* !__PYX_HAVE__pynastranIO */ +#endif /* !__PYX_HAVE__pynastran_io */ diff --git a/src/mesh/pynastranIO.pyx b/src/mesh/pynastran_io.pyx similarity index 100% rename from src/mesh/pynastranIO.pyx rename to src/mesh/pynastran_io.pyx From 5791c934e0f75ea3ec5c241999a7a1cf73d29c25 Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Tue, 26 Nov 2019 12:18:27 -0500 Subject: [PATCH 023/111] Moved NastranIO into MAST namespace. --- src/mesh/nastran_io.cpp | 32 ++++---- src/mesh/nastran_io.h | 165 ++++++++++++++++++++-------------------- 2 files changed, 99 insertions(+), 98 deletions(-) diff --git a/src/mesh/nastran_io.cpp b/src/mesh/nastran_io.cpp index 3961b384..a276fc9b 100644 --- a/src/mesh/nastran_io.cpp +++ b/src/mesh/nastran_io.cpp @@ -17,7 +17,7 @@ #include "Python.h" -void printElementMap(std::map>> elementMap) +void MAST::printElementMap(std::map>> elementMap) { // Iterate through element types for (const auto& item : elementMap) @@ -39,7 +39,7 @@ void printElementMap(std::map>> elemen } -void printNodeCoords(std::vector> nodes) +void MAST::printNodeCoords(std::vector> nodes) { // Iterate through nodes for (const auto& node : nodes) @@ -49,7 +49,7 @@ void printNodeCoords(std::vector> nodes) } -NastranIO::NastranIO (libMesh::MeshBase& mesh, const bool pythonPreinitialized): +MAST::NastranIO::NastranIO (libMesh::MeshBase& mesh, const bool pythonPreinitialized): libMesh::MeshInput (mesh), _pythonPreinitialized(pythonPreinitialized) { @@ -61,7 +61,7 @@ _pythonPreinitialized(pythonPreinitialized) } -NastranIO::~NastranIO () +MAST::NastranIO::~NastranIO () { if((pythonInitialized) and (not _pythonPreinitialized)) { @@ -70,30 +70,30 @@ NastranIO::~NastranIO () } -std::map NastranIO::getNastran2libMeshNodeMap() +std::map MAST::NastranIO::getNastran2libMeshNodeMap() { return nastran2libMeshNodeMap; } -std::map NastranIO::getlibMesh2NastranNodeMap() +std::map MAST::NastranIO::getlibMesh2NastranNodeMap() { return libMesh2NastranNodeMap; } -std::map NastranIO::getNastran2libMeshElemMap() +std::map MAST::NastranIO::getNastran2libMeshElemMap() { return nastran2libMeshElemMap; } -std::map NastranIO::getlibMesh2NastranElemMap() +std::map MAST::NastranIO::getlibMesh2NastranElemMap() { return libMesh2NastranElemMap; } -std::map> NastranIO::getPID2subdomainIDsMap() +std::map> MAST::NastranIO::getPID2subdomainIDsMap() { std::map> pid2SubdomainIDsMap; for (const auto& item : pid_elemType2subdomainMap) @@ -107,12 +107,12 @@ std::map> NastranIO::getPID2subdomainIDsMap() } -std::map, int> NastranIO::getPIDElemtype2SubdomainIDMap() +std::map, int> MAST::NastranIO::getPIDElemtype2SubdomainIDMap() { return pid_elemType2subdomainMap; } -void NastranIO::read_nodes(BDFModel* model, libMesh::MeshBase& the_mesh) +void MAST::NastranIO::read_nodes(BDFModel* model, libMesh::MeshBase& the_mesh) { // Get the nodes from the bulk data file std::vector> nodes = getNodes(model); @@ -135,7 +135,7 @@ void NastranIO::read_nodes(BDFModel* model, libMesh::MeshBase& the_mesh) } -void NastranIO::read_elements(BDFModel* model, libMesh::MeshBase& the_mesh) +void MAST::NastranIO::read_elements(BDFModel* model, libMesh::MeshBase& the_mesh) { // Reserve space in the mesh for the nodes and elements the_mesh.reserve_elem(model->nElems); @@ -203,7 +203,7 @@ void NastranIO::read_elements(BDFModel* model, libMesh::MeshBase& the_mesh) } -void NastranIO::read (const std::string & fname) +void MAST::NastranIO::read (const std::string & fname) { // Get a reference to the mesh we are reading libMesh::MeshBase& the_mesh = MeshInput::mesh(); @@ -224,7 +224,7 @@ void NastranIO::read (const std::string & fname) read_elements(model, the_mesh); } -void NastranIO::read(BDFModel* model) +void MAST::NastranIO::read(BDFModel* model) { // Get a reference to the mesh we are reading libMesh::MeshBase& the_mesh = MeshInput::mesh(); @@ -244,7 +244,7 @@ void NastranIO::read(BDFModel* model) -void NastranIO::initializePython() +void MAST::NastranIO::initializePython() { // StackOverFlow, "Use generated header file from Cython" int status = PyImport_AppendInittab("pynastranIO", PyInit_pynastran_io); @@ -261,7 +261,7 @@ void NastranIO::initializePython() } -void NastranIO::finalizePython() +void MAST::NastranIO::finalizePython() { Py_Finalize(); pythonInitialized = false; diff --git a/src/mesh/nastran_io.h b/src/mesh/nastran_io.h index f8d5be33..87824e36 100644 --- a/src/mesh/nastran_io.h +++ b/src/mesh/nastran_io.h @@ -1,5 +1,5 @@ -#ifndef NASTRANIO_H -#define NASTRANIO_H +#ifndef __mast_nastran_io_h__ +#define __mast_nastran_io_h__ // C++ Includes @@ -16,85 +16,86 @@ #include "mesh/nastran_io.h" #include "mesh/pynastran_io.h" -void printElementMap(std::map>> elementMap); - -void printNodeCoords(std::vector> nodes); - - -/** - * The NastranIO class is a preliminary implementation for reading NASTRAN - * mesh files using pyNastran with BDF files as input. - */ -class NastranIO : public libMesh::MeshInput -{ -public: - explicit - NastranIO(libMesh::MeshBase& mesh, const bool pythonPreinitialized=false); - - virtual ~NastranIO (); - - virtual void read (const std::string & name) override; - virtual void read (BDFModel* model); - - std::map getNastran2libMeshNodeMap(); - std::map getlibMesh2NastranNodeMap(); - - std::map getNastran2libMeshElemMap(); - std::map getlibMesh2NastranElemMap(); - - std::map, int> getPIDElemtype2SubdomainIDMap(); - std::map> getPID2subdomainIDsMap(); - -private: - - const bool _pythonPreinitialized = false; - bool pythonInitialized = false; - - std::map nastran2libMeshNodeMap; - std::map libMesh2NastranNodeMap; - std::map nastran2libMeshElemMap; - std::map libMesh2NastranElemMap; - std::map, int> pid_elemType2subdomainMap = {}; - - void read_nodes(BDFModel* model, libMesh::MeshBase& the_mesh); - void read_elements(BDFModel* model, libMesh::MeshBase& the_mesh); - - // Map from NASTRAN Elements to Equivalent libMesh Elements - // TODO: Not yet complete, need to add all NASTRAN elements which we need support for. - std::map nastranToLibMeshElem = { - - // 0D Elements (i.e. Ground Springs) - {"CELAS1_1", libMesh::NODEELEM}, {"CELAS2_1", libMesh::NODEELEM}, - {"CELAS3_1", libMesh::NODEELEM}, {"CELAS4_1", libMesh::NODEELEM}, - {"CBUSH_1", libMesh::NODEELEM}, {"CBUSH1D_1", libMesh::NODEELEM}, - - // 1D Elements - {"CELAS1_2", libMesh::EDGE2}, {"CELAS2_2", libMesh::EDGE2}, - {"CELAS3_2", libMesh::EDGE2}, {"CELAS4_2", libMesh::EDGE2}, - {"CBUSH_2", libMesh::EDGE2}, {"CBUSH1D_2", libMesh::EDGE2}, - {"CBUSH2D_2",libMesh::EDGE2}, - {"CROD_2", libMesh::EDGE2}, {"CBAR_2", libMesh::EDGE2}, - {"CBEAM_2", libMesh::EDGE2}, {"CBEAM3_3", libMesh::EDGE3}, - - // 2D Elements - {"CTRIA3_3", libMesh::TRI3}, {"CTRIA6_6", libMesh::TRI6}, - {"CTRIAR_3", libMesh::TRI3}, - {"CQUAD4_4", libMesh::QUAD4}, {"CQUAD8_8", libMesh::QUAD8}, - {"CQUADR_4", libMesh::QUADSHELL4}, {"CQUAD_4", libMesh::QUAD4}, - {"CQUAD_8", libMesh::QUAD8}, {"CQUAD_9", libMesh::QUAD9}, - {"CQUADX_4", libMesh::QUAD4}, {"CQUADX_8", libMesh::QUAD8}, - {"CQUADX_9", libMesh::QUAD9}, - - // 3D Elements - {"CTETRA_4", libMesh::TET4}, {"CTETRA_10", libMesh::TET10}, - {"CPENTA_6", libMesh::PRISM6}, {"CPENTA_15", libMesh::PRISM15}, - {"CPYRAM_5", libMesh::PYRAMID5}, {"CPYRAM_13", libMesh::PYRAMID13}, - {"CHEXA_8", libMesh::HEX8}, {"CHEXA_20", libMesh::HEX20} - }; - - void initializePython(); - void finalizePython(); -}; +namespace MAST { + + void printElementMap(std::map>> elementMap); + + void printNodeCoords(std::vector> nodes); + + /** + * The NastranIO class is a preliminary implementation for reading NASTRAN + * mesh files using pyNastran with BDF files as input. + */ + class NastranIO : public libMesh::MeshInput + { + public: + explicit + NastranIO(libMesh::MeshBase& mesh, const bool pythonPreinitialized=false); + + virtual ~NastranIO (); + + virtual void read (const std::string & name) override; + virtual void read (BDFModel* model); + + std::map getNastran2libMeshNodeMap(); + std::map getlibMesh2NastranNodeMap(); + + std::map getNastran2libMeshElemMap(); + std::map getlibMesh2NastranElemMap(); + + std::map, int> getPIDElemtype2SubdomainIDMap(); + std::map> getPID2subdomainIDsMap(); + + private: + const bool _pythonPreinitialized = false; + bool pythonInitialized = false; + + std::map nastran2libMeshNodeMap; + std::map libMesh2NastranNodeMap; + std::map nastran2libMeshElemMap; + std::map libMesh2NastranElemMap; + std::map, int> pid_elemType2subdomainMap = {}; + + void read_nodes(BDFModel* model, libMesh::MeshBase& the_mesh); + void read_elements(BDFModel* model, libMesh::MeshBase& the_mesh); + + // Map from NASTRAN Elements to Equivalent libMesh Elements + // TODO: Not yet complete, need to add all NASTRAN elements which we need support for. + std::map nastranToLibMeshElem = { + + // 0D Elements (i.e. Ground Springs) + {"CELAS1_1", libMesh::NODEELEM}, {"CELAS2_1", libMesh::NODEELEM}, + {"CELAS3_1", libMesh::NODEELEM}, {"CELAS4_1", libMesh::NODEELEM}, + {"CBUSH_1", libMesh::NODEELEM}, {"CBUSH1D_1", libMesh::NODEELEM}, + + // 1D Elements + {"CELAS1_2", libMesh::EDGE2}, {"CELAS2_2", libMesh::EDGE2}, + {"CELAS3_2", libMesh::EDGE2}, {"CELAS4_2", libMesh::EDGE2}, + {"CBUSH_2", libMesh::EDGE2}, {"CBUSH1D_2", libMesh::EDGE2}, + {"CBUSH2D_2",libMesh::EDGE2}, + {"CROD_2", libMesh::EDGE2}, {"CBAR_2", libMesh::EDGE2}, + {"CBEAM_2", libMesh::EDGE2}, {"CBEAM3_3", libMesh::EDGE3}, + + // 2D Elements + {"CTRIA3_3", libMesh::TRI3}, {"CTRIA6_6", libMesh::TRI6}, + {"CTRIAR_3", libMesh::TRI3}, + {"CQUAD4_4", libMesh::QUAD4}, {"CQUAD8_8", libMesh::QUAD8}, + {"CQUADR_4", libMesh::QUADSHELL4}, {"CQUAD_4", libMesh::QUAD4}, + {"CQUAD_8", libMesh::QUAD8}, {"CQUAD_9", libMesh::QUAD9}, + {"CQUADX_4", libMesh::QUAD4}, {"CQUADX_8", libMesh::QUAD8}, + {"CQUADX_9", libMesh::QUAD9}, + + // 3D Elements + {"CTETRA_4", libMesh::TET4}, {"CTETRA_10", libMesh::TET10}, + {"CPENTA_6", libMesh::PRISM6}, {"CPENTA_15", libMesh::PRISM15}, + {"CPYRAM_5", libMesh::PYRAMID5}, {"CPYRAM_13", libMesh::PYRAMID13}, + {"CHEXA_8", libMesh::HEX8}, {"CHEXA_20", libMesh::HEX20} + }; + + void initializePython(); + void finalizePython(); + }; +} -#endif // NASTRANIO_H +#endif // __mast_nastran_io_h__ From 1265e5251d87a4dfa4334efa9f5a3317964a3f86 Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Thu, 5 Dec 2019 13:56:55 -0500 Subject: [PATCH 024/111] Update Travis CI integration to test build on multiple OS's/compilers. (#47) * Initial multi-libMesh version CI build. * Migrate before_install and install stages to scripts from .travis.yml. * Multi-libMesh build on OSX. * Separate CI docs build from code build for efficiency. * Added exit status to CI scripts, organized CI, added all cases. - Also updated documentation deployment conditions. * Added README for the Travis CI build testing updates. * Setup both Debug and Release builds on Travis CI jobs. * Remove Debug build from Travis CI for libMesh < v1.5.0 when using GCC. - Reference https://github.com/libMesh/libmesh/issues/2337 for discussion of extra flags necessary for MAST build when using libmesh_dbg <1.5.0 - Recommendation for GCC users is to simply move to libMesh v1.5.0. --- .gitignore | 2 +- .travis.yml | 82 +++++++++---------- ci/README.md | 48 ++++++++++++ ci/build_dependencies.sh | 36 +++++++++ ci/build_mast.sh | 157 +++++++++++++++++++++++++++++++++++++ {doc => ci}/deploy_docs.sh | 0 ci/get_libmesh.sh | 33 ++++++++ 7 files changed, 317 insertions(+), 41 deletions(-) create mode 100644 ci/README.md create mode 100755 ci/build_dependencies.sh create mode 100755 ci/build_mast.sh rename {doc => ci}/deploy_docs.sh (100%) create mode 100755 ci/get_libmesh.sh diff --git a/.gitignore b/.gitignore index 6c8b68e0..454df28a 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,7 @@ doc/example_3.dox # CLion IDE files. .idea/ -cmake-build-debug/ +cmake-build*/ build2 # Visual Studio Code settings. diff --git a/.travis.yml b/.travis.yml index 39b6d1da..9302a03e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,49 +1,51 @@ language: cpp -dist: xenial + +matrix: + include: + # macOS/Linux builds - libMesh version 1.5.0 + - os: osx + osx_image: xcode10.2 + env: LIBMESH_VERSION=1.5.0 + - os: linux + dist: xenial + env: LIBMESH_VERSION=1.5.0 + + # Doxygen documentation build + # - this job also progresses to deployment when on master branch + - os: linux + dist: xenial + env: CI_BUILD_DOCS=true CI_DEPLOY_DOCS=true LIBMESH_VERSION=1.4.1 + + # macOS/Linux builds - libMesh version 1.4.1 + - os: osx + osx_image: xcode10.2 + env: LIBMESH_VERSION=1.4.1 + - os: linux + dist: xenial + env: LIBMESH_VERSION=1.4.1 + + # macOS/Linux builds - libMesh version 1.3.1 + - os: osx + osx_image: xcode10.2 + env: LIBMESH_VERSION=1.3.1 + - os: linux + dist: xenial + env: LIBMESH_VERSION=1.3.1 before_install: -- sudo apt-get -qq install -y gfortran wget m4 -- sudo apt-get -qq install -y openmpi-bin libopenmpi-dev -- sudo apt-get -qq install -y libpetsc3.6 libpetsc3.6.2-dev -- sudo apt-get -qq install -y libslepc3.6 libslepc3.6.1-dev libparpack2-dev -- sudo apt-get -qq install -y libboost-all-dev -- sudo apt-get -qq install -y libeigen3-dev -- sudo apt-get -qq install -y doxygen graphviz rsync -- sudo apt-get -qq install -y texlive-latex-base dvi2ps ghostscript + - ci/build_dependencies.sh install: -- cd ${HOME} -- wget -nv https://github.com/MASTmultiphysics/mast-ci-packages/releases/download/libmesh-1.3.1-1.deb/libmesh-1.3.1-1.deb -- sudo apt install ./libmesh-1.3.1-1.deb - -before_script: -- export MAST_INSTALL_DIR=${HOME}/mast -- cd ${TRAVIS_BUILD_DIR} -- mkdir build -- cd build -- cmake .. - -DCMAKE_INSTALL_PREFIX=${MAST_INSTALL_DIR} - -DCMAKE_C_COMPILER=mpicc - -DCMAKE_CXX_COMPILER=mpic++ - -DCMAKE_Fortran_COMPILER=mpifort - -DlibMesh_DIR=/usr/local - -DPETSc_DIR=/usr/lib/petscdir/3.6.2/x86_64-linux-gnu-real - -DSLEPc_DIR=/usr/lib/slepcdir/3.6.1/x86_64-linux-gnu-real - -DEIGEN3_ROOT=/usr/include/eigen3 - -DBOOST_ROOT=/usr - -DBUILD_DOC=ON - -DENABLE_DOT=OFF - -DENABLE_GCMMA=OFF - -DENABLE_SNOPT=OFF + - ci/get_libmesh.sh script: -- make -j 2 -- make -j 2 doc_doxygen -- cd ${TRAVIS_BUILD_DIR} + - ci/build_mast.sh + - deploy: - provider: script - script: bash doc/deploy_docs.sh - skip_cleanup: true - on: - branch: master + provider: script + script: bash ci/deploy_docs.sh + skip_cleanup: true + on: + branch: master + condition: ${CI_DEPLOY_DOCS} = true diff --git a/ci/README.md b/ci/README.md new file mode 100644 index 00000000..ae03d5da --- /dev/null +++ b/ci/README.md @@ -0,0 +1,48 @@ +# Travis CI Testing/Deployment + +On the GitHub repository of MAST, Travis CI (https://travis-ci.com) is utilized for build testing on multiple OS's and +deployment of updated documentation online. In the future we will integrate the execution of both unit tests as well as +example problems for integration testing. + +This directory contains scripts utilized by the Travis CI process. + +## Travis CI Processes +When a commit is pushed to the MASTmultiphysics/mast-multiphysics GitHub repository, GitHub initiates the continuous +integration processes on Travis CI. What these processes do is controlled by the `.travis.yml` file in the root of the +repository. The different phases of a Travis CI are described at https://docs.travis-ci.com/user/job-lifecycle/. This +repository utilizes a relatively basic subset of the phases and overall capability of Travis CI. + +The files in this directory are utilized in the main phases of the Travis CI lifecycle: + +1. `before_install` - `build_dependencies.sh` - This script ensures that the Travis CI runner executing the current job +has the required dependencies for libMesh and building MAST. +2. `install` - `get_libmesh.sh` - This script fetches pre-built binaries of libMesh on Linux or the entire dependency +package on macOS. Travis CI jobs have a limited time for execution that is not long enough to build libMesh +(which is not available in job runners standard Linux/macOS package managers.) +3. `script` - `build_mast.sh` - Depending on the job, this script either builds the MAST library/examples or builds the +doxygen documentation. +4. `deploy` - `deploy_docs.sh` - For the job satisfying the appropriate conditions, this script pushes the documentation +website produced by doxygen to the hosting location. + +## Multiple OS's/Jobs/Environments +The `matrix` section of the `.travis.yml` file allows for the definition of multiple jobs to be run that can be done +in different environments or on different workers. Each item under `matrix/include` causes the execution of different +Travis CI worker with the specified environment. In the current setup, we utilize both Linux and macOS to test builds +against different compilers as well as different versions of the libMesh dependency, which is periodically updated by +that projects maintainers. In this setup, Travis CI allows for the specification of system environment variables that +are utilized by the scripts in the `ci` folder for distinguishing work that is specific to each environment. + +### Linux +The current Linux build environment utilizes Ubuntu 16.04. Dependencies available in the Ubuntu apt package repositories +are leveraged; however, in the future these may be updated as versions of PETSc/SLEPc are quite old. The current +compiler on Linux is GNU GCC-5.4.0. The libMesh dependencies are provided as external binaries that were built in an +identical environment and archived. + +### macOS +The macOS build on Travis CI current utilizes macOS version 10.14.4 with the default clang C/C++ compiler (Apple LLVM +version 10.0.1). Travis CI suggests utilizing Homebrew to install dependencies, which currently does not contain many of +the packages required for libMesh/MAST. To overcome this, a complete set dependencies (including multiple versions of +libMesh) is built/archived using Spack on the same environment setup (macOS version/compiler) the Travis CI utilizes. +These dependencies are fetched by the Travis CI runner and MAST is built against them. Since macOS does not provide a +Fortran compiler, GCC-9.1.0 is first built via Spack. The compiler toolchain is then macOS-provided C/C++ and +gfortran-9. \ No newline at end of file diff --git a/ci/build_dependencies.sh b/ci/build_dependencies.sh new file mode 100755 index 00000000..3f630aab --- /dev/null +++ b/ci/build_dependencies.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux + + if [ "${TRAVIS_DIST}" = xenial ]; then # Ubuntu 16.04 Xenial Xerus + sudo apt-get -qq update + sudo apt-get -qq install -y gfortran wget m4 + sudo apt-get -qq install -y openmpi-bin libopenmpi-dev + sudo apt-get -qq install -y libpetsc3.6 libpetsc3.6.2-dev + sudo apt-get -qq install -y libslepc3.6 libslepc3.6.1-dev libparpack2-dev + sudo apt-get -qq install -y libboost-all-dev + sudo apt-get -qq install -y libeigen3-dev + sudo apt-get -qq install -y doxygen graphviz rsync + sudo apt-get -qq install -y texlive-latex-base dvi2ps ghostscript + + # elif [ "${TRAVIS_DIST}" = bionic ]; then # Ubuntu 18.04 Bionic Beaver + # sudo apt-get -qq update + # sudo apt-get -qq install -y gfortran wget m4 + # which gfortran + # gcc --version + # echo "Hello From BIONIC" + + else + echo "INVALID LINUX DISTRO: ${TRAVIS_DIST}" + exit 1 + fi + +elif [ "${TRAVIS_OS_NAME}" = osx ]; then # macOS 10.14, XCode 10.2 + # Currently we don't do anything here since we get all dependencies for macOS + # from the binary download with "ci/get_libmesh.sh" in the next stage. + echo "Hello From OSX" + +else + echo "INVALID OS: ${TRAVIS_OS_NAME}" + exit 1 +fi \ No newline at end of file diff --git a/ci/build_mast.sh b/ci/build_mast.sh new file mode 100755 index 00000000..980c2b2f --- /dev/null +++ b/ci/build_mast.sh @@ -0,0 +1,157 @@ +#!/usr/bin/env bash + +# Steps common to all OS/toolchains. +export MAST_INSTALL_DIR=${HOME}/mast || exit +cd ${TRAVIS_BUILD_DIR} || exit + +# Create directories to test both Release (optimized) and Debug build. +mkdir build_rel || exit +mkdir build_dbg || exit + +# Outer if chooses Linux/macOS based on Travis CI worker. +if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux + + # We could test on multiple Ubuntu distributions, which by default supply different versions + # of GCC in their default repos. For now we just use 16.04. + if [ "${TRAVIS_DIST}" = xenial ]; then # Ubuntu 16.04 Xenial Xerus + + # First let us build/install a Release (optimized) version of MAST (-DCMAKE_BUILD_TYPE=Release). + echo "TEST RELEASE/OPTIMIZED BUILD..." + cd build_rel || exit + cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX="${MAST_INSTALL_DIR}" \ + -DCMAKE_C_COMPILER=mpicc \ + -DCMAKE_CXX_COMPILER=mpic++ \ + -DCMAKE_Fortran_COMPILER=mpifort \ + -DlibMesh_DIR=/usr/local \ + -DPETSc_DIR=/usr/lib/petscdir/3.6.2/x86_64-linux-gnu-real \ + -DSLEPc_DIR=/usr/lib/slepcdir/3.6.1/x86_64-linux-gnu-real \ + -DEIGEN3_ROOT=/usr/include/eigen3 \ + -DBOOST_ROOT=/usr \ + -DBUILD_DOC=ON \ + -DENABLE_DOT=OFF \ + -DENABLE_GCMMA=OFF \ + -DENABLE_SNOPT=OFF || exit + + if [ ${CI_BUILD_DOCS} ]; then + make doc_doxygen || exit + else + make -j 2 || exit + make install || exit + fi + + # Now do a build/install of a Debug version (-DCMAKE_BUILD_TYPE=Debug). + echo "TEST DEBUG BUILD..." + + if [ "${LIBMESH_VERSION}" = "1.3.1" ]; then # No Debug build for libMesh < 1.5.0 + echo "-- NO DEBUG BUILD WITH libMesh < 1.5.0" + elif [ "${LIBMESH_VERSION}" = "1.4.1" ]; then + echo "-- NO DEBUG BUILD WITH libMesh < 1.5.0" + else + + cd ../build_dbg || exit + cmake .. \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_INSTALL_PREFIX="${MAST_INSTALL_DIR}" \ + -DCMAKE_C_COMPILER=mpicc \ + -DCMAKE_CXX_COMPILER=mpic++ \ + -DCMAKE_Fortran_COMPILER=mpifort \ + -DlibMesh_DIR=/usr/local \ + -DPETSc_DIR=/usr/lib/petscdir/3.6.2/x86_64-linux-gnu-real \ + -DSLEPc_DIR=/usr/lib/slepcdir/3.6.1/x86_64-linux-gnu-real \ + -DEIGEN3_ROOT=/usr/include/eigen3 \ + -DBOOST_ROOT=/usr \ + -DBUILD_DOC=ON \ + -DENABLE_DOT=OFF \ + -DENABLE_GCMMA=OFF \ + -DENABLE_SNOPT=OFF || exit + + if [ ${CI_BUILD_DOCS} ]; then + echo "No CI documentation for a Debug build." + else + make -j 2 || exit + fi + + fi # No Debug build for libMesh < 1.5.0 + + # elif [ "${TRAVIS_DIST}" = bionic ]; then # Ubuntu 18.04 Bionic Beaver + + else + echo "INVALID LINUX DISTRO: ${TRAVIS_DIST}" + exit 1 + fi + +elif [ "${TRAVIS_OS_NAME}" = osx ]; then # macOS 10.14, XCode 10.2 + + if [ "${LIBMESH_VERSION}" = "1.3.1" ]; then + PETSc_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/petsc-3.11.4-4ode2ljnkurc55362bc6k6wtlgfjpdmf + SLEPc_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/slepc-3.11.2-nts2wrpmixfsvfev7x5b5e2e4vpct6wy + libMesh_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/libmesh-1.3.1-gsiac4h5rvdoowg2mjfvwrvmwbbnw5yv + elif [ "${LIBMESH_VERSION}" = "1.4.1" ]; then + PETSc_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/petsc-3.11.4-4ode2ljnkurc55362bc6k6wtlgfjpdmf + SLEPc_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/slepc-3.11.2-nts2wrpmixfsvfev7x5b5e2e4vpct6wy + libMesh_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/libmesh-1.4.1-3zx2df3tra2fd6znisp5cthgawkh4zol + elif [ "${LIBMESH_VERSION}" = "1.5.0" ]; then + PETSc_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/petsc-3.12.1-edmddchkkhtwckfumww3mtghyadytdxj + SLEPc_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/slepc-3.12.0-dbsf3rtgj4hoih6okdja6godorotij22 + libMesh_DIR=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/libmesh-1.5.0-dxjeof7unenkr5ivfpdekiuftgyktkeh + fi + + # First let us build/install a Release (optimized) version of MAST (-DCMAKE_BUILD_TYPE=Release). + echo "TEST RELEASE/OPTIMIZED BUILD..." + cd build_rel || exit + /Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/cmake-3.14.4-vlzpkvowre6hweutogn563ouzkb73jsq/bin/cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX="${MAST_INSTALL_DIR}" \ + -DCMAKE_C_COMPILER=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openmpi-3.1.4-sep4omvhokkexyojwrahdckfugactovb/bin/mpicc \ + -DCMAKE_CXX_COMPILER=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openmpi-3.1.4-sep4omvhokkexyojwrahdckfugactovb/bin/mpic++ \ + -DCMAKE_Fortran_COMPILER=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openmpi-3.1.4-sep4omvhokkexyojwrahdckfugactovb/bin/mpif90 \ + -DlibMesh_DIR="${libMesh_DIR}" \ + -DPETSc_DIR="${PETSc_DIR}" \ + -DSLEPc_DIR="${SLEPc_DIR}" \ + -DBOOST_ROOT=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/boost-1.70.0-3mel532oks2cxz76mqrxvn4xrl3bg5ri \ + -DHDF5_ROOT=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/hdf5-1.10.5-kfyeqhtsenqumr7eut6b47mjev7tstom \ + -DEIGEN3_ROOT=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/eigen-3.3.7-bd2r4aqrkox7dpebj2r3gqvgpqzwuh7x \ + -DLAPACK_LIBRARIES=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openblas-0.3.7-xqeap7iegoomce3es67cd7exlnq3neue/lib/libopenblas.dylib \ + -DBLAS_LIBRARIES=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openblas-0.3.7-xqeap7iegoomce3es67cd7exlnq3neue/lib/libopenblas.dylib \ + -DENABLE_GCMMA=OFF \ + -DENABLE_DOT=OFF \ + -DENABLE_SNOPT=OFF \ + -DENABLE_NLOPT=OFF \ + -DENABLE_CYTHON=OFF \ + -DBUILD_DOC=OFF || exit + make -j 2 || exit + make install || exit + + # Now do a build/install of a Debug version (-DCMAKE_BUILD_TYPE=Debug). + echo "TEST DEBUG BUILD..." + cd ../build_dbg || exit + /Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/cmake-3.14.4-vlzpkvowre6hweutogn563ouzkb73jsq/bin/cmake .. \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_INSTALL_PREFIX="${MAST_INSTALL_DIR}" \ + -DCMAKE_C_COMPILER=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openmpi-3.1.4-sep4omvhokkexyojwrahdckfugactovb/bin/mpicc \ + -DCMAKE_CXX_COMPILER=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openmpi-3.1.4-sep4omvhokkexyojwrahdckfugactovb/bin/mpic++ \ + -DCMAKE_Fortran_COMPILER=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openmpi-3.1.4-sep4omvhokkexyojwrahdckfugactovb/bin/mpif90 \ + -DlibMesh_DIR="${libMesh_DIR}" \ + -DPETSc_DIR="${PETSc_DIR}" \ + -DSLEPc_DIR="${SLEPc_DIR}" \ + -DBOOST_ROOT=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/boost-1.70.0-3mel532oks2cxz76mqrxvn4xrl3bg5ri \ + -DHDF5_ROOT=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/hdf5-1.10.5-kfyeqhtsenqumr7eut6b47mjev7tstom \ + -DEIGEN3_ROOT=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/eigen-3.3.7-bd2r4aqrkox7dpebj2r3gqvgpqzwuh7x \ + -DLAPACK_LIBRARIES=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openblas-0.3.7-xqeap7iegoomce3es67cd7exlnq3neue/lib/libopenblas.dylib \ + -DBLAS_LIBRARIES=/Users/travis/Code/spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/openblas-0.3.7-xqeap7iegoomce3es67cd7exlnq3neue/lib/libopenblas.dylib \ + -DENABLE_GCMMA=OFF \ + -DENABLE_DOT=OFF \ + -DENABLE_SNOPT=OFF \ + -DENABLE_NLOPT=OFF \ + -DENABLE_CYTHON=OFF \ + -DBUILD_DOC=OFF || exit + make -j 2 || exit + +else + echo "INVALID OS: ${TRAVIS_OS_NAME}" + exit 1 +fi + +cd ${TRAVIS_BUILD_DIR} || exit \ No newline at end of file diff --git a/doc/deploy_docs.sh b/ci/deploy_docs.sh similarity index 100% rename from doc/deploy_docs.sh rename to ci/deploy_docs.sh diff --git a/ci/get_libmesh.sh b/ci/get_libmesh.sh new file mode 100755 index 00000000..4905bb6e --- /dev/null +++ b/ci/get_libmesh.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +cd "${HOME}" || exit + +if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux + + if [ "${TRAVIS_DIST}" = xenial ]; then # Ubuntu 16.04 Xenial Xerus + wget -nv "https://github.com/MASTmultiphysics/mast-ci-packages/releases/download/libmesh-${LIBMESH_VERSION}-1.deb/libmesh-${LIBMESH_VERSION}-1.deb" || exit + sudo apt install "./libmesh-${LIBMESH_VERSION}-1.deb" || exit + + # elif [ "${TRAVIS_DIST}" = bionic ]; then # Ubuntu 18.04 Bionic Beaver + + else + echo "INVALID LINUX DISTRO: ${TRAVIS_DIST}" + exit 1 + fi + +elif [ "${TRAVIS_OS_NAME}" = osx ]; then # macOS 10.14, XCode 10.2 + mkdir "Code" || exit + mkdir "Code/spack-mstc" || exit + mkdir "Code/spack-mstc/spack" || exit + cd "Code/spack-mstc/spack" || exit + wget -nv https://github.com/MASTmultiphysics/mast-ci-packages/releases/download/libmesh_macos_xcode12.2/libmesh_multiple_versions_macos_xcode_10.2.zip || exit + unzip -qq libmesh_multiple_versions_macos_xcode_10.2.zip || exit + + #command -v opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/gcc-9.1.0-4amtftgtal2cnomzekpogzanzv6weadk/bin/gfortran + #opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/gcc-9.1.0-4amtftgtal2cnomzekpogzanzv6weadk/bin/gfortran --version + #opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/gcc-9.1.0-4amtftgtal2cnomzekpogzanzv6weadk/bin/gfortran + +else + echo "INVALID OS: ${TRAVIS_OS_NAME}" + exit 1 +fi \ No newline at end of file From 2f229ea74f923439e69ac4f408a078b2ed59f61b Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Thu, 5 Dec 2019 13:57:21 -0500 Subject: [PATCH 025/111] Update for compatibility with libMesh v1.5.0 (#48) * Initial multi-libMesh version CI build. * Migrate before_install and install stages to scripts from .travis.yml. * Multi-libMesh build on OSX. * Separate CI docs build from code build for efficiency. * Added exit status to CI scripts, organized CI, added all cases. - Also updated documentation deployment conditions. * Added README for the Travis CI build testing updates. * Setup both Debug and Release builds on Travis CI jobs. * Remove Debug build from Travis CI for libMesh < v1.5.0 when using GCC. - Reference https://github.com/libMesh/libmesh/issues/2337 for discussion of extra flags necessary for MAST build when using libmesh_dbg <1.5.0 - Recommendation for GCC users is to simply move to libMesh v1.5.0. * Updates for compatibility with libMesh release v1.5.0. - Headers were refactored in libMesh in v1.5.0, which means we needed to include some of the relevant stuff that got dropped out. https://github.com/libMesh/libmesh/pull/2219 --- ...stiffened_plate_thermally_stressed_flutter_optimization.cpp | 1 + ...e_thermally_stressed_piston_theory_flutter_optimization.cpp | 1 + examples/structural/example_1/example_1.cpp | 1 + examples/structural/example_2/example_2.cpp | 1 + examples/structural/example_6/example_6.cpp | 1 + src/base/nonlinear_system.cpp | 1 + src/elasticity/compliance_output.cpp | 2 ++ src/elasticity/ks_stress_output.cpp | 3 ++- src/elasticity/smooth_ramp_stress_output.cpp | 2 ++ src/elasticity/stress_output_base.cpp | 2 ++ src/elasticity/structural_system.cpp | 1 + src/fluid/integrated_force_output.cpp | 1 + src/level_set/level_set_perimeter_output.cpp | 1 + src/level_set/level_set_volume_output.cpp | 1 + src/solver/complex_solver_base.cpp | 1 + src/solver/multiphysics_nonlinear_solver.cpp | 1 + .../stabilized_first_order_transient_sensitivity_solver.cpp | 1 + 17 files changed, 21 insertions(+), 1 deletion(-) diff --git a/examples/old/fsi/stiffened_plate_thermally_stressed_flutter_optimization/stiffened_plate_thermally_stressed_flutter_optimization.cpp b/examples/old/fsi/stiffened_plate_thermally_stressed_flutter_optimization/stiffened_plate_thermally_stressed_flutter_optimization.cpp index 48577092..535dc740 100644 --- a/examples/old/fsi/stiffened_plate_thermally_stressed_flutter_optimization/stiffened_plate_thermally_stressed_flutter_optimization.cpp +++ b/examples/old/fsi/stiffened_plate_thermally_stressed_flutter_optimization/stiffened_plate_thermally_stressed_flutter_optimization.cpp @@ -57,6 +57,7 @@ // libMesh includes +#include "libmesh/parallel.h" #include "libmesh/parallel_mesh.h" #include "libmesh/mesh_generation.h" #include "libmesh/exodusII_io.h" diff --git a/examples/old/structural/stiffened_plate_optimization_thermally_stressed_piston_theory_flutter/stiffened_plate_thermally_stressed_piston_theory_flutter_optimization.cpp b/examples/old/structural/stiffened_plate_optimization_thermally_stressed_piston_theory_flutter/stiffened_plate_thermally_stressed_piston_theory_flutter_optimization.cpp index cff96837..c7c7d9a0 100644 --- a/examples/old/structural/stiffened_plate_optimization_thermally_stressed_piston_theory_flutter/stiffened_plate_thermally_stressed_piston_theory_flutter_optimization.cpp +++ b/examples/old/structural/stiffened_plate_optimization_thermally_stressed_piston_theory_flutter/stiffened_plate_thermally_stressed_piston_theory_flutter_optimization.cpp @@ -40,6 +40,7 @@ #include "examples/base/plot_results.h" // libMesh includes +#include "libmesh/parallel.h" #include "libmesh/parallel_mesh.h" #include "libmesh/exodusII_io.h" #include "libmesh/numeric_vector.h" diff --git a/examples/structural/example_1/example_1.cpp b/examples/structural/example_1/example_1.cpp index c76012c9..3f6bbb52 100644 --- a/examples/structural/example_1/example_1.cpp +++ b/examples/structural/example_1/example_1.cpp @@ -22,6 +22,7 @@ // libMesh includes. #include +#include #include #include #include diff --git a/examples/structural/example_2/example_2.cpp b/examples/structural/example_2/example_2.cpp index f54f03b8..7ad379ae 100644 --- a/examples/structural/example_2/example_2.cpp +++ b/examples/structural/example_2/example_2.cpp @@ -23,6 +23,7 @@ // libMesh includes. #include +#include #include #include #include diff --git a/examples/structural/example_6/example_6.cpp b/examples/structural/example_6/example_6.cpp index 9784d5d3..656f9f38 100644 --- a/examples/structural/example_6/example_6.cpp +++ b/examples/structural/example_6/example_6.cpp @@ -49,6 +49,7 @@ // libMesh includes +#include "libmesh/parallel.h" #include "libmesh/fe_type.h" #include "libmesh/serial_mesh.h" #include "libmesh/equation_systems.h" diff --git a/src/base/nonlinear_system.cpp b/src/base/nonlinear_system.cpp index b4ca1337..0144ab84 100644 --- a/src/base/nonlinear_system.cpp +++ b/src/base/nonlinear_system.cpp @@ -47,6 +47,7 @@ #include "libmesh/generic_projector.h" #include "libmesh/wrapped_functor.h" #include "libmesh/fem_context.h" +#include "libmesh/parallel.h" MAST::NonlinearSystem::NonlinearSystem(libMesh::EquationSystems& es, diff --git a/src/elasticity/compliance_output.cpp b/src/elasticity/compliance_output.cpp index 3ace0601..46b9698a 100644 --- a/src/elasticity/compliance_output.cpp +++ b/src/elasticity/compliance_output.cpp @@ -31,6 +31,8 @@ #include "level_set/level_set_intersected_elem.h" #include "mesh/geom_elem.h" +// libMesh includes +#include "libmesh/parallel.h" MAST::ComplianceOutput::ComplianceOutput(): MAST::OutputAssemblyElemOperations(), diff --git a/src/elasticity/ks_stress_output.cpp b/src/elasticity/ks_stress_output.cpp index 9388e7d9..5fa75b52 100644 --- a/src/elasticity/ks_stress_output.cpp +++ b/src/elasticity/ks_stress_output.cpp @@ -31,7 +31,8 @@ #include "level_set/level_set_intersected_elem.h" #include "mesh/geom_elem.h" - +// libMesh includes. +#include "libmesh/parallel.h" MAST::KSStressStrainOutput::KSStressStrainOutput(): MAST::StressStrainOutputBase() { diff --git a/src/elasticity/smooth_ramp_stress_output.cpp b/src/elasticity/smooth_ramp_stress_output.cpp index 6d8fa8f7..92577f85 100644 --- a/src/elasticity/smooth_ramp_stress_output.cpp +++ b/src/elasticity/smooth_ramp_stress_output.cpp @@ -31,6 +31,8 @@ #include "level_set/level_set_intersected_elem.h" #include "mesh/geom_elem.h" +// libMesh includes +#include "libmesh/parallel.h" MAST::SmoothRampStressStrainOutput::SmoothRampStressStrainOutput(): diff --git a/src/elasticity/stress_output_base.cpp b/src/elasticity/stress_output_base.cpp index 5b29c6c0..16af69ce 100644 --- a/src/elasticity/stress_output_base.cpp +++ b/src/elasticity/stress_output_base.cpp @@ -31,6 +31,8 @@ #include "level_set/level_set_intersected_elem.h" #include "mesh/geom_elem.h" +// libMesh includes +#include "libmesh/parallel.h" MAST::StressStrainOutputBase::Data::Data(const RealVectorX& stress, const RealVectorX& strain, diff --git a/src/elasticity/structural_system.cpp b/src/elasticity/structural_system.cpp index 2c50f4a4..ba06ac54 100644 --- a/src/elasticity/structural_system.cpp +++ b/src/elasticity/structural_system.cpp @@ -25,6 +25,7 @@ #include "base/parameter.h" // libMesh includes +#include "libmesh/libmesh_logging.h" #include "libmesh/numeric_vector.h" #include "libmesh/equation_systems.h" #include "libmesh/sparse_matrix.h" diff --git a/src/fluid/integrated_force_output.cpp b/src/fluid/integrated_force_output.cpp index 84eee999..82f5830d 100644 --- a/src/fluid/integrated_force_output.cpp +++ b/src/fluid/integrated_force_output.cpp @@ -30,6 +30,7 @@ // libMesh includes #include "libmesh/boundary_info.h" +#include "libmesh/parallel.h" MAST::IntegratedForceOutput::IntegratedForceOutput(const RealVectorX& nvec): diff --git a/src/level_set/level_set_perimeter_output.cpp b/src/level_set/level_set_perimeter_output.cpp index 9ae887b1..78aae29a 100644 --- a/src/level_set/level_set_perimeter_output.cpp +++ b/src/level_set/level_set_perimeter_output.cpp @@ -27,6 +27,7 @@ #include "base/assembly_base.h" #include "base/function_base.h" +#include "libmesh/parallel.h" MAST::LevelSetPerimeter::LevelSetPerimeter(MAST::LevelSetIntersection& intersection): MAST::OutputAssemblyElemOperations(), diff --git a/src/level_set/level_set_volume_output.cpp b/src/level_set/level_set_volume_output.cpp index 035c086c..549b0c3a 100644 --- a/src/level_set/level_set_volume_output.cpp +++ b/src/level_set/level_set_volume_output.cpp @@ -27,6 +27,7 @@ #include "base/assembly_base.h" #include "base/function_base.h" +#include "libmesh/parallel.h" MAST::LevelSetVolume::LevelSetVolume(MAST::LevelSetIntersection& intersection): MAST::OutputAssemblyElemOperations(), diff --git a/src/solver/complex_solver_base.cpp b/src/solver/complex_solver_base.cpp index 80984e63..20b236c9 100644 --- a/src/solver/complex_solver_base.cpp +++ b/src/solver/complex_solver_base.cpp @@ -25,6 +25,7 @@ // libMesh includes +#include "libmesh/libmesh_logging.h" #include "libmesh/numeric_vector.h" #include "libmesh/system.h" #include "libmesh/petsc_matrix.h" diff --git a/src/solver/multiphysics_nonlinear_solver.cpp b/src/solver/multiphysics_nonlinear_solver.cpp index aa93fdb3..bf53b86a 100644 --- a/src/solver/multiphysics_nonlinear_solver.cpp +++ b/src/solver/multiphysics_nonlinear_solver.cpp @@ -25,6 +25,7 @@ #include "base/nonlinear_system.h" // libMesh includes +#include "libmesh/libmesh_logging.h" #include "libmesh/dof_map.h" #include "libmesh/petsc_matrix.h" #include "libmesh/petsc_vector.h" diff --git a/src/solver/stabilized_first_order_transient_sensitivity_solver.cpp b/src/solver/stabilized_first_order_transient_sensitivity_solver.cpp index e0ea6823..163ff20a 100644 --- a/src/solver/stabilized_first_order_transient_sensitivity_solver.cpp +++ b/src/solver/stabilized_first_order_transient_sensitivity_solver.cpp @@ -29,6 +29,7 @@ #include "base/output_assembly_elem_operations.h" // libMesh includes +#include "libmesh/libmesh_logging.h" #include "libmesh/sparse_matrix.h" #include "libmesh/numeric_vector.h" #include "libmesh/linear_solver.h" From 6eb2e6acb5b0d4e54dafedfc8893ae9954e4bb54 Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Thu, 5 Dec 2019 14:58:12 -0500 Subject: [PATCH 026/111] Hotfix for CI deployment of documentation website. --- ci/deploy_docs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/deploy_docs.sh b/ci/deploy_docs.sh index be83a485..b3eb07a9 100755 --- a/ci/deploy_docs.sh +++ b/ci/deploy_docs.sh @@ -16,7 +16,7 @@ git config --global user.name "Travis CI" # HTML and other desired files. mkdir ${TRAVIS_BUILD_DIR}/website cd ${TRAVIS_BUILD_DIR}/website -rsync -r ${TRAVIS_BUILD_DIR}/build/doc/doxygen/html/ . +rsync -r ${TRAVIS_BUILD_DIR}/build_rel/doc/doxygen/html/ . cp ${TRAVIS_BUILD_DIR}/doc/README.md . # Initialize empty git repository. Add all files. Commit. From 65ecace2b9a02a2153c1d75371b0471905048d6b Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Thu, 12 Dec 2019 18:38:06 -0500 Subject: [PATCH 027/111] Refactored CI docs deployment so errors will be caught. - Should prevent error previously encountered where some errors in processing documentation for deployment to website was only caught after pushing to master branch. --- .travis.yml | 1 - ci/build_mast.sh | 2 ++ ci/deploy_docs.sh | 32 +++++++++----------------------- ci/prepare_docs.sh | 27 +++++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 24 deletions(-) create mode 100755 ci/prepare_docs.sh diff --git a/.travis.yml b/.travis.yml index 9302a03e..da834707 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,7 +40,6 @@ install: script: - ci/build_mast.sh - - deploy: provider: script diff --git a/ci/build_mast.sh b/ci/build_mast.sh index ab861834..87451487 100755 --- a/ci/build_mast.sh +++ b/ci/build_mast.sh @@ -39,6 +39,8 @@ if [ "${TRAVIS_OS_NAME}" = linux ]; then # Ubuntu Linux if [ ${CI_BUILD_DOCS} ]; then make doc_doxygen || exit + cd ${TRAVIS_BUILD_DIR} || exit + ci/prepare_docs.sh || exit else make -j 2 || exit make install || exit diff --git a/ci/deploy_docs.sh b/ci/deploy_docs.sh index b3eb07a9..c5428fd5 100755 --- a/ci/deploy_docs.sh +++ b/ci/deploy_docs.sh @@ -1,31 +1,17 @@ #!/usr/bin/env bash -# Deploy Doxygen generated HTML documentation to Github for hosting. +# Deploy organized HTML documentation to Github for hosting. # -# This script deploys Doxygen generated HTML documentation to the MAST Github repository for hosting. It is meant -# to be called during the Travis-CI 'deploy' stage and requires the GH_TOKEN environment variable be set in -# the Travis-CI job from an account that can push to https://github.com/MASTmultiphysics/MASTmultiphysics.github.io +# This script deploys organized HTML documentation produced by `prepare_docs.sh` to a repository in the MAST Team +# GitHub repository for hosting. It is meant to be called during the Travis-CI `deploy` stage and requires the +# GH_TOKEN environment variable be set in the Travis-CI job from an account that can push +# to https://github.com/MASTmultiphysics/MASTmultiphysics.github.io # -# Contents of this script were inspired in part by https://gist.github.com/willprice/e07efd73fb7f13f917ea. - -# Setup git user for website commit information. -git config --global user.email "travis@travis-ci.org" -git config --global user.name "Travis CI" - -# Organize website content. First delete all current contents (except .git directory) and then copy generated -# HTML and other desired files. -mkdir ${TRAVIS_BUILD_DIR}/website -cd ${TRAVIS_BUILD_DIR}/website -rsync -r ${TRAVIS_BUILD_DIR}/build_rel/doc/doxygen/html/ . -cp ${TRAVIS_BUILD_DIR}/doc/README.md . - -# Initialize empty git repository. Add all files. Commit. -git init -git add . -git commit --quiet --message "Travis build ${TRAVIS_BUILD_NUMBER}, mast-multiphysics commit ${TRAVIS_COMMIT}" +# Contents of this script (and `prepare_docs.sh`) were inspired in part +# by https://gist.github.com/willprice/e07efd73fb7f13f917ea. # Set git remote URL. Force push to GitHub website repository. # Update git remote URL to include ${GH_TOKEN} key. Push files back to GitHub website repository. -git remote add origin https://${GH_TOKEN}@github.com/MASTmultiphysics/MASTmultiphysics.github.io.git -git push --force origin master +git remote add origin https://${GH_TOKEN}@github.com/MASTmultiphysics/MASTmultiphysics.github.io.git || exit +git push --force origin master || exit diff --git a/ci/prepare_docs.sh b/ci/prepare_docs.sh new file mode 100755 index 00000000..6fe968f5 --- /dev/null +++ b/ci/prepare_docs.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +# Prepare/organized Doxygen generated HTML documentation to Github for hosting by `deploy_docs.sh`. +# +# This script organizes the Doxygen generated HTML documentation and commits it to local .git repository. +# Doxygen generated HTML documentation to the MAST Github repository for hosting. This script should be called +# during the Travis-CI 'script' phase after documentation is built so that if an error occurs we can catch it +# on a non-master build (the 'deploy' stage only runs for commits on the `master` branch). We currently call it +# inside of `ci/build_mast.sh` on the worker that satisfies ${CI_BUILD_DOCS}=true. +# +# Contents of this script (and `deploy_docs.sh`) were inspired in part by +# https://gist.github.com/willprice/e07efd73fb7f13f917ea. + +# Setup git user for website commit information. +git config --global user.email "travis@travis-ci.org" || exit +git config --global user.name "Travis CI" || exit + +# Organize website content. First delete all current contents (except .git directory) and then copy generated +# HTML and other desired files. +mkdir ${TRAVIS_BUILD_DIR}/website || exit +cd ${TRAVIS_BUILD_DIR}/website || exit +rsync -r ${TRAVIS_BUILD_DIR}/build_rel/doc/doxygen/html/ . || exit + +# Initialize empty git repository. Add all files. Commit. +git init || exit +git add . || exit +git commit --quiet --message "Travis build ${TRAVIS_BUILD_NUMBER}, mast-multiphysics commit ${TRAVIS_COMMIT}" || exit \ No newline at end of file From a3eeed86e50d3eda3668540611916b1426d1cde6 Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Fri, 20 Dec 2019 21:27:19 -0500 Subject: [PATCH 028/111] Added third party utility/source for tabular output to console. --- CMakeLists.txt | 2 +- src/CMakeLists.txt | 1 + src/external/CMakeLists.txt | 11 + src/external/README.md | 10 + src/external/fort.c | 5983 +++++++++++++++++++++++++++++++++++ src/external/fort.h | 889 ++++++ src/external/fort.hpp | 1001 ++++++ 7 files changed, 7896 insertions(+), 1 deletion(-) create mode 100644 src/external/CMakeLists.txt create mode 100644 src/external/README.md create mode 100644 src/external/fort.c create mode 100644 src/external/fort.h create mode 100644 src/external/fort.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index ae2904d3..acea44c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ option(ENABLE_NASTRANIO "Build with support for reading Nastran meshes" OFF) option(ENABLE_CYTHON "Build with support for Cython development" OFF) option(BUILD_DOC "Build documentation" OFF) -# Dependency paths - these paths help CMake find dependencies. +# Dependency paths (optional) - these paths help CMake find dependencies. set(MAST_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}) set(libMesh_DIR "libMesh_DIR" CACHE PATH "Directory containing libMesh include/ and lib/") set(PETSc_DIR "PETSc_DIR" CACHE PATH "Directory containing PETSc include/ and lib/") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index de73d122..f19c3a7e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -48,6 +48,7 @@ add_subdirectory(base) add_subdirectory(boundary_condition) add_subdirectory(coordinates) add_subdirectory(elasticity) +add_subdirectory(external) add_subdirectory(fluid) add_subdirectory(heat_conduction) add_subdirectory(level_set) diff --git a/src/external/CMakeLists.txt b/src/external/CMakeLists.txt new file mode 100644 index 00000000..c6c3965a --- /dev/null +++ b/src/external/CMakeLists.txt @@ -0,0 +1,11 @@ +target_sources(mast + PUBLIC + ${CMAKE_CURRENT_LIST_DIR}/fort.c + ${CMAKE_CURRENT_LIST_DIR}/fort.h + ${CMAKE_CURRENT_LIST_DIR}/fort.hpp) + +# Install MAST headers for this directory. +install(DIRECTORY ./ DESTINATION include/external + FILES_MATCHING PATTERN "*.h") +install(DIRECTORY ./ DESTINATION include/external + FILES_MATCHING PATTERN "*.hpp") \ No newline at end of file diff --git a/src/external/README.md b/src/external/README.md new file mode 100644 index 00000000..29aaecef --- /dev/null +++ b/src/external/README.md @@ -0,0 +1,10 @@ +# External Third Party Sources +This directory contains files developed by third parties and are included in the MAST +source for convenience. In all cases, this is permitted by both the third party project's +license and the MAST license. + +## libfort (Library to create FORmatted Tables) +- C/C++ library to create formatted ASCII tables for console applications +- Files: `fort.c`, `fort.h`, `fort.hpp` +- License: [MIT](https://github.com/seleznevae/libfort/blob/develop/LICENSE) +- https://github.com/seleznevae/libfort diff --git a/src/external/fort.c b/src/external/fort.c new file mode 100644 index 00000000..aaf96f7f --- /dev/null +++ b/src/external/fort.c @@ -0,0 +1,5983 @@ +/* +libfort + +MIT License + +Copyright (c) 2017 - 2018 Seleznev Anton + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +/* The file was GENERATED by an amalgamation script.*/ +/* DO NOT EDIT BY HAND!!! */ + + +#define FT_AMALGAMED_SOURCE /* Macros to make internal libfort functions static */ + + +/******************************************************** + Begin of file "fort_utils.h" + ********************************************************/ + +#ifndef FORT_IMPL_H +#define FORT_IMPL_H + +#if defined(_MSC_VER) +#define _CRT_SECURE_NO_WARNINGS /* To disable warnings for unsafe functions */ +#endif + +#include +#include +#include +#include +#include +#include "fort.h" + +/* Define FT_INTERNAL to make internal libfort functions static + * in the result amalgamed source file. + */ +#ifdef FT_AMALGAMED_SOURCE +#define FT_INTERNAL static +#else +#define FT_INTERNAL +#endif /* FT_AMALGAMED_SORCE */ + + +#define FORT_DEFAULT_COL_SEPARATOR '|' +extern char g_col_separator; + +#define FORT_COL_SEPARATOR_LENGTH 1 + +#define FORT_UNUSED __attribute__((unused)) + +#define F_MALLOC fort_malloc +#define F_FREE fort_free +#define F_CALLOC fort_calloc +#define F_REALLOC fort_realloc +#define F_STRDUP fort_strdup +#define F_WCSDUP fort_wcsdup + +#define F_CREATE(type) ((type *)F_CALLOC(sizeof(type), 1)) + +#define MAX(a,b) ((a) > (b) ? (a) : (b)) +#define MIN(a,b) ((a) < (b) ? (a) : (b)) + + +enum PolicyOnNull { + Create, + DoNotCreate +}; + + +enum F_BOOL { + F_FALSE = 0, + F_TRUE = 1 +}; + + +#define FT_STR_2_CAT_(arg1, arg2) \ + arg1##arg2 +#define FT_STR_2_CAT(arg1, arg2) \ + FT_STR_2_CAT_(arg1, arg2) + +#define UNIQUE_NAME_(prefix) \ + FT_STR_2_CAT(prefix,__COUNTER__) +#define UNIQUE_NAME(prefix) \ + UNIQUE_NAME_(prefix) + + + +/***************************************************************************** + * LOGGER + *****************************************************************************/ +#define SYS_LOG_ERROR(...) + + + +/***************************************************************************** + * DEFAULT_SIZES + * ***************************************************************************/ +#define DEFAULT_STR_BUF_SIZE 1024 +#define DEFAULT_VECTOR_CAPACITY 10 + + + +struct fort_table_properties; +struct fort_column_properties; +struct fort_row; +struct vector; +struct fort_cell; +struct string_buffer; +struct separator { + int enabled; +}; + +typedef struct fort_table_properties fort_table_properties_t; +struct fort_context { + fort_table_properties_t *table_properties; + size_t row; + size_t column; +}; +typedef struct fort_context context_t; +typedef struct fort_column_properties fort_column_properties_t; +typedef struct vector vector_t; +typedef struct fort_cell fort_cell_t; +typedef struct string_buffer string_buffer_t; +typedef struct fort_row fort_row_t; +/*typedef struct ft_table ft_table_t;*/ +typedef struct separator separator_t; + +enum CellType { + CommonCell, + GroupMasterCell, + GroupSlaveCell +}; + +enum request_geom_type { + VISIBLE_GEOMETRY, + INTERN_REPR_GEOMETRY +}; + +/***************************************************************************** + * LIBFORT helpers + *****************************************************************************/ + +extern void *(*fort_malloc)(size_t size); +extern void (*fort_free)(void *ptr); +extern void *(*fort_calloc)(size_t nmemb, size_t size); +extern void *(*fort_realloc)(void *ptr, size_t size); + +FT_INTERNAL +void set_memory_funcs(void *(*f_malloc)(size_t size), void (*f_free)(void *ptr)); + +FT_INTERNAL +char *fort_strdup(const char *str); + +FT_INTERNAL +size_t number_of_columns_in_format_string(const char *fmt); + +#if defined(FT_HAVE_WCHAR) +FT_INTERNAL +wchar_t *fort_wcsdup(const wchar_t *str); + +FT_INTERNAL +size_t number_of_columns_in_format_wstring(const wchar_t *fmt); +#endif + +FT_INTERNAL +int snprint_n_strings(char *buf, size_t length, size_t n, const char *str); + +#if defined(FT_HAVE_WCHAR) +FT_INTERNAL +int wsnprint_n_string(wchar_t *buf, size_t length, size_t n, const char *str); +#endif + + +#define CHCK_RSLT_ADD_TO_WRITTEN(statement) \ + do { \ + tmp = statement; \ + if (tmp < 0) {\ + goto clear; \ + } \ + written += (size_t)tmp; \ + } while(0) + +#define CHCK_RSLT_ADD_TO_INVISIBLE_WRITTEN(statement) \ + do { \ + tmp = statement; \ + if (tmp < 0) {\ + goto clear; \ + } \ + invisible_written += (size_t)tmp; \ + } while(0) + + +#define CHECK_NOT_NEGATIVE(x) \ + do { if ((x) < 0) goto fort_fail; } while (0) + +#endif /* FORT_IMPL_H */ + +/******************************************************** + End of file "fort_utils.h" + ********************************************************/ + + +/******************************************************** + Begin of file "vector.h" + ********************************************************/ + +#ifndef VECTOR_H +#define VECTOR_H + +/* #include "fort_utils.h" */ /* Commented by amalgamation script */ + + +#define INVALID_VEC_INDEX ((size_t) -1) + +FT_INTERNAL +vector_t *create_vector(size_t item_size, size_t capacity); + +FT_INTERNAL +void destroy_vector(vector_t *); + +FT_INTERNAL +size_t vector_size(const vector_t *); + +FT_INTERNAL +size_t vector_capacity(const vector_t *); + +FT_INTERNAL +int vector_push(vector_t *, const void *item); + +FT_INTERNAL +const void *vector_at_c(const vector_t *vector, size_t index); + +FT_INTERNAL +void *vector_at(vector_t *, size_t index); + +FT_INTERNAL +fort_status_t vector_swap(vector_t *cur_vec, vector_t *mv_vec, size_t pos); + +/* +#define FOR_EACH_(type, item, vector, index_name) \ + size_t index_name = 0; \ + for (index_name = 0; (index_name < vector_size(vector)) ? ((item = *(type*)vector_at(vector, index_name)), 1) : 0; ++index_name) + +#define FOR_EACH(type, item, vector) \ + FOR_EACH_(type, item, vector, UNIQUE_NAME(i)) +*/ + + +#ifdef FT_TEST_BUILD +vector_t *copy_vector(vector_t *); +size_t vector_index_of(const vector_t *, const void *item); +int vector_erase(vector_t *, size_t index); +void vector_clear(vector_t *); +#endif + +#endif /* VECTOR_H */ + +/******************************************************** + End of file "vector.h" + ********************************************************/ + + +/******************************************************** + Begin of file "wcwidth.h" + ********************************************************/ + +#ifndef WCWIDTH_H +#define WCWIDTH_H + +/* #include "fort_utils.h" */ /* Commented by amalgamation script */ + +#ifdef FT_HAVE_WCHAR +#include + +FT_INTERNAL +int mk_wcswidth(const wchar_t *pwcs, size_t n); + +#endif /* FT_HAVE_WCHAR */ + +#endif /* WCWIDTH_H */ + +/******************************************************** + End of file "wcwidth.h" + ********************************************************/ + + +/******************************************************** + Begin of file "string_buffer.h" + ********************************************************/ + +#ifndef STRING_BUFFER_H +#define STRING_BUFFER_H + +/* #include "fort_utils.h" */ /* Commented by amalgamation script */ + + +/***************************************************************************** + * STRING BUFFER + * ***************************************************************************/ +enum str_buf_type { + CharBuf, +#ifdef FT_HAVE_WCHAR + WCharBuf +#endif /* FT_HAVE_WCHAR */ +}; + +struct string_buffer { + union { + char *cstr; + wchar_t *wstr; + void *data; + } str; + size_t data_sz; + enum str_buf_type type; +}; + +FT_INTERNAL +string_buffer_t *create_string_buffer(size_t number_of_chars, enum str_buf_type type); + +FT_INTERNAL +void destroy_string_buffer(string_buffer_t *buffer); + +FT_INTERNAL +string_buffer_t *copy_string_buffer(const string_buffer_t *buffer); + +FT_INTERNAL +fort_status_t realloc_string_buffer_without_copy(string_buffer_t *buffer); + +FT_INTERNAL +fort_status_t fill_buffer_from_string(string_buffer_t *buffer, const char *str); + +#ifdef FT_HAVE_WCHAR +FT_INTERNAL +fort_status_t fill_buffer_from_wstring(string_buffer_t *buffer, const wchar_t *str); +#endif /* FT_HAVE_WCHAR */ + +FT_INTERNAL +size_t buffer_text_height(const string_buffer_t *buffer); + +FT_INTERNAL +size_t string_buffer_capacity(const string_buffer_t *buffer); + +FT_INTERNAL +void *buffer_get_data(string_buffer_t *buffer); + +FT_INTERNAL +size_t buffer_text_width(const string_buffer_t *buffer); + +FT_INTERNAL +int buffer_printf(string_buffer_t *buffer, size_t buffer_row, char *buf, size_t total_buf_len, + const context_t *context, const char *content_style_tag, const char *reset_content_style_tag); + +#ifdef FT_HAVE_WCHAR +FT_INTERNAL +int buffer_wprintf(string_buffer_t *buffer, size_t buffer_row, wchar_t *buf, size_t total_buf_len, + const context_t *context, const char *content_style_tag, const char *reset_content_style_tag); +#endif /* FT_HAVE_WCHAR */ + +#endif /* STRING_BUFFER_H */ + +/******************************************************** + End of file "string_buffer.h" + ********************************************************/ + + +/******************************************************** + Begin of file "properties.h" + ********************************************************/ + +#ifndef PROPERTIES_H +#define PROPERTIES_H + +/* #include "fort_utils.h" */ /* Commented by amalgamation script */ +#include +#include + +#define PROP_IS_SET(ft_props, property) ((ft_props) & (property)) +#define PROP_SET(ft_props, property) ((ft_props) |=(property)) +#define PROP_UNSET(ft_props, property) ((ft_props) &= ~((uint32_t)(property))) + +#define TEXT_STYLE_TAG_MAX_SIZE 64 + +FT_INTERNAL +void get_style_tag_for_cell(const fort_table_properties_t *props, + size_t row, size_t col, char *style_tag, size_t sz); + +FT_INTERNAL +void get_reset_style_tag_for_cell(const fort_table_properties_t *props, + size_t row, size_t col, char *style_tag, size_t sz); + +FT_INTERNAL +void get_style_tag_for_content(const fort_table_properties_t *props, + size_t row, size_t col, char *style_tag, size_t sz); + +FT_INTERNAL +void get_reset_style_tag_for_content(const fort_table_properties_t *props, + size_t row, size_t col, char *style_tag, size_t sz); + + +struct fort_cell_props { + size_t cell_row; + size_t cell_col; + uint32_t properties_flags; + + unsigned int col_min_width; + enum ft_text_alignment align; + unsigned int cell_padding_top; + unsigned int cell_padding_bottom; + unsigned int cell_padding_left; + unsigned int cell_padding_right; + unsigned int cell_empty_string_height; + enum ft_row_type row_type; + unsigned int content_fg_color_number; + unsigned int content_bg_color_number; + unsigned int cell_bg_color_number; + enum ft_text_style cell_text_style; + enum ft_text_style content_text_style; +}; + +typedef struct fort_cell_props fort_cell_props_t; +typedef vector_t fort_cell_prop_container_t; + +FT_INTERNAL +fort_cell_prop_container_t *create_cell_prop_container(void); + +FT_INTERNAL +void destroy_cell_prop_container(fort_cell_prop_container_t *cont); + +FT_INTERNAL +const fort_cell_props_t *cget_cell_prop(const fort_cell_prop_container_t *cont, size_t row, size_t col); + +FT_INTERNAL +fort_cell_props_t *get_cell_prop_and_create_if_not_exists(fort_cell_prop_container_t *cont, size_t row, size_t col); + +FT_INTERNAL +fort_status_t set_cell_property(fort_cell_prop_container_t *cont, size_t row, size_t col, uint32_t property, int value); + +FT_INTERNAL +int get_cell_property_value_hierarcial(const fort_table_properties_t *properties, size_t row, size_t column, uint32_t property); + +FT_INTERNAL +fort_status_t set_default_cell_property(uint32_t property, int value); + + +/* TABLE BORDER DESRIPTION + * + * + * TL TT TT TT TV TT TT TT TT TT TT TT TR + * LL IV RR + * LL IV RR + * LH IH IH IH II IH IH IH TI IH IH IH RH + * LL IV IV RR + * LL IV IV RR + * LL LI IH IH IH RI RH + * LL IV IV RR + * LL IV IV RR + * LH IH IH IH BI IH IH IH II IH IH IH RH + * LL IV RR + * LL IV RR + * BL BB BB BB BV BB BB BB BV BB BB BB BR + */ + + +/* HORIZONTAL SEPARATOR DESCRIPTION + * + * + * TL TT TT TT TV TT TT TT TV TT TT TT TR <----- TopSeparator + * LL IV IV RR + * LH IH IH IH II IH IH IH II IH IH IH RH <----- InsideSeparator + * LL IV IV RR + * BL BB BB BB BV BB BB BB BV BB BB BB BR <----- BottomSeparator + */ + +enum HorSeparatorPos { + TopSeparator, + InsideSeparator, + BottomSeparator +}; + +enum BorderItemPos { + TL_bip = 0, + TT_bip = 1, + TV_bip = 2, + TR_bip = 3, + + LL_bip = 4, + IV_bip = 5, + RR_bip = 6, + + LH_bip = 7, + IH_bip = 8, + II_bip = 9, + RH_bip = 10, + + BL_bip = 11, + BB_bip = 12, + BV_bip = 13, + BR_bip = 14, + + LI_bip = 15, + TI_bip = 16, + RI_bip = 17, + BI_bip = 18, + + BorderItemPosSize +}; + + +enum SeparatorItemPos { + LH_sip = 0, + IH_sip = 1, + II_sip = 2, + RH_sip = 3, + + TI_sip = 4, + BI_sip = 5, + + SepratorItemPosSize +}; + + +struct fort_border_style { + const char *border_chars[BorderItemPosSize]; + const char *header_border_chars[BorderItemPosSize]; + const char *separator_chars[SepratorItemPosSize]; +}; +extern struct fort_border_style FORT_BASIC_STYLE; +extern struct fort_border_style FORT_BASIC2_STYLE; +extern struct fort_border_style FORT_SIMPLE_STYLE; +extern struct fort_border_style FORT_PLAIN_STYLE; +extern struct fort_border_style FORT_DOT_STYLE; +extern struct fort_border_style FORT_EMPTY_STYLE; +extern struct fort_border_style FORT_EMPTY2_STYLE; +extern struct fort_border_style FORT_SOLID_STYLE; +extern struct fort_border_style FORT_SOLID_ROUND_STYLE; +extern struct fort_border_style FORT_NICE_STYLE; +extern struct fort_border_style FORT_DOUBLE_STYLE; +extern struct fort_border_style FORT_DOUBLE2_STYLE; +extern struct fort_border_style FORT_BOLD_STYLE; +extern struct fort_border_style FORT_BOLD2_STYLE; +extern struct fort_border_style FORT_FRAME_STYLE; + + +struct fort_entire_table_properties { + unsigned int left_margin; + unsigned int top_margin; + unsigned int right_margin; + unsigned int bottom_margin; +}; +typedef struct fort_entire_table_properties fort_entire_table_properties_t; +extern fort_entire_table_properties_t g_entire_table_properties; + +FT_INTERNAL +fort_status_t set_entire_table_property(fort_table_properties_t *table_properties, uint32_t property, int value); + +FT_INTERNAL +fort_status_t set_default_entire_table_property(uint32_t property, int value); + +struct fort_table_properties { + struct fort_border_style border_style; + fort_cell_prop_container_t *cell_properties; + fort_entire_table_properties_t entire_table_properties; +}; +extern fort_table_properties_t g_table_properties; + +FT_INTERNAL +size_t max_border_elem_strlen(struct fort_table_properties *); + +FT_INTERNAL +fort_table_properties_t *create_table_properties(void); + +FT_INTERNAL +void destroy_table_properties(fort_table_properties_t *properties); + +FT_INTERNAL +fort_table_properties_t *copy_table_properties(const fort_table_properties_t *property); + +#endif /* PROPERTIES_H */ + +/******************************************************** + End of file "properties.h" + ********************************************************/ + + +/******************************************************** + Begin of file "cell.h" + ********************************************************/ + +#ifndef CELL_H +#define CELL_H + +/* #include "fort_utils.h" */ /* Commented by amalgamation script */ + +FT_INTERNAL +fort_cell_t *create_cell(void); + +FT_INTERNAL +void destroy_cell(fort_cell_t *cell); + +FT_INTERNAL +fort_cell_t *copy_cell(fort_cell_t *cell); + +FT_INTERNAL +size_t hint_width_cell(const fort_cell_t *cell, const context_t *context, enum request_geom_type geom); + +FT_INTERNAL +size_t hint_height_cell(const fort_cell_t *cell, const context_t *context); + +FT_INTERNAL +void set_cell_type(fort_cell_t *cell, enum CellType type); + +FT_INTERNAL +enum CellType get_cell_type(const fort_cell_t *cell); + +FT_INTERNAL +int cell_printf(fort_cell_t *cell, size_t row, char *buf, size_t buf_len, const context_t *context); + +FT_INTERNAL +fort_status_t fill_cell_from_string(fort_cell_t *cell, const char *str); + +#ifdef FT_HAVE_WCHAR +FT_INTERNAL +int cell_wprintf(fort_cell_t *cell, size_t row, wchar_t *buf, size_t buf_len, const context_t *context); + +FT_INTERNAL +fort_status_t fill_cell_from_wstring(fort_cell_t *cell, const wchar_t *str); +#endif + +FT_INTERNAL +string_buffer_t *cell_get_string_buffer(fort_cell_t *cell); + +#endif /* CELL_H */ + +/******************************************************** + End of file "cell.h" + ********************************************************/ + + +/******************************************************** + Begin of file "row.h" + ********************************************************/ + +#ifndef ROW_H +#define ROW_H + +/* #include "fort_utils.h" */ /* Commented by amalgamation script */ +#include "fort.h" +#include +/* #include "properties.h" */ /* Commented by amalgamation script */ +#ifdef FT_HAVE_WCHAR +#include +#endif + +FT_INTERNAL +fort_row_t *create_row(void); + +FT_INTERNAL +void destroy_row(fort_row_t *row); + +FT_INTERNAL +fort_row_t *copy_row(fort_row_t *row); + +FT_INTERNAL +fort_row_t *create_row_from_string(const char *str); + +FT_PRINTF_ATTRIBUTE_FORMAT(1, 0) +FT_INTERNAL +fort_row_t *create_row_from_fmt_string(const char *fmt, va_list *va_args); + +FT_INTERNAL +size_t columns_in_row(const fort_row_t *row); + +FT_INTERNAL +fort_cell_t *get_cell(fort_row_t *row, size_t col); + +FT_INTERNAL +const fort_cell_t *get_cell_c(const fort_row_t *row, size_t col); + +FT_INTERNAL +fort_cell_t *get_cell_and_create_if_not_exists(fort_row_t *row, size_t col); + +FT_INTERNAL +fort_status_t swap_row(fort_row_t *cur_row, fort_row_t *ins_row, size_t pos); + +FT_INTERNAL +size_t group_cell_number(const fort_row_t *row, size_t master_cell_col); + +FT_INTERNAL +int get_row_cell_types(const fort_row_t *row, enum CellType *types, size_t types_sz); + +FT_INTERNAL +fort_status_t row_set_cell_span(fort_row_t *row, size_t cell_column, size_t hor_span); + +FT_INTERNAL +int print_row_separator(char *buffer, size_t buffer_sz, + const size_t *col_width_arr, size_t cols, + const fort_row_t *upper_row, const fort_row_t *lower_row, + enum HorSeparatorPos separatorPos, const separator_t *sep, + const context_t *context); + +FT_INTERNAL +int snprintf_row(const fort_row_t *row, char *buffer, size_t buf_sz, size_t *col_width_arr, size_t col_width_arr_sz, + size_t row_height, const context_t *context); + +#ifdef FT_HAVE_WCHAR +FT_INTERNAL +fort_row_t *create_row_from_wstring(const wchar_t *str); + +FT_INTERNAL +fort_row_t *create_row_from_fmt_wstring(const wchar_t *fmt, va_list *va_args); + +FT_INTERNAL +int wprint_row_separator(wchar_t *buffer, size_t buffer_sz, + const size_t *col_width_arr, size_t cols, + const fort_row_t *upper_row, const fort_row_t *lower_row, + enum HorSeparatorPos separatorPos, const separator_t *sep, + const context_t *context); + +FT_INTERNAL +int wsnprintf_row(const fort_row_t *row, wchar_t *buffer, size_t buf_sz, size_t *col_width_arr, size_t col_width_arr_sz, + size_t row_height, const context_t *context); +#endif + + +#endif /* ROW_H */ + +/******************************************************** + End of file "row.h" + ********************************************************/ + + +/******************************************************** + Begin of file "table.h" + ********************************************************/ + +#ifndef TABLE_H +#define TABLE_H + +/* #include "fort_utils.h" */ /* Commented by amalgamation script */ + +struct ft_table { + vector_t *rows; + fort_table_properties_t *properties; + string_buffer_t *conv_buffer; + size_t cur_row; + size_t cur_col; + vector_t *separators; +}; + +FT_INTERNAL +separator_t *create_separator(int enabled); + +FT_INTERNAL +void destroy_separator(separator_t *sep); + +FT_INTERNAL +separator_t *copy_separator(separator_t *sep); + +FT_INTERNAL +fort_status_t get_table_sizes(const ft_table_t *table, size_t *rows, size_t *cols); + +FT_INTERNAL +fort_row_t *get_row(ft_table_t *table, size_t row); + +FT_INTERNAL +const fort_row_t *get_row_c(const ft_table_t *table, size_t row); + +FT_INTERNAL +fort_row_t *get_row_and_create_if_not_exists(ft_table_t *table, size_t row); + +FT_INTERNAL +string_buffer_t *get_cur_str_buffer_and_create_if_not_exists(ft_table_t *table); + + +FT_INTERNAL +fort_status_t table_rows_and_cols_geometry(const ft_table_t *table, + size_t **col_width_arr_p, size_t *col_width_arr_sz, + size_t **row_height_arr_p, size_t *row_height_arr_sz, + enum request_geom_type geom); + +FT_INTERNAL +fort_status_t table_geometry(const ft_table_t *table, size_t *height, size_t *width); + +#endif /* TABLE_H */ + +/******************************************************** + End of file "table.h" + ********************************************************/ + + +/******************************************************** + Begin of file "cell.c" + ********************************************************/ + +/* #include "cell.h" */ /* Commented by amalgamation script */ +/* #include "properties.h" */ /* Commented by amalgamation script */ +/* #include "string_buffer.h" */ /* Commented by amalgamation script */ +#include + +struct fort_cell { + string_buffer_t *str_buffer; + enum CellType cell_type; +}; + +FT_INTERNAL +fort_cell_t *create_cell(void) +{ + fort_cell_t *cell = (fort_cell_t *)F_CALLOC(sizeof(fort_cell_t), 1); + if (cell == NULL) + return NULL; + cell->str_buffer = create_string_buffer(DEFAULT_STR_BUF_SIZE, CharBuf); + if (cell->str_buffer == NULL) { + F_FREE(cell); + return NULL; + } + cell->cell_type = CommonCell; + return cell; +} + +FT_INTERNAL +void destroy_cell(fort_cell_t *cell) +{ + if (cell == NULL) + return; + destroy_string_buffer(cell->str_buffer); + F_FREE(cell); +} + +FT_INTERNAL +fort_cell_t *copy_cell(fort_cell_t *cell) +{ + assert(cell); + + fort_cell_t *result = create_cell(); + if (result == NULL) + return NULL; + destroy_string_buffer(result->str_buffer); + result->str_buffer = copy_string_buffer(cell->str_buffer); + if (result->str_buffer == NULL) { + destroy_cell(result); + return NULL; + } + result->cell_type = cell->cell_type; + return result; +} + +FT_INTERNAL +void set_cell_type(fort_cell_t *cell, enum CellType type) +{ + assert(cell); + cell->cell_type = type; +} + +FT_INTERNAL +enum CellType get_cell_type(const fort_cell_t *cell) +{ + assert(cell); + return cell->cell_type; +} + +FT_INTERNAL +size_t hint_width_cell(const fort_cell_t *cell, const context_t *context, enum request_geom_type geom) +{ + /* todo: + * At the moment min width includes paddings. Maybe it is better that min width weren't include + * paddings but be min width of the cell content without padding + */ + + assert(cell); + assert(context); + size_t cell_padding_left = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_LEFT_PADDING); + size_t cell_padding_right = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_RIGHT_PADDING); + size_t result = cell_padding_left + cell_padding_right; + if (cell->str_buffer && cell->str_buffer->str.data) { + result += buffer_text_width(cell->str_buffer); + } + result = MAX(result, (size_t)get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_MIN_WIDTH)); + + if (geom == INTERN_REPR_GEOMETRY) { + char cell_style_tag[TEXT_STYLE_TAG_MAX_SIZE]; + get_style_tag_for_cell(context->table_properties, context->row, context->column, cell_style_tag, TEXT_STYLE_TAG_MAX_SIZE); + result += strlen(cell_style_tag); + + char reset_cell_style_tag[TEXT_STYLE_TAG_MAX_SIZE]; + get_reset_style_tag_for_cell(context->table_properties, context->row, context->column, reset_cell_style_tag, TEXT_STYLE_TAG_MAX_SIZE); + result += strlen(reset_cell_style_tag); + + char content_style_tag[TEXT_STYLE_TAG_MAX_SIZE]; + get_style_tag_for_content(context->table_properties, context->row, context->column, content_style_tag, TEXT_STYLE_TAG_MAX_SIZE); + result += strlen(content_style_tag); + + char reset_content_style_tag[TEXT_STYLE_TAG_MAX_SIZE]; + get_reset_style_tag_for_content(context->table_properties, context->row, context->column, reset_content_style_tag, TEXT_STYLE_TAG_MAX_SIZE); + result += strlen(reset_content_style_tag); + } + + return result; +} + +FT_INTERNAL +size_t hint_height_cell(const fort_cell_t *cell, const context_t *context) +{ + assert(cell); + assert(context); + size_t cell_padding_top = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_TOP_PADDING); + size_t cell_padding_bottom = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_BOTTOM_PADDING); + size_t cell_empty_string_height = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_EMPTY_STR_HEIGHT); + size_t result = cell_padding_top + cell_padding_bottom; + if (cell->str_buffer && cell->str_buffer->str.data) { + size_t text_height = buffer_text_height(cell->str_buffer); + result += text_height == 0 ? cell_empty_string_height : text_height; + } + return result; +} + + +FT_INTERNAL +int cell_printf(fort_cell_t *cell, size_t row, char *buf, size_t buf_len, const context_t *context) +{ + const char *space_char = " "; + int (*buffer_printf_)(string_buffer_t *, size_t, char *, size_t, const context_t *, const char *, const char *) = buffer_printf; + int (*snprint_n_strings_)(char *, size_t, size_t, const char *) = snprint_n_strings; + + if (cell == NULL || buf_len == 0 + || (buf_len <= hint_width_cell(cell, context, VISIBLE_GEOMETRY))) { + return -1; + } + + unsigned int cell_padding_top = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_TOP_PADDING); + unsigned int cell_padding_left = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_LEFT_PADDING); + unsigned int cell_padding_right = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_RIGHT_PADDING); + + size_t written = 0; + size_t invisible_written = 0; + int tmp = 0; + + /* todo: Dirty hack with changing buf_len! need refactoring. */ + /* Also maybe it is better to move all struff with colors to buffers? */ + char cell_style_tag[TEXT_STYLE_TAG_MAX_SIZE]; + get_style_tag_for_cell(context->table_properties, context->row, context->column, cell_style_tag, TEXT_STYLE_TAG_MAX_SIZE); + buf_len += strlen(cell_style_tag); + + char reset_cell_style_tag[TEXT_STYLE_TAG_MAX_SIZE]; + get_reset_style_tag_for_cell(context->table_properties, context->row, context->column, reset_cell_style_tag, TEXT_STYLE_TAG_MAX_SIZE); + buf_len += strlen(reset_cell_style_tag); + + char content_style_tag[TEXT_STYLE_TAG_MAX_SIZE]; + get_style_tag_for_content(context->table_properties, context->row, context->column, content_style_tag, TEXT_STYLE_TAG_MAX_SIZE); + buf_len += strlen(content_style_tag); + + char reset_content_style_tag[TEXT_STYLE_TAG_MAX_SIZE]; + get_reset_style_tag_for_content(context->table_properties, context->row, context->column, reset_content_style_tag, TEXT_STYLE_TAG_MAX_SIZE); + buf_len += strlen(reset_content_style_tag); + + /* CELL_STYLE_T LEFT_PADDING CONTENT_STYLE_T CONTENT RESET_CONTENT_STYLE_T RIGHT_PADDING RESET_CELL_STYLE_T + * | | | | | | | | + * L1 R1 + * L2 R2 + * L3 R3 + */ + + size_t L2 = cell_padding_left; + + size_t R2 = cell_padding_right; + size_t R3 = strlen(reset_cell_style_tag); + +#define TOTAL_WRITTEN (written + invisible_written) +#define RIGHT (cell_padding_right + extra_right) + +#define WRITE_CELL_STYLE_TAG CHCK_RSLT_ADD_TO_INVISIBLE_WRITTEN(snprint_n_strings_(buf + TOTAL_WRITTEN, buf_len - TOTAL_WRITTEN, 1, cell_style_tag)) +#define WRITE_RESET_CELL_STYLE_TAG CHCK_RSLT_ADD_TO_INVISIBLE_WRITTEN(snprint_n_strings_(buf + TOTAL_WRITTEN, buf_len - TOTAL_WRITTEN, 1, reset_cell_style_tag)) +#define WRITE_CONTENT_STYLE_TAG CHCK_RSLT_ADD_TO_INVISIBLE_WRITTEN(snprint_n_strings_(buf + TOTAL_WRITTEN, buf_len - TOTAL_WRITTEN, 1, content_style_tag)) +#define WRITE_RESET_CONTENT_STYLE_TAG CHCK_RSLT_ADD_TO_INVISIBLE_WRITTEN(snprint_n_strings_(buf + TOTAL_WRITTEN, buf_len - TOTAL_WRITTEN, 1, reset_content_style_tag)) + + if (row >= hint_height_cell(cell, context) + || row < cell_padding_top + || row >= (cell_padding_top + buffer_text_height(cell->str_buffer))) { + WRITE_CELL_STYLE_TAG; + WRITE_CONTENT_STYLE_TAG; + WRITE_RESET_CONTENT_STYLE_TAG; + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buf + TOTAL_WRITTEN, buf_len, buf_len - 1 - TOTAL_WRITTEN - R3, space_char)); + WRITE_RESET_CELL_STYLE_TAG; + return (int)TOTAL_WRITTEN; + } + + WRITE_CELL_STYLE_TAG; + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buf + TOTAL_WRITTEN, buf_len - TOTAL_WRITTEN, L2, space_char)); + if (cell->str_buffer) { + CHCK_RSLT_ADD_TO_WRITTEN(buffer_printf_(cell->str_buffer, row - cell_padding_top, buf + TOTAL_WRITTEN, buf_len - TOTAL_WRITTEN - R2 - R3, context, content_style_tag, reset_content_style_tag)); + } else { + WRITE_CONTENT_STYLE_TAG; + WRITE_RESET_CONTENT_STYLE_TAG; + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buf + TOTAL_WRITTEN, buf_len - TOTAL_WRITTEN, buf_len - TOTAL_WRITTEN - R2 - R3, space_char)); + } + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buf + TOTAL_WRITTEN, buf_len - TOTAL_WRITTEN, R2, space_char)); + WRITE_RESET_CELL_STYLE_TAG; + + return (int)TOTAL_WRITTEN; + +clear: + return -1; +#undef WRITE_CELL_STYLE_TAG +#undef WRITE_RESET_CELL_STYLE_TAG +#undef WRITE_CONTENT_STYLE_TAG +#undef WRITE_RESET_CONTENT_STYLE_TAG +#undef TOTAL_WRITTEN +#undef RIGHT +} + +#ifdef FT_HAVE_WCHAR +FT_INTERNAL +int cell_wprintf(fort_cell_t *cell, size_t row, wchar_t *buf, size_t buf_len, const context_t *context) +{ + const char *space_char = " "; + int (*buffer_printf_)(string_buffer_t *, size_t, wchar_t *, size_t, const context_t *, const char *, const char *) = buffer_wprintf; + int (*snprint_n_strings_)(wchar_t *, size_t, size_t, const char *) = wsnprint_n_string; + + if (cell == NULL || buf_len == 0 + || (buf_len <= hint_width_cell(cell, context, VISIBLE_GEOMETRY))) { + return -1; + } + + unsigned int cell_padding_top = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_TOP_PADDING); + unsigned int cell_padding_left = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_LEFT_PADDING); + unsigned int cell_padding_right = get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_RIGHT_PADDING); + + size_t written = 0; + size_t invisible_written = 0; + int tmp = 0; + + /* todo: Dirty hack with changing buf_len! need refactoring. */ + /* Also maybe it is better to move all struff with colors to buffers? */ + char cell_style_tag[TEXT_STYLE_TAG_MAX_SIZE]; + get_style_tag_for_cell(context->table_properties, context->row, context->column, cell_style_tag, TEXT_STYLE_TAG_MAX_SIZE); + buf_len += strlen(cell_style_tag); + + char reset_cell_style_tag[TEXT_STYLE_TAG_MAX_SIZE]; + get_reset_style_tag_for_cell(context->table_properties, context->row, context->column, reset_cell_style_tag, TEXT_STYLE_TAG_MAX_SIZE); + buf_len += strlen(reset_cell_style_tag); + + char content_style_tag[TEXT_STYLE_TAG_MAX_SIZE]; + get_style_tag_for_content(context->table_properties, context->row, context->column, content_style_tag, TEXT_STYLE_TAG_MAX_SIZE); + buf_len += strlen(content_style_tag); + + char reset_content_style_tag[TEXT_STYLE_TAG_MAX_SIZE]; + get_reset_style_tag_for_content(context->table_properties, context->row, context->column, reset_content_style_tag, TEXT_STYLE_TAG_MAX_SIZE); + buf_len += strlen(reset_content_style_tag); + + /* CELL_STYLE_T LEFT_PADDING CONTENT_STYLE_T CONTENT RESET_CONTENT_STYLE_T RIGHT_PADDING RESET_CELL_STYLE_T + * | | | | | | | | + * L1 R1 + * L2 R2 + * L3 R3 + */ + + size_t L2 = cell_padding_left; + + size_t R2 = cell_padding_right; + size_t R3 = strlen(reset_cell_style_tag); + +#define TOTAL_WRITTEN (written + invisible_written) +#define RIGHT (right + extra_right) + +#define WRITE_CELL_STYLE_TAG CHCK_RSLT_ADD_TO_INVISIBLE_WRITTEN(snprint_n_strings_(buf + TOTAL_WRITTEN, buf_len - TOTAL_WRITTEN, 1, cell_style_tag)) +#define WRITE_RESET_CELL_STYLE_TAG CHCK_RSLT_ADD_TO_INVISIBLE_WRITTEN(snprint_n_strings_(buf + TOTAL_WRITTEN, buf_len - TOTAL_WRITTEN, 1, reset_cell_style_tag)) +#define WRITE_CONTENT_STYLE_TAG CHCK_RSLT_ADD_TO_INVISIBLE_WRITTEN(snprint_n_strings_(buf + TOTAL_WRITTEN, buf_len - TOTAL_WRITTEN, 1, content_style_tag)) +#define WRITE_RESET_CONTENT_STYLE_TAG CHCK_RSLT_ADD_TO_INVISIBLE_WRITTEN(snprint_n_strings_(buf + TOTAL_WRITTEN, buf_len - TOTAL_WRITTEN, 1, reset_content_style_tag)) + + if (row >= hint_height_cell(cell, context) + || row < cell_padding_top + || row >= (cell_padding_top + buffer_text_height(cell->str_buffer))) { + WRITE_CELL_STYLE_TAG; + WRITE_CONTENT_STYLE_TAG; + WRITE_RESET_CONTENT_STYLE_TAG; + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buf + TOTAL_WRITTEN, buf_len, buf_len - 1 - TOTAL_WRITTEN - R3, space_char)); + WRITE_RESET_CELL_STYLE_TAG; + return (int)TOTAL_WRITTEN; + } + + WRITE_CELL_STYLE_TAG; + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buf + TOTAL_WRITTEN, buf_len - TOTAL_WRITTEN, L2, space_char)); + if (cell->str_buffer) { + CHCK_RSLT_ADD_TO_WRITTEN(buffer_printf_(cell->str_buffer, row - cell_padding_top, buf + TOTAL_WRITTEN, buf_len - TOTAL_WRITTEN - R2 - R3, context, content_style_tag, reset_content_style_tag)); + } else { + WRITE_CONTENT_STYLE_TAG; + WRITE_RESET_CONTENT_STYLE_TAG; + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buf + TOTAL_WRITTEN, buf_len - TOTAL_WRITTEN, buf_len - TOTAL_WRITTEN - R2 - R3, space_char)); + } + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buf + TOTAL_WRITTEN, buf_len - TOTAL_WRITTEN, R2, space_char)); + WRITE_RESET_CELL_STYLE_TAG; + + return (int)TOTAL_WRITTEN; + +clear: + return -1; +#undef WRITE_CELL_STYLE_TAG +#undef WRITE_RESET_CELL_STYLE_TAG +#undef WRITE_CONTENT_STYLE_TAG +#undef WRITE_RESET_CONTENT_STYLE_TAG +#undef TOTAL_WRITTEN +#undef RIGHT +} +#endif + +FT_INTERNAL +fort_status_t fill_cell_from_string(fort_cell_t *cell, const char *str) +{ + assert(str); + assert(cell); + + return fill_buffer_from_string(cell->str_buffer, str); +} + +#ifdef FT_HAVE_WCHAR +FT_INTERNAL +fort_status_t fill_cell_from_wstring(fort_cell_t *cell, const wchar_t *str) +{ + assert(str); + assert(cell); + + return fill_buffer_from_wstring(cell->str_buffer, str); +} + +#endif + +FT_INTERNAL +string_buffer_t *cell_get_string_buffer(fort_cell_t *cell) +{ + assert(cell); + assert(cell->str_buffer); + return cell->str_buffer; +} + + +/******************************************************** + End of file "cell.c" + ********************************************************/ + + +/******************************************************** + Begin of file "fort_impl.c" + ********************************************************/ + +/* +libfort + +MIT License + +Copyright (c) 2017 - 2018 Seleznev Anton + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#include +#include +#include +#include "fort.h" +#include +#include +#include +#include + +/* #include "vector.h" */ /* Commented by amalgamation script */ +/* #include "fort_utils.h" */ /* Commented by amalgamation script */ +/* #include "string_buffer.h" */ /* Commented by amalgamation script */ +/* #include "table.h" */ /* Commented by amalgamation script */ +/* #include "row.h" */ /* Commented by amalgamation script */ +/* #include "properties.h" */ /* Commented by amalgamation script */ + + +ft_table_t *ft_create_table(void) +{ + ft_table_t *result = (ft_table_t *)F_CALLOC(1, sizeof(ft_table_t)); + if (result == NULL) + return NULL; + + result->rows = create_vector(sizeof(fort_row_t *), DEFAULT_VECTOR_CAPACITY); + if (result->rows == NULL) { + F_FREE(result); + return NULL; + } + result->separators = create_vector(sizeof(separator_t *), DEFAULT_VECTOR_CAPACITY); + if (result->separators == NULL) { + destroy_vector(result->rows); + F_FREE(result); + return NULL; + } + result->properties = NULL; + result->conv_buffer = NULL; + result->cur_row = 0; + result->cur_col = 0; + return result; +} + + +void ft_destroy_table(ft_table_t *table) +{ + size_t i = 0; + + if (table == NULL) + return; + + if (table->rows) { + size_t row_n = vector_size(table->rows); + for (i = 0; i < row_n; ++i) { + destroy_row(*(fort_row_t **)vector_at(table->rows, i)); + } + destroy_vector(table->rows); + } + if (table->separators) { + size_t row_n = vector_size(table->separators); + for (i = 0; i < row_n; ++i) { + destroy_separator(*(separator_t **)vector_at(table->separators, i)); + } + destroy_vector(table->separators); + } + destroy_table_properties(table->properties); + destroy_string_buffer(table->conv_buffer); + F_FREE(table); +} + +ft_table_t *ft_copy_table(ft_table_t *table) +{ + if (table == NULL) + return NULL; + + ft_table_t *result = ft_create_table(); + if (result == NULL) + return NULL; + + size_t i = 0; + size_t rows_n = vector_size(table->rows); + for (i = 0; i < rows_n; ++i) { + fort_row_t *row = *(fort_row_t **)vector_at(table->rows, i); + fort_row_t *new_row = copy_row(row); + if (new_row == NULL) { + ft_destroy_table(result); + return NULL; + } + vector_push(result->rows, &new_row); + } + + size_t sep_sz = vector_size(table->separators); + for (i = 0; i < sep_sz; ++i) { + separator_t *sep = *(separator_t **)vector_at(table->separators, i); + separator_t *new_sep = copy_separator(sep); + if (new_sep == NULL) { + ft_destroy_table(result); + return NULL; + } + vector_push(result->separators, &new_sep); + } + + + result->properties = copy_table_properties(table->properties); + if (result->properties == NULL) { + ft_destroy_table(result); + return NULL; + } + + /* todo: copy conv_buffer ?? */ + + result->cur_row = table->cur_row; + result->cur_col = table->cur_col; + return result; +} + + +void ft_ln(ft_table_t *table) +{ + assert(table); + table->cur_col = 0; + table->cur_row++; +} + +size_t ft_cur_row(ft_table_t *table) +{ + assert(table); + return table->cur_row; +} + +size_t ft_cur_col(ft_table_t *table) +{ + assert(table); + return table->cur_col; +} + +void ft_set_cur_cell(ft_table_t *table, size_t row, size_t col) +{ + assert(table); + table->cur_row = row; + table->cur_col = col; +} + +FT_PRINTF_ATTRIBUTE_FORMAT(3, 0) +static int ft_row_printf_impl(ft_table_t *table, size_t row, const char *fmt, va_list *va) +{ +#define CREATE_ROW_FROM_FMT_STRING create_row_from_fmt_string + size_t i = 0; + size_t new_cols = 0; + + if (table == NULL) + return -1; + + fort_row_t *new_row = CREATE_ROW_FROM_FMT_STRING(fmt, va); + + if (new_row == NULL) { + return -1; + } + + fort_row_t **cur_row_p = NULL; + size_t sz = vector_size(table->rows); + if (row >= sz) { + size_t push_n = row - sz + 1; + for (i = 0; i < push_n; ++i) { + fort_row_t *padding_row = create_row(); + if (padding_row == NULL) + goto clear; + + if (FT_IS_ERROR(vector_push(table->rows, &padding_row))) { + destroy_row(padding_row); + goto clear; + } + } + } + /* todo: clearing pushed items in case of error ?? */ + + new_cols = columns_in_row(new_row); + cur_row_p = (fort_row_t **)vector_at(table->rows, row); + swap_row(*cur_row_p, new_row, table->cur_col); + + table->cur_col += new_cols; + destroy_row(new_row); + return (int)new_cols; + +clear: + destroy_row(new_row); + return -1; +#undef CREATE_ROW_FROM_FMT_STRING +} + +#ifdef FT_HAVE_WCHAR +static int ft_row_wprintf_impl(ft_table_t *table, size_t row, const wchar_t *fmt, va_list *va) +{ +#define CREATE_ROW_FROM_FMT_STRING create_row_from_fmt_wstring + size_t i = 0; + size_t new_cols = 0; + + if (table == NULL) + return -1; + + fort_row_t *new_row = CREATE_ROW_FROM_FMT_STRING(fmt, va); + + if (new_row == NULL) { + return -1; + } + + fort_row_t **cur_row_p = NULL; + size_t sz = vector_size(table->rows); + if (row >= sz) { + size_t push_n = row - sz + 1; + for (i = 0; i < push_n; ++i) { + fort_row_t *padding_row = create_row(); + if (padding_row == NULL) + goto clear; + + if (FT_IS_ERROR(vector_push(table->rows, &padding_row))) { + destroy_row(padding_row); + goto clear; + } + } + } + /* todo: clearing pushed items in case of error ?? */ + + new_cols = columns_in_row(new_row); + cur_row_p = (fort_row_t **)vector_at(table->rows, row); + swap_row(*cur_row_p, new_row, table->cur_col); + + table->cur_col += new_cols; + destroy_row(new_row); + return (int)new_cols; + +clear: + destroy_row(new_row); + return -1; +#undef CREATE_ROW_FROM_FMT_STRING +} +#endif + +#if defined(FT_CLANG_COMPILER) || defined(FT_GCC_COMPILER) +#define FT_PRINTF ft_printf +#define FT_PRINTF_LN ft_printf_ln +#else +#define FT_PRINTF ft_printf_impl +#define FT_PRINTF_LN ft_printf_ln_impl +#endif + + + +int FT_PRINTF(ft_table_t *table, const char *fmt, ...) +{ + assert(table); + va_list va; + va_start(va, fmt); + int result = ft_row_printf_impl(table, table->cur_row, fmt, &va); + va_end(va); + return result; +} + +int FT_PRINTF_LN(ft_table_t *table, const char *fmt, ...) +{ + assert(table); + va_list va; + va_start(va, fmt); + int result = ft_row_printf_impl(table, table->cur_row, fmt, &va); + if (result >= 0) { + ft_ln(table); + } + va_end(va); + return result; +} + +#undef FT_PRINTF +#undef FT_PRINTF_LN +#undef FT_HDR_PRINTF +#undef FT_HDR_PRINTF_LN + +#ifdef FT_HAVE_WCHAR +int ft_wprintf(ft_table_t *table, const wchar_t *fmt, ...) +{ + assert(table); + va_list va; + va_start(va, fmt); + int result = ft_row_wprintf_impl(table, table->cur_row, fmt, &va); + va_end(va); + return result; +} + +int ft_wprintf_ln(ft_table_t *table, const wchar_t *fmt, ...) +{ + assert(table); + va_list va; + va_start(va, fmt); + int result = ft_row_wprintf_impl(table, table->cur_row, fmt, &va); + if (result >= 0) { + ft_ln(table); + } + va_end(va); + return result; +} + +#endif + +void ft_set_default_printf_field_separator(char separator) +{ + g_col_separator = separator; +} + + +static int ft_write_impl(ft_table_t *table, const char *cell_content) +{ + assert(table); + string_buffer_t *str_buffer = get_cur_str_buffer_and_create_if_not_exists(table); + if (str_buffer == NULL) + return FT_ERROR; + + int status = fill_buffer_from_string(str_buffer, cell_content); + if (FT_IS_SUCCESS(status)) { + table->cur_col++; + } + return status; +} + + +#ifdef FT_HAVE_WCHAR + +static int ft_wwrite_impl(ft_table_t *table, const wchar_t *cell_content) +{ + assert(table); + string_buffer_t *str_buffer = get_cur_str_buffer_and_create_if_not_exists(table); + if (str_buffer == NULL) + return FT_ERROR; + + int status = fill_buffer_from_wstring(str_buffer, cell_content); + if (FT_IS_SUCCESS(status)) { + table->cur_col++; + } + return status; +} + +#endif + + +int ft_nwrite(ft_table_t *table, size_t count, const char *cell_content, ...) +{ + size_t i = 0; + assert(table); + int status = ft_write_impl(table, cell_content); + if (FT_IS_ERROR(status)) + return status; + + va_list va; + va_start(va, cell_content); + --count; + for (i = 0; i < count; ++i) { + const char *cell = va_arg(va, const char *); + status = ft_write_impl(table, cell); + if (FT_IS_ERROR(status)) { + va_end(va); + return status; + } + } + va_end(va); + return status; +} + +int ft_nwrite_ln(ft_table_t *table, size_t count, const char *cell_content, ...) +{ + size_t i = 0; + assert(table); + int status = ft_write_impl(table, cell_content); + if (FT_IS_ERROR(status)) + return status; + + va_list va; + va_start(va, cell_content); + --count; + for (i = 0; i < count; ++i) { + const char *cell = va_arg(va, const char *); + status = ft_write_impl(table, cell); + if (FT_IS_ERROR(status)) { + va_end(va); + return status; + } + } + va_end(va); + + ft_ln(table); + return status; +} + +#ifdef FT_HAVE_WCHAR + +int ft_nwwrite(ft_table_t *table, size_t n, const wchar_t *cell_content, ...) +{ + size_t i = 0; + assert(table); + int status = ft_wwrite_impl(table, cell_content); + if (FT_IS_ERROR(status)) + return status; + + va_list va; + va_start(va, cell_content); + --n; + for (i = 0; i < n; ++i) { + const wchar_t *cell = va_arg(va, const wchar_t *); + status = ft_wwrite_impl(table, cell); + if (FT_IS_ERROR(status)) { + va_end(va); + return status; + } + } + va_end(va); + return status; +} + +int ft_nwwrite_ln(ft_table_t *table, size_t n, const wchar_t *cell_content, ...) +{ + size_t i = 0; + assert(table); + int status = ft_wwrite_impl(table, cell_content); + if (FT_IS_ERROR(status)) + return status; + + va_list va; + va_start(va, cell_content); + --n; + for (i = 0; i < n; ++i) { + const wchar_t *cell = va_arg(va, const wchar_t *); + status = ft_wwrite_impl(table, cell); + if (FT_IS_ERROR(status)) { + va_end(va); + return status; + } + } + va_end(va); + + ft_ln(table); + return status; +} +#endif + + +int ft_row_write(ft_table_t *table, size_t cols, const char *cells[]) +{ + size_t i = 0; + assert(table); + for (i = 0; i < cols; ++i) { + int status = ft_write_impl(table, cells[i]); + if (FT_IS_ERROR(status)) { + /* todo: maybe current pos in case of error should be equal to the one before function call? */ + return status; + } + } + return FT_SUCCESS; +} + +int ft_row_write_ln(ft_table_t *table, size_t cols, const char *cells[]) +{ + assert(table); + int status = ft_row_write(table, cols, cells); + if (FT_IS_SUCCESS(status)) { + ft_ln(table); + } + return status; +} + +#ifdef FT_HAVE_WCHAR +int ft_row_wwrite(ft_table_t *table, size_t cols, const wchar_t *cells[]) +{ + size_t i = 0; + assert(table); + for (i = 0; i < cols; ++i) { + int status = ft_wwrite_impl(table, cells[i]); + if (FT_IS_ERROR(status)) { + /* todo: maybe current pos in case of error should be equal + * to the one before function call? + */ + return status; + } + } + return FT_SUCCESS; +} + +int ft_row_wwrite_ln(ft_table_t *table, size_t cols, const wchar_t *cells[]) +{ + assert(table); + int status = ft_row_wwrite(table, cols, cells); + if (FT_IS_SUCCESS(status)) { + ft_ln(table); + } + return status; +} +#endif + + + +int ft_table_write(ft_table_t *table, size_t rows, size_t cols, const char *table_cells[]) +{ + size_t i = 0; + assert(table); + for (i = 0; i < rows; ++i) { + int status = ft_row_write(table, cols, (const char **)&table_cells[i * cols]); + if (FT_IS_ERROR(status)) { + /* todo: maybe current pos in case of error should be equal + * to the one before function call? + */ + return status; + } + if (i != rows - 1) + ft_ln(table); + } + return FT_SUCCESS; +} + +int ft_table_write_ln(ft_table_t *table, size_t rows, size_t cols, const char *table_cells[]) +{ + assert(table); + int status = ft_table_write(table, rows, cols, table_cells); + if (FT_IS_SUCCESS(status)) { + ft_ln(table); + } + return status; +} + + +#ifdef FT_HAVE_WCHAR +int ft_table_wwrite(ft_table_t *table, size_t rows, size_t cols, const wchar_t *table_cells[]) +{ + size_t i = 0; + assert(table); + for (i = 0; i < rows; ++i) { + int status = ft_row_wwrite(table, cols, (const wchar_t **)&table_cells[i * cols]); + if (FT_IS_ERROR(status)) { + /* todo: maybe current pos in case of error should be equal + * to the one before function call? + */ + return status; + } + if (i != rows - 1) + ft_ln(table); + } + return FT_SUCCESS; +} + +int ft_table_wwrite_ln(ft_table_t *table, size_t rows, size_t cols, const wchar_t *table_cells[]) +{ + assert(table); + int status = ft_table_wwrite(table, rows, cols, table_cells); + if (FT_IS_SUCCESS(status)) { + ft_ln(table); + } + return status; +} +#endif + + + +const char *ft_to_string(const ft_table_t *table) +{ + typedef char char_type; + const enum str_buf_type buf_type = CharBuf; + const char *space_char = " "; + const char *new_line_char = "\n"; +#define EMPTY_STRING "" + int (*snprintf_row_)(const fort_row_t *, char *, size_t, size_t *, size_t, size_t, const context_t *) = snprintf_row; + int (*print_row_separator_)(char *, size_t, + const size_t *, size_t, + const fort_row_t *, const fort_row_t *, + enum HorSeparatorPos, const separator_t *, + const context_t *) = print_row_separator; + int (*snprint_n_strings_)(char *, size_t, size_t, const char *) = snprint_n_strings; + assert(table); + + /* Determing size of table string representation */ + size_t height = 0; + size_t width = 0; + int status = table_geometry(table, &height, &width); + if (FT_IS_ERROR(status)) { + return NULL; + } + size_t sz = height * width + 1; + + /* Allocate string buffer for string representation */ + if (table->conv_buffer == NULL) { + ((ft_table_t *)table)->conv_buffer = create_string_buffer(sz, buf_type); + if (table->conv_buffer == NULL) + return NULL; + } + while (string_buffer_capacity(table->conv_buffer) < sz) { + if (FT_IS_ERROR(realloc_string_buffer_without_copy(table->conv_buffer))) { + return NULL; + } + } + char_type *buffer = (char_type *)buffer_get_data(table->conv_buffer); + + + size_t cols = 0; + size_t rows = 0; + size_t *col_width_arr = NULL; + size_t *row_height_arr = NULL; + status = table_rows_and_cols_geometry(table, &col_width_arr, &cols, &row_height_arr, &rows, VISIBLE_GEOMETRY); + if (FT_IS_ERROR(status)) + return NULL; + + if (rows == 0) + return EMPTY_STRING; + + size_t written = 0; + int tmp = 0; + size_t i = 0; + context_t context; + context.table_properties = (table->properties ? table->properties : &g_table_properties); + fort_row_t *prev_row = NULL; + fort_row_t *cur_row = NULL; + separator_t *cur_sep = NULL; + size_t sep_size = vector_size(table->separators); + + /* Print top margin */ + for (i = 0; i < context.table_properties->entire_table_properties.top_margin; ++i) { + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, sz - written, width - 1/* minus new_line*/, space_char)); + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, sz - written, 1, new_line_char)); + } + + for (i = 0; i < rows; ++i) { + cur_sep = (i < sep_size) ? (*(separator_t **)vector_at(table->separators, i)) : NULL; + cur_row = *(fort_row_t **)vector_at(table->rows, i); + enum HorSeparatorPos separatorPos = (i == 0) ? TopSeparator : InsideSeparator; + context.row = i; + CHCK_RSLT_ADD_TO_WRITTEN(print_row_separator_(buffer + written, sz - written, col_width_arr, cols, prev_row, cur_row, separatorPos, cur_sep, &context)); + CHCK_RSLT_ADD_TO_WRITTEN(snprintf_row_(cur_row, buffer + written, sz - written, col_width_arr, cols, row_height_arr[i], &context)); + prev_row = cur_row; + } + cur_row = NULL; + cur_sep = (i < sep_size) ? (*(separator_t **)vector_at(table->separators, i)) : NULL; + CHCK_RSLT_ADD_TO_WRITTEN(print_row_separator_(buffer + written, sz - written, col_width_arr, cols, prev_row, cur_row, BottomSeparator, cur_sep, &context)); + + /* Print bottom margin */ + for (i = 0; i < context.table_properties->entire_table_properties.bottom_margin; ++i) { + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, sz - written, width - 1/* minus new_line*/, space_char)); + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, sz - written, 1, new_line_char)); + } + + + F_FREE(col_width_arr); + F_FREE(row_height_arr); + return buffer; + +clear: + F_FREE(col_width_arr); + F_FREE(row_height_arr); + return NULL; +#undef EMPTY_STRING +} + + +#ifdef FT_HAVE_WCHAR + +const wchar_t *ft_to_wstring(const ft_table_t *table) +{ + typedef wchar_t char_type; + const enum str_buf_type buf_type = WCharBuf; + const char *space_char = " "; + const char *new_line_char = "\n"; +#define EMPTY_STRING L"" + int (*snprintf_row_)(const fort_row_t *, wchar_t *, size_t, size_t *, size_t, size_t, const context_t *) = wsnprintf_row; + int (*print_row_separator_)(wchar_t *, size_t, + const size_t *, size_t, + const fort_row_t *, const fort_row_t *, + enum HorSeparatorPos, const separator_t *, + const context_t *) = wprint_row_separator; + int (*snprint_n_strings_)(wchar_t *, size_t, size_t, const char *) = wsnprint_n_string; + + + assert(table); + + /* Determing size of table string representation */ + size_t height = 0; + size_t width = 0; + int status = table_geometry(table, &height, &width); + if (FT_IS_ERROR(status)) { + return NULL; + } + size_t sz = height * width + 1; + + /* Allocate string buffer for string representation */ + if (table->conv_buffer == NULL) { + ((ft_table_t *)table)->conv_buffer = create_string_buffer(sz, buf_type); + if (table->conv_buffer == NULL) + return NULL; + } + while (string_buffer_capacity(table->conv_buffer) < sz) { + if (FT_IS_ERROR(realloc_string_buffer_without_copy(table->conv_buffer))) { + return NULL; + } + } + char_type *buffer = (char_type *)buffer_get_data(table->conv_buffer); + + + size_t cols = 0; + size_t rows = 0; + size_t *col_width_arr = NULL; + size_t *row_height_arr = NULL; + status = table_rows_and_cols_geometry(table, &col_width_arr, &cols, &row_height_arr, &rows, VISIBLE_GEOMETRY); + + if (rows == 0) + return EMPTY_STRING; + + if (FT_IS_ERROR(status)) + return NULL; + + size_t written = 0; + int tmp = 0; + size_t i = 0; + context_t context; + context.table_properties = (table->properties ? table->properties : &g_table_properties); + fort_row_t *prev_row = NULL; + fort_row_t *cur_row = NULL; + separator_t *cur_sep = NULL; + size_t sep_size = vector_size(table->separators); + + /* Print top margin */ + for (i = 0; i < context.table_properties->entire_table_properties.top_margin; ++i) { + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, sz - written, width - 1/* minus new_line*/, space_char)); + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, sz - written, 1, new_line_char)); + } + + for (i = 0; i < rows; ++i) { + cur_sep = (i < sep_size) ? (*(separator_t **)vector_at(table->separators, i)) : NULL; + cur_row = *(fort_row_t **)vector_at(table->rows, i); + enum HorSeparatorPos separatorPos = (i == 0) ? TopSeparator : InsideSeparator; + context.row = i; + CHCK_RSLT_ADD_TO_WRITTEN(print_row_separator_(buffer + written, sz - written, col_width_arr, cols, prev_row, cur_row, separatorPos, cur_sep, &context)); + CHCK_RSLT_ADD_TO_WRITTEN(snprintf_row_(cur_row, buffer + written, sz - written, col_width_arr, cols, row_height_arr[i], &context)); + prev_row = cur_row; + } + cur_row = NULL; + cur_sep = (i < sep_size) ? (*(separator_t **)vector_at(table->separators, i)) : NULL; + CHCK_RSLT_ADD_TO_WRITTEN(print_row_separator_(buffer + written, sz - written, col_width_arr, cols, prev_row, cur_row, BottomSeparator, cur_sep, &context)); + + /* Print bottom margin */ + for (i = 0; i < context.table_properties->entire_table_properties.bottom_margin; ++i) { + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, sz - written, width - 1/* minus new_line*/, space_char)); + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, sz - written, 1, new_line_char)); + } + + F_FREE(col_width_arr); + F_FREE(row_height_arr); + return buffer; + +clear: + F_FREE(col_width_arr); + F_FREE(row_height_arr); + return NULL; +#undef EMPTY_STRING +} + +#endif + + +int ft_add_separator(ft_table_t *table) +{ + assert(table); + assert(table->separators); + + while (vector_size(table->separators) <= table->cur_row) { + separator_t *sep_p = create_separator(F_FALSE); + if (sep_p == NULL) + return FT_MEMORY_ERROR; + int status = vector_push(table->separators, &sep_p); + if (FT_IS_ERROR(status)) + return status; + } + + separator_t **sep_p = (separator_t **)vector_at(table->separators, table->cur_row); + if (*sep_p == NULL) + *sep_p = create_separator(F_TRUE); + else + (*sep_p)->enabled = F_TRUE; + + if (*sep_p == NULL) + return FT_ERROR; + return FT_SUCCESS; +} + + + +struct ft_border_style *const FT_BASIC_STYLE = (struct ft_border_style *) &FORT_BASIC_STYLE; +struct ft_border_style *const FT_BASIC2_STYLE = (struct ft_border_style *) &FORT_BASIC2_STYLE; +struct ft_border_style *const FT_SIMPLE_STYLE = (struct ft_border_style *) &FORT_SIMPLE_STYLE; +struct ft_border_style *const FT_PLAIN_STYLE = (struct ft_border_style *) &FORT_PLAIN_STYLE; +struct ft_border_style *const FT_DOT_STYLE = (struct ft_border_style *) &FORT_DOT_STYLE; +struct ft_border_style *const FT_EMPTY_STYLE = (struct ft_border_style *) &FORT_EMPTY_STYLE; +struct ft_border_style *const FT_EMPTY2_STYLE = (struct ft_border_style *) &FORT_EMPTY2_STYLE; +struct ft_border_style *const FT_SOLID_STYLE = (struct ft_border_style *) &FORT_SOLID_STYLE; +struct ft_border_style *const FT_SOLID_ROUND_STYLE = (struct ft_border_style *) &FORT_SOLID_ROUND_STYLE; +struct ft_border_style *const FT_NICE_STYLE = (struct ft_border_style *) &FORT_NICE_STYLE; +struct ft_border_style *const FT_DOUBLE_STYLE = (struct ft_border_style *) &FORT_DOUBLE_STYLE; +struct ft_border_style *const FT_DOUBLE2_STYLE = (struct ft_border_style *) &FORT_DOUBLE2_STYLE; +struct ft_border_style *const FT_BOLD_STYLE = (struct ft_border_style *) &FORT_BOLD_STYLE; +struct ft_border_style *const FT_BOLD2_STYLE = (struct ft_border_style *) &FORT_BOLD2_STYLE; +struct ft_border_style *const FT_FRAME_STYLE = (struct ft_border_style *) &FORT_FRAME_STYLE; + + + +static void set_border_props_for_props(fort_table_properties_t *properties, const struct ft_border_style *style) +{ + if ((const struct fort_border_style *)style == &FORT_BASIC_STYLE + || (const struct fort_border_style *)style == &FORT_BASIC2_STYLE + || (const struct fort_border_style *)style == &FORT_SIMPLE_STYLE + || (const struct fort_border_style *)style == &FORT_DOT_STYLE + || (const struct fort_border_style *)style == &FORT_PLAIN_STYLE + || (const struct fort_border_style *)style == &FORT_EMPTY_STYLE + || (const struct fort_border_style *)style == &FORT_EMPTY2_STYLE + || (const struct fort_border_style *)style == &FORT_SOLID_STYLE + || (const struct fort_border_style *)style == &FORT_SOLID_ROUND_STYLE + || (const struct fort_border_style *)style == &FORT_NICE_STYLE + || (const struct fort_border_style *)style == &FORT_DOUBLE_STYLE + || (const struct fort_border_style *)style == &FORT_DOUBLE2_STYLE + || (const struct fort_border_style *)style == &FORT_BOLD_STYLE + || (const struct fort_border_style *)style == &FORT_BOLD2_STYLE + || (const struct fort_border_style *)style == &FORT_FRAME_STYLE) { + memcpy(&(properties->border_style), (const struct fort_border_style *)style, sizeof(struct fort_border_style)); + return; + } + + const struct ft_border_chars *border_chs = &(style->border_chs); + const struct ft_border_chars *header_border_chs = &(style->header_border_chs); + +#define BOR_CHARS properties->border_style.border_chars +#define H_BOR_CHARS properties->border_style.header_border_chars +#define SEP_CHARS properties->border_style.separator_chars + + /* + BOR_CHARS[TL_bip] = BOR_CHARS[TT_bip] = BOR_CHARS[TV_bip] = BOR_CHARS[TR_bip] = border_chs->top_border_ch; + BOR_CHARS[LH_bip] = BOR_CHARS[IH_bip] = BOR_CHARS[II_bip] = BOR_CHARS[RH_bip] = border_chs->separator_ch; + BOR_CHARS[BL_bip] = BOR_CHARS[BB_bip] = BOR_CHARS[BV_bip] = BOR_CHARS[BR_bip] = border_chs->bottom_border_ch; + BOR_CHARS[LL_bip] = BOR_CHARS[IV_bip] = BOR_CHARS[RR_bip] = border_chs->side_border_ch; + + H_BOR_CHARS[TL_bip] = H_BOR_CHARS[TT_bip] = H_BOR_CHARS[TV_bip] = H_BOR_CHARS[TR_bip] = header_border_chs->top_border_ch; + H_BOR_CHARS[LH_bip] = H_BOR_CHARS[IH_bip] = H_BOR_CHARS[II_bip] = H_BOR_CHARS[RH_bip] = header_border_chs->separator_ch; + H_BOR_CHARS[BL_bip] = H_BOR_CHARS[BB_bip] = H_BOR_CHARS[BV_bip] = H_BOR_CHARS[BR_bip] = header_border_chs->bottom_border_ch; + H_BOR_CHARS[LL_bip] = H_BOR_CHARS[IV_bip] = H_BOR_CHARS[RR_bip] = header_border_chs->side_border_ch; + */ + + BOR_CHARS[TT_bip] = border_chs->top_border_ch; + BOR_CHARS[IH_bip] = border_chs->separator_ch; + BOR_CHARS[BB_bip] = border_chs->bottom_border_ch; + BOR_CHARS[LL_bip] = BOR_CHARS[IV_bip] = BOR_CHARS[RR_bip] = border_chs->side_border_ch; + + BOR_CHARS[TL_bip] = BOR_CHARS[TV_bip] = BOR_CHARS[TR_bip] = border_chs->out_intersect_ch; + BOR_CHARS[LH_bip] = BOR_CHARS[RH_bip] = border_chs->out_intersect_ch; + BOR_CHARS[BL_bip] = BOR_CHARS[BV_bip] = BOR_CHARS[BR_bip] = border_chs->out_intersect_ch; + BOR_CHARS[II_bip] = border_chs->in_intersect_ch; + + BOR_CHARS[LI_bip] = BOR_CHARS[TI_bip] = BOR_CHARS[RI_bip] = BOR_CHARS[BI_bip] = border_chs->in_intersect_ch; + + /* + if (border_chs->separator_ch == '\0' && border_chs->in_intersect_ch == '\0') { + BOR_CHARS[LH_bip] = BOR_CHARS[RH_bip] = '\0'; + } + */ + if (strlen(border_chs->separator_ch) == 0 && strlen(border_chs->in_intersect_ch) == 0) { + BOR_CHARS[LH_bip] = BOR_CHARS[RH_bip] = "\0"; + } + + + H_BOR_CHARS[TT_bip] = header_border_chs->top_border_ch; + H_BOR_CHARS[IH_bip] = header_border_chs->separator_ch; + H_BOR_CHARS[BB_bip] = header_border_chs->bottom_border_ch; + H_BOR_CHARS[LL_bip] = H_BOR_CHARS[IV_bip] = H_BOR_CHARS[RR_bip] = header_border_chs->side_border_ch; + + H_BOR_CHARS[TL_bip] = H_BOR_CHARS[TV_bip] = H_BOR_CHARS[TR_bip] = header_border_chs->out_intersect_ch; + H_BOR_CHARS[LH_bip] = H_BOR_CHARS[RH_bip] = header_border_chs->out_intersect_ch; + H_BOR_CHARS[BL_bip] = H_BOR_CHARS[BV_bip] = H_BOR_CHARS[BR_bip] = header_border_chs->out_intersect_ch; + H_BOR_CHARS[II_bip] = header_border_chs->in_intersect_ch; + + H_BOR_CHARS[LI_bip] = H_BOR_CHARS[TI_bip] = H_BOR_CHARS[RI_bip] = H_BOR_CHARS[BI_bip] = header_border_chs->in_intersect_ch; + + /* + if (header_border_chs->separator_ch == '\0' && header_border_chs->in_intersect_ch == '\0') { + H_BOR_CHARS[LH_bip] = H_BOR_CHARS[RH_bip] = '\0'; + } + */ + if (strlen(header_border_chs->separator_ch) == 0 && strlen(header_border_chs->in_intersect_ch) == 0) { + BOR_CHARS[LH_bip] = BOR_CHARS[RH_bip] = "\0"; + } + + SEP_CHARS[LH_sip] = SEP_CHARS[RH_sip] = SEP_CHARS[II_sip] = header_border_chs->out_intersect_ch; + SEP_CHARS[TI_sip] = SEP_CHARS[BI_sip] = header_border_chs->out_intersect_ch; + SEP_CHARS[IH_sip] = style->hor_separator_char; + + +#undef BOR_CHARS +#undef H_BOR_CHARS +#undef SEP_CHARS +} + + +int ft_set_default_border_style(const struct ft_border_style *style) +{ + set_border_props_for_props(&g_table_properties, style); + return FT_SUCCESS; +} + +int ft_set_border_style(ft_table_t *table, const struct ft_border_style *style) +{ + assert(table); + if (table->properties == NULL) { + table->properties = create_table_properties(); + if (table->properties == NULL) + return FT_MEMORY_ERROR; + } + set_border_props_for_props(table->properties, style); + return FT_SUCCESS; +} + + + +int ft_set_cell_prop(ft_table_t *table, size_t row, size_t col, uint32_t property, int value) +{ + assert(table); + + if (table->properties == NULL) { + table->properties = create_table_properties(); + if (table->properties == NULL) + return FT_MEMORY_ERROR; + } + if (table->properties->cell_properties == NULL) { + table->properties->cell_properties = create_cell_prop_container(); + if (table->properties->cell_properties == NULL) { + return FT_ERROR; + } + } + + if (row == FT_CUR_ROW) + row = table->cur_row; + if (row == FT_CUR_COLUMN) + col = table->cur_col; + + return set_cell_property(table->properties->cell_properties, row, col, property, value); +} + +int ft_set_default_cell_prop(uint32_t property, int value) +{ + return set_default_cell_property(property, value); +} + + +int ft_set_default_tbl_prop(uint32_t property, int value) +{ + return set_default_entire_table_property(property, value); +} + +int ft_set_tbl_prop(ft_table_t *table, uint32_t property, int value) +{ + assert(table); + + if (table->properties == NULL) { + table->properties = create_table_properties(); + if (table->properties == NULL) + return FT_MEMORY_ERROR; + } + return set_entire_table_property(table->properties, property, value); +} + +void ft_set_memory_funcs(void *(*f_malloc)(size_t size), void (*f_free)(void *ptr)) +{ + set_memory_funcs(f_malloc, f_free); +} + +int ft_set_cell_span(ft_table_t *table, size_t row, size_t col, size_t hor_span) +{ + assert(table); + if (hor_span < 2) + return FT_EINVAL; + + if (row == FT_CUR_ROW) + row = table->cur_row; + if (row == FT_CUR_COLUMN) + col = table->cur_col; + + fort_row_t *row_p = get_row_and_create_if_not_exists(table, row); + if (row_p == NULL) + return FT_ERROR; + + return row_set_cell_span(row_p, col, hor_span); +} + +/******************************************************** + End of file "fort_impl.c" + ********************************************************/ + + +/******************************************************** + Begin of file "fort_utils.c" + ********************************************************/ + +/* #include "fort_utils.h" */ /* Commented by amalgamation script */ +#ifdef FT_HAVE_WCHAR +#include +#endif + + +char g_col_separator = FORT_DEFAULT_COL_SEPARATOR; + +/***************************************************************************** + * LIBFORT helpers + *****************************************************************************/ + +#ifndef FT_MICROSOFT_COMPILER +void *(*fort_malloc)(size_t size) = &malloc; +void (*fort_free)(void *ptr) = &free; +void *(*fort_calloc)(size_t nmemb, size_t size) = &calloc; +void *(*fort_realloc)(void *ptr, size_t size) = &realloc; +#else +static void *local_malloc(size_t size) +{ + return malloc(size); +} + +static void local_free(void *ptr) +{ + free(ptr); +} + +static void *local_calloc(size_t nmemb, size_t size) +{ + return calloc(nmemb, size); +} + +static void *local_realloc(void *ptr, size_t size) +{ + return realloc(ptr, size); +} + +void *(*fort_malloc)(size_t size) = &local_malloc; +void (*fort_free)(void *ptr) = &local_free; +void *(*fort_calloc)(size_t nmemb, size_t size) = &local_calloc; +void *(*fort_realloc)(void *ptr, size_t size) = &local_realloc; +#endif + +static void *custom_fort_calloc(size_t nmemb, size_t size) +{ + size_t total_size = nmemb * size; + void *result = F_MALLOC(total_size); + if (result != NULL) + memset(result, 0, total_size); + return result; +} + +static void *custom_fort_realloc(void *ptr, size_t size) +{ + if (ptr == NULL) + return F_MALLOC(size); + if (size == 0) { + F_FREE(ptr); + return NULL; + } + + void *new_chunk = F_MALLOC(size); + if (new_chunk == NULL) + return NULL; + + /* + * In theory we should copy MIN(size, size allocated for ptr) bytes, + * but this is rather dummy implementation so we don't care about it + */ + memcpy(new_chunk, ptr, size); + F_FREE(ptr); + return new_chunk; +} + + +FT_INTERNAL +void set_memory_funcs(void *(*f_malloc)(size_t size), void (*f_free)(void *ptr)) +{ + assert((f_malloc == NULL && f_free == NULL) /* Use std functions */ + || (f_malloc != NULL && f_free != NULL) /* Use custom functions */); + + if (f_malloc == NULL && f_free == NULL) { +#ifndef FT_MICROSOFT_COMPILER + fort_malloc = &malloc; + fort_free = &free; + fort_calloc = &calloc; + fort_realloc = &realloc; +#else + fort_malloc = &local_malloc; + fort_free = &local_free; + fort_calloc = &local_calloc; + fort_realloc = &local_realloc; +#endif + } else { + fort_malloc = f_malloc; + fort_free = f_free; + fort_calloc = &custom_fort_calloc; + fort_realloc = &custom_fort_realloc; + } + +} + +FT_INTERNAL +char *fort_strdup(const char *str) +{ + if (str == NULL) + return NULL; + + size_t sz = strlen(str); + char *str_copy = (char *)F_MALLOC((sz + 1) * sizeof(char)); + if (str_copy == NULL) + return NULL; + + strcpy(str_copy, str); + return str_copy; +} + +#if defined(FT_HAVE_WCHAR) +FT_INTERNAL +wchar_t *fort_wcsdup(const wchar_t *str) +{ + if (str == NULL) + return NULL; + + size_t sz = wcslen(str); + wchar_t *str_copy = (wchar_t *)F_MALLOC((sz + 1) * sizeof(wchar_t)); + if (str_copy == NULL) + return NULL; + + wcscpy(str_copy, str); + return str_copy; +} +#endif + + +FT_INTERNAL +size_t number_of_columns_in_format_string(const char *fmt) +{ + size_t separator_counter = 0; + const char *pos = fmt; + while (1) { + pos = strchr(pos, g_col_separator); + if (pos == NULL) + break; + + separator_counter++; + ++pos; + } + return separator_counter + 1; +} + + +#if defined(FT_HAVE_WCHAR) +FT_INTERNAL +size_t number_of_columns_in_format_wstring(const wchar_t *fmt) +{ + size_t separator_counter = 0; + const wchar_t *pos = fmt; + while (1) { + pos = wcschr(pos, g_col_separator); + if (pos == NULL) + break; + + separator_counter++; + ++pos; + } + return separator_counter + 1; +} +#endif + + +FT_INTERNAL +int snprint_n_strings(char *buf, size_t length, size_t n, const char *str) +{ + size_t str_len = strlen(str); + if (length <= n * str_len) + return -1; + + if (n == 0) + return 0; + + /* To ensure valid return value it is safely not print such big strings */ + if (n * str_len > INT_MAX) + return -1; + + if (str_len == 0) + return 0; + + int status = snprintf(buf, length, "%0*d", (int)(n * str_len), 0); + if (status < 0) + return status; + + size_t i = 0; + for (i = 0; i < n; ++i) { + const char *str_p = str; + while (*str_p) + *(buf++) = *(str_p++); + } + return (int)(n * str_len); +} + + + +#if defined(FT_HAVE_WCHAR) +#define WCS_SIZE 64 + +FT_INTERNAL +int wsnprint_n_string(wchar_t *buf, size_t length, size_t n, const char *str) +{ + size_t str_len = strlen(str); + + /* note: baybe it's, better to return -1 in case of multibyte character + * strings (not sure this case is done correctly). + */ + if (str_len > 1) { + const unsigned char *p = (const unsigned char *)str; + while (*p) { + if (*p <= 127) + p++; + else { + wchar_t wcs[WCS_SIZE]; + const char *ptr = str; + size_t wcs_len; + mbstate_t mbst; + memset(&mbst, 0, sizeof(mbst)); + wcs_len = mbsrtowcs(wcs, (const char **)&ptr, WCS_SIZE, &mbst); + /* for simplicity */ + if ((wcs_len == (size_t) - 1) || wcs_len > 1) { + return -1; + } else { + wcs[wcs_len] = L'\0'; + size_t k = n; + while (k) { + *buf = *wcs; + ++buf; + --k; + } + buf[n] = L'\0'; + return (int)n; + } + } + } + } + + if (length <= n * str_len) + return -1; + + if (n == 0) + return 0; + + /* To ensure valid return value it is safely not print such big strings */ + if (n * str_len > INT_MAX) + return -1; + + if (str_len == 0) + return 0; + + int status = swprintf(buf, length, L"%0*d", (int)(n * str_len), 0); + if (status < 0) + return status; + + size_t i = 0; + for (i = 0; i < n; ++i) { + const char *str_p = str; + while (*str_p) + *(buf++) = (wchar_t) * (str_p++); + } + return (int)(n * str_len); +} +#endif + +/******************************************************** + End of file "fort_utils.c" + ********************************************************/ + + +/******************************************************** + Begin of file "properties.c" + ********************************************************/ + +/* #include "fort_utils.h" */ /* Commented by amalgamation script */ +#include +/* #include "properties.h" */ /* Commented by amalgamation script */ +/* #include "vector.h" */ /* Commented by amalgamation script */ + +#define FT_RESET_COLOR "\033[0m" + +static const char *fg_colors[] = { + "", + "\033[30m", + "\033[31m", + "\033[32m", + "\033[33m", + "\033[34m", + "\033[35m", + "\033[36m", + "\033[37m", + "\033[90m", + "\033[91m", + "\033[92m", + "\033[93m", + "\033[94m", + "\033[95m", + "\033[96m", + "\033[97m", +}; + +static const char *reset_fg_colors[] = { + "", + "\033[39m", + "\033[39m", + "\033[39m", + "\033[39m", + "\033[39m", + "\033[39m", + "\033[39m", + "\033[39m", + "\033[39m", + "\033[39m", + "\033[39m", + "\033[39m", + "\033[39m", + "\033[39m", + "\033[39m", + "\033[39m", +}; + +static const char *bg_colors[] = { + "", + "\033[40m", + "\033[41m", + "\033[42m", + "\033[43m", + "\033[44m", + "\033[45m", + "\033[46m", + "\033[47m", + "\033[100m", + "\033[101m", + "\033[102m", + "\033[103m", + "\033[104m", + "\033[105m", + "\033[106m", + "\033[107m", +}; + +static const char *reset_bg_colors[] = { + "", + "\033[49m", + "\033[49m", + "\033[49m", + "\033[49m", + "\033[49m", + "\033[49m", + "\033[49m", + "\033[49m", + "\033[49m", + "\033[49m", + "\033[49m", + "\033[49m", + "\033[49m", + "\033[49m", + "\033[49m", + "\033[49m", +}; + + +static const char *text_styles[] = { + "", + "\033[1m", + "\033[2m", + "\033[3m", + "\033[4m", + "\033[5m", + "\033[7m", + "\033[8m", +}; + +static const char *reset_text_styles[] = { + "", + "\033[21m", + "\033[22m", + "\033[23m", + "\033[24m", + "\033[25m", + "\033[27m", + "\033[28m", +}; + + +static const size_t n_fg_colors = sizeof(fg_colors) / sizeof(fg_colors[0]); +static const size_t n_bg_colors = sizeof(bg_colors) / sizeof(bg_colors[0]); +static const size_t n_styles = sizeof(text_styles) / sizeof(text_styles[0]); + +void get_style_tag_for_cell(const fort_table_properties_t *props, + size_t row, size_t col, char *style_tag, size_t sz) +{ + (void)sz; + size_t i = 0; + + unsigned bg_color_number = get_cell_property_value_hierarcial(props, row, col, FT_CPROP_CELL_BG_COLOR); + unsigned text_style = get_cell_property_value_hierarcial(props, row, col, FT_CPROP_CELL_TEXT_STYLE); + + style_tag[0] = '\0'; + + if (text_style < (1U << n_styles)) { + for (i = 0; i < n_styles; ++i) { + if (text_style & (1 << i)) { + strcat(style_tag, text_styles[i]); + } + } + } else { + goto error; + } + + if (bg_color_number < n_bg_colors) { + strcat(style_tag, bg_colors[bg_color_number]); + } else { + goto error; + } + + return; + +error: + /* shouldn't be here */ + assert(0); + style_tag[0] = '\0'; + return; +} + +void get_reset_style_tag_for_cell(const fort_table_properties_t *props, + size_t row, size_t col, char *reset_style_tag, size_t sz) +{ + (void)sz; + size_t i = 0; + + unsigned bg_color_number = get_cell_property_value_hierarcial(props, row, col, FT_CPROP_CELL_BG_COLOR); + unsigned text_style = get_cell_property_value_hierarcial(props, row, col, FT_CPROP_CELL_TEXT_STYLE); + + reset_style_tag[0] = '\0'; + + if (text_style < (1U << n_styles)) { + for (i = 0; i < n_styles; ++i) { + if (text_style & (1 << i)) { + strcat(reset_style_tag, reset_text_styles[i]); + } + } + } else { + goto error; + } + + if (bg_color_number < n_bg_colors) { + strcat(reset_style_tag, reset_bg_colors[bg_color_number]); + } else { + goto error; + } + + return; + +error: + /* shouldn't be here */ + assert(0); + reset_style_tag[0] = '\0'; + return; +} + + +void get_style_tag_for_content(const fort_table_properties_t *props, + size_t row, size_t col, char *style_tag, size_t sz) +{ + (void)sz; + size_t i = 0; + + unsigned text_style = get_cell_property_value_hierarcial(props, row, col, FT_CPROP_CONT_TEXT_STYLE); + unsigned fg_color_number = get_cell_property_value_hierarcial(props, row, col, FT_CPROP_CONT_FG_COLOR); + unsigned bg_color_number = get_cell_property_value_hierarcial(props, row, col, FT_CPROP_CONT_BG_COLOR); + + style_tag[0] = '\0'; + + if (text_style < (1U << n_styles)) { + for (i = 0; i < n_styles; ++i) { + if (text_style & (1 << i)) { + strcat(style_tag, text_styles[i]); + } + } + } else { + goto error; + } + + if (fg_color_number < n_fg_colors) { + strcat(style_tag, fg_colors[fg_color_number]); + } else { + goto error; + } + + if (bg_color_number < n_bg_colors) { + strcat(style_tag, bg_colors[bg_color_number]); + } else { + goto error; + } + + return; + +error: + /* shouldn't be here */ + assert(0); + style_tag[0] = '\0'; + return; +} + +void get_reset_style_tag_for_content(const fort_table_properties_t *props, + size_t row, size_t col, char *reset_style_tag, size_t sz) +{ + (void)sz; + size_t i = 0; + + unsigned text_style = get_cell_property_value_hierarcial(props, row, col, FT_CPROP_CONT_TEXT_STYLE); + unsigned fg_color_number = get_cell_property_value_hierarcial(props, row, col, FT_CPROP_CONT_FG_COLOR); + unsigned bg_color_number = get_cell_property_value_hierarcial(props, row, col, FT_CPROP_CONT_BG_COLOR); + + reset_style_tag[0] = '\0'; + + if (text_style < (1U << n_styles)) { + for (i = 0; i < n_styles; ++i) { + if (text_style & (1 << i)) { + strcat(reset_style_tag, reset_text_styles[i]); + } + } + } else { + goto error; + } + + if (fg_color_number < n_fg_colors) { + strcat(reset_style_tag, reset_fg_colors[fg_color_number]); + } else { + goto error; + } + + if (bg_color_number < n_bg_colors) { + strcat(reset_style_tag, reset_bg_colors[bg_color_number]); + } else { + goto error; + } + + return; + +error: + /* shouldn't be here */ + assert(0); + reset_style_tag[0] = '\0'; + return; +} + + +static struct fort_cell_props g_default_cell_properties = { + FT_ANY_ROW, /* cell_row */ + FT_ANY_COLUMN, /* cell_col */ + + /* properties_flags */ + FT_CPROP_MIN_WIDTH | FT_CPROP_TEXT_ALIGN | FT_CPROP_TOP_PADDING + | FT_CPROP_BOTTOM_PADDING | FT_CPROP_LEFT_PADDING | FT_CPROP_RIGHT_PADDING + | FT_CPROP_EMPTY_STR_HEIGHT | FT_CPROP_CONT_FG_COLOR | FT_CPROP_CELL_BG_COLOR + | FT_CPROP_CONT_BG_COLOR | FT_CPROP_CELL_TEXT_STYLE | FT_CPROP_CONT_TEXT_STYLE, + + 0, /* col_min_width */ + FT_ALIGNED_LEFT, /* align */ + 0, /* cell_padding_top */ + 0, /* cell_padding_bottom */ + 1, /* cell_padding_left */ + 1, /* cell_padding_right */ + 1, /* cell_empty_string_height */ + + FT_ROW_COMMON, /* row_type */ + FT_COLOR_DEFAULT, /* content_fg_color_number */ + FT_COLOR_DEFAULT, /* content_bg_color_number */ + FT_COLOR_DEFAULT, /* cell_bg_color_number */ + FT_TSTYLE_DEFAULT, /* cell_text_style */ + FT_TSTYLE_DEFAULT, /* content_text_style */ +}; + +static int get_prop_value_if_exists_otherwise_default(const struct fort_cell_props *cell_opts, uint32_t property) +{ + if (cell_opts == NULL || !PROP_IS_SET(cell_opts->properties_flags, property)) { + cell_opts = &g_default_cell_properties; + } + + switch (property) { + case FT_CPROP_MIN_WIDTH: + return cell_opts->col_min_width; + case FT_CPROP_TEXT_ALIGN: + return cell_opts->align; + case FT_CPROP_TOP_PADDING: + return cell_opts->cell_padding_top; + case FT_CPROP_BOTTOM_PADDING: + return cell_opts->cell_padding_bottom; + case FT_CPROP_LEFT_PADDING: + return cell_opts->cell_padding_left; + case FT_CPROP_RIGHT_PADDING: + return cell_opts->cell_padding_right; + case FT_CPROP_EMPTY_STR_HEIGHT: + return cell_opts->cell_empty_string_height; + case FT_CPROP_ROW_TYPE: + return cell_opts->row_type; + case FT_CPROP_CONT_FG_COLOR: + return cell_opts->content_fg_color_number; + case FT_CPROP_CONT_BG_COLOR: + return cell_opts->content_bg_color_number; + case FT_CPROP_CELL_BG_COLOR: + return cell_opts->cell_bg_color_number; + case FT_CPROP_CELL_TEXT_STYLE: + return cell_opts->cell_text_style; + case FT_CPROP_CONT_TEXT_STYLE: + return cell_opts->content_text_style; + default: + /* todo: implement later */ + exit(333); + } +} + + +FT_INTERNAL +fort_cell_prop_container_t *create_cell_prop_container(void) +{ + fort_cell_prop_container_t *ret = create_vector(sizeof(fort_cell_props_t), DEFAULT_VECTOR_CAPACITY); + return ret; +} + + +FT_INTERNAL +void destroy_cell_prop_container(fort_cell_prop_container_t *cont) +{ + if (cont) + destroy_vector(cont); +} + + +FT_INTERNAL +const fort_cell_props_t *cget_cell_prop(const fort_cell_prop_container_t *cont, size_t row, size_t col) +{ + assert(cont); + size_t sz = vector_size(cont); + size_t i = 0; + for (i = 0; i < sz; ++i) { + const fort_cell_props_t *opt = (const fort_cell_props_t *)vector_at_c(cont, i); + if (opt->cell_row == row && opt->cell_col == col) + return opt; + } + return NULL; +} + + +FT_INTERNAL +fort_cell_props_t *get_cell_prop_and_create_if_not_exists(fort_cell_prop_container_t *cont, size_t row, size_t col) +{ + assert(cont); + size_t sz = vector_size(cont); + size_t i = 0; + for (i = 0; i < sz; ++i) { + fort_cell_props_t *opt = (fort_cell_props_t *)vector_at(cont, i); + if (opt->cell_row == row && opt->cell_col == col) + return opt; + } + + fort_cell_props_t opt; + if (row == FT_ANY_ROW && col == FT_ANY_COLUMN) + memcpy(&opt, &g_default_cell_properties, sizeof(fort_cell_props_t)); + else + memset(&opt, 0, sizeof(fort_cell_props_t)); + + opt.cell_row = row; + opt.cell_col = col; + if (FT_IS_SUCCESS(vector_push(cont, &opt))) { + return (fort_cell_props_t *)vector_at(cont, sz); + } + + return NULL; +} + + +FT_INTERNAL +int get_cell_property_value_hierarcial(const fort_table_properties_t *propertiess, size_t row, size_t column, uint32_t property) +{ + assert(propertiess); + size_t row_origin = row; + + const fort_cell_props_t *opt = NULL; + if (propertiess->cell_properties != NULL) { + while (1) { + opt = cget_cell_prop(propertiess->cell_properties, row, column); + if (opt != NULL && PROP_IS_SET(opt->properties_flags, property)) + break; + + if (row != FT_ANY_ROW && column != FT_ANY_COLUMN) { + row = FT_ANY_ROW; + continue; + } else if (row == FT_ANY_ROW && column != FT_ANY_COLUMN) { + row = row_origin; + column = FT_ANY_COLUMN; + continue; + } else if (row != FT_ANY_ROW && column == FT_ANY_COLUMN) { + row = FT_ANY_ROW; + column = FT_ANY_COLUMN; + continue; + } + + opt = NULL; + break; + } + } + + return get_prop_value_if_exists_otherwise_default(opt, property); +} + + +static fort_status_t set_cell_property_impl(fort_cell_props_t *opt, uint32_t property, int value) +{ + assert(opt); + + PROP_SET(opt->properties_flags, property); + if (PROP_IS_SET(property, FT_CPROP_MIN_WIDTH)) { + CHECK_NOT_NEGATIVE(value); + opt->col_min_width = value; + } else if (PROP_IS_SET(property, FT_CPROP_TEXT_ALIGN)) { + opt->align = (enum ft_text_alignment)value; + } else if (PROP_IS_SET(property, FT_CPROP_TOP_PADDING)) { + CHECK_NOT_NEGATIVE(value); + opt->cell_padding_top = value; + } else if (PROP_IS_SET(property, FT_CPROP_BOTTOM_PADDING)) { + CHECK_NOT_NEGATIVE(value); + opt->cell_padding_bottom = value; + } else if (PROP_IS_SET(property, FT_CPROP_LEFT_PADDING)) { + CHECK_NOT_NEGATIVE(value); + opt->cell_padding_left = value; + } else if (PROP_IS_SET(property, FT_CPROP_RIGHT_PADDING)) { + CHECK_NOT_NEGATIVE(value); + opt->cell_padding_right = value; + } else if (PROP_IS_SET(property, FT_CPROP_EMPTY_STR_HEIGHT)) { + CHECK_NOT_NEGATIVE(value); + opt->cell_empty_string_height = value; + } else if (PROP_IS_SET(property, FT_CPROP_ROW_TYPE)) { + opt->row_type = (enum ft_row_type)value; + } else if (PROP_IS_SET(property, FT_CPROP_CONT_FG_COLOR)) { + opt->content_fg_color_number = value; + } else if (PROP_IS_SET(property, FT_CPROP_CONT_BG_COLOR)) { + opt->content_bg_color_number = value; + } else if (PROP_IS_SET(property, FT_CPROP_CELL_BG_COLOR)) { + opt->cell_bg_color_number = value; + } else if (PROP_IS_SET(property, FT_CPROP_CELL_TEXT_STYLE)) { + enum ft_text_style v = (enum ft_text_style)value; + if (v == FT_TSTYLE_DEFAULT) { + opt->cell_text_style = FT_TSTYLE_DEFAULT; + } else { + opt->cell_text_style = (enum ft_text_style)(opt->cell_text_style | v); + } + } else if (PROP_IS_SET(property, FT_CPROP_CONT_TEXT_STYLE)) { + enum ft_text_style v = (enum ft_text_style)value; + if (v == FT_TSTYLE_DEFAULT) { + opt->content_text_style = v; + } else { + opt->content_text_style = (enum ft_text_style)(opt->content_text_style | v); + } + } + + return FT_SUCCESS; + +fort_fail: + return FT_EINVAL; +} + + +FT_INTERNAL +fort_status_t set_cell_property(fort_cell_prop_container_t *cont, size_t row, size_t col, uint32_t property, int value) +{ + fort_cell_props_t *opt = get_cell_prop_and_create_if_not_exists(cont, row, col); + if (opt == NULL) + return FT_ERROR; + + return set_cell_property_impl(opt, property, value); + /* + PROP_SET(opt->propertiess, property); + if (PROP_IS_SET(property, FT_CPROP_MIN_WIDTH)) { + opt->col_min_width = value; + } else if (PROP_IS_SET(property, FT_CPROP_TEXT_ALIGN)) { + opt->align = value; + } + + return FT_SUCCESS; + */ +} + + +FT_INTERNAL +fort_status_t set_default_cell_property(uint32_t property, int value) +{ + return set_cell_property_impl(&g_default_cell_properties, property, value); +} + + +#define BASIC_STYLE { \ + /* border_chars */ \ + { \ + "+", "-", "+", "+", \ + "|", "|", "|", \ + "\0", "\0", "\0", "\0", \ + "+", "-", "+", "+", \ + "+", "+", "+", "+", \ + }, \ + /* header_border_chars */ \ + { \ + "+", "-", "+", "+", \ + "|", "|", "|", \ + "+", "-", "+", "+", \ + "+", "-", "+", "+", \ + "+", "+", "+", "+", \ + }, \ + /* separator_chars */ \ + { \ + "+", "-", "+", "+", \ + "+", "+", \ + }, \ +} + +#define BASIC2_STYLE { \ + /* border_chars */ \ + { \ + "+", "-", "+", "+", \ + "|", "|", "|", \ + "+", "-", "+", "+", \ + "+", "-", "+", "+", \ + "+", "+", "+", "+", \ + }, \ + /* header_border_chars */ \ + { \ + "+", "-", "+", "+", \ + "|", "|", "|", \ + "+", "-", "+", "+", \ + "+", "-", "+", "+", \ + "+", "+", "+", "+", \ + }, \ + /* separator_chars */ \ + { \ + "+", "-", "+", "+", \ + "+", "+", \ + }, \ +} + +#define SIMPLE_STYLE { \ + /* border_chars */ \ + { \ + " ", " ", " ", " ", \ + " ", " ", " ", \ + "\0", "\0", "\0", "\0", \ + " ", " ", " ", " ", \ + " ", " ", " ", " ", \ + }, \ + /* header_border_chars */ \ + { \ + " ", " ", " ", " ", \ + " ", " ", " ", \ + " ", "-", " ", " ", \ + " ", " ", " ", " ", \ + " ", "-", " ", "-", \ + }, \ + /* separator_chars */ \ + { \ + " ", "-", " ", " ", \ + " ", " ", \ + }, \ +} + +#define PLAIN_STYLE { \ + /* border_chars */ \ + { \ + " ", " ", " ", " ", \ + " ", " ", " ", \ + "\0", "\0", "\0", "\0", \ + " ", " ", " ", " ", \ + " ", " ", " ", " ", \ + }, \ + /* header_border_chars */ \ + { \ + " ", "-", "-", " ", \ + " ", " ", " ", \ + " ", "-", "-", " ", \ + " ", "-", "-", " ", \ + " ", "-", " ", "-", \ + }, \ + /* separator_chars */ \ + { \ + " ", "-", "-", " ", \ + "-", "-", \ + }, \ +} + +#define DOT_STYLE { \ + /* border_chars */ \ + { \ + ".", ".", ".", ".", \ + ":", ":", ":", \ + "\0", "\0", "\0", "\0", \ + ":", ".", ":", ":", \ + "+", ":", "+", ":", \ + }, \ + /* header_border_chars */ \ + { \ + ".", ".", ".", ".", \ + ":", ":", ":", \ + ":", ".", ":", ":", \ + ":", ".", ":", ":", \ + "+", ".", "+", ".", \ + }, \ + /* separator_chars */ \ + { \ + ":", ".", ":", ":", \ + ":", ":", \ + }, \ +} + +#define EMPTY_STYLE { \ + /* border_chars */ \ + { \ + "\0", "\0", "\0", "\0", \ + "\0", "\0", "\0", \ + "\0", "\0", "\0", "\0", \ + "\0", "\0", "\0", "\0", \ + "\0", "\0", "\0", "\0", \ + }, \ + /* header_border_chars */ \ + { \ + "\0", "\0", "\0", "\0", \ + "\0", "\0", "\0", \ + "\0", "\0", "\0", "\0", \ + "\0", "\0", "\0", "\0", \ + "\0", "\0", "\0", "\0", \ + }, \ + /* separator_chars */ \ + { \ + "\0", " ", "\0 ", "\0", \ + "\0", "\0", \ + }, \ +} + + +#define EMPTY2_STYLE { \ + /* border_chars */ \ + { \ + " ", " ", " ", " ", \ + " ", " ", " ", \ + "\0", "\0", "\0", "\0", \ + " ", " ", " ", " ", \ + " ", " ", " ", " ", \ + }, \ + /* header_border_chars */ \ + { \ + " ", " ", " ", " ", \ + " ", " ", " ", \ + "\0", "\0", "\0", "\0", \ + " ", " ", " ", " ", \ + " ", " ", " ", " ", \ + }, \ + /* separator_chars */ \ + { \ + " ", " ", " ", " ", \ + " ", " ", \ + }, \ +} + +#define SOLID_STYLE { \ + /* border_chars */ \ + { \ + "┌", "─", "┬", "┐", \ + "│", "│", "│", \ + "", "", "", "", \ + "└", "─", "┴", "╯", \ + "│", "─", "│", "─", \ + }, \ + /* header_border_chars */ \ + { \ + "┌", "─", "┬", "┐", \ + "│", "│", "│", \ + "├", "─", "┼", "┤", \ + "└", "─", "┴", "┘", \ + "┼", "┬", "┼", "┴", \ + }, \ + /* separator_chars */ \ + { \ + "├", "─", "┼", "┤", \ + "┬", "┴", \ + }, \ +} + +#define SOLID_ROUND_STYLE { \ + /* border_chars */ \ + { \ + "╭", "─", "┬", "╮", \ + "│", "│", "│", \ + "", "", "", "", \ + "╰", "─", "┴", "╯", \ + "│", "─", "│", "─", \ + }, \ + /* header_border_chars */ \ + { \ + "╭", "─", "┬", "╮", \ + "│", "│", "│", \ + "├", "─", "┼", "┤", \ + "╰", "─", "┴", "╯", \ + "┼", "┬", "┼", "┴", \ + }, \ + /* separator_chars */ \ + { \ + "├", "─", "┼", "┤", \ + "┬", "┴", \ + }, \ +} + +#define NICE_STYLE { \ + /* border_chars */ \ + { \ + "╔", "═", "╦", "╗", \ + "║", "║", "║", \ + "", "", "", "", \ + "╚", "═", "╩", "╝", \ + "┣", "┻", "┣", "┳", \ + }, \ + /* header_border_chars */ \ + { \ + "╔", "═", "╦", "╗", \ + "║", "║", "║", \ + "╠", "═", "╬", "╣", \ + "╚", "═", "╩", "╝", \ + "┣", "╦", "┣", "╩", \ + }, \ + /* separator_chars */ \ + { \ + "╟", "─", "╫", "╢", \ + "╥", "╨", \ + }, \ +} + +#define DOUBLE_STYLE { \ + /* border_chars */ \ + { \ + "╔", "═", "╦", "╗", \ + "║", "║", "║", \ + "", "", "", "", \ + "╚", "═", "╩", "╝", \ + "┣", "┻", "┣", "┳", \ + }, \ + /* header_border_chars */ \ + { \ + "╔", "═", "╦", "╗", \ + "║", "║", "║", \ + "╠", "═", "╬", "╣", \ + "╚", "═", "╩", "╝", \ + "┣", "╦", "┣", "╩", \ + }, \ + /* separator_chars */ \ + { \ + "╠", "═", "╬", "╣", \ + "╦", "╩", \ + }, \ +} + + + + +#define DOUBLE2_STYLE { \ + /* border_chars */ \ + { \ + "╔", "═", "╤", "╗", \ + "║", "│", "║", \ + "╟", "─", "┼", "╢", \ + "╚", "═", "╧", "╝", \ + "├", "┬", "┤", "┴", \ + }, \ + /* header_border_chars */ \ + { \ + "╔", "═", "╤", "╗", \ + "║", "│", "║", \ + "╠", "═", "╪", "╣", \ + "╚", "═", "╧", "╝", \ + "├", "╤", "┤", "╧", \ + }, \ + /* separator_chars */ \ + { \ + "╠", "═", "╪", "╣", \ + "╤", "╧", \ + }, \ +} + + +#define BOLD_STYLE { \ + /* border_chars */ \ + { \ + "┏", "━", "┳", "┓", \ + "┃", "┃", "┃", \ + "", "", "", "", \ + "┗", "━", "┻", "┛", \ + "┣", "┻", "┣", "┳", \ + }, \ + /* header_border_chars */ \ + { \ + "┏", "━", "┳", "┓", \ + "┃", "┃", "┃", \ + "┣", "━", "╋", "┫", \ + "┗", "━", "┻", "┛", \ + "┣", "┳", "┣", "┻", \ + }, \ + /* separator_chars */ \ + { \ + "┣", "━", "╋", "┫", \ + "┳", "┻", \ + }, \ +} + +#define BOLD2_STYLE { \ + /* border_chars */ \ + { \ + "┏", "━", "┯", "┓", \ + "┃", "│", "┃", \ + "┠", "─", "┼", "┨", \ + "┗", "━", "┷", "┛", \ + "┣", "┬", "┣", "┴", \ + }, \ + /* header_border_chars */ \ + { \ + "┏", "━", "┯", "┓", \ + "┃", "│", "┃", \ + "┣", "━", "┿", "┫", \ + "┗", "━", "┷", "┛", \ + "┣", "┯", "┣", "┷", \ + }, \ + /* separator_chars */ \ + { \ + "┣", "━", "┿", "┫", \ + "┯", "┷", \ + }, \ +} + +#define FRAME_STYLE { \ + /* border_chars */ \ + { \ + "▛", "▀", "▀", "▜", \ + "▌", "┃", "▐", \ + "", "", "", "", \ + "▙", "▄", "▄", "▟", \ + "┣", "━", "┣", "━" \ + }, \ + /* header_border_chars */ \ + { \ + "▛", "▀", "▀", "▜", \ + "▌", "┃", "▐", \ + "▌", "━", "╋", "▐", \ + "▙", "▄", "▄", "▟", \ + "┣", "━", "┣", "━", \ + }, \ + /* separator_chars */ \ + { \ + "▌", "━", "╋", "▐", \ + "╋", "╋", \ + }, \ +} + + +struct fort_border_style FORT_BASIC_STYLE = BASIC_STYLE; +struct fort_border_style FORT_BASIC2_STYLE = BASIC2_STYLE; +struct fort_border_style FORT_SIMPLE_STYLE = SIMPLE_STYLE; +struct fort_border_style FORT_PLAIN_STYLE = PLAIN_STYLE; +struct fort_border_style FORT_DOT_STYLE = DOT_STYLE; +struct fort_border_style FORT_EMPTY_STYLE = EMPTY_STYLE; +struct fort_border_style FORT_EMPTY2_STYLE = EMPTY2_STYLE; +struct fort_border_style FORT_SOLID_STYLE = SOLID_STYLE; +struct fort_border_style FORT_SOLID_ROUND_STYLE = SOLID_ROUND_STYLE; +struct fort_border_style FORT_NICE_STYLE = NICE_STYLE; +struct fort_border_style FORT_DOUBLE_STYLE = DOUBLE_STYLE; +struct fort_border_style FORT_DOUBLE2_STYLE = DOUBLE2_STYLE; +struct fort_border_style FORT_BOLD_STYLE = BOLD_STYLE; +struct fort_border_style FORT_BOLD2_STYLE = BOLD2_STYLE; +struct fort_border_style FORT_FRAME_STYLE = FRAME_STYLE; + + + +fort_entire_table_properties_t g_entire_table_properties = { + 0, /* left_margin */ + 0, /* top_margin */ + 0, /* right_margin */ + 0, /* bottom_margin */ +}; + +static fort_status_t set_entire_table_property_internal(fort_entire_table_properties_t *properties, uint32_t property, int value) +{ + assert(properties); + CHECK_NOT_NEGATIVE(value); + if (PROP_IS_SET(property, FT_TPROP_LEFT_MARGIN)) { + properties->left_margin = value; + } else if (PROP_IS_SET(property, FT_TPROP_TOP_MARGIN)) { + properties->top_margin = value; + } else if (PROP_IS_SET(property, FT_TPROP_RIGHT_MARGIN)) { + properties->right_margin = value; + } else if (PROP_IS_SET(property, FT_TPROP_BOTTOM_MARGIN)) { + properties->bottom_margin = value; + } else { + return FT_EINVAL; + } + return FT_SUCCESS; + +fort_fail: + return FT_EINVAL; +} + + +FT_INTERNAL +fort_status_t set_entire_table_property(fort_table_properties_t *table_properties, uint32_t property, int value) +{ + assert(table_properties); + return set_entire_table_property_internal(&table_properties->entire_table_properties, property, value); +} + + +FT_INTERNAL +fort_status_t set_default_entire_table_property(uint32_t property, int value) +{ + return set_entire_table_property_internal(&g_entire_table_properties, property, value); +} + + +FT_INTERNAL +size_t max_border_elem_strlen(struct fort_table_properties *properties) +{ + assert(properties); + size_t result = 1; + int i = 0; + for (i = 0; i < BorderItemPosSize; ++i) { + result = MAX(result, strlen(properties->border_style.border_chars[i])); + } + + for (i = 0; i < BorderItemPosSize; ++i) { + result = MAX(result, strlen(properties->border_style.header_border_chars[i])); + } + + for (i = 0; i < SepratorItemPosSize; ++i) { + result = MAX(result, strlen(properties->border_style.separator_chars[i])); + } + return result; +} + + +fort_table_properties_t g_table_properties = { + /* border_style */ + BASIC_STYLE, + NULL, /* cell_properties */ + /* entire_table_properties */ + { + 0, /* left_margin */ + 0, /* top_margin */ + 0, /* right_margin */ + 0 /* bottom_margin */ + } +}; + + +FT_INTERNAL +fort_table_properties_t *create_table_properties(void) +{ + fort_table_properties_t *properties = (fort_table_properties_t *)F_CALLOC(sizeof(fort_table_properties_t), 1); + if (properties == NULL) { + return NULL; + } + memcpy(properties, &g_table_properties, sizeof(fort_table_properties_t)); + properties->cell_properties = create_cell_prop_container(); + if (properties->cell_properties == NULL) { + destroy_table_properties(properties); + return NULL; + } + memcpy(&properties->entire_table_properties, &g_entire_table_properties, sizeof(fort_entire_table_properties_t)); + return properties; +} + +FT_INTERNAL +void destroy_table_properties(fort_table_properties_t *properties) +{ + if (properties == NULL) + return; + + if (properties->cell_properties != NULL) { + destroy_cell_prop_container(properties->cell_properties); + } + F_FREE(properties); +} + +static +fort_cell_prop_container_t *copy_cell_properties(fort_cell_prop_container_t *cont) +{ + fort_cell_prop_container_t *result = create_cell_prop_container(); + if (result == NULL) + return NULL; + + size_t i = 0; + size_t sz = vector_size(cont); + for (i = 0; i < sz; ++i) { + fort_cell_props_t *opt = (fort_cell_props_t *)vector_at(cont, i); + if (FT_IS_ERROR(vector_push(result, opt))) { + destroy_cell_prop_container(result); + return NULL; + } + } + return result; +} + +FT_INTERNAL +fort_table_properties_t *copy_table_properties(const fort_table_properties_t *properties) +{ + fort_table_properties_t *new_opt = create_table_properties(); + if (new_opt == NULL) + return NULL; + + destroy_vector(new_opt->cell_properties); + new_opt->cell_properties = copy_cell_properties(properties->cell_properties); + if (new_opt->cell_properties == NULL) { + destroy_table_properties(new_opt); + return NULL; + } + + memcpy(&new_opt->border_style, &properties->border_style, sizeof(struct fort_border_style)); + memcpy(&new_opt->entire_table_properties, + &properties->entire_table_properties, sizeof(fort_entire_table_properties_t)); + + return new_opt; +} + +/******************************************************** + End of file "properties.c" + ********************************************************/ + + +/******************************************************** + Begin of file "row.c" + ********************************************************/ + +#include +#include +/* #include "row.h" */ /* Commented by amalgamation script */ +/* #include "cell.h" */ /* Commented by amalgamation script */ +/* #include "string_buffer.h" */ /* Commented by amalgamation script */ +/* #include "vector.h" */ /* Commented by amalgamation script */ + + +struct fort_row { + vector_t *cells; + /*enum ft_row_type type;*/ +}; + + +FT_INTERNAL +fort_row_t *create_row(void) +{ + fort_row_t *row = (fort_row_t *)F_CALLOC(sizeof(fort_row_t), 1); + if (row == NULL) + return NULL; + row->cells = create_vector(sizeof(fort_cell_t *), DEFAULT_VECTOR_CAPACITY); + if (row->cells == NULL) { + F_FREE(row); + return NULL; + } + + /* + row->is_header = F_FALSE; + row->type = FT_ROW_COMMON; + */ + return row; +} + +FT_INTERNAL +void destroy_row(fort_row_t *row) +{ + if (row == NULL) + return; + + if (row->cells) { + size_t i = 0; + size_t cells_n = vector_size(row->cells); + for (i = 0; i < cells_n; ++i) { + fort_cell_t *cell = *(fort_cell_t **)vector_at(row->cells, i); + destroy_cell(cell); + } + destroy_vector(row->cells); + } + + F_FREE(row); +} + +FT_INTERNAL +fort_row_t *copy_row(fort_row_t *row) +{ + assert(row); + fort_row_t *result = create_row(); + if (result == NULL) + return NULL; + + size_t i = 0; + size_t cols_n = vector_size(row->cells); + for (i = 0; i < cols_n; ++i) { + fort_cell_t *cell = *(fort_cell_t **)vector_at(row->cells, i); + fort_cell_t *new_cell = copy_cell(cell); + if (new_cell == NULL) { + destroy_row(result); + return NULL; + } + vector_push(result->cells, &new_cell); + } + + return result; +} + +FT_INTERNAL +size_t columns_in_row(const fort_row_t *row) +{ + if (row == NULL || row->cells == NULL) + return 0; + + return vector_size(row->cells); +} + + +static +fort_cell_t *get_cell_implementation(fort_row_t *row, size_t col, enum PolicyOnNull policy) +{ + if (row == NULL || row->cells == NULL) { + return NULL; + } + + switch (policy) { + case DoNotCreate: + if (col < columns_in_row(row)) { + return *(fort_cell_t **)vector_at(row->cells, col); + } + return NULL; + case Create: + while (col >= columns_in_row(row)) { + fort_cell_t *new_cell = create_cell(); + if (new_cell == NULL) + return NULL; + if (FT_IS_ERROR(vector_push(row->cells, &new_cell))) { + destroy_cell(new_cell); + return NULL; + } + } + return *(fort_cell_t **)vector_at(row->cells, col); + } + + assert(0 && "Shouldn't be here!"); + return NULL; +} + + +FT_INTERNAL +fort_cell_t *get_cell(fort_row_t *row, size_t col) +{ + return get_cell_implementation(row, col, DoNotCreate); +} + + +FT_INTERNAL +const fort_cell_t *get_cell_c(const fort_row_t *row, size_t col) +{ + return get_cell((fort_row_t *)row, col); +} + + +FT_INTERNAL +fort_cell_t *get_cell_and_create_if_not_exists(fort_row_t *row, size_t col) +{ + return get_cell_implementation(row, col, Create); +} + + +FT_INTERNAL +fort_status_t swap_row(fort_row_t *cur_row, fort_row_t *ins_row, size_t pos) +{ + assert(cur_row); + assert(ins_row); + size_t cur_sz = vector_size(cur_row->cells); + if (cur_sz == 0 && pos == 0) { + fort_row_t tmp; + memcpy(&tmp, cur_row, sizeof(fort_row_t)); + memcpy(cur_row, ins_row, sizeof(fort_row_t)); + memcpy(ins_row, &tmp, sizeof(fort_row_t)); + return FT_SUCCESS; + } + + return vector_swap(cur_row->cells, ins_row->cells, pos); +} + + +FT_INTERNAL +size_t group_cell_number(const fort_row_t *row, size_t master_cell_col) +{ + assert(row); + const fort_cell_t *master_cell = get_cell_c(row, master_cell_col); + if (master_cell == NULL) + return 0; + + if (get_cell_type(master_cell) != GroupMasterCell) + return 1; + + size_t total_cols = vector_size(row->cells); + size_t slave_col = master_cell_col + 1; + while (slave_col < total_cols) { + const fort_cell_t *cell = get_cell_c(row, slave_col); + if (cell && get_cell_type(cell) == GroupSlaveCell) { + ++slave_col; + } else { + break; + } + } + return slave_col - master_cell_col; +} + + +FT_INTERNAL +int get_row_cell_types(const fort_row_t *row, enum CellType *types, size_t types_sz) +{ + assert(row); + assert(types); + size_t i = 0; + for (i = 0; i < types_sz; ++i) { + const fort_cell_t *cell = get_cell_c(row, i); + if (cell) { + types[i] = get_cell_type(cell); + } else { + types[i] = CommonCell; + } + } + return FT_SUCCESS; +} + + +FT_INTERNAL +fort_status_t row_set_cell_span(fort_row_t *row, size_t cell_column, size_t hor_span) +{ + assert(row); + + if (hor_span < 2) + return FT_EINVAL; + + fort_cell_t *main_cell = get_cell_and_create_if_not_exists(row, cell_column); + if (main_cell == NULL) { + return FT_ERROR; + } + set_cell_type(main_cell, GroupMasterCell); + --hor_span; + ++cell_column; + + while (hor_span) { + fort_cell_t *slave_cell = get_cell_and_create_if_not_exists(row, cell_column); + if (slave_cell == NULL) { + return FT_ERROR; + } + set_cell_type(slave_cell, GroupSlaveCell); + --hor_span; + ++cell_column; + } + + return FT_SUCCESS; +} + + +FT_INTERNAL +int print_row_separator(char *buffer, size_t buffer_sz, + const size_t *col_width_arr, size_t cols, + const fort_row_t *upper_row, const fort_row_t *lower_row, + enum HorSeparatorPos separatorPos, + const separator_t *sep, const context_t *context) +{ + int (*snprint_n_strings_)(char *, size_t, size_t, const char *) = snprint_n_strings; + + assert(buffer); + assert(context); + + const char *space_char = " "; + int status = -1; + + /* Get cell types + * + * Regions above top row and below bottom row areconsidered full of virtual + * GroupSlaveCell cells + */ + enum CellType *top_row_types = (enum CellType *)F_MALLOC(sizeof(enum CellType) * cols * 2); + if (top_row_types == NULL) { + return FT_MEMORY_ERROR; + } + enum CellType *bottom_row_types = top_row_types + cols; + if (upper_row) { + get_row_cell_types(upper_row, top_row_types, cols); + } else { + size_t i = 0; + for (i = 0; i < cols; ++i) + top_row_types[i] = GroupSlaveCell; + } + if (lower_row) { + get_row_cell_types(lower_row, bottom_row_types, cols); + } else { + size_t i = 0; + for (i = 0; i < cols; ++i) + bottom_row_types[i] = GroupSlaveCell; + } + + + size_t written = 0; + int tmp = 0; + + enum ft_row_type lower_row_type = FT_ROW_COMMON; + if (lower_row != NULL) { + lower_row_type = (enum ft_row_type)get_cell_property_value_hierarcial(context->table_properties, context->row, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE); + } + enum ft_row_type upper_row_type = FT_ROW_COMMON; + if (upper_row != NULL) { + upper_row_type = (enum ft_row_type)get_cell_property_value_hierarcial(context->table_properties, context->row - 1, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE); + } + + /* Row separator anatomy + * + * | C11 | C12 C13 | C14 C15 | + * L I I I IV I I IT I I I IB I I II I I R + * | C21 | C22 | C23 C24 C25 | + */ + const char **L = NULL; + const char **I = NULL; + const char **IV = NULL; + const char **R = NULL; + const char **IT = NULL; + const char **IB = NULL; + const char **II = NULL; + + + typedef const char *(*border_chars_point_t)[BorderItemPosSize]; + const char *(*border_chars)[BorderItemPosSize] = NULL; + border_chars = (border_chars_point_t)&context->table_properties->border_style.border_chars; + if (upper_row_type == FT_ROW_HEADER || lower_row_type == FT_ROW_HEADER) { + border_chars = (border_chars_point_t)&context->table_properties->border_style.header_border_chars; + } + + if (sep && sep->enabled) { + L = &(context->table_properties->border_style.separator_chars[LH_sip]); + I = &(context->table_properties->border_style.separator_chars[IH_sip]); + IV = &(context->table_properties->border_style.separator_chars[II_sip]); + R = &(context->table_properties->border_style.separator_chars[RH_sip]); + + IT = &(context->table_properties->border_style.separator_chars[TI_sip]); + IB = &(context->table_properties->border_style.separator_chars[BI_sip]); + II = &(context->table_properties->border_style.separator_chars[IH_sip]); + + if (lower_row == NULL) { + L = &(*border_chars)[BL_bip]; + R = &(*border_chars)[BR_bip]; + } else if (upper_row == NULL) { + L = &(*border_chars)[TL_bip]; + R = &(*border_chars)[TR_bip]; + } + } else { + switch (separatorPos) { + case TopSeparator: + L = &(*border_chars)[TL_bip]; + I = &(*border_chars)[TT_bip]; + IV = &(*border_chars)[TV_bip]; + R = &(*border_chars)[TR_bip]; + + IT = &(*border_chars)[TV_bip]; + IB = &(*border_chars)[TV_bip]; + II = &(*border_chars)[TT_bip]; + break; + case InsideSeparator: + L = &(*border_chars)[LH_bip]; + I = &(*border_chars)[IH_bip]; + IV = &(*border_chars)[II_bip]; + R = &(*border_chars)[RH_bip]; + + /* + IT = &(*border_chars)[TV_bip]; + IB = &(*border_chars)[BV_bip]; + */ + IT = &(*border_chars)[TI_bip]; + IB = &(*border_chars)[BI_bip]; + II = &(*border_chars)[IH_bip]; + break; + case BottomSeparator: + L = &(*border_chars)[BL_bip]; + I = &(*border_chars)[BB_bip]; + IV = &(*border_chars)[BV_bip]; + R = &(*border_chars)[BR_bip]; + + IT = &(*border_chars)[BV_bip]; + IB = &(*border_chars)[BV_bip]; + II = &(*border_chars)[BB_bip]; + break; + default: + break; + } + } + + size_t i = 0; + + /* If all chars are not printable, skip line separator */ + /* todo: add processing for wchar_t */ + /* + if (!isprint(*L) && !isprint(*I) && !isprint(*IV) && !isprint(*R)) { + status = 0; + goto clear; + } + */ + if ((strlen(*L) == 0 || (strlen(*L) == 1 && !isprint(**L))) + && (strlen(*I) == 0 || (strlen(*I) == 1 && !isprint(**I))) + && (strlen(*IV) == 0 || (strlen(*IV) == 1 && !isprint(**IV))) + && (strlen(*R) == 0 || (strlen(*R) == 1 && !isprint(**R)))) { + status = 0; + goto clear; + } + + /* Print left margin */ + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, context->table_properties->entire_table_properties.left_margin, space_char)); + + for (i = 0; i < cols; ++i) { + if (i == 0) { + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, 1, *L)); + } else { + if ((top_row_types[i] == CommonCell || top_row_types[i] == GroupMasterCell) + && (bottom_row_types[i] == CommonCell || bottom_row_types[i] == GroupMasterCell)) { + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, 1, *IV)); + } else if (top_row_types[i] == GroupSlaveCell && bottom_row_types[i] == GroupSlaveCell) { + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, 1, *II)); + } else if (top_row_types[i] == GroupSlaveCell) { + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, 1, *IT)); + } else { + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, 1, *IB)); + } + } + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, col_width_arr[i], *I)); + } + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, 1, *R)); + + /* Print right margin */ + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, context->table_properties->entire_table_properties.right_margin, space_char)); + + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, 1, "\n")); + + status = (int)written; + +clear: + F_FREE(top_row_types); + return status; +} + + +#ifdef FT_HAVE_WCHAR +FT_INTERNAL +int wprint_row_separator(wchar_t *buffer, size_t buffer_sz, + const size_t *col_width_arr, size_t cols, + const fort_row_t *upper_row, const fort_row_t *lower_row, + enum HorSeparatorPos separatorPos, const separator_t *sep, + const context_t *context) +{ + int (*snprint_n_strings_)(wchar_t *, size_t, size_t, const char *) = wsnprint_n_string; + + assert(buffer); + assert(context); + + const char *space_char = " "; + int status = -1; + + /* Get cell types + * + * Regions above top row and below bottom row areconsidered full of virtual + * GroupSlaveCell cells + */ + enum CellType *top_row_types = (enum CellType *)F_MALLOC(sizeof(enum CellType) * cols * 2); + if (top_row_types == NULL) { + return FT_MEMORY_ERROR; + } + enum CellType *bottom_row_types = top_row_types + cols; + if (upper_row) { + get_row_cell_types(upper_row, top_row_types, cols); + } else { + size_t i = 0; + for (i = 0; i < cols; ++i) + top_row_types[i] = GroupSlaveCell; + } + if (lower_row) { + get_row_cell_types(lower_row, bottom_row_types, cols); + } else { + size_t i = 0; + for (i = 0; i < cols; ++i) + bottom_row_types[i] = GroupSlaveCell; + } + + + size_t written = 0; + int tmp = 0; + + enum ft_row_type lower_row_type = FT_ROW_COMMON; + if (lower_row != NULL) { + lower_row_type = (enum ft_row_type)get_cell_property_value_hierarcial(context->table_properties, context->row, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE); + } + enum ft_row_type upper_row_type = FT_ROW_COMMON; + if (upper_row != NULL) { + upper_row_type = (enum ft_row_type)get_cell_property_value_hierarcial(context->table_properties, context->row - 1, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE); + } + + /* Row separator anatomy + * + * | C11 | C12 C13 | C14 C15 | + * L I I I IV I I IT I I I IB I I II I I R + * | C21 | C22 | C23 C24 C25 | + */ + const char **L = NULL; + const char **I = NULL; + const char **IV = NULL; + const char **R = NULL; + const char **IT = NULL; + const char **IB = NULL; + const char **II = NULL; + + + typedef const char *(*border_chars_point_t)[BorderItemPosSize]; + const char *(*border_chars)[BorderItemPosSize] = NULL; + border_chars = (border_chars_point_t)&context->table_properties->border_style.border_chars; + if (upper_row_type == FT_ROW_HEADER || lower_row_type == FT_ROW_HEADER) { + border_chars = (border_chars_point_t)&context->table_properties->border_style.header_border_chars; + } + + if (sep && sep->enabled) { + L = &(context->table_properties->border_style.separator_chars[LH_sip]); + I = &(context->table_properties->border_style.separator_chars[IH_sip]); + IV = &(context->table_properties->border_style.separator_chars[II_sip]); + R = &(context->table_properties->border_style.separator_chars[RH_sip]); + + IT = &(context->table_properties->border_style.separator_chars[TI_sip]); + IB = &(context->table_properties->border_style.separator_chars[BI_sip]); + II = &(context->table_properties->border_style.separator_chars[IH_sip]); + + if (lower_row == NULL) { + L = &(*border_chars)[BL_bip]; + R = &(*border_chars)[BR_bip]; + } else if (upper_row == NULL) { + L = &(*border_chars)[TL_bip]; + R = &(*border_chars)[TR_bip]; + } + } else { + switch (separatorPos) { + case TopSeparator: + L = &(*border_chars)[TL_bip]; + I = &(*border_chars)[TT_bip]; + IV = &(*border_chars)[TV_bip]; + R = &(*border_chars)[TR_bip]; + + IT = &(*border_chars)[TV_bip]; + IB = &(*border_chars)[TV_bip]; + II = &(*border_chars)[TT_bip]; + break; + case InsideSeparator: + L = &(*border_chars)[LH_bip]; + I = &(*border_chars)[IH_bip]; + IV = &(*border_chars)[II_bip]; + R = &(*border_chars)[RH_bip]; + + /* + IT = &(*border_chars)[TV_bip]; + IB = &(*border_chars)[BV_bip]; + */ + IT = &(*border_chars)[TI_bip]; + IB = &(*border_chars)[BI_bip]; + II = &(*border_chars)[IH_bip]; + break; + case BottomSeparator: + L = &(*border_chars)[BL_bip]; + I = &(*border_chars)[BB_bip]; + IV = &(*border_chars)[BV_bip]; + R = &(*border_chars)[BR_bip]; + + IT = &(*border_chars)[BV_bip]; + IB = &(*border_chars)[BV_bip]; + II = &(*border_chars)[BB_bip]; + break; + default: + break; + } + } + + size_t i = 0; + + /* If all chars are not printable, skip line separator */ + /* todo: add processing for wchar_t */ + /* + if (!isprint(*L) && !isprint(*I) && !isprint(*IV) && !isprint(*R)) { + status = 0; + goto clear; + } + */ + if ((strlen(*L) == 0 || (strlen(*L) == 1 && !isprint(**L))) + && (strlen(*I) == 0 || (strlen(*I) == 1 && !isprint(**I))) + && (strlen(*IV) == 0 || (strlen(*IV) == 1 && !isprint(**IV))) + && (strlen(*R) == 0 || (strlen(*R) == 1 && !isprint(**R)))) { + status = 0; + goto clear; + } + + /* Print left margin */ + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, context->table_properties->entire_table_properties.left_margin, space_char)); + + for (i = 0; i < cols; ++i) { + if (i == 0) { + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, 1, *L)); + } else { + if ((top_row_types[i] == CommonCell || top_row_types[i] == GroupMasterCell) + && (bottom_row_types[i] == CommonCell || bottom_row_types[i] == GroupMasterCell)) { + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, 1, *IV)); + } else if (top_row_types[i] == GroupSlaveCell && bottom_row_types[i] == GroupSlaveCell) { + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, 1, *II)); + } else if (top_row_types[i] == GroupSlaveCell) { + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, 1, *IT)); + } else { + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, 1, *IB)); + } + } + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, col_width_arr[i], *I)); + } + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, 1, *R)); + + /* Print right margin */ + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, context->table_properties->entire_table_properties.right_margin, space_char)); + + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buffer_sz - written, 1, "\n")); + + status = (int)written; + +clear: + F_FREE(top_row_types); + return status; +} + +#endif + +FT_INTERNAL +fort_row_t *create_row_from_string(const char *str) +{ + typedef char char_type; + char_type *(*strdup_)(const char_type * str) = F_STRDUP; + const char_type zero_char = '\0'; + fort_status_t (*fill_cell_from_string_)(fort_cell_t *cell, const char *str) = fill_cell_from_string; + const char_type *const zero_string = ""; +#define STRCHR strchr + + char_type *pos = NULL; + char_type *base_pos = NULL; + size_t number_of_separators = 0; + + fort_row_t *row = create_row(); + if (row == NULL) + return NULL; + + if (str == NULL) + return row; + + char_type *str_copy = strdup_(str); + if (str_copy == NULL) + goto clear; + + pos = str_copy; + base_pos = str_copy; + number_of_separators = 0; + while (*pos) { + pos = STRCHR(pos, g_col_separator); + if (pos != NULL) { + *(pos) = zero_char; + ++pos; + number_of_separators++; + } + + fort_cell_t *cell = create_cell(); + if (cell == NULL) + goto clear; + + int status = fill_cell_from_string_(cell, base_pos); + if (FT_IS_ERROR(status)) { + destroy_cell(cell); + goto clear; + } + + status = vector_push(row->cells, &cell); + if (FT_IS_ERROR(status)) { + destroy_cell(cell); + goto clear; + } + + if (pos == NULL) + break; + base_pos = pos; + } + + /* special case if in format string last cell is empty */ + while (vector_size(row->cells) < (number_of_separators + 1)) { + fort_cell_t *cell = create_cell(); + if (cell == NULL) + goto clear; + + int status = fill_cell_from_string_(cell, zero_string); + if (FT_IS_ERROR(status)) { + destroy_cell(cell); + goto clear; + } + + status = vector_push(row->cells, &cell); + if (FT_IS_ERROR(status)) { + destroy_cell(cell); + goto clear; + } + } + + F_FREE(str_copy); + return row; + +clear: + destroy_row(row); + F_FREE(str_copy); + return NULL; + +#undef STRCHR +} + + +#ifdef FT_HAVE_WCHAR +FT_INTERNAL +fort_row_t *create_row_from_wstring(const wchar_t *str) +{ + typedef wchar_t char_type; + char_type *(*strdup_)(const char_type * str) = F_WCSDUP; + const char_type zero_char = L'\0'; + fort_status_t (*fill_cell_from_string_)(fort_cell_t *cell, const wchar_t *str) = fill_cell_from_wstring; + const char_type *const zero_string = L""; +#define STRCHR wcschr + + char_type *pos = NULL; + char_type *base_pos = NULL; + size_t number_of_separators = 0; + + fort_row_t *row = create_row(); + if (row == NULL) + return NULL; + + if (str == NULL) + return row; + + char_type *str_copy = strdup_(str); + if (str_copy == NULL) + goto clear; + + pos = str_copy; + base_pos = str_copy; + number_of_separators = 0; + while (*pos) { + pos = STRCHR(pos, g_col_separator); + if (pos != NULL) { + *(pos) = zero_char; + ++pos; + number_of_separators++; + } + + fort_cell_t *cell = create_cell(); + if (cell == NULL) + goto clear; + + int status = fill_cell_from_string_(cell, base_pos); + if (FT_IS_ERROR(status)) { + destroy_cell(cell); + goto clear; + } + + status = vector_push(row->cells, &cell); + if (FT_IS_ERROR(status)) { + destroy_cell(cell); + goto clear; + } + + if (pos == NULL) + break; + base_pos = pos; + } + + /* special case if in format string last cell is empty */ + while (vector_size(row->cells) < (number_of_separators + 1)) { + fort_cell_t *cell = create_cell(); + if (cell == NULL) + goto clear; + + int status = fill_cell_from_string_(cell, zero_string); + if (FT_IS_ERROR(status)) { + destroy_cell(cell); + goto clear; + } + + status = vector_push(row->cells, &cell); + if (FT_IS_ERROR(status)) { + destroy_cell(cell); + goto clear; + } + } + + F_FREE(str_copy); + return row; + +clear: + destroy_row(row); + F_FREE(str_copy); + return NULL; +#undef STRCHR +} +#endif + +FT_INTERNAL +fort_row_t *create_row_from_fmt_string(const char *fmt, va_list *va_args) +{ +#define VSNPRINTF vsnprintf +#define STR_FILED cstr +#define CREATE_ROW_FROM_STRING create_row_from_string +#define NUMBER_OF_COLUMNS_IN_FORMAT_STRING number_of_columns_in_format_string +#define FILL_CELL_FROM_STRING fill_cell_from_string +#define STR_BUF_TYPE CharBuf + + string_buffer_t *buffer = create_string_buffer(DEFAULT_STR_BUF_SIZE, STR_BUF_TYPE); + if (buffer == NULL) + return NULL; + + size_t cols_origin = NUMBER_OF_COLUMNS_IN_FORMAT_STRING(fmt); + size_t cols = 0; + + while (1) { + va_list va; + va_copy(va, *va_args); + int virtual_sz = VSNPRINTF(buffer->str.STR_FILED, string_buffer_capacity(buffer), fmt, va); + va_end(va); + /* If error encountered */ + if (virtual_sz < 0) + goto clear; + + /* Successful write */ + if ((size_t)virtual_sz < string_buffer_capacity(buffer)) + break; + + /* Otherwise buffer was too small, so incr. buffer size ant try again. */ + if (!FT_IS_SUCCESS(realloc_string_buffer_without_copy(buffer))) + goto clear; + } + + cols = NUMBER_OF_COLUMNS_IN_FORMAT_STRING(buffer->str.STR_FILED); + if (cols == cols_origin) { + + fort_row_t *row = CREATE_ROW_FROM_STRING(buffer->str.STR_FILED); + if (row == NULL) { + goto clear; + } + + destroy_string_buffer(buffer); + return row; + } + + if (cols_origin == 1) { + fort_row_t *row = create_row(); + if (row == NULL) { + goto clear; + } + + fort_cell_t *cell = get_cell_and_create_if_not_exists(row, 0); + if (cell == NULL) { + destroy_row(row); + goto clear; + } + + fort_status_t result = FILL_CELL_FROM_STRING(cell, buffer->str.STR_FILED); + if (FT_IS_ERROR(result)) { + destroy_row(row); + goto clear; + } + + destroy_string_buffer(buffer); + return row; + } + + /* + * todo: add processing of cols != cols_origin in a general way + * (when cols_origin != 1). + */ + +clear: + destroy_string_buffer(buffer); + return NULL; +#undef VSNPRINTF +#undef STR_FILED +#undef CREATE_ROW_FROM_STRING +#undef NUMBER_OF_COLUMNS_IN_FORMAT_STRING +#undef FILL_CELL_FROM_STRING +#undef STR_BUF_TYPE +} + +#ifdef FT_HAVE_WCHAR +FT_INTERNAL +fort_row_t *create_row_from_fmt_wstring(const wchar_t *fmt, va_list *va_args) +{ +#define VSNPRINTF vswprintf +#define STR_FILED wstr +#define CREATE_ROW_FROM_STRING create_row_from_wstring +#define NUMBER_OF_COLUMNS_IN_FORMAT_STRING number_of_columns_in_format_wstring +#define FILL_CELL_FROM_STRING fill_cell_from_wstring +#define STR_BUF_TYPE WCharBuf + + string_buffer_t *buffer = create_string_buffer(DEFAULT_STR_BUF_SIZE, STR_BUF_TYPE); + if (buffer == NULL) + return NULL; + + size_t cols_origin = NUMBER_OF_COLUMNS_IN_FORMAT_STRING(fmt); + size_t cols = 0; + + while (1) { + va_list va; + va_copy(va, *va_args); + int virtual_sz = VSNPRINTF(buffer->str.STR_FILED, string_buffer_capacity(buffer), fmt, va); + va_end(va); + /* If error encountered */ + if (virtual_sz < 0) + goto clear; + + /* Successful write */ + if ((size_t)virtual_sz < string_buffer_capacity(buffer)) + break; + + /* Otherwise buffer was too small, so incr. buffer size ant try again. */ + if (!FT_IS_SUCCESS(realloc_string_buffer_without_copy(buffer))) + goto clear; + } + + cols = NUMBER_OF_COLUMNS_IN_FORMAT_STRING(buffer->str.STR_FILED); + if (cols == cols_origin) { + + fort_row_t *row = CREATE_ROW_FROM_STRING(buffer->str.STR_FILED); + if (row == NULL) { + goto clear; + } + + destroy_string_buffer(buffer); + return row; + } + + if (cols_origin == 1) { + fort_row_t *row = create_row(); + if (row == NULL) { + goto clear; + } + + fort_cell_t *cell = get_cell_and_create_if_not_exists(row, 0); + if (cell == NULL) { + destroy_row(row); + goto clear; + } + + fort_status_t result = FILL_CELL_FROM_STRING(cell, buffer->str.STR_FILED); + if (FT_IS_ERROR(result)) { + destroy_row(row); + goto clear; + } + + destroy_string_buffer(buffer); + return row; + } + + /* + * todo: add processing of cols != cols_origin in a general way + * (when cols_origin != 1). + */ + +clear: + destroy_string_buffer(buffer); + return NULL; +#undef VSNPRINTF +#undef STR_FILED +#undef CREATE_ROW_FROM_STRING +#undef NUMBER_OF_COLUMNS_IN_FORMAT_STRING +#undef FILL_CELL_FROM_STRING +#undef STR_BUF_TYPE +} +#endif + + +FT_INTERNAL +int snprintf_row(const fort_row_t *row, char *buffer, size_t buf_sz, size_t *col_width_arr, size_t col_width_arr_sz, + size_t row_height, const context_t *context) +{ + int (*snprint_n_strings_)(char *, size_t, size_t, const char *) = snprint_n_strings; + int (*cell_printf_)(fort_cell_t *, size_t, char *, size_t, const context_t *) = cell_printf; + + assert(context); + const char *space_char = " "; + const char *new_line_char = "\n"; + + if (row == NULL) + return -1; + + size_t cols_in_row = columns_in_row(row); + if (cols_in_row > col_width_arr_sz) + return -1; + + /* Row separator anatomy + * + * L data IV data IV data R + */ + + typedef const char *(*border_chars_point_t)[BorderItemPosSize]; + enum ft_row_type row_type = (enum ft_row_type)get_cell_property_value_hierarcial(context->table_properties, context->row, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE); + const char *(*bord_chars)[BorderItemPosSize] = (row_type == FT_ROW_HEADER) + ? (border_chars_point_t)(&context->table_properties->border_style.header_border_chars) + : (border_chars_point_t)(&context->table_properties->border_style.border_chars); + const char **L = &(*bord_chars)[LL_bip]; + const char **IV = &(*bord_chars)[IV_bip]; + const char **R = &(*bord_chars)[RR_bip]; + + + size_t written = 0; + int tmp = 0; + size_t i = 0; + for (i = 0; i < row_height; ++i) { + /* Print left margin */ + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, context->table_properties->entire_table_properties.left_margin, space_char)); + + /* Print left table boundary */ + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, 1, *L)); + size_t j = 0; + while (j < col_width_arr_sz) { + if (j < cols_in_row) { + ((context_t *)context)->column = j; + fort_cell_t *cell = *(fort_cell_t **)vector_at(row->cells, j); + size_t cell_width = 0; + + size_t group_slave_sz = group_cell_number(row, j); + cell_width = col_width_arr[j]; + size_t slave_j = 0; + size_t master_j = j; + for (slave_j = master_j + 1; slave_j < (master_j + group_slave_sz); ++slave_j) { + cell_width += col_width_arr[slave_j] + FORT_COL_SEPARATOR_LENGTH; + ++j; + } + + CHCK_RSLT_ADD_TO_WRITTEN(cell_printf_(cell, i, buffer + written, cell_width + 1, context)); + } else { + /* Print empty cell */ + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, col_width_arr[j], space_char)); + } + + /* Print boundary between cells */ + if (j < col_width_arr_sz - 1) + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, 1, *IV)); + + ++j; + } + + /* Print right table boundary */ + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, 1, *R)); + + /* Print right margin */ + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, context->table_properties->entire_table_properties.right_margin, space_char)); + + /* Print new line character */ + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, 1, new_line_char)); + } + return (int)written; + +clear: + return -1; +} + + +#ifdef FT_HAVE_WCHAR +FT_INTERNAL +int wsnprintf_row(const fort_row_t *row, wchar_t *buffer, size_t buf_sz, size_t *col_width_arr, size_t col_width_arr_sz, + size_t row_height, const context_t *context) +{ + int (*snprint_n_strings_)(wchar_t *, size_t, size_t, const char *) = wsnprint_n_string; + int (*cell_printf_)(fort_cell_t *, size_t, wchar_t *, size_t, const context_t *) = cell_wprintf; + + assert(context); + const char *space_char = " "; + const char *new_line_char = "\n"; + + if (row == NULL) + return -1; + + size_t cols_in_row = columns_in_row(row); + if (cols_in_row > col_width_arr_sz) + return -1; + + /* Row separator anatomy + * + * L data IV data IV data R + */ + + typedef const char *(*border_chars_point_t)[BorderItemPosSize]; + enum ft_row_type row_type = (enum ft_row_type)get_cell_property_value_hierarcial(context->table_properties, context->row, FT_ANY_COLUMN, FT_CPROP_ROW_TYPE); + const char *(*bord_chars)[BorderItemPosSize] = (row_type == FT_ROW_HEADER) + ? (border_chars_point_t)(&context->table_properties->border_style.header_border_chars) + : (border_chars_point_t)(&context->table_properties->border_style.border_chars); + const char **L = &(*bord_chars)[LL_bip]; + const char **IV = &(*bord_chars)[IV_bip]; + const char **R = &(*bord_chars)[RR_bip]; + + + size_t written = 0; + int tmp = 0; + size_t i = 0; + for (i = 0; i < row_height; ++i) { + /* Print left margin */ + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, context->table_properties->entire_table_properties.left_margin, space_char)); + + /* Print left table boundary */ + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, 1, *L)); + size_t j = 0; + while (j < col_width_arr_sz) { + if (j < cols_in_row) { + ((context_t *)context)->column = j; + fort_cell_t *cell = *(fort_cell_t **)vector_at(row->cells, j); + size_t cell_width = 0; + + size_t group_slave_sz = group_cell_number(row, j); + cell_width = col_width_arr[j]; + size_t slave_j = 0; + size_t master_j = j; + for (slave_j = master_j + 1; slave_j < (master_j + group_slave_sz); ++slave_j) { + cell_width += col_width_arr[slave_j] + FORT_COL_SEPARATOR_LENGTH; + ++j; + } + + CHCK_RSLT_ADD_TO_WRITTEN(cell_printf_(cell, i, buffer + written, cell_width + 1, context)); + } else { + /* Print empty cell */ + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, col_width_arr[j], space_char)); + } + + /* Print boundary between cells */ + if (j < col_width_arr_sz - 1) + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, 1, *IV)); + + ++j; + } + + /* Print right table boundary */ + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, 1, *R)); + + /* Print right margin */ + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, context->table_properties->entire_table_properties.right_margin, space_char)); + + /* Print new line character */ + CHCK_RSLT_ADD_TO_WRITTEN(snprint_n_strings_(buffer + written, buf_sz - written, 1, new_line_char)); + } + return (int)written; + +clear: + return -1; +} + +#endif + + + +/******************************************************** + End of file "row.c" + ********************************************************/ + + +/******************************************************** + Begin of file "string_buffer.c" + ********************************************************/ + +/* #include "string_buffer.h" */ /* Commented by amalgamation script */ +/* #include "properties.h" */ /* Commented by amalgamation script */ +/* #include "wcwidth.h" */ /* Commented by amalgamation script */ +#include +#include +#include + + +static ptrdiff_t str_iter_width(const char *beg, const char *end) +{ + assert(end >= beg); + return (end - beg); +} + + +#ifdef FT_HAVE_WCHAR +static ptrdiff_t wcs_iter_width(const wchar_t *beg, const wchar_t *end) +{ + assert(end >= beg); + return mk_wcswidth(beg, (size_t)(end - beg)); +} +#endif /* FT_HAVE_WCHAR */ + + +static size_t buf_str_len(const string_buffer_t *buf) +{ + assert(buf); + if (buf->type == CharBuf) { + return strlen(buf->str.cstr); + } else { + return wcslen(buf->str.wstr); + } +} + + +FT_INTERNAL +size_t strchr_count(const char *str, char ch) +{ + if (str == NULL) + return 0; + + size_t count = 0; + str = strchr(str, ch); + while (str) { + count++; + str++; + str = strchr(str, ch); + } + return count; +} + + +FT_INTERNAL +size_t wstrchr_count(const wchar_t *str, wchar_t ch) +{ + if (str == NULL) + return 0; + + size_t count = 0; + str = wcschr(str, ch); + while (str) { + count++; + str++; + str = wcschr(str, ch); + } + return count; +} + + +FT_INTERNAL +const char *str_n_substring_beg(const char *str, char ch_separator, size_t n) +{ + if (str == NULL) + return NULL; + + if (n == 0) + return str; + + str = strchr(str, ch_separator); + --n; + while (n > 0) { + if (str == NULL) + return NULL; + --n; + str++; + str = strchr(str, ch_separator); + } + return str ? (str + 1) : NULL; +} + + +#ifdef FT_HAVE_WCHAR +FT_INTERNAL +const wchar_t *wstr_n_substring_beg(const wchar_t *str, wchar_t ch_separator, size_t n) +{ + if (str == NULL) + return NULL; + + if (n == 0) + return str; + + str = wcschr(str, ch_separator); + --n; + while (n > 0) { + if (str == NULL) + return NULL; + --n; + str++; + str = wcschr(str, ch_separator); + } + return str ? (str + 1) : NULL; +} +#endif /* FT_HAVE_WCHAR */ + + +FT_INTERNAL +void str_n_substring(const char *str, char ch_separator, size_t n, const char **begin, const char **end) +{ + const char *beg = str_n_substring_beg(str, ch_separator, n); + if (beg == NULL) { + *begin = NULL; + *end = NULL; + return; + } + + const char *en = strchr(beg, ch_separator); + if (en == NULL) { + en = str + strlen(str); + } + + *begin = beg; + *end = en; + return; +} + + +#ifdef FT_HAVE_WCHAR +FT_INTERNAL +void wstr_n_substring(const wchar_t *str, wchar_t ch_separator, size_t n, const wchar_t **begin, const wchar_t **end) +{ + const wchar_t *beg = wstr_n_substring_beg(str, ch_separator, n); + if (beg == NULL) { + *begin = NULL; + *end = NULL; + return; + } + + const wchar_t *en = wcschr(beg, ch_separator); + if (en == NULL) { + en = str + wcslen(str); + } + + *begin = beg; + *end = en; + return; +} +#endif /* FT_HAVE_WCHAR */ + + +FT_INTERNAL +string_buffer_t *create_string_buffer(size_t number_of_chars, enum str_buf_type type) +{ + size_t sz = (number_of_chars) * (type == CharBuf ? sizeof(char) : sizeof(wchar_t)); + string_buffer_t *result = (string_buffer_t *)F_MALLOC(sizeof(string_buffer_t)); + if (result == NULL) + return NULL; + result->str.data = F_MALLOC(sz); + if (result->str.data == NULL) { + F_FREE(result); + return NULL; + } + result->data_sz = sz; + result->type = type; + + if (sz && type == CharBuf) { + result->str.cstr[0] = '\0'; +#ifdef FT_HAVE_WCHAR + } else if (sz && type == WCharBuf) { + result->str.wstr[0] = L'\0'; +#endif /* FT_HAVE_WCHAR */ + } + + return result; +} + + +FT_INTERNAL +void destroy_string_buffer(string_buffer_t *buffer) +{ + if (buffer == NULL) + return; + F_FREE(buffer->str.data); + buffer->str.data = NULL; + F_FREE(buffer); +} + +FT_INTERNAL +string_buffer_t *copy_string_buffer(const string_buffer_t *buffer) +{ + assert(buffer); + string_buffer_t *result = create_string_buffer(buffer->data_sz, buffer->type); + if (result == NULL) + return NULL; + switch (buffer->type) { + case CharBuf: + if (FT_IS_ERROR(fill_buffer_from_string(result, buffer->str.cstr))) { + destroy_string_buffer(result); + return NULL; + } + break; +#ifdef FT_HAVE_WCHAR + case WCharBuf: + if (FT_IS_ERROR(fill_buffer_from_wstring(result, buffer->str.wstr))) { + destroy_string_buffer(result); + return NULL; + } + break; +#endif /* FT_HAVE_WCHAR */ + default: + destroy_string_buffer(result); + return NULL; + } + return result; +} + +FT_INTERNAL +fort_status_t realloc_string_buffer_without_copy(string_buffer_t *buffer) +{ + assert(buffer); + char *new_str = (char *)F_MALLOC(buffer->data_sz * 2); + if (new_str == NULL) { + return FT_MEMORY_ERROR; + } + F_FREE(buffer->str.data); + buffer->str.data = new_str; + buffer->data_sz *= 2; + return FT_SUCCESS; +} + + +FT_INTERNAL +fort_status_t fill_buffer_from_string(string_buffer_t *buffer, const char *str) +{ + assert(buffer); + assert(str); + + char *copy = F_STRDUP(str); + if (copy == NULL) + return FT_MEMORY_ERROR; + + F_FREE(buffer->str.data); + buffer->str.cstr = copy; + buffer->type = CharBuf; + + return FT_SUCCESS; +} + + +#ifdef FT_HAVE_WCHAR +FT_INTERNAL +fort_status_t fill_buffer_from_wstring(string_buffer_t *buffer, const wchar_t *str) +{ + assert(buffer); + assert(str); + + wchar_t *copy = F_WCSDUP(str); + if (copy == NULL) + return FT_MEMORY_ERROR; + + F_FREE(buffer->str.data); + buffer->str.wstr = copy; + buffer->type = WCharBuf; + + return FT_SUCCESS; +} +#endif /* FT_HAVE_WCHAR */ + + +FT_INTERNAL +size_t buffer_text_height(const string_buffer_t *buffer) +{ + if (buffer == NULL || buffer->str.data == NULL || buf_str_len(buffer) == 0) { + return 0; + } + if (buffer->type == CharBuf) + return 1 + strchr_count(buffer->str.cstr, '\n'); + else + return 1 + wstrchr_count(buffer->str.wstr, L'\n'); +} + + +FT_INTERNAL +size_t buffer_text_width(const string_buffer_t *buffer) +{ + size_t max_length = 0; + if (buffer->type == CharBuf) { + size_t n = 0; + while (1) { + const char *beg = NULL; + const char *end = NULL; + str_n_substring(buffer->str.cstr, '\n', n, &beg, &end); + if (beg == NULL || end == NULL) + return max_length; + + max_length = MAX(max_length, (size_t)(end - beg)); + ++n; + } +#ifdef FT_HAVE_WCHAR + } else { + size_t n = 0; + while (1) { + const wchar_t *beg = NULL; + const wchar_t *end = NULL; + wstr_n_substring(buffer->str.wstr, L'\n', n, &beg, &end); + if (beg == NULL || end == NULL) + return max_length; + + int line_width = mk_wcswidth(beg, (size_t)(end - beg)); + if (line_width < 0) /* For safety */ + line_width = 0; + max_length = MAX(max_length, (size_t)line_width); + + ++n; + } +#endif /* FT_HAVE_WCHAR */ + } + + return max_length; /* shouldn't be here */ +} + + +FT_INTERNAL +int buffer_printf(string_buffer_t *buffer, size_t buffer_row, char *buf, size_t total_buf_len, + const context_t *context, const char *content_style_tag, const char *reset_content_style_tag) +{ +#define CHAR_TYPE char +#define NULL_CHAR '\0' +#define NEWLINE_CHAR '\n' +#define SPACE_CHAR " " +#define SNPRINTF_FMT_STR "%*s" +#define SNPRINTF snprintf +#define BUFFER_STR str.cstr +#define SNPRINT_N_STRINGS snprint_n_strings +#define STR_N_SUBSTRING str_n_substring +#define STR_ITER_WIDTH str_iter_width + + size_t buf_len = total_buf_len - strlen(content_style_tag) - strlen(reset_content_style_tag); + + if (buffer == NULL || buffer->str.data == NULL + || buffer_row >= buffer_text_height(buffer) || buf_len == 0) { + return -1; + } + + size_t content_width = buffer_text_width(buffer); + if ((buf_len - 1) < content_width) + return -1; + + size_t left = 0; + size_t right = 0; + + switch (get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_TEXT_ALIGN)) { + case FT_ALIGNED_LEFT: + left = 0; + right = (buf_len - 1) - content_width; + break; + case FT_ALIGNED_CENTER: + left = ((buf_len - 1) - content_width) / 2; + right = ((buf_len - 1) - content_width) - left; + break; + case FT_ALIGNED_RIGHT: + left = (buf_len - 1) - content_width; + right = 0; + break; + default: + assert(0); + break; + } + + int set_old_value = 0; + size_t written = 0; + int tmp = 0; + ptrdiff_t str_it_width = 0; + const CHAR_TYPE *beg = NULL; + const CHAR_TYPE *end = NULL; + CHAR_TYPE old_value = (CHAR_TYPE)0; + + CHCK_RSLT_ADD_TO_WRITTEN(SNPRINT_N_STRINGS(buf + written, total_buf_len - written, left, SPACE_CHAR)); + + STR_N_SUBSTRING(buffer->BUFFER_STR, NEWLINE_CHAR, buffer_row, &beg, &end); + if (beg == NULL || end == NULL) + return -1; + old_value = *end; + *(CHAR_TYPE *)end = NULL_CHAR; + set_old_value = 1; + + str_it_width = STR_ITER_WIDTH(beg, end); + if (str_it_width < 0 || content_width < (size_t)str_it_width) + goto clear; + + CHCK_RSLT_ADD_TO_WRITTEN(SNPRINT_N_STRINGS(buf + written, total_buf_len - written, 1, content_style_tag)); + CHCK_RSLT_ADD_TO_WRITTEN(SNPRINTF(buf + written, total_buf_len - written, SNPRINTF_FMT_STR, (int)(end - beg), beg)); + CHCK_RSLT_ADD_TO_WRITTEN(SNPRINT_N_STRINGS(buf + written, total_buf_len - written, 1, reset_content_style_tag)); + + *(CHAR_TYPE *)end = old_value; + set_old_value = 0; + CHCK_RSLT_ADD_TO_WRITTEN(SNPRINT_N_STRINGS(buf + written, total_buf_len - written, (content_width - (size_t)str_it_width), SPACE_CHAR)); + CHCK_RSLT_ADD_TO_WRITTEN(SNPRINT_N_STRINGS(buf + written, total_buf_len - written, right, SPACE_CHAR)); + return (int)written; + +clear: + if (set_old_value) + *(CHAR_TYPE *)end = old_value; + return -1; + +#undef CHAR_TYPE +#undef NULL_CHAR +#undef NEWLINE_CHAR +#undef SPACE_CHAR +#undef SNPRINTF_FMT_STR +#undef SNPRINTF +#undef BUFFER_STR +#undef SNPRINT_N_STRINGS +#undef STR_N_SUBSTRING +#undef STR_ITER_WIDTH +} + + +#ifdef FT_HAVE_WCHAR +FT_INTERNAL +int buffer_wprintf(string_buffer_t *buffer, size_t buffer_row, wchar_t *buf, size_t total_buf_len, + const context_t *context, const char *content_style_tag, const char *reset_content_style_tag) +{ +#define CHAR_TYPE wchar_t +#define NULL_CHAR L'\0' +#define NEWLINE_CHAR L'\n' +#define SPACE_CHAR " " +#define SNPRINTF_FMT_STR L"%*ls" +#define SNPRINTF swprintf +#define BUFFER_STR str.wstr +#define SNPRINT_N_STRINGS wsnprint_n_string +#define STR_N_SUBSTRING wstr_n_substring +#define STR_ITER_WIDTH wcs_iter_width + + size_t buf_len = total_buf_len - strlen(content_style_tag) - strlen(reset_content_style_tag); + + if (buffer == NULL || buffer->str.data == NULL + || buffer_row >= buffer_text_height(buffer) || buf_len == 0) { + return -1; + } + + size_t content_width = buffer_text_width(buffer); + if ((buf_len - 1) < content_width) + return -1; + + size_t left = 0; + size_t right = 0; + + switch (get_cell_property_value_hierarcial(context->table_properties, context->row, context->column, FT_CPROP_TEXT_ALIGN)) { + case FT_ALIGNED_LEFT: + left = 0; + right = (buf_len - 1) - content_width; + break; + case FT_ALIGNED_CENTER: + left = ((buf_len - 1) - content_width) / 2; + right = ((buf_len - 1) - content_width) - left; + break; + case FT_ALIGNED_RIGHT: + left = (buf_len - 1) - content_width; + right = 0; + break; + default: + assert(0); + break; + } + + int set_old_value = 0; + size_t written = 0; + int tmp = 0; + ptrdiff_t str_it_width = 0; + const CHAR_TYPE *beg = NULL; + const CHAR_TYPE *end = NULL; + CHAR_TYPE old_value = (CHAR_TYPE)0; + + CHCK_RSLT_ADD_TO_WRITTEN(SNPRINT_N_STRINGS(buf + written, total_buf_len - written, left, SPACE_CHAR)); + + STR_N_SUBSTRING(buffer->BUFFER_STR, NEWLINE_CHAR, buffer_row, &beg, &end); + if (beg == NULL || end == NULL) + return -1; + old_value = *end; + *(CHAR_TYPE *)end = NULL_CHAR; + set_old_value = 1; + + str_it_width = STR_ITER_WIDTH(beg, end); + if (str_it_width < 0 || content_width < (size_t)str_it_width) + goto clear; + + CHCK_RSLT_ADD_TO_WRITTEN(SNPRINT_N_STRINGS(buf + written, total_buf_len - written, 1, content_style_tag)); + CHCK_RSLT_ADD_TO_WRITTEN(SNPRINTF(buf + written, total_buf_len - written, SNPRINTF_FMT_STR, (int)(end - beg), beg)); + CHCK_RSLT_ADD_TO_WRITTEN(SNPRINT_N_STRINGS(buf + written, total_buf_len - written, 1, reset_content_style_tag)); + + *(CHAR_TYPE *)end = old_value; + set_old_value = 0; + CHCK_RSLT_ADD_TO_WRITTEN(SNPRINT_N_STRINGS(buf + written, total_buf_len - written, (content_width - (size_t)str_it_width), SPACE_CHAR)); + CHCK_RSLT_ADD_TO_WRITTEN(SNPRINT_N_STRINGS(buf + written, total_buf_len - written, right, SPACE_CHAR)); + return (int)written; + +clear: + if (set_old_value) + *(CHAR_TYPE *)end = old_value; + return -1; + +#undef CHAR_TYPE +#undef NULL_CHAR +#undef NEWLINE_CHAR +#undef SPACE_CHAR +#undef SNPRINTF_FMT_STR +#undef SNPRINTF +#undef BUFFER_STR +#undef SNPRINT_N_STRINGS +#undef STR_N_SUBSTRING +#undef STR_ITER_WIDTH +} +#endif /* FT_HAVE_WCHAR */ + + +FT_INTERNAL +size_t string_buffer_capacity(const string_buffer_t *buffer) +{ + assert(buffer); + if (buffer->type == CharBuf) + return buffer->data_sz; + else + return buffer->data_sz / sizeof(wchar_t); +} + + +FT_INTERNAL +void *buffer_get_data(string_buffer_t *buffer) +{ + assert(buffer); + return buffer->str.data; +} + +/******************************************************** + End of file "string_buffer.c" + ********************************************************/ + + +/******************************************************** + Begin of file "table.c" + ********************************************************/ + +/* #include "table.h" */ /* Commented by amalgamation script */ +/* #include "string_buffer.h" */ /* Commented by amalgamation script */ +/* #include "cell.h" */ /* Commented by amalgamation script */ +/* #include "vector.h" */ /* Commented by amalgamation script */ +/* #include "row.h" */ /* Commented by amalgamation script */ + +FT_INTERNAL +separator_t *create_separator(int enabled) +{ + separator_t *res = (separator_t *)F_CALLOC(1, sizeof(separator_t)); + if (res == NULL) + return NULL; + res->enabled = enabled; + return res; +} + + +FT_INTERNAL +void destroy_separator(separator_t *sep) +{ + F_FREE(sep); +} + + +FT_INTERNAL +separator_t *copy_separator(separator_t *sep) +{ + assert(sep); + return create_separator(sep->enabled); +} + + +static +fort_row_t *get_row_implementation(ft_table_t *table, size_t row, enum PolicyOnNull policy) +{ + if (table == NULL || table->rows == NULL) { + return NULL; + } + + switch (policy) { + case DoNotCreate: + if (row < vector_size(table->rows)) { + return *(fort_row_t **)vector_at(table->rows, row); + } + return NULL; + case Create: + while (row >= vector_size(table->rows)) { + fort_row_t *new_row = create_row(); + if (new_row == NULL) + return NULL; + if (FT_IS_ERROR(vector_push(table->rows, &new_row))) { + destroy_row(new_row); + return NULL; + } + } + return *(fort_row_t **)vector_at(table->rows, row); + } + + assert(0 && "Shouldn't be here!"); + return NULL; +} + + +FT_INTERNAL +fort_row_t *get_row(ft_table_t *table, size_t row) +{ + return get_row_implementation(table, row, DoNotCreate); +} + + +FT_INTERNAL +const fort_row_t *get_row_c(const ft_table_t *table, size_t row) +{ + return get_row((ft_table_t *)table, row); +} + + +FT_INTERNAL +fort_row_t *get_row_and_create_if_not_exists(ft_table_t *table, size_t row) +{ + return get_row_implementation(table, row, Create); +} + + +FT_INTERNAL +string_buffer_t *get_cur_str_buffer_and_create_if_not_exists(ft_table_t *table) +{ + assert(table); + + fort_row_t *row = get_row_and_create_if_not_exists(table, table->cur_row); + if (row == NULL) + return NULL; + fort_cell_t *cell = get_cell_and_create_if_not_exists(row, table->cur_col); + if (cell == NULL) + return NULL; + + return cell_get_string_buffer(cell); +} + + +/* + * Returns number of cells (rows * cols) + */ +FT_INTERNAL +fort_status_t get_table_sizes(const ft_table_t *table, size_t *rows, size_t *cols) +{ + *rows = 0; + *cols = 0; + if (table && table->rows) { + *rows = vector_size(table->rows); + /* + fort_row_t *row = NULL; + FOR_EACH(fort_row_t *, row, table->rows) { + (void)i0; + size_t cols_in_row = columns_in_row(row); + if (cols_in_row > *cols) + *cols = cols_in_row; + } + */ + size_t row_index = 0; + for (row_index = 0; row_index < vector_size(table->rows); ++row_index) { + fort_row_t *row = *(fort_row_t **)vector_at(table->rows, row_index); + size_t cols_in_row = columns_in_row(row); + if (cols_in_row > *cols) + *cols = cols_in_row; + } + } + return FT_SUCCESS; +} + + +FT_INTERNAL +fort_status_t table_rows_and_cols_geometry(const ft_table_t *table, + size_t **col_width_arr_p, size_t *col_width_arr_sz, + size_t **row_height_arr_p, size_t *row_height_arr_sz, + enum request_geom_type geom) +{ + if (table == NULL) { + return FT_ERROR; + } + + + + size_t cols = 0; + size_t rows = 0; + int status = get_table_sizes(table, &rows, &cols); + if (FT_IS_ERROR(status)) + return status; + + size_t *col_width_arr = (size_t *)F_CALLOC(sizeof(size_t), cols); + size_t *row_height_arr = (size_t *)F_CALLOC(sizeof(size_t), rows); + if (col_width_arr == NULL || row_height_arr == NULL) { + F_FREE(col_width_arr); + F_FREE(row_height_arr); + return FT_ERROR; + } + + int combined_cells_found = 0; + context_t context; + context.table_properties = (table->properties ? table->properties : &g_table_properties); + size_t col = 0; + for (col = 0; col < cols; ++col) { + col_width_arr[col] = 0; + size_t row = 0; + for (row = 0; row < rows; ++row) { + const fort_row_t *row_p = get_row_c(table, row); + const fort_cell_t *cell = get_cell_c(row_p, col); + context.column = col; + context.row = row; + if (cell) { + switch (get_cell_type(cell)) { + case CommonCell: + col_width_arr[col] = MAX(col_width_arr[col], hint_width_cell(cell, &context, geom)); + break; + case GroupMasterCell: + combined_cells_found = 1; + break; + case GroupSlaveCell: + ; /* Do nothing */ + break; + } + row_height_arr[row] = MAX(row_height_arr[row], hint_height_cell(cell, &context)); + } else { + size_t cell_empty_string_height = get_cell_property_value_hierarcial(context.table_properties, context.row, context.column, FT_CPROP_EMPTY_STR_HEIGHT); + if (cell_empty_string_height) { + size_t cell_top_padding = get_cell_property_value_hierarcial(context.table_properties, context.row, context.column, FT_CPROP_TOP_PADDING); + size_t cell_bottom_padding = get_cell_property_value_hierarcial(context.table_properties, context.row, context.column, FT_CPROP_BOTTOM_PADDING); + row_height_arr[row] = MAX(row_height_arr[row], cell_empty_string_height + cell_top_padding + cell_bottom_padding); + } + } + } + } + + if (combined_cells_found) { + for (col = 0; col < cols; ++col) { + size_t row = 0; + for (row = 0; row < rows; ++row) { + const fort_row_t *row_p = get_row_c(table, row); + const fort_cell_t *cell = get_cell_c(row_p, col); + context.column = col; + context.row = row; + if (cell) { + if (get_cell_type(cell) == GroupMasterCell) { + size_t hint_width = hint_width_cell(cell, &context, geom); + size_t slave_col = col + group_cell_number(row_p, col); + size_t cur_adj_col = col; + size_t group_width = col_width_arr[col]; + size_t i; + for (i = col + 1; i < slave_col; ++i) + group_width += col_width_arr[i] + FORT_COL_SEPARATOR_LENGTH; + /* adjust col. widths */ + while (1) { + if (group_width >= hint_width) + break; + col_width_arr[cur_adj_col] += 1; + group_width++; + cur_adj_col++; + if (cur_adj_col == slave_col) + cur_adj_col = col; + } + } + } + } + } + } + + /* todo: Maybe it is better to move min width checking to a particular cell width checking. + * At the moment min width includes paddings. Maybe it is better that min width weren't include + * paddings but be min width of the cell content without padding + */ + /* + if (table->properties) { + for (size_t i = 0; i < cols; ++i) { + col_width_arr[i] = MAX((int)col_width_arr[i], fort_props_column_width(table->properties, i)); + } + } + */ + + *col_width_arr_p = col_width_arr; + *col_width_arr_sz = cols; + *row_height_arr_p = row_height_arr; + *row_height_arr_sz = rows; + return FT_SUCCESS; +} + + +/* + * Returns geometry in characters + */ +FT_INTERNAL +fort_status_t table_geometry(const ft_table_t *table, size_t *height, size_t *width) +{ + if (table == NULL) + return FT_ERROR; + + *height = 0; + *width = 0; + size_t cols = 0; + size_t rows = 0; + size_t *col_width_arr = NULL; + size_t *row_height_arr = NULL; + + int status = table_rows_and_cols_geometry(table, &col_width_arr, &cols, &row_height_arr, &rows, INTERN_REPR_GEOMETRY); + if (FT_IS_ERROR(status)) + return status; + + *width = 1 + (cols == 0 ? 1 : cols) + 1; /* for boundaries (that take 1 symbol) + newline */ + size_t i = 0; + for (i = 0; i < cols; ++i) { + *width += col_width_arr[i]; + } + + /* todo: add check for non printable horizontal row separators */ + *height = 1 + (rows == 0 ? 1 : rows); /* for boundaries (that take 1 symbol) */ + for (i = 0; i < rows; ++i) { + *height += row_height_arr[i]; + } + F_FREE(col_width_arr); + F_FREE(row_height_arr); + + if (table->properties) { + *height += table->properties->entire_table_properties.top_margin; + *height += table->properties->entire_table_properties.bottom_margin; + *width += table->properties->entire_table_properties.left_margin; + *width += table->properties->entire_table_properties.right_margin; + } + + /* Take into account that border elements can be more than one byte long */ + fort_table_properties_t *table_properties = table->properties ? table->properties : &g_table_properties; + size_t max_border_elem_len = max_border_elem_strlen(table_properties); + *width *= max_border_elem_len; + + return FT_SUCCESS; + +} + + +/******************************************************** + End of file "table.c" + ********************************************************/ + + +/******************************************************** + Begin of file "vector.c" + ********************************************************/ + +/* #include "vector.h" */ /* Commented by amalgamation script */ +#include +#include + +struct vector { + size_t m_size; + void *m_data; + size_t m_capacity; + size_t m_item_size; +}; + + +static int vector_reallocate_(vector_t *vector, size_t new_capacity) +{ + assert(vector); + assert(new_capacity > vector->m_capacity); + + size_t new_size = new_capacity * vector->m_item_size; + vector->m_data = F_REALLOC(vector->m_data, new_size); + if (vector->m_data == NULL) + return -1; + return 0; +} + + +FT_INTERNAL +vector_t *create_vector(size_t item_size, size_t capacity) +{ + vector_t *vector = (vector_t *)F_MALLOC(sizeof(vector_t)); + if (vector == NULL) { + SYS_LOG_ERROR("Failed to allocate memory for asock vector"); + return NULL; + } + + size_t init_size = MAX(item_size * capacity, 1); + vector->m_data = F_MALLOC(init_size); + if (vector->m_data == NULL) { + SYS_LOG_ERROR("Failed to allocate memory for asock vector inern. buffer"); + F_FREE(vector); + return NULL; + } + + vector->m_size = 0; + vector->m_capacity = capacity; + vector->m_item_size = item_size; + + return vector; +} + + +FT_INTERNAL +void destroy_vector(vector_t *vector) +{ + assert(vector); + F_FREE(vector->m_data); + F_FREE(vector); +} + + +FT_INTERNAL +size_t vector_size(const vector_t *vector) +{ + assert(vector); + return vector->m_size; +} + + +FT_INTERNAL +size_t vector_capacity(const vector_t *vector) +{ + assert(vector); + return vector->m_capacity; +} + + +FT_INTERNAL +int vector_push(vector_t *vector, const void *item) +{ + assert(vector); + assert(item); + + if (vector->m_size == vector->m_capacity) { + if (vector_reallocate_(vector, vector->m_capacity * 2) == -1) + return FT_ERROR; + vector->m_capacity = vector->m_capacity * 2; + } + + size_t offset = vector->m_size * vector->m_item_size; + memcpy((char *)vector->m_data + offset, item, vector->m_item_size); + + ++(vector->m_size); + + return FT_SUCCESS; +} + + +FT_INTERNAL +const void *vector_at_c(const vector_t *vector, size_t index) +{ + if (index >= vector->m_size) + return NULL; + + return (char *)vector->m_data + index * vector->m_item_size; +} + + +FT_INTERNAL +void *vector_at(vector_t *vector, size_t index) +{ + if (index >= vector->m_size) + return NULL; + + return (char *)vector->m_data + index * vector->m_item_size; +} + + +FT_INTERNAL +fort_status_t vector_swap(vector_t *cur_vec, vector_t *mv_vec, size_t pos) +{ + assert(cur_vec); + assert(mv_vec); + assert(cur_vec != mv_vec); + assert(cur_vec->m_item_size == mv_vec->m_item_size); + + size_t cur_sz = vector_size(cur_vec); + size_t mv_sz = vector_size(mv_vec); + if (mv_sz == 0) { + return FT_SUCCESS; + } + + size_t min_targ_size = pos + mv_sz; + if (vector_capacity(cur_vec) < min_targ_size) { + if (vector_reallocate_(cur_vec, min_targ_size) == -1) + return FT_ERROR; + cur_vec->m_capacity = min_targ_size; + } + + size_t offset = pos * cur_vec->m_item_size; + void *tmp = NULL; + size_t new_mv_sz = 0; + if (cur_sz > pos) { + new_mv_sz = MIN(cur_sz - pos, mv_sz); + tmp = F_MALLOC(cur_vec->m_item_size * new_mv_sz); + if (tmp == NULL) { + return FT_MEMORY_ERROR; + } + } + + if (tmp) { + memcpy(tmp, + (char *)cur_vec->m_data + offset, + cur_vec->m_item_size * new_mv_sz); + } + + memcpy((char *)cur_vec->m_data + offset, + mv_vec->m_data, + cur_vec->m_item_size * mv_sz); + + if (tmp) { + memcpy(mv_vec->m_data, + tmp, + cur_vec->m_item_size * new_mv_sz); + } + + cur_vec->m_size = MAX(cur_vec->m_size, min_targ_size); + mv_vec->m_size = new_mv_sz; + F_FREE(tmp); + return FT_SUCCESS; +} + + +#ifdef FT_TEST_BUILD + +vector_t *copy_vector(vector_t *v) +{ + if (v == NULL) + return NULL; + + vector_t *new_vector = create_vector(v->m_item_size, v->m_capacity); + if (new_vector == NULL) + return NULL; + + memcpy(new_vector->m_data, v->m_data, v->m_item_size * v->m_size); + new_vector->m_size = v->m_size ; + new_vector->m_item_size = v->m_item_size ; + return new_vector; +} + +size_t vector_index_of(const vector_t *vector, const void *item) +{ + assert(vector); + assert(item); + + size_t i = 0; + for (i = 0; i < vector->m_size; ++i) { + void *data_pos = (char *)vector->m_data + i * vector->m_item_size; + if (memcmp(data_pos, item, vector->m_item_size) == 0) { + return i; + } + } + return INVALID_VEC_INDEX; +} + + +int vector_erase(vector_t *vector, size_t index) +{ + assert(vector); + + if (vector->m_size == 0 || index >= vector->m_size) + return FT_ERROR; + + memmove((char *)vector->m_data + vector->m_item_size * index, + (char *)vector->m_data + vector->m_item_size * (index + 1), + (vector->m_size - 1 - index) * vector->m_item_size); + vector->m_size--; + return FT_SUCCESS; +} + + +void vector_clear(vector_t *vector) +{ + vector->m_size = 0; +} +#endif + +/******************************************************** + End of file "vector.c" + ********************************************************/ + + +/******************************************************** + Begin of file "wcwidth.c" + ********************************************************/ + +/* + * This is an implementation of wcwidth() and wcswidth() (defined in + * IEEE Std 1002.1-2001) for Unicode. + * + * http://www.opengroup.org/onlinepubs/007904975/functions/wcwidth.html + * http://www.opengroup.org/onlinepubs/007904975/functions/wcswidth.html + * + * In fixed-width output devices, Latin characters all occupy a single + * "cell" position of equal width, whereas ideographic CJK characters + * occupy two such cells. Interoperability between terminal-line + * applications and (teletype-style) character terminals using the + * UTF-8 encoding requires agreement on which character should advance + * the cursor by how many cell positions. No established formal + * standards exist at present on which Unicode character shall occupy + * how many cell positions on character terminals. These routines are + * a first attempt of defining such behavior based on simple rules + * applied to data provided by the Unicode Consortium. + * + * For some graphical characters, the Unicode standard explicitly + * defines a character-cell width via the definition of the East Asian + * FullWidth (F), Wide (W), Half-width (H), and Narrow (Na) classes. + * In all these cases, there is no ambiguity about which width a + * terminal shall use. For characters in the East Asian Ambiguous (A) + * class, the width choice depends purely on a preference of backward + * compatibility with either historic CJK or Western practice. + * Choosing single-width for these characters is easy to justify as + * the appropriate long-term solution, as the CJK practice of + * displaying these characters as double-width comes from historic + * implementation simplicity (8-bit encoded characters were displayed + * single-width and 16-bit ones double-width, even for Greek, + * Cyrillic, etc.) and not any typographic considerations. + * + * Much less clear is the choice of width for the Not East Asian + * (Neutral) class. Existing practice does not dictate a width for any + * of these characters. It would nevertheless make sense + * typographically to allocate two character cells to characters such + * as for instance EM SPACE or VOLUME INTEGRAL, which cannot be + * represented adequately with a single-width glyph. The following + * routines at present merely assign a single-cell width to all + * neutral characters, in the interest of simplicity. This is not + * entirely satisfactory and should be reconsidered before + * establishing a formal standard in this area. At the moment, the + * decision which Not East Asian (Neutral) characters should be + * represented by double-width glyphs cannot yet be answered by + * applying a simple rule from the Unicode database content. Setting + * up a proper standard for the behavior of UTF-8 character terminals + * will require a careful analysis not only of each Unicode character, + * but also of each presentation form, something the author of these + * routines has avoided to do so far. + * + * http://www.unicode.org/unicode/reports/tr11/ + * + * Markus Kuhn -- 2007-05-26 (Unicode 5.0) + * + * Permission to use, copy, modify, and distribute this software + * for any purpose and without fee is hereby granted. The author + * disclaims all warranties with regard to this software. + * + * Latest version: http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c + */ + +/* #include "wcwidth.h" */ /* Commented by amalgamation script */ + +#ifdef FT_HAVE_WCHAR + + +struct interval { + int first; + int last; +}; + +/* auxiliary function for binary search in interval table */ +static int bisearch(wchar_t ucs, const struct interval *table, int max) +{ + int min = 0; + + if (ucs < table[0].first || ucs > table[max].last) + return 0; + while (max >= min) { + int mid = (min + max) / 2; + if (ucs > table[mid].last) + min = mid + 1; + else if (ucs < table[mid].first) + max = mid - 1; + else + return 1; + } + + return 0; +} + + +/* The following two functions define the column width of an ISO 10646 + * character as follows: + * + * - The null character (U+0000) has a column width of 0. + * + * - Other C0/C1 control characters and DEL will lead to a return + * value of -1. + * + * - Non-spacing and enclosing combining characters (general + * category code Mn or Me in the Unicode database) have a + * column width of 0. + * + * - SOFT HYPHEN (U+00AD) has a column width of 1. + * + * - Other format characters (general category code Cf in the Unicode + * database) and ZERO WIDTH SPACE (U+200B) have a column width of 0. + * + * - Hangul Jamo medial vowels and final consonants (U+1160-U+11FF) + * have a column width of 0. + * + * - Spacing characters in the East Asian Wide (W) or East Asian + * Full-width (F) category as defined in Unicode Technical + * Report #11 have a column width of 2. + * + * - All remaining characters (including all printable + * ISO 8859-1 and WGL4 characters, Unicode control characters, + * etc.) have a column width of 1. + * + * This implementation assumes that wchar_t characters are encoded + * in ISO 10646. + */ + +static int mk_wcwidth(wchar_t ucs) +{ + /* sorted list of non-overlapping intervals of non-spacing characters */ + /* generated by "uniset +cat=Me +cat=Mn +cat=Cf -00AD +1160-11FF +200B c" */ + static const struct interval combining[] = { + { 0x0300, 0x036F }, { 0x0483, 0x0486 }, { 0x0488, 0x0489 }, + { 0x0591, 0x05BD }, { 0x05BF, 0x05BF }, { 0x05C1, 0x05C2 }, + { 0x05C4, 0x05C5 }, { 0x05C7, 0x05C7 }, { 0x0600, 0x0603 }, + { 0x0610, 0x0615 }, { 0x064B, 0x065E }, { 0x0670, 0x0670 }, + { 0x06D6, 0x06E4 }, { 0x06E7, 0x06E8 }, { 0x06EA, 0x06ED }, + { 0x070F, 0x070F }, { 0x0711, 0x0711 }, { 0x0730, 0x074A }, + { 0x07A6, 0x07B0 }, { 0x07EB, 0x07F3 }, { 0x0901, 0x0902 }, + { 0x093C, 0x093C }, { 0x0941, 0x0948 }, { 0x094D, 0x094D }, + { 0x0951, 0x0954 }, { 0x0962, 0x0963 }, { 0x0981, 0x0981 }, + { 0x09BC, 0x09BC }, { 0x09C1, 0x09C4 }, { 0x09CD, 0x09CD }, + { 0x09E2, 0x09E3 }, { 0x0A01, 0x0A02 }, { 0x0A3C, 0x0A3C }, + { 0x0A41, 0x0A42 }, { 0x0A47, 0x0A48 }, { 0x0A4B, 0x0A4D }, + { 0x0A70, 0x0A71 }, { 0x0A81, 0x0A82 }, { 0x0ABC, 0x0ABC }, + { 0x0AC1, 0x0AC5 }, { 0x0AC7, 0x0AC8 }, { 0x0ACD, 0x0ACD }, + { 0x0AE2, 0x0AE3 }, { 0x0B01, 0x0B01 }, { 0x0B3C, 0x0B3C }, + { 0x0B3F, 0x0B3F }, { 0x0B41, 0x0B43 }, { 0x0B4D, 0x0B4D }, + { 0x0B56, 0x0B56 }, { 0x0B82, 0x0B82 }, { 0x0BC0, 0x0BC0 }, + { 0x0BCD, 0x0BCD }, { 0x0C3E, 0x0C40 }, { 0x0C46, 0x0C48 }, + { 0x0C4A, 0x0C4D }, { 0x0C55, 0x0C56 }, { 0x0CBC, 0x0CBC }, + { 0x0CBF, 0x0CBF }, { 0x0CC6, 0x0CC6 }, { 0x0CCC, 0x0CCD }, + { 0x0CE2, 0x0CE3 }, { 0x0D41, 0x0D43 }, { 0x0D4D, 0x0D4D }, + { 0x0DCA, 0x0DCA }, { 0x0DD2, 0x0DD4 }, { 0x0DD6, 0x0DD6 }, + { 0x0E31, 0x0E31 }, { 0x0E34, 0x0E3A }, { 0x0E47, 0x0E4E }, + { 0x0EB1, 0x0EB1 }, { 0x0EB4, 0x0EB9 }, { 0x0EBB, 0x0EBC }, + { 0x0EC8, 0x0ECD }, { 0x0F18, 0x0F19 }, { 0x0F35, 0x0F35 }, + { 0x0F37, 0x0F37 }, { 0x0F39, 0x0F39 }, { 0x0F71, 0x0F7E }, + { 0x0F80, 0x0F84 }, { 0x0F86, 0x0F87 }, { 0x0F90, 0x0F97 }, + { 0x0F99, 0x0FBC }, { 0x0FC6, 0x0FC6 }, { 0x102D, 0x1030 }, + { 0x1032, 0x1032 }, { 0x1036, 0x1037 }, { 0x1039, 0x1039 }, + { 0x1058, 0x1059 }, { 0x1160, 0x11FF }, { 0x135F, 0x135F }, + { 0x1712, 0x1714 }, { 0x1732, 0x1734 }, { 0x1752, 0x1753 }, + { 0x1772, 0x1773 }, { 0x17B4, 0x17B5 }, { 0x17B7, 0x17BD }, + { 0x17C6, 0x17C6 }, { 0x17C9, 0x17D3 }, { 0x17DD, 0x17DD }, + { 0x180B, 0x180D }, { 0x18A9, 0x18A9 }, { 0x1920, 0x1922 }, + { 0x1927, 0x1928 }, { 0x1932, 0x1932 }, { 0x1939, 0x193B }, + { 0x1A17, 0x1A18 }, { 0x1B00, 0x1B03 }, { 0x1B34, 0x1B34 }, + { 0x1B36, 0x1B3A }, { 0x1B3C, 0x1B3C }, { 0x1B42, 0x1B42 }, + { 0x1B6B, 0x1B73 }, { 0x1DC0, 0x1DCA }, { 0x1DFE, 0x1DFF }, + { 0x200B, 0x200F }, { 0x202A, 0x202E }, { 0x2060, 0x2063 }, + { 0x206A, 0x206F }, { 0x20D0, 0x20EF }, { 0x302A, 0x302F }, + { 0x3099, 0x309A }, { 0xA806, 0xA806 }, { 0xA80B, 0xA80B }, + { 0xA825, 0xA826 }, { 0xFB1E, 0xFB1E }, { 0xFE00, 0xFE0F }, + { 0xFE20, 0xFE23 }, { 0xFEFF, 0xFEFF }, { 0xFFF9, 0xFFFB }, + { 0x10A01, 0x10A03 }, { 0x10A05, 0x10A06 }, { 0x10A0C, 0x10A0F }, + { 0x10A38, 0x10A3A }, { 0x10A3F, 0x10A3F }, { 0x1D167, 0x1D169 }, + { 0x1D173, 0x1D182 }, { 0x1D185, 0x1D18B }, { 0x1D1AA, 0x1D1AD }, + { 0x1D242, 0x1D244 }, { 0xE0001, 0xE0001 }, { 0xE0020, 0xE007F }, + { 0xE0100, 0xE01EF } + }; + + /* test for 8-bit control characters */ + if (ucs == 0) + return 0; + if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0)) + return -1; + + /* binary search in table of non-spacing characters */ + if (bisearch(ucs, combining, + sizeof(combining) / sizeof(struct interval) - 1)) + return 0; + + /* if we arrive here, ucs is not a combining or C0/C1 control character */ + + return 1 + + (ucs >= 0x1100 && + (ucs <= 0x115f || /* Hangul Jamo init. consonants */ + ucs == 0x2329 || ucs == 0x232a || + (ucs >= 0x2e80 && ucs <= 0xa4cf && + ucs != 0x303f) || /* CJK ... Yi */ + (ucs >= 0xac00 && ucs <= 0xd7a3) || /* Hangul Syllables */ + (ucs >= 0xf900 && ucs <= 0xfaff) || /* CJK Compatibility Ideographs */ + (ucs >= 0xfe10 && ucs <= 0xfe19) || /* Vertical forms */ + (ucs >= 0xfe30 && ucs <= 0xfe6f) || /* CJK Compatibility Forms */ + (ucs >= 0xff00 && ucs <= 0xff60) || /* Fullwidth Forms */ + (ucs >= 0xffe0 && ucs <= 0xffe6) || + (ucs >= 0x20000 && ucs <= 0x2fffd) || + (ucs >= 0x30000 && ucs <= 0x3fffd))); +} + + +FT_INTERNAL +int mk_wcswidth(const wchar_t *pwcs, size_t n) +{ + int width = 0; + + for (; *pwcs && n-- > 0; pwcs++) { + int w; + if ((w = mk_wcwidth(*pwcs)) < 0) + return -1; + else + width += w; + } + + return width; +} +#endif /* FT_HAVE_WCHAR */ + +/******************************************************** + End of file "wcwidth.c" + ********************************************************/ + diff --git a/src/external/fort.h b/src/external/fort.h new file mode 100644 index 00000000..897c838c --- /dev/null +++ b/src/external/fort.h @@ -0,0 +1,889 @@ +/* +libfort + +MIT License + +Copyright (c) 2017 - 2018 Seleznev Anton + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +/** + * @file fort.h + * @brief Main header file describing libfort API. + * + * This file contains declarations of all libfort functions and macro + * definitions. + */ + +#ifndef LIBFORT_H +#define LIBFORT_H + +#include +#include +#include +#include + +/***************************************************************************** + * Configuration + *****************************************************************************/ +/** + * libfort configuration macros + * (to enable/disable some options this macros should be defined/undefined) + */ +/** #define FT_CONGIG_HAVE_WCHAR */ + +#if defined(FT_CONGIG_HAVE_WCHAR) +#define FT_HAVE_WCHAR +#endif + + +/***************************************************************************** + * RETURN CODES + *****************************************************************************/ +typedef int fort_status_t; +#define FT_SUCCESS 0 +#define FT_MEMORY_ERROR -1 +#define FT_ERROR -2 +#define FT_EINVAL -3 +#define FT_IS_SUCCESS(arg) ((arg) >= 0) +#define FT_IS_ERROR(arg) ((arg) < 0) + + + + +/** + * @cond HELPER_MACROS + */ + +/***************************************************************************** + * Determine compiler + *****************************************************************************/ + +#if defined(__clang__) +#define FT_CLANG_COMPILER +#elif defined(__GNUC__) +#define FT_GCC_COMPILER +#elif defined(_MSC_VER) +#define FT_MICROSOFT_COMPILER +#else +#define FT_UNDEFINED_COMPILER +#endif + + +/***************************************************************************** + * Declare inline + *****************************************************************************/ + +#if defined(__cplusplus) +#define FT_INLINE inline +#else +#define FT_INLINE __inline +#endif /* if defined(__cplusplus) */ + + +/***************************************************************************** + * C++ needs to know that types and declarations are C, not C++. + *****************************************************************************/ + +#ifdef __cplusplus +# define FT_BEGIN_DECLS extern "C" { +# define FT_END_DECLS } +#else +# define FT_BEGIN_DECLS +# define FT_END_DECLS +#endif + + +/***************************************************************************** + * Helper macros + *****************************************************************************/ + +#define FT_STR_2_CAT_(arg1, arg2) \ + arg1##arg2 +#define FT_STR_2_CAT(arg1, arg2) \ + FT_STR_2_CAT_(arg1, arg2) + +/** + * @interanl + */ +static FT_INLINE int ft_check_if_string_helper(const char *str) +{ + (void)str; + return 0; +} + +/** + * @interanl + */ +static FT_INLINE int ft_check_if_wstring_helper(const wchar_t *str) +{ + (void)str; + return 0; +} + +#define FT_NARGS_IMPL_(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,N,...) N +#define FT_EXPAND_(x) x +#define FT_PP_NARG_(...) \ + FT_EXPAND_(FT_NARGS_IMPL_(__VA_ARGS__,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)) + +#define FT_CHECK_IF_STR_32(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_31(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_31(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_30(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_30(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_29(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_29(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_28(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_28(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_27(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_27(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_26(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_26(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_25(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_25(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_24(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_24(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_23(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_23(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_22(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_22(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_21(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_21(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_20(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_20(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_19(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_19(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_18(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_18(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_17(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_17(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_16(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_16(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_15(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_15(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_14(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_14(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_13(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_13(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_12(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_12(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_11(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_11(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_10(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_10(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_9(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_9(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_8(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_8(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_7(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_7(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_6(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_6(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_5(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_5(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_4(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_4(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_3(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_3(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_2(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_2(checker,arg,...) (checker(arg),FT_EXPAND_(FT_CHECK_IF_STR_1(checker,__VA_ARGS__))) +#define FT_CHECK_IF_STR_1(checker,arg) (checker(arg)) + +#define FT_CHECK_IF_ARGS_ARE_STRINGS__(checker,func, ...) \ + FT_EXPAND_(func(checker,__VA_ARGS__)) +#define FT_CHECK_IF_ARGS_ARE_STRINGS_(checker,basis, n, ...) \ + FT_CHECK_IF_ARGS_ARE_STRINGS__(checker,FT_STR_2_CAT_(basis, n), __VA_ARGS__) +#define FT_CHECK_IF_ARGS_ARE_STRINGS(...) \ + FT_CHECK_IF_ARGS_ARE_STRINGS_(ft_check_if_string_helper,FT_CHECK_IF_STR_,FT_PP_NARG_(__VA_ARGS__), __VA_ARGS__) + +#ifdef FT_HAVE_WCHAR +#define CHECK_IF_ARGS_ARE_WSTRINGS(...) \ + FT_CHECK_IF_ARGS_ARE_STRINGS_(ft_check_if_wstring_helper,FT_CHECK_IF_STR_,FT_PP_NARG_(__VA_ARGS__), __VA_ARGS__) +#endif + +/** + * @endcond + */ + + +/***************************************************************************** + * Attribute format for argument checking + *****************************************************************************/ + +#if defined(FT_CLANG_COMPILER) || defined(FT_GCC_COMPILER) +#define FT_PRINTF_ATTRIBUTE_FORMAT(string_index, first_to_check) \ + __attribute__ ((format (printf, string_index, first_to_check))) +#else +#define FT_PRINTF_ATTRIBUTE_FORMAT(string_index, first_to_check) +#endif /* defined(FT_CLANG_COMPILER) || defined(FT_GCC_COMPILER) */ + + +/***************************************************************************** + * libfort API + *****************************************************************************/ + +FT_BEGIN_DECLS + +/** + * The main structure of libfort containing information about formatted table. + */ +struct ft_table; + +/** + * The main structure of libfort containing information about formatted table. + * + * ft_table_t objects should be created by a call to ft_create_table and + * destroyed with ft_destroy_table. + */ +typedef struct ft_table ft_table_t; + +/** + * Create formatted table. + * + * @return + * The pointer to the new allocated ft_table_t, on success. NULL on error. + */ +ft_table_t *ft_create_table(void); + +/** + * Destroy formatted table. + * + * Destroy formatted table and free all resources allocated during table creation + * and work with it. + * + * @param table + * Pointer to formatted table previousley created with ft_create_table. If + * table is a null pointer, the function does nothing. + */ +void ft_destroy_table(ft_table_t *table); + +/** + * Copy formatted table. + * + * @param table + * Pointer to formatted table previousley created with ft_create_table. If + * table is a null pointer, the function returns null. + * @return + * The pointer to the new allocated ft_table_t, on success. NULL on error. + */ +ft_table_t *ft_copy_table(ft_table_t *table); + +/** + * Move current position to the first cell of the next line(row). + * + * @param table + * Pointer to formatted table. + */ +void ft_ln(ft_table_t *table); + +/** + * Get row number of the current cell. + * + * @param table + * Pointer to formatted table. + * @return + * Row number of the current cell. + */ +size_t ft_cur_row(ft_table_t *table); + +/** + * Get column number of the current cell. + * + * @param table + * Pointer to formatted table. + * @return + * Column number of the current cell. + */ +size_t ft_cur_col(ft_table_t *table); + +/** + * Set current cell position. + * + * Current cell - cell that will be edited with all modifiing functions + * (ft_printf, ft_write ...). + * + * @param table + * Pointer to formatted table. + * @param row + * New row number for the current cell. + * @param col + * New row number for the current cell. + */ +void ft_set_cur_cell(ft_table_t *table, size_t row, size_t col); + + + +#if defined(FT_CLANG_COMPILER) || defined(FT_GCC_COMPILER) + +/** + * Write data formatted acording to the format string to a variety of table + * cells. + * + * @param table + * Pointer to formatted table. + * @param fmt + * Pointer to a null-terminated multibyte string specifying how to interpret + * the data. The format string consists of ordinary characters (except % and |), + * which are copied unchanged into the output stream, and conversion + * specifications. Conversion specifications are the same as for standard + * printf function. Character '|' (wich can be changed with + * {@link ft_set_default_printf_field_separator}) in the format string is treated as + * a cell separator. + * @param ... + * Arguments specifying data to print. Similarly to standard printf-like + * functions if any argument after default conversions is not the type + * expected by the corresponding conversion specifier, or if there are fewer + * arguments than required by format, the behavior is undefined. If there are + * more arguments than required by format, the extraneous arguments are + * evaluated and ignored. + * @return + * - Number of printed cells + * - (<0): In case of error + */ +int ft_printf(ft_table_t *table, const char *fmt, ...) FT_PRINTF_ATTRIBUTE_FORMAT(2, 3); + +/** + * Write data formatted acording to the format string to a variety of table + * cells and move current position to the first cell of the next line(row). + * + * @param table + * Pointer to formatted table. + * @param fmt + * Pointer to a null-terminated multibyte string specifying how to interpret + * the data. The format string consists of ordinary characters (except % and |), + * which are copied unchanged into the output stream, and conversion + * specifications. Conversion specifications are the same as for standard + * printf function. Character '|' (wich can be changed with + * {@link ft_set_default_printf_field_separator}) in the format string is treated as + * a cell separator. + * @param ... + * Arguments specifying data to print. Similarly to standard printf-like + * functions if any argument after default conversions is not the type + * expected by the corresponding conversion specifier, or if there are fewer + * arguments than required by format, the behavior is undefined. If there are + * more arguments than required by format, the extraneous arguments are + * evaluated and ignored. + * @return + * - Number of printed cells. + * - (<0): In case of error. + */ +int ft_printf_ln(ft_table_t *table, const char *fmt, ...) FT_PRINTF_ATTRIBUTE_FORMAT(2, 3); + +#else + +/** + * @cond IGNORE_DOC + */ + +int ft_printf_impl(ft_table_t *table, const char *fmt, ...) FT_PRINTF_ATTRIBUTE_FORMAT(2, 3); +int ft_printf_ln_impl(ft_table_t *table, const char *fmt, ...) FT_PRINTF_ATTRIBUTE_FORMAT(2, 3); + +#define ft_printf(table, ...) \ + (( 0 ? fprintf(stderr, __VA_ARGS__) : 1), ft_printf_impl(table, __VA_ARGS__)) +#define ft_printf_ln(table, ...) \ + (( 0 ? fprintf(stderr, __VA_ARGS__) : 1), ft_printf_ln_impl(table, __VA_ARGS__)) + +/** + * @endcond + */ +#endif + +/** + * Set field separator for {@link ft_printf}, {@link ft_printf_ln} + * (default separator is '|'). + * + * @param separator + * New separator. + */ +void ft_set_default_printf_field_separator(char separator); + + +/** + * Write strings to the table. + * + * Write specified strings to the same number of consecutive cells in the + * current row. + * + * @param table + * Pointer to formatted table. + * @param ... + * Strings to write. + * @return + * - 0: Success; data were written + * - (<0): In case of error + */ +#define ft_write(table, ...)\ + (0 ? FT_CHECK_IF_ARGS_ARE_STRINGS(__VA_ARGS__) : ft_nwrite(table, FT_PP_NARG_(__VA_ARGS__), __VA_ARGS__)) + +/** + * Write strings to the table and go to the next line. + * + * Write specified strings to the same number of consecutive cells in the + * current row and move current position to the first cell of the next + * line(row). + * + * @param table + * Pointer to formatted table. + * @param ... + * Strings to write. + * @return + * - 0: Success; data were written + * - (<0): In case of error + */ +#define ft_write_ln(table, ...)\ + (0 ? FT_CHECK_IF_ARGS_ARE_STRINGS(__VA_ARGS__) : ft_nwrite_ln(table, FT_PP_NARG_(__VA_ARGS__), __VA_ARGS__)) + +/** + * Write specified number of strings to the table. + * + * Write specified number of strings to the same number of consecutive cells in + * the current row. + * + * @note In most cases it is more preferable to use MACRO @ref ft_write instead + * of @ref ft_nwrite, which is more safe (@ref ft_write automatically counts the + * number of string arguments and at compile check that all passed arguments are + * strings). + * + * @param table + * Pointer to formatted table. + * @param count + * Number of strings to write. + * @param cell_content + * First string to write. + * @param ... + * Other strings to write. + * @return + * - 0: Success; data were written + * - (<0): In case of error + */ +int ft_nwrite(ft_table_t *table, size_t count, const char *cell_content, ...); + +/** + * Write specified number of strings to the table and go to the next line. + * + * Write specified number of strings to the same number of consecutive cells + * in the current row and move current position to the first cell of the next + * line(row). + * + * @note In most cases it is more preferable to use MACRO @ref ft_write instead + * of @ref ft_nwrite, which is more safe (@ref ft_write automatically counts the + * number of string arguments and at compile check that all passed arguments are + * strings). + * + * @param table + * Pointer to formatted table. + * @param count + * Number of strings to write. + * @param cell_content + * First string to write. + * @param ... + * Other strings to write. + * @return + * - 0: Success; data were written + * - (<0): In case of error + */ +int ft_nwrite_ln(ft_table_t *table, size_t count, const char *cell_content, ...); + + + + + +/** + * Write strings from the array to the table. + * + * Write specified number of strings from the array to the same number of + * consecutive cells in the current row. + * + * @param table + * Pointer to formatted table. + * @param cols + * Number of elements in row_cells. + * @param row_cells + * Array of strings to write. + * @return + * - 0: Success; data were written + * - (<0): In case of error + */ +int ft_row_write(ft_table_t *table, size_t cols, const char *row_cells[]); + +/** + * Write strings from the array to the table and go to the next line. + * + * Write specified number of strings from the array to the same number of + * consecutive cells in the current row and move current position to the first + * cell of the next line(row). + * + * @param table + * Pointer to formatted table. + * @param cols + * Number of elements in row_cells. + * @param row_cells + * Array of strings to write. + * @return + * - 0: Success; data were written + * - (<0): In case of error + */ +int ft_row_write_ln(ft_table_t *table, size_t cols, const char *row_cells[]); + + +/** + * Write strings from the 2D array to the table. + * + * Write specified number of strings from the 2D array to the formatted table. + * + * @param table + * Pointer to formatted table. + * @param rows + * Number of rows in the 2D array. + * @param cols + * Number of columns in the 2D array. + * @param table_cells + * 2D array of strings to write. + * @return + * - 0: Success; data were written + * - (<0): In case of error + */ +int ft_table_write(ft_table_t *table, size_t rows, size_t cols, const char *table_cells[]); + +/** + * Write strings from the 2D array to the table and go to the next line. + * + * Write specified number of strings from the 2D array to the formatted table + * and move current position to the first cell of the next line(row). + * + * @param table + * Pointer to formatted table. + * @param rows + * Number of rows in the 2D array. + * @param cols + * Number of columns in the 2D array. + * @param table_cells + * 2D array of strings to write. + * @return + * - 0: Success; data were written + * - (<0): In case of error + */ +int ft_table_write_ln(ft_table_t *table, size_t rows, size_t cols, const char *table_cells[]); + + +/** + * Add separator after the current row. + * + * @param table + * Formatted table. + * @return + * - 0: Success; separator was added. + * - (<0): In case of error + */ +int ft_add_separator(ft_table_t *table); + + +/** + * Convert table to string representation. + * + * ft_table_t has ownership of the returned pointer. So there is no need to + * free it. To take ownership user should explicitly copy the returned + * string with strdup or similar functions. + * + * Returned pointer may be later invalidated by: + * - Calling ft_destroy_table; + * - Other invocations of ft_to_string. + * + * @param table + * Formatted table. + * @return + * - The pointer to the string representation of formatted table, on success. + * - NULL on error. + */ +const char *ft_to_string(const ft_table_t *table); + + + + + + + +/** + * Structure describing border appearance. + */ +struct ft_border_chars { + const char *top_border_ch; + const char *separator_ch; + const char *bottom_border_ch; + const char *side_border_ch; + const char *out_intersect_ch; + const char *in_intersect_ch; +}; + +/** + * Structure describing border style. + */ +struct ft_border_style { + struct ft_border_chars border_chs; + struct ft_border_chars header_border_chs; + const char *hor_separator_char; +}; + +/** + * @defgroup BasicStyles + * @name Built-in table border styles. + * @{ + */ +extern struct ft_border_style *const FT_BASIC_STYLE; +extern struct ft_border_style *const FT_BASIC2_STYLE; +extern struct ft_border_style *const FT_SIMPLE_STYLE; +extern struct ft_border_style *const FT_PLAIN_STYLE; +extern struct ft_border_style *const FT_DOT_STYLE; +extern struct ft_border_style *const FT_EMPTY_STYLE; +extern struct ft_border_style *const FT_EMPTY2_STYLE; +extern struct ft_border_style *const FT_SOLID_STYLE; +extern struct ft_border_style *const FT_SOLID_ROUND_STYLE; +extern struct ft_border_style *const FT_NICE_STYLE; +extern struct ft_border_style *const FT_DOUBLE_STYLE; +extern struct ft_border_style *const FT_DOUBLE2_STYLE; +extern struct ft_border_style *const FT_BOLD_STYLE; +extern struct ft_border_style *const FT_BOLD2_STYLE; +extern struct ft_border_style *const FT_FRAME_STYLE; +/** @} */ + + + +/** + * Set default border style for all new formatted tables. + * + * @param style + * Pointer to border style. + * @return + * - 0: Success; default border style was changed. + * - (<0): In case of error + */ +int ft_set_default_border_style(const struct ft_border_style *style); + +/** + * Set border style for the table. + * + * @param table + * A pointer to the ft_table_t structure. + * @param style + * Pointer to border style. + * @return + * - 0: Success; table border style was changed. + * - (<0): In case of error + */ +int ft_set_border_style(ft_table_t *table, const struct ft_border_style *style); + + + +/** + * @name Special macros to define cell position (row and column). + * @{ + */ +#define FT_ANY_COLUMN (UINT_MAX) /**< Any column (can be used to refer to all cells in a row)*/ +#define FT_CUR_COLUMN (UINT_MAX - 1) /**< Current column */ +#define FT_ANY_ROW (UINT_MAX) /**< Any row (can be used to refer to all cells in a column)*/ +#define FT_CUR_ROW (UINT_MAX - 1) /**< Current row */ +/** @} */ + + + +/** + * @name Cell properties identifiers. + * @{ + */ +#define FT_CPROP_MIN_WIDTH (0x01U << 0) /**< Minimum width */ +#define FT_CPROP_TEXT_ALIGN (0x01U << 1) /**< Text alignment */ +#define FT_CPROP_TOP_PADDING (0x01U << 2) /**< Top padding for cell content */ +#define FT_CPROP_BOTTOM_PADDING (0x01U << 3) /**< Bottom padding for cell content */ +#define FT_CPROP_LEFT_PADDING (0x01U << 4) /**< Left padding for cell content */ +#define FT_CPROP_RIGHT_PADDING (0x01U << 5) /**< Right padding for cell content */ +#define FT_CPROP_EMPTY_STR_HEIGHT (0x01U << 6) /**< Height of empty cell */ +#define FT_CPROP_ROW_TYPE (0x01U << 7) /**< Row type */ +#define FT_CPROP_CONT_FG_COLOR (0x01U << 8) /**< Cell content foreground text color */ +#define FT_CPROP_CELL_BG_COLOR (0x01U << 9) /**< Cell background color */ +#define FT_CPROP_CONT_BG_COLOR (0x01U << 10) /**< Cell content background color */ +#define FT_CPROP_CELL_TEXT_STYLE (0x01U << 11) /**< Cell text style */ +#define FT_CPROP_CONT_TEXT_STYLE (0x01U << 12) /**< Cell content text style */ +/** @} */ + + +/** + * Colors. + */ +enum ft_color { + FT_COLOR_DEFAULT = 0, /**< Default color */ + FT_COLOR_BLACK = 1, /**< Black color*/ + FT_COLOR_RED = 2, /**< Red color */ + FT_COLOR_GREEN = 3, /**< Green color */ + FT_COLOR_YELLOW = 4, /**< Yellow color */ + FT_COLOR_BLUE = 5, /**< Blue color */ + FT_COLOR_MAGENTA = 6, /**< Magenta color */ + FT_COLOR_CYAN = 7, /**< Cyan color */ + FT_COLOR_LIGHT_GRAY = 8, /**< Light gray color */ + FT_COLOR_DARK_GRAY = 9, /**< Dark gray color */ + FT_COLOR_LIGHT_RED = 10, /**< Light red color */ + FT_COLOR_LIGHT_GREEN = 11, /**< Light green color */ + FT_COLOR_LIGHT_YELLOW = 12, /**< Light yellow color */ + FT_COLOR_LIGHT_BLUE = 13, /**< Light blue color */ + FT_COLOR_LIGHT_MAGENTA = 15, /**< Light magenta color */ + FT_COLOR_LIGHT_CYAN = 16, /**< Light cyan color */ + FT_COLOR_LIGHT_WHYTE = 17 /**< Light whyte color */ +}; + +/** + * Text styles. + */ +enum ft_text_style { + FT_TSTYLE_DEFAULT = (1U << 0), /**< Default style */ + FT_TSTYLE_BOLD = (1U << 1), /**< Bold */ + FT_TSTYLE_DIM = (1U << 2), /**< Dim */ + FT_TSTYLE_ITALIC = (1U << 3), /**< Italic */ + FT_TSTYLE_UNDERLINED = (1U << 4), /**< Underlined */ + FT_TSTYLE_BLINK = (1U << 5), /**< Blink */ + FT_TSTYLE_INVERTED = (1U << 6), /**< Reverse (invert the foreground and background colors) */ + FT_TSTYLE_HIDDEN = (1U << 7) /**< Hidden (useful for passwords) */ +}; + + +/** + * Alignment of cell content. + */ +enum ft_text_alignment { + FT_ALIGNED_LEFT = 0, /**< Align left */ + FT_ALIGNED_CENTER, /**< Align center */ + FT_ALIGNED_RIGHT /**< Align right */ +}; + +/** + * Type of table row. Determines appearance of row. + */ +enum ft_row_type { + FT_ROW_COMMON = 0, /**< Common row */ + FT_ROW_HEADER /**< Header row */ +}; + +/** + * Set default cell property for all new formatted tables. + * + * @param property + * Cell property identifier. + * @param value + * Cell property value. + * @return + * - 0: Success; default cell property was changed. + * - (<0): In case of error + */ +int ft_set_default_cell_prop(uint32_t property, int value); + +/** + * Set property for the specified cell of the table. + * + * @param table + * A pointer to the ft_table_t structure. + * @param row + * Cell row. + * @param col + * Cell column. + * @param property + * Cell property identifier. + * @param value + * Cell property value. + * @return + * - 0: Success; cell property was changed. + * - (<0): In case of error + */ +int ft_set_cell_prop(ft_table_t *table, size_t row, size_t col, uint32_t property, int value); + + +/** + * @name Table properties identifiers. + * @{ + */ +#define FT_TPROP_LEFT_MARGIN (0x01U << 0) +#define FT_TPROP_TOP_MARGIN (0x01U << 1) +#define FT_TPROP_RIGHT_MARGIN (0x01U << 2) +#define FT_TPROP_BOTTOM_MARGIN (0x01U << 3) +/** @} */ + + + +/** + * Set default table property. + * + * @param property + * Table property identifier. + * @param value + * Table property value. + * @return + * - 0: Success; default table property was changed. + * - (<0): In case of error + */ +int ft_set_default_tbl_prop(uint32_t property, int value); + +/** + * Set table property. + * + * @param table + * A pointer to the ft_table_t structure. + * @param property + * Table property identifier. + * @param value + * Table property value. + * @return + * - 0: Success; default table property was changed. + * - (<0): In case of error + */ +int ft_set_tbl_prop(ft_table_t *table, uint32_t property, int value); + + +/** + * Set column span for the specified cell of the table. + * + * @param table + * A pointer to the ft_table_t structure. + * @param row + * Cell row. + * @param col + * Cell column. + * @param hor_span + * Column span. + * @return + * - 0: Success; cell span was changed. + * - (<0): In case of error + */ +int ft_set_cell_span(ft_table_t *table, size_t row, size_t col, size_t hor_span); + + +/** + * Set functions for memory allocation and deallocation to be used instead of + * standard ones. + * + * @param f_malloc + * Pointer to a function for memory allocation that should be used instead of + * malloc. + * @param f_free + * Pointer to a function for memory deallocation that should be used instead + * of free. + * @note + * To return memory allocation/deallocation functions to their standard values + * set f_malloc and f_free to NULL. + */ +void ft_set_memory_funcs(void *(*f_malloc)(size_t size), void (*f_free)(void *ptr)); + + + + +#ifdef FT_HAVE_WCHAR + + +int ft_wprintf(ft_table_t *table, const wchar_t *fmt, ...); +int ft_wprintf_ln(ft_table_t *table, const wchar_t *fmt, ...); + + +#define ft_wwrite(table, ...)\ + (0 ? CHECK_IF_ARGS_ARE_WSTRINGS(__VA_ARGS__) : ft_nwwrite(table, FT_PP_NARG_(__VA_ARGS__), __VA_ARGS__)) +#define ft_wwrite_ln(table, ...)\ + (0 ? CHECK_IF_ARGS_ARE_WSTRINGS(__VA_ARGS__) : ft_nwwrite_ln(table, FT_PP_NARG_(__VA_ARGS__), __VA_ARGS__)) +int ft_nwwrite(ft_table_t *table, size_t n, const wchar_t *cell_content, ...); +int ft_nwwrite_ln(ft_table_t *table, size_t n, const wchar_t *cell_content, ...); + +int ft_row_wwrite(ft_table_t *table, size_t cols, const wchar_t *row_cells[]); +int ft_row_wwrite_ln(ft_table_t *table, size_t cols, const wchar_t *row_cells[]); + +int ft_table_wwrite(ft_table_t *table, size_t rows, size_t cols, const wchar_t *table_cells[]); +int ft_table_wwrite_ln(ft_table_t *table, size_t rows, size_t cols, const wchar_t *table_cells[]); + +const wchar_t *ft_to_wstring(const ft_table_t *table); +#endif + + + +FT_END_DECLS + +#endif /* LIBFORT_H */ diff --git a/src/external/fort.hpp b/src/external/fort.hpp new file mode 100644 index 00000000..bd7598fa --- /dev/null +++ b/src/external/fort.hpp @@ -0,0 +1,1001 @@ +/* +libfort + +MIT License + +Copyright (c) 2017 - 2018 Seleznev Anton + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +/** + * @file fort.hpp + * @brief Main header file describing libfort C++ API . + * + * This files contains C++ wrappers around libfort API that can + * be used in C++ code. + */ +#ifndef LIBFORT_HPP +#define LIBFORT_HPP + +#include +#include +#include + +#include "fort.h" + +namespace fort +{ + +/** + * Alignment of cell content. + */ +enum class text_align { + left = FT_ALIGNED_LEFT, + center = FT_ALIGNED_CENTER, + right = FT_ALIGNED_RIGHT +}; + +/** + * Type of table row. Determines appearance of row. + */ +enum class row_type { + common = FT_ROW_COMMON, + header = FT_ROW_HEADER +}; + +/** + * Colors. + */ +enum class color { + default_color = FT_COLOR_DEFAULT, + black = FT_COLOR_BLACK, + red = FT_COLOR_RED, + green = FT_COLOR_GREEN, + yellow = FT_COLOR_YELLOW, + blue = FT_COLOR_BLUE, + magenta = FT_COLOR_MAGENTA, + cyan = FT_COLOR_CYAN, + light_gray = FT_COLOR_LIGHT_GRAY, + dark_gray = FT_COLOR_DARK_GRAY, + light_red = FT_COLOR_LIGHT_RED, + light_green = FT_COLOR_LIGHT_GREEN, + light_yellow = FT_COLOR_LIGHT_YELLOW, + light_blue = FT_COLOR_LIGHT_BLUE, + light_magenta = FT_COLOR_LIGHT_MAGENTA, + light_cyan = FT_COLOR_LIGHT_CYAN, + light_whyte = FT_COLOR_LIGHT_WHYTE +}; + +/** + * Text styles. + */ +enum class text_style { + default_style = FT_TSTYLE_DEFAULT, + bold = FT_TSTYLE_BOLD, + dim = FT_TSTYLE_DIM, + italic = FT_TSTYLE_ITALIC, + underlined = FT_TSTYLE_UNDERLINED, + blink = FT_TSTYLE_BLINK, + inverted = FT_TSTYLE_INVERTED, + hidden = FT_TSTYLE_HIDDEN +}; + +/** + * Table manipulator. + * + * Table manipulators can be used to change current cell and change appearance + * of cells. + */ +class table_manipulator { +public: + explicit table_manipulator(int i) + :value(i) + { + } + friend class table; +private: + int value; +}; + +/** + * Table manipulator to set current row as a header. + */ +const table_manipulator header(0); + +/** + * Table manipulator to move current cell to the first cell of the next row. + */ +const table_manipulator endr(1); + +/** + * Table manipulator to add separator to the table. + */ +const table_manipulator separator(2); + +/** + * Property owner. + * + * property_owner is a base class for all objects (table, row, column, cell) for + * which user can specify properties. + */ +template +class property_owner { +public: + + property_owner(std::size_t row_idx, std::size_t coll_idx, table *tbl, bool def = false) + :ps_row_idx_(row_idx), ps_coll_idx_(coll_idx), + ps_table_(tbl), set_default_properties_(def) {} + + /** + * Set min width for the specified cell of the table. + * + * @param value + * Value of the min width. + * @return + * - true: Success; cell property was changed. + * - false: In case of error + */ + bool set_cell_min_width(unsigned value) + { + return set_property(FT_CPROP_MIN_WIDTH, value); + } + + /** + * Set text alignment for the specified cell of the table. + * + * @param value + * Value of the text alignment. + * @return + * - true: Success; cell property was changed. + * - false: In case of error + */ + bool set_cell_text_align(enum fort::text_align value) + { + return set_property(FT_CPROP_TEXT_ALIGN, static_cast(value)); + } + + /** + * Set top padding for the specified cell of the table. + * + * @param value + * Value of the top padding. + * @return + * - true: Success; cell property was changed. + * - false: In case of error. + */ + bool set_cell_top_padding(unsigned value) + { + return set_property(FT_CPROP_TOP_PADDING, value); + } + + /** + * Set bottom padding for the specified cell of the table. + * + * @param value + * Value of the bottom padding. + * @return + * - true: Success; cell property was changed. + * - false: In case of error. + */ + bool set_cell_bottom_padding(unsigned value) + { + return set_property(FT_CPROP_BOTTOM_PADDING, value); + } + + /** + * Set left padding for the specified cell of the table. + * + * @param value + * Value of the left padding. + * @return + * - true: Success; cell property was changed. + * - false: In case of error. + */ + bool set_cell_left_padding(unsigned value) + { + return set_property(FT_CPROP_LEFT_PADDING, value); + } + + /** + * Set right padding for the specified cell of the table. + * + * @param value + * Value of the left padding. + * @return + * - true: Success; cell property was changed. + * - false: In case of error. + */ + bool set_cell_right_padding(unsigned value) + { + return set_property(FT_CPROP_RIGHT_PADDING, value); + } + + /** + * Set row type for the specified cell of the table. + * + * @param value + * Value of the row type. + * @return + * - true: Success; cell property was changed. + * - false: In case of error. + */ + bool set_cell_row_type(enum fort::row_type value) + { + return set_property(FT_CPROP_ROW_TYPE, static_cast(value)); + } + + /** + * Set empty string height for the specified cell of the table. + * + * @param value + * Value of the empty string height. + * @return + * - true: Success; cell property was changed. + * - false: In case of error. + */ + bool set_cell_empty_str_height(unsigned value) + { + return set_property(FT_CPROP_EMPTY_STR_HEIGHT, value); + } + + /** + * Set content foreground color for the specified cell of the table. + * + * @param value + * Color. + * @return + * - true: Success; cell property was changed. + * - false: In case of error. + */ + bool set_cell_content_fg_color(enum fort::color value) + { + return set_property(FT_CPROP_CONT_FG_COLOR, static_cast(value)); + } + + /** + * Set cell background color for the specified cell of the table. + * + * @param value + * Color. + * @return + * - true: Success; cell property was changed. + * - false: In case of error. + */ + bool set_cell_bg_color(enum fort::color value) + { + return set_property(FT_CPROP_CELL_BG_COLOR, static_cast(value)); + } + + /** + * Set content background color for the specified cell of the table. + * + * @param value + * Color. + * @return + * - true: Success; cell property was changed. + * - false: In case of error. + */ + bool set_cell_content_bg_color(enum fort::color value) + { + return set_property(FT_CPROP_CONT_BG_COLOR, static_cast(value)); + } + + /** + * Set cell text style for the specified cell of the table. + * + * @param value + * Text style. + * @return + * - true: Success; cell property was changed. + * - false: In case of error. + */ + bool set_cell_text_style(enum fort::text_style value) + { + return set_property(FT_CPROP_CELL_TEXT_STYLE, static_cast(value)); + } + + /** + * Set content text style for the specified cell of the table. + * + * @param value + * Text style. + * @return + * - true: Success; cell property was changed. + * - false: In case of error. + */ + bool set_cell_content_text_style(enum fort::text_style value) + { + return set_property(FT_CPROP_CONT_TEXT_STYLE, static_cast(value)); + } + +protected: + std::size_t ps_row_idx_; + std::size_t ps_coll_idx_; + table *ps_table_; + bool set_default_properties_; + + bool set_property(uint32_t property, int value) + { + int status; + if (set_default_properties_) { + status = ft_set_default_cell_prop(property, value); + } else { + status = ft_set_cell_prop(ps_table_->table_, ps_row_idx_, ps_coll_idx_, property, value); + } + return FT_IS_SUCCESS(status); + } +}; + +/** + * Formatted table. + * + * Table class is a C++ wrapper around struct ft_table. + */ +class table: public property_owner { +public: + + /** + * Default constructor. + */ + table() + :property_owner(FT_ANY_ROW, FT_ANY_COLUMN, this), table_(ft_create_table()) + { + + if (table_ == NULL) + throw std::runtime_error("Libfort runtime error"); + } + + /** + * Destructor. + */ + ~table() + { + ft_destroy_table(table_); + } + + /** + * Copy contstructor. + */ + table(const table& tbl) + :property_owner(FT_ANY_ROW, FT_ANY_COLUMN, this), table_(NULL) + { + if (tbl.table_) { + ft_table_t *table_copy = ft_copy_table(tbl.table_); + if (table_copy == NULL) + throw std::runtime_error("Libfort runtime error"); + + stream_.str(std::string()); + if (tbl.stream_.tellp() >= 0) { + stream_ << tbl.stream_.str(); + } + table_ = table_copy; + } + } + + /** + * Move contstructor. + */ + table(table&& tbl) + :property_owner(FT_ANY_ROW, FT_ANY_COLUMN, this), table_(tbl.table_) + { + if (tbl.stream_.tellp() >= 0) { + stream_ << tbl.stream_.str(); + tbl.stream_.str(std::string()); + } + tbl.table_ = 0; + } + + /** + * Copy assignment operator. + */ + table& operator=(const table& tbl) + { + if (&tbl == this) + return *this; + + if (tbl.table_) { + ft_table_t *table_copy = ft_copy_table(tbl.table_); + if (table_copy == NULL) + throw std::runtime_error("Libfort runtime error"); + + stream_.str(std::string()); + if (tbl.stream_.tellp() >= 0) { + stream_ << tbl.stream_.str(); + } + ft_destroy_table(table_); + table_ = table_copy; + } + return *this; + } + + /** + * Move assignment operator. + */ + table& operator=(table&& tbl) + { + if (&tbl == this) + return *this; + + if (tbl.table_) { + stream_.str(std::string()); + if (tbl.stream_.tellp() >= 0) { + stream_ << tbl.stream_.str(); + tbl.stream_.str(std::string()); + } + ft_destroy_table(table_); + table_ = tbl.table_; + tbl.table_ = NULL; + } + return *this; + } + + /** + * Convert table to string representation. + * + * @return + * - String representation of formatted table, on success. + * - In case of error std::runtime_error is thrown. + */ + std::string to_string() const + { + const char *str = ft_to_string(table_); + if (str == NULL) + throw std::runtime_error("Libfort runtime error"); + return str; + } + + /** + * Convert table to string representation. + * + * Table object has ownership of the returned pointer. So there is no need to + * free it. To take ownership user should explicitly copy the returned + * string with strdup or similar functions. + * + * Returned pointer may be later invalidated by: + * - Calling destroying the table; + * - Other invocations of c_str or to_string. + * + * @return + * - The pointer to the string representation of formatted table, on success. + * - NULL on error. + */ + const char *c_str() const + { + return ft_to_string(table_); + } + + /** + * Write provided object to the table. + * + * To convert object to the string representation conversion for + * std::ostream is used. + * + * @param arg + * Obect that would be inserted in the current cell. + * @return + * - Reference to the current table. + */ + template + table &operator<<(const T &arg) + { + stream_ << arg; + if (stream_.tellp() >= 0) { + ft_nwrite(table_, 1, stream_.str().c_str()); + stream_.str(std::string()); + } + return *this; + } + + table &operator<<(const table_manipulator &arg) + { + if (arg.value == header.value) + ft_set_cell_prop(table_, FT_CUR_ROW, FT_ANY_ROW, FT_CPROP_ROW_TYPE, FT_ROW_HEADER); + else if (arg.value == endr.value) + ft_ln(table_); + else if (arg.value == separator.value) + ft_add_separator(table_); + return *this; + } + + /** + * Write string to the the table. + * + * Write specified string to the current cell. + * + * @param str + * String to write. + * @return + * - 0: Success; data were written + * - (<0): In case of error + */ + bool write(const char *str) + { + return FT_IS_SUCCESS(ft_write(table_, str)); + } + + /** + * Write string to the the table and go to the next line. + * + * Write specified string to the current cell and move current position to + * the first cell of the next line(row). + * + * @param str + * String to write. + * @return + * - 0: Success; data were written + * - (<0): In case of error + */ + bool write_ln(const char *str) + { + return FT_IS_SUCCESS(ft_write_ln(table_, str)); + } + + /** + * Write string to the the table. + * + * Write specified string to the current cell. + * + * @param str + * String to write. + * @return + * - 0: Success; data were written + * - (<0): In case of error + */ + bool write(const std::string &str) + { + return write(str.c_str()); + } + + /** + * Write string to the the table and go to the next line. + * + * Write specified string to the current cell and move current position to + * the first cell of the next line(row). + * + * @param str + * String to write. + * @return + * - 0: Success; data were written + * - (<0): In case of error + */ + bool write_ln(const std::string &str) + { + return write_ln(str.c_str()); + } + +#ifdef __cpp_variadic_templates + /** + * Write strings to the table. + * + * Write specified strings to the same number of consecutive cells in the + * current row. + * + * @param str + * String to write. + * @param strings + * Strings to write. + * @return + * - 0: Success; data were written + * - (<0): In case of error + */ + template + bool write(const T &str, const Ts &...strings) + { + return write(str) && write(strings...); + } + + /** + * Write strings to the table and go to the next line. + * + * Write specified strings to the same number of consecutive cells in the + * current row and move current position to the first cell of the next + * line(row). + * + * @param str + * String to write. + * @param strings + * Strings to write. + * @return + * - 0: Success; data were written + * - (<0): In case of error + */ + template + bool write_ln(const T &str, const Ts &...strings) + { + return write(str) && write_ln(strings...); + } +#else /* __cpp_variadic_templates */ + + template + bool write(const T_0 &arg_0, const T_1 &arg_1) + { + return write(arg_0) && write(arg_1); + } + + template + bool write(const T_0 &arg_0, const T_1 &arg_1, const T_2 &arg_2) + { + return write(arg_0) && write(arg_1, arg_2); + } + + template + bool write(const T_0 &arg_0, const T_1 &arg_1, const T_2 &arg_2, const T_3 &arg_3) + { + return write(arg_0) && write(arg_1, arg_2, arg_3); + } + + template + bool write(const T_0 &arg_0, const T_1 &arg_1, const T_2 &arg_2, const T_3 &arg_3, const T_4 &arg_4) + { + return write(arg_0) && write(arg_1, arg_2, arg_3, arg_4); + } + + template + bool write(const T_0 &arg_0, const T_1 &arg_1, const T_2 &arg_2, const T_3 &arg_3, const T_4 &arg_4, const T_5 &arg_5) + { + return write(arg_0) && write(arg_1, arg_2, arg_3, arg_4, arg_5); + } + + template + bool write(const T_0 &arg_0, const T_1 &arg_1, const T_2 &arg_2, const T_3 &arg_3, const T_4 &arg_4, const T_5 &arg_5, const T_6 &arg_6) + { + return write(arg_0) && write(arg_1, arg_2, arg_3, arg_4, arg_5, arg_6); + } + + template + bool write(const T_0 &arg_0, const T_1 &arg_1, const T_2 &arg_2, const T_3 &arg_3, const T_4 &arg_4, const T_5 &arg_5, const T_6 &arg_6, const T_7 &arg_7) + { + return write(arg_0) && write(arg_1, arg_2, arg_3, arg_4, arg_5, arg_6, arg_7); + } + + + template + bool write_ln(const T_0 &arg_0, const T_1 &arg_1) + { + return write(arg_0) && write_ln(arg_1); + } + + template + bool write_ln(const T_0 &arg_0, const T_1 &arg_1, const T_2 &arg_2) + { + return write(arg_0) && write_ln(arg_1, arg_2); + } + + template + bool write_ln(const T_0 &arg_0, const T_1 &arg_1, const T_2 &arg_2, const T_3 &arg_3) + { + return write(arg_0) && write_ln(arg_1, arg_2, arg_3); + } + + template + bool write_ln(const T_0 &arg_0, const T_1 &arg_1, const T_2 &arg_2, const T_3 &arg_3, const T_4 &arg_4) + { + return write(arg_0) && write_ln(arg_1, arg_2, arg_3, arg_4); + } + + template + bool write_ln(const T_0 &arg_0, const T_1 &arg_1, const T_2 &arg_2, const T_3 &arg_3, const T_4 &arg_4, const T_5 &arg_5) + { + return write(arg_0) && write_ln(arg_1, arg_2, arg_3, arg_4, arg_5); + } + + template + bool write_ln(const T_0 &arg_0, const T_1 &arg_1, const T_2 &arg_2, const T_3 &arg_3, const T_4 &arg_4, const T_5 &arg_5, const T_6 &arg_6) + { + return write(arg_0) && write_ln(arg_1, arg_2, arg_3, arg_4, arg_5, arg_6); + } + + template + bool write_ln(const T_0 &arg_0, const T_1 &arg_1, const T_2 &arg_2, const T_3 &arg_3, const T_4 &arg_4, const T_5 &arg_5, const T_6 &arg_6, const T_7 &arg_7) + { + return write(arg_0) && write_ln(arg_1, arg_2, arg_3, arg_4, arg_5, arg_6, arg_7); + } + +#endif /* __cpp_variadic_templates */ + + /** + * Write elements from range to the table. + * + * Write objects from range to consecutive cells in the current row. + * + * @param first, last + * Range of elements. + * @return + * - 0: Success; data were written + * - (<0): In case of error + */ + template + bool range_write(InputIt first, InputIt last) + { + while (first != last) { + *this << *first; + ++first; + } + return true; + } + + /** + * Write elements from range to the table and go to the next line. + * + * Write objects from range to consecutive cells in the current row and + * move current position to the first cell of the next line(row). + * + * @param first, last + * Range of elements. + * @return + * - 0: Success; data were written + * - (<0): In case of error + */ + template + bool range_write_ln(InputIt first, InputIt last) + { + while (first != last) { + *this << *first; + ++first; + } + ft_ln(table_); + return true; + } + + /** + * Set border style for the table. + * + * @param style + * Pointer to border style. + * @return + * - True: Success; table border style was changed. + * - False: Error + */ + bool set_border_style(struct ft_border_style *style) + { + return FT_IS_SUCCESS(ft_set_border_style(table_, style)); + } + + /** + * Set current cell position. + * + * Current cell - cell that will be edited with all modifiing functions. + * + * @param row_i + * New row number for the current cell. + * @param col_i + * New row number for the current cell. + */ + void set_cur_cell(size_t row_i, size_t col_i) + { + ft_set_cur_cell(table_, row_i, col_i); + } + + + /** + * Set table left margin. + * + * @param value + * Left margin. + * @return + * - true: Success; table property was changed. + * - false: In case of error. + */ + bool set_left_margin(unsigned value) + { + return FT_IS_SUCCESS(ft_set_tbl_prop(table_, FT_TPROP_LEFT_MARGIN, value)); + } + + /** + * Set table top margin. + * + * @param value + * Top margin. + * @return + * - true: Success; table property was changed. + * - false: In case of error. + */ + bool set_top_margin(unsigned value) + { + return FT_IS_SUCCESS(ft_set_tbl_prop(table_, FT_TPROP_TOP_MARGIN, value)); + } + + /** + * Set table right margin. + * + * @param value + * Right margin. + * @return + * - true: Success; table property was changed. + * - false: In case of error. + */ + bool set_right_margin(unsigned value) + { + return FT_IS_SUCCESS(ft_set_tbl_prop(table_, FT_TPROP_RIGHT_MARGIN, value)); + } + + /** + * Set table bottom margin. + * + * @param value + * Bottom margin. + * @return + * - true: Success; table property was changed. + * - false: In case of error. + */ + bool set_bottom_margin(unsigned value) + { + return FT_IS_SUCCESS(ft_set_tbl_prop(table_, FT_TPROP_BOTTOM_MARGIN, value)); + } +private: + ft_table_t *table_; + mutable std::stringstream stream_; + friend class property_owner
; + + +public: + + /* Iterators */ + /* todo: implement chains like table[0][0] = table [0][1] = "somethings" */ + + /** + * Table cell. + */ + class table_cell: public property_owner
+ { + public: + table_cell(std::size_t row_idx, std::size_t coll_idx, table &tbl) + :property_owner(row_idx, coll_idx, &tbl) {} + + table_cell& operator=(const char *str) + { + ft_set_cur_cell(ps_table_->table_, ps_row_idx_, ps_coll_idx_); + ps_table_->write(str); + return *this; + } + + table_cell& operator=(const std::string &str) + { + return operator=(str.c_str()); + } + + /** + * Set column span for the specified cell of the table. + * + * @param hor_span + * Column span. + * @return + * - true: Success; cell span was changed. + * - false: In case of error. + */ + bool set_cell_span(size_t hor_span) + { + if (set_default_properties_) + return false; + + return FT_IS_SUCCESS(ft_set_cell_span(ps_table_->table_, ps_row_idx_, ps_coll_idx_, hor_span)); + } + }; + + /** + * Table row. + */ + class table_row: public property_owner
+ { + public: + table_row(std::size_t row_idx, table &tbl) + :property_owner(row_idx, FT_ANY_COLUMN, &tbl) {} + + class table_cell + operator[](std::size_t coll_idx) + { + return table_cell(ps_row_idx_, coll_idx, *ps_table_); + } + }; + + /** + * Table column. + */ + class table_column: public property_owner
+ { + public: + table_column(std::size_t col_idx, table &tbl) + :property_owner(FT_ANY_ROW, col_idx, &tbl) {} + }; + + class default_properties: public property_owner
+ { + public: + default_properties(table *tbl) + :property_owner(FT_ANY_ROW, FT_ANY_COLUMN, tbl, true) {} + }; + + class table_row + operator[](std::size_t row_idx) + { + return table_row(row_idx, *this); + } + + + /** + * Get cell. + * + * @param row_idx + * Row index. + * @param col_idx + * Column index. + * @return + * table_cell object. + */ + class table_cell + cell(std::size_t row_idx, std::size_t col_idx) + { + return (*this)[row_idx][col_idx]; + } + + /** + * Get row. + * + * @param row_idx + * Row index. + * @return + * table_row object. + */ + class table_row + row(std::size_t row_idx) + { + return table_row(row_idx, *this); + } + + /** + * Get column. + * + * @param col_idx + * Column index. + * @return + * table_column object. + */ + class table_column + column(std::size_t col_idx) + { + return table_column(col_idx, *this); + } + + static class default_properties + default_props() + { + return default_properties(NULL); + } +}; + + +/** + * Set default border style for all new formatted tables. + * + * @param style + * Pointer to border style. + * @return + * - True: Success; table border style was changed. + * - False: Error + */ +inline bool set_default_border_style(struct ft_border_style *style) +{ + return FT_IS_SUCCESS(ft_set_default_border_style(style)); +} + + +} + +#endif // LIBFORT_HPP From 7144d5164c6da318eff4b98b6758bc42b4825dde Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Fri, 20 Dec 2019 22:03:45 -0500 Subject: [PATCH 029/111] Added capability to read nodal boundaries (SPC) domains from BDF. - also added method to print Nastran property ID to libMesh/MAST subdomain ID mapping --- src/mesh/nastran_io.cpp | 97 +++- src/mesh/nastran_io.h | 51 +- src/mesh/pynastran_io.cpp | 1150 ++++++++++++++++++++++++++----------- src/mesh/pynastran_io.h | 3 +- src/mesh/pynastran_io.pyx | 16 + 5 files changed, 948 insertions(+), 369 deletions(-) diff --git a/src/mesh/nastran_io.cpp b/src/mesh/nastran_io.cpp index a276fc9b..a322ba84 100644 --- a/src/mesh/nastran_io.cpp +++ b/src/mesh/nastran_io.cpp @@ -1,23 +1,23 @@ -// C++ includes +// C++ includes. #include #include -//libMesh includes -#include "libmesh/point.h" -#include "libmesh/elem.h" -#include "libmesh/string_to_enum.h" -#include "libmesh/boundary_info.h" -#include "libmesh/utility.h" -#include "libmesh/libmesh_common.h" -#include "libmesh/mesh_input.h" -#include "libmesh/elem.h" - -// Local includes +// libMesh includes. +#include +#include +#include +#include +#include +#include +#include +#include + +// MAST includes. #include "mesh/nastran_io.h" -#include "Python.h" +#include "external/fort.hpp" -void MAST::printElementMap(std::map>> elementMap) +MAST::NastranIO::NastranIO (libMesh::MeshBase& mesh, const bool python_preinit): { // Iterate through element types for (const auto& item : elementMap) @@ -49,11 +49,10 @@ void MAST::printNodeCoords(std::vector> nodes) } -MAST::NastranIO::NastranIO (libMesh::MeshBase& mesh, const bool pythonPreinitialized): libMesh::MeshInput (mesh), -_pythonPreinitialized(pythonPreinitialized) +_pythonPreinitialized(python_preinit) { - // Initialize Python if it hasn't already been initialized + // Initialize Python if it hasn't already been initialized. if ((not pythonInitialized) and (not _pythonPreinitialized)) { initializePython(); @@ -203,7 +202,25 @@ void MAST::NastranIO::read_elements(BDFModel* model, libMesh::MeshBase& the_mesh } -void MAST::NastranIO::read (const std::string & fname) +void MAST::NastranIO::read_node_boundaries(BDFModel* model, libMesh::MeshBase& the_mesh) +{ + // Currently we simply translate all the SPC ID's that show up inside the BDF + // over into node boundaries in libMesh. + + std::map> SPCs = getSPCs(model); + uint j=1; + for (const auto& spc : SPCs) + { + for (uint i=0; iadd_node(nastran2libMeshNodeMap[spc.second[i]], j); + } + j++; + } +} + + +void MAST::NastranIO::read (const std::string& filename) { // Get a reference to the mesh we are reading libMesh::MeshBase& the_mesh = MeshInput::mesh(); @@ -212,7 +229,7 @@ void MAST::NastranIO::read (const std::string & fname) the_mesh.clear(); // Read the Nastran BDF using pyNastran - BDFModel* model = buildBDFModel(fname); + BDFModel* model = buildBDFModel(filename); // Set the dimensions of the mesh the_mesh.set_mesh_dimension(model->nDims); @@ -222,6 +239,12 @@ void MAST::NastranIO::read (const std::string & fname) // Add elements from the model to the mesh read_elements(model, the_mesh); + + // Add nodal boundary conditions defined as SPCs from the model to the mesh + read_node_boundaries(model, the_mesh); + + // Prepare mesh for use. + the_mesh.prepare_for_use(); } void MAST::NastranIO::read(BDFModel* model) @@ -247,15 +270,19 @@ void MAST::NastranIO::read(BDFModel* model) void MAST::NastranIO::initializePython() { // StackOverFlow, "Use generated header file from Cython" - int status = PyImport_AppendInittab("pynastranIO", PyInit_pynastran_io); - if(status==1){ - libmesh_error_msg("ERROR: During Python import for pynastranIO."); + // - related to using multi-stage imports + int status = PyImport_AppendInittab("pynastran_io", PyInit_pynastran_io); + if(status==-1){ + libmesh_error_msg("ERROR: During Python import for pynastran_io."); } Py_Initialize(); - PyObject* pynastran_module = PyImport_ImportModule("pynastranIO"); + + PyObject* pynastran_module = PyImport_ImportModule("pynastran_io"); + if(pynastran_module==NULL){ + PyErr_Print(); // Prints out error that occurred back in the Python interpreter. Py_Finalize(); - libmesh_error_msg("ERROR: During Python initialization for pynastranIO."); + libmesh_error_msg("ERROR: During Python initialization for pynastran_io."); } pythonInitialized = true; } @@ -266,7 +293,21 @@ void MAST::NastranIO::finalizePython() Py_Finalize(); pythonInitialized = false; } - - - - + + +void MAST::NastranIO::print_pid_to_subdomain_id_map() { + fort::table table; + table << fort::header << "Nastran Property ID" << "libMesh/MAST Subdomain ID" << fort::endr; + + std::string sid_str; // must reduce std::set of libMesh subdomain IDs to string for table output. + for (const auto& id_pair: getPID2subdomainIDsMap()) { + table << std::to_string(id_pair.first); + for (const auto& sid: id_pair.second) { + sid_str.append(std::to_string(sid) + " "); + } + table << sid_str << fort::endr; + } + libMesh::out << std::endl << "DOMAIN MAPPING" << std::endl; + libMesh::out << table.to_string() << std::endl; +} + diff --git a/src/mesh/nastran_io.h b/src/mesh/nastran_io.h index 87824e36..5326a43c 100644 --- a/src/mesh/nastran_io.h +++ b/src/mesh/nastran_io.h @@ -1,21 +1,24 @@ #ifndef __mast_nastran_io_h__ #define __mast_nastran_io_h__ - -// C++ Includes +// C++ includes. #include #include #include -// libMesh Includes -#include "libmesh/libmesh_common.h" -#include "libmesh/mesh_input.h" -#include "libmesh/elem.h" +// libMesh includes. +#include +#include +#include + +// Python includes. +#include -#include "Python.h" +// MAST includes. #include "mesh/nastran_io.h" #include "mesh/pynastran_io.h" + namespace MAST { void printElementMap(std::map>> elementMap); @@ -23,15 +26,28 @@ namespace MAST { void printNodeCoords(std::vector> nodes); /** - * The NastranIO class is a preliminary implementation for reading NASTRAN - * mesh files using pyNastran with BDF files as input. + * Nastran BDF mesh input. + * The NastranIO class is a preliminary implementation for reading NASTRAN mesh information + * using pyNastran with BDF data as input. Currently nodes, elements, & node boundary condition + * definition are supported. + * + * Nodal BCs are mapped into libMesh node boundary sets based on + * SPC IDs and nodes assigned to them in the BDF file. */ class NastranIO : public libMesh::MeshInput { public: - explicit - NastranIO(libMesh::MeshBase& mesh, const bool pythonPreinitialized=false); - + /** + * Constructor. + * @param mesh a libMesh mesh object. + * @param python_preinit bool describing if Python has been already initialized somewhere + * in the current program (by another C++/Python interface). + */ + explicit NastranIO(libMesh::MeshBase& mesh, const bool python_preinit=false); + + /** + * Destructor. + */ virtual ~NastranIO (); virtual void read (const std::string & name) override; @@ -46,6 +62,16 @@ namespace MAST { std::map, int> getPIDElemtype2SubdomainIDMap(); std::map> getPID2subdomainIDsMap(); + /** + * Print map between Nastran property ID's (PID) to libMesh subdomain + * ID's (SID) to libMesh::out. Note that some PID will correspond to + * multiple SID since libMesh requires all elements in a subdomain to + * be the same type, but Nastran allows property assignment to multiple + * element types from the same property card (ie. one PSHELL card + * providing properties to both CQUAD4 and CTRIA3). + */ + void print_pid_to_subdomain_id_map(); + private: const bool _pythonPreinitialized = false; @@ -59,6 +85,7 @@ namespace MAST { void read_nodes(BDFModel* model, libMesh::MeshBase& the_mesh); void read_elements(BDFModel* model, libMesh::MeshBase& the_mesh); + void read_node_boundaries(BDFModel* model, libMesh::MeshBase& the_mesh); // Map from NASTRAN Elements to Equivalent libMesh Elements // TODO: Not yet complete, need to add all NASTRAN elements which we need support for. diff --git a/src/mesh/pynastran_io.cpp b/src/mesh/pynastran_io.cpp index f3c264c8..d0045792 100644 --- a/src/mesh/pynastran_io.cpp +++ b/src/mesh/pynastran_io.cpp @@ -1,4 +1,4 @@ -/* Generated by Cython 0.29.6 */ +/* Generated by Cython 0.29.13 */ #define PY_SSIZE_T_CLEAN #include "Python.h" @@ -7,8 +7,8 @@ #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) #error Cython requires Python 2.6+ or Python 3.3+. #else -#define CYTHON_ABI "0_29_6" -#define CYTHON_HEX_VERSION 0x001D06F0 +#define CYTHON_ABI "0_29_13" +#define CYTHON_HEX_VERSION 0x001D0DF0 #define CYTHON_FUTURE_DIVISION 1 #include #ifndef offsetof @@ -324,8 +324,13 @@ class __Pyx_FakeReference { #define __Pyx_DefaultClassType PyClass_Type #else #define __Pyx_BUILTIN_MODULE_NAME "builtins" +#if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2 + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ + PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) +#else #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) +#endif #define __Pyx_DefaultClassType PyType_Type #endif #ifndef Py_TPFLAGS_CHECKTYPES @@ -852,7 +857,7 @@ static const char *__pyx_f[] = { "type.pxd", }; -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":776 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":776 * # in Cython to enable them only on the right systems. * * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< @@ -861,7 +866,7 @@ static const char *__pyx_f[] = { */ typedef npy_int8 __pyx_t_5numpy_int8_t; -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":777 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":777 * * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< @@ -870,7 +875,7 @@ typedef npy_int8 __pyx_t_5numpy_int8_t; */ typedef npy_int16 __pyx_t_5numpy_int16_t; -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":778 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":778 * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< @@ -879,7 +884,7 @@ typedef npy_int16 __pyx_t_5numpy_int16_t; */ typedef npy_int32 __pyx_t_5numpy_int32_t; -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":779 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":779 * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< @@ -888,7 +893,7 @@ typedef npy_int32 __pyx_t_5numpy_int32_t; */ typedef npy_int64 __pyx_t_5numpy_int64_t; -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":783 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":783 * #ctypedef npy_int128 int128_t * * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< @@ -897,7 +902,7 @@ typedef npy_int64 __pyx_t_5numpy_int64_t; */ typedef npy_uint8 __pyx_t_5numpy_uint8_t; -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":784 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":784 * * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< @@ -906,7 +911,7 @@ typedef npy_uint8 __pyx_t_5numpy_uint8_t; */ typedef npy_uint16 __pyx_t_5numpy_uint16_t; -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":785 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":785 * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< @@ -915,7 +920,7 @@ typedef npy_uint16 __pyx_t_5numpy_uint16_t; */ typedef npy_uint32 __pyx_t_5numpy_uint32_t; -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":786 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":786 * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< @@ -924,7 +929,7 @@ typedef npy_uint32 __pyx_t_5numpy_uint32_t; */ typedef npy_uint64 __pyx_t_5numpy_uint64_t; -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":790 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":790 * #ctypedef npy_uint128 uint128_t * * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< @@ -933,7 +938,7 @@ typedef npy_uint64 __pyx_t_5numpy_uint64_t; */ typedef npy_float32 __pyx_t_5numpy_float32_t; -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":791 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":791 * * ctypedef npy_float32 float32_t * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< @@ -942,7 +947,7 @@ typedef npy_float32 __pyx_t_5numpy_float32_t; */ typedef npy_float64 __pyx_t_5numpy_float64_t; -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":800 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":800 * # The int types are mapped a bit surprising -- * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t # <<<<<<<<<<<<<< @@ -951,7 +956,7 @@ typedef npy_float64 __pyx_t_5numpy_float64_t; */ typedef npy_long __pyx_t_5numpy_int_t; -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< @@ -960,7 +965,7 @@ typedef npy_long __pyx_t_5numpy_int_t; */ typedef npy_longlong __pyx_t_5numpy_long_t; -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":802 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":802 * ctypedef npy_long int_t * ctypedef npy_longlong long_t * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< @@ -969,7 +974,7 @@ typedef npy_longlong __pyx_t_5numpy_long_t; */ typedef npy_longlong __pyx_t_5numpy_longlong_t; -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":804 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":804 * ctypedef npy_longlong longlong_t * * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< @@ -978,7 +983,7 @@ typedef npy_longlong __pyx_t_5numpy_longlong_t; */ typedef npy_ulong __pyx_t_5numpy_uint_t; -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":805 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":805 * * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< @@ -987,7 +992,7 @@ typedef npy_ulong __pyx_t_5numpy_uint_t; */ typedef npy_ulonglong __pyx_t_5numpy_ulong_t; -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":806 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":806 * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< @@ -996,7 +1001,7 @@ typedef npy_ulonglong __pyx_t_5numpy_ulong_t; */ typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":808 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":808 * ctypedef npy_ulonglong ulonglong_t * * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< @@ -1005,7 +1010,7 @@ typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; */ typedef npy_intp __pyx_t_5numpy_intp_t; -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":809 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":809 * * ctypedef npy_intp intp_t * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< @@ -1014,7 +1019,7 @@ typedef npy_intp __pyx_t_5numpy_intp_t; */ typedef npy_uintp __pyx_t_5numpy_uintp_t; -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":811 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":811 * ctypedef npy_uintp uintp_t * * ctypedef npy_double float_t # <<<<<<<<<<<<<< @@ -1023,7 +1028,7 @@ typedef npy_uintp __pyx_t_5numpy_uintp_t; */ typedef npy_double __pyx_t_5numpy_float_t; -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":812 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":812 * * ctypedef npy_double float_t * ctypedef npy_double double_t # <<<<<<<<<<<<<< @@ -1032,7 +1037,7 @@ typedef npy_double __pyx_t_5numpy_float_t; */ typedef npy_double __pyx_t_5numpy_double_t; -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":813 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":813 * ctypedef npy_double float_t * ctypedef npy_double double_t * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< @@ -1077,7 +1082,7 @@ static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(do /*--- Type declarations ---*/ struct BDFModel; -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":815 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":815 * ctypedef npy_longdouble longdouble_t * * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< @@ -1086,7 +1091,7 @@ struct BDFModel; */ typedef npy_cfloat __pyx_t_5numpy_cfloat_t; -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":816 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":816 * * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< @@ -1095,7 +1100,7 @@ typedef npy_cfloat __pyx_t_5numpy_cfloat_t; */ typedef npy_cdouble __pyx_t_5numpy_cdouble_t; -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":817 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":817 * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< @@ -1104,7 +1109,7 @@ typedef npy_cdouble __pyx_t_5numpy_cdouble_t; */ typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":819 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":819 * ctypedef npy_clongdouble clongdouble_t * * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< @@ -1272,7 +1277,7 @@ static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name); #define __Pyx_PyFunction_FastCall(func, args, nargs)\ __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) #if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs); +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs); #else #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) #endif @@ -1503,6 +1508,14 @@ static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { #define __Pyx_PyList_Append(L,x) PyList_Append(L,x) #endif +/* PyIntBinop.proto */ +#if !CYTHON_COMPILING_IN_PYPY +static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check); +#else +#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\ + (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2)) +#endif + /* DictGetItem.proto */ #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key); @@ -1857,6 +1870,7 @@ __PYX_EXTERN_C void printBDFStats(struct BDFModel *); /*proto*/ __PYX_EXTERN_C std::vector > getNodes(struct BDFModel *); /*proto*/ __PYX_EXTERN_C std::map > > getElements(struct BDFModel *); /*proto*/ __PYX_EXTERN_C std::map getNumberOfElementTypes(struct BDFModel *); /*proto*/ +__PYX_EXTERN_C std::map > getSPCs(struct BDFModel *); /*proto*/ static PyObject *__pyx_f_12pynastran_io_perturbZeroLengthBushings(struct BDFModel *); /*proto*/ static std::string __pyx_convert_string_from_py_std__in_string(PyObject *); /*proto*/ static CYTHON_INLINE PyObject *__pyx_convert_PyObject_string_to_py_std__in_string(std::string const &); /*proto*/ @@ -1865,6 +1879,7 @@ static CYTHON_INLINE PyObject *__pyx_convert_PyStr_string_to_py_std__in_string(s static CYTHON_INLINE PyObject *__pyx_convert_PyBytes_string_to_py_std__in_string(std::string const &); /*proto*/ static CYTHON_INLINE PyObject *__pyx_convert_PyByteArray_string_to_py_std__in_string(std::string const &); /*proto*/ static PyObject *__pyx_convert_map_to_py_std_3a__3a_string____int(std::map const &); /*proto*/ +static std::vector __pyx_convert_vector_from_py_int(PyObject *); /*proto*/ #define __Pyx_MODULE_NAME "pynastran_io" extern int __pyx_module_is_main_pynastran_io; int __pyx_module_is_main_pynastran_io = 0; @@ -1894,6 +1909,7 @@ static const char __pyx_k_keys[] = "keys"; static const char __pyx_k_main[] = "__main__"; static const char __pyx_k_name[] = "__name__"; static const char __pyx_k_norm[] = "norm"; +static const char __pyx_k_spcs[] = "spcs"; static const char __pyx_k_test[] = "__test__"; static const char __pyx_k_type[] = "type"; static const char __pyx_k_warn[] = "warn"; @@ -1940,6 +1956,7 @@ static const char __pyx_k_reject_count[] = "reject_count"; static const char __pyx_k_get_bdf_stats[] = "get_bdf_stats"; static const char __pyx_k_reduce_cython[] = "__reduce_cython__"; static const char __pyx_k_reject_count_s[] = "reject_count = %s\n"; +static const char __pyx_k_Subcase_i__s__i[] = "Subcase-%i_%s_%i"; static const char __pyx_k_setstate_cython[] = "__setstate_cython__"; static const char __pyx_k_object_attributes[] = "object_attributes"; static const char __pyx_k_pyNastran_bdf_bdf[] = "pyNastran.bdf.bdf"; @@ -1972,6 +1989,7 @@ static PyObject *__pyx_kp_u_Non_native_byte_order_not_suppor; static PyObject *__pyx_n_s_NotImplementedError; static PyObject *__pyx_kp_u_Perturbing_GRID_i_by_s_to_define; static PyObject *__pyx_n_s_RuntimeError; +static PyObject *__pyx_kp_u_Subcase_i__s__i; static PyObject *__pyx_kp_u_Support_of_non_zero_offets_not_y; static PyObject *__pyx_kp_u_Support_of_non_zero_offsets_not; static PyObject *__pyx_n_s_TypeError; @@ -2030,6 +2048,7 @@ static PyObject *__pyx_n_s_reject_count; static PyObject *__pyx_kp_u_reject_count_s; static PyObject *__pyx_n_s_setstate; static PyObject *__pyx_n_s_setstate_cython; +static PyObject *__pyx_n_s_spcs; static PyObject *__pyx_n_s_strip; static PyObject *__pyx_n_s_test; static PyObject *__pyx_n_s_tolist; @@ -2056,6 +2075,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s static PyObject *__pyx_tp_new_12pynastran_io_BDFModel(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_float_0_0; static PyObject *__pyx_int_0; +static PyObject *__pyx_int_1; static PyObject *__pyx_tuple_; static PyObject *__pyx_tuple__2; static PyObject *__pyx_tuple__5; @@ -4118,6 +4138,230 @@ std::map getNumberOfElementTypes(struct BDFModel *__pyx_v_mode } /* "pynastran_io.pyx":208 + * + * + * cdef public map[string, vector[int]] getSPCs(BDFModel model): # <<<<<<<<<<<<<< + * """ + * Create a map of subcase SPCs and the nodes that belong to that SPC. Useful for creating boundaries in libMesh. + */ + +std::map > getSPCs(struct BDFModel *__pyx_v_model) { + std::map > __pyx_v_SPCs; + PyObject *__pyx_v_subcase_num = NULL; + PyObject *__pyx_v_spcs = NULL; + PyObject *__pyx_v_i = NULL; + PyObject *__pyx_v_spc = NULL; + PyObject *__pyx_v_name = NULL; + std::map > __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; + Py_ssize_t __pyx_t_3; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + Py_ssize_t __pyx_t_8; + PyObject *(*__pyx_t_9)(PyObject *); + PyObject *__pyx_t_10 = NULL; + std::vector __pyx_t_11; + std::string __pyx_t_12; + __Pyx_RefNannySetupContext("getSPCs", 0); + + /* "pynastran_io.pyx":214 + * cdef map[string, vector[int]] SPCs + * + * for subcase_num, spcs in model.myBDF.spcs.items(): # <<<<<<<<<<<<<< + * i = 1 + * for spc in spcs: + */ + __pyx_t_2 = 0; + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_model->myBDF, __pyx_n_s_spcs); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 214, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + if (unlikely(__pyx_t_5 == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); + __PYX_ERR(1, 214, __pyx_L1_error) + } + __pyx_t_6 = __Pyx_dict_iterator(__pyx_t_5, 0, __pyx_n_s_items, (&__pyx_t_3), (&__pyx_t_4)); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 214, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_XDECREF(__pyx_t_1); + __pyx_t_1 = __pyx_t_6; + __pyx_t_6 = 0; + while (1) { + __pyx_t_7 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_3, &__pyx_t_2, &__pyx_t_6, &__pyx_t_5, NULL, __pyx_t_4); + if (unlikely(__pyx_t_7 == 0)) break; + if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(1, 214, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_GOTREF(__pyx_t_5); + __Pyx_XDECREF_SET(__pyx_v_subcase_num, __pyx_t_6); + __pyx_t_6 = 0; + __Pyx_XDECREF_SET(__pyx_v_spcs, __pyx_t_5); + __pyx_t_5 = 0; + + /* "pynastran_io.pyx":215 + * + * for subcase_num, spcs in model.myBDF.spcs.items(): + * i = 1 # <<<<<<<<<<<<<< + * for spc in spcs: + * name = "Subcase-%i_%s_%i"%(subcase_num, spc.type, i) + */ + __Pyx_INCREF(__pyx_int_1); + __Pyx_XDECREF_SET(__pyx_v_i, __pyx_int_1); + + /* "pynastran_io.pyx":216 + * for subcase_num, spcs in model.myBDF.spcs.items(): + * i = 1 + * for spc in spcs: # <<<<<<<<<<<<<< + * name = "Subcase-%i_%s_%i"%(subcase_num, spc.type, i) + * SPCs[name.encode("utf-8")] = spc.nodes + */ + if (likely(PyList_CheckExact(__pyx_v_spcs)) || PyTuple_CheckExact(__pyx_v_spcs)) { + __pyx_t_5 = __pyx_v_spcs; __Pyx_INCREF(__pyx_t_5); __pyx_t_8 = 0; + __pyx_t_9 = NULL; + } else { + __pyx_t_8 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_spcs); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 216, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_9 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 216, __pyx_L1_error) + } + for (;;) { + if (likely(!__pyx_t_9)) { + if (likely(PyList_CheckExact(__pyx_t_5))) { + if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_5)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_6 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_8); __Pyx_INCREF(__pyx_t_6); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(1, 216, __pyx_L1_error) + #else + __pyx_t_6 = PySequence_ITEM(__pyx_t_5, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 216, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + #endif + } else { + if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_5)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_8); __Pyx_INCREF(__pyx_t_6); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(1, 216, __pyx_L1_error) + #else + __pyx_t_6 = PySequence_ITEM(__pyx_t_5, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 216, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + #endif + } + } else { + __pyx_t_6 = __pyx_t_9(__pyx_t_5); + if (unlikely(!__pyx_t_6)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(1, 216, __pyx_L1_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_6); + } + __Pyx_XDECREF_SET(__pyx_v_spc, __pyx_t_6); + __pyx_t_6 = 0; + + /* "pynastran_io.pyx":217 + * i = 1 + * for spc in spcs: + * name = "Subcase-%i_%s_%i"%(subcase_num, spc.type, i) # <<<<<<<<<<<<<< + * SPCs[name.encode("utf-8")] = spc.nodes + * i+=1 + */ + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_spc, __pyx_n_s_type); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 217, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 217, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_INCREF(__pyx_v_subcase_num); + __Pyx_GIVEREF(__pyx_v_subcase_num); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_subcase_num); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_6); + __Pyx_INCREF(__pyx_v_i); + __Pyx_GIVEREF(__pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_v_i); + __pyx_t_6 = 0; + __pyx_t_6 = PyUnicode_Format(__pyx_kp_u_Subcase_i__s__i, __pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 217, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_XDECREF_SET(__pyx_v_name, ((PyObject*)__pyx_t_6)); + __pyx_t_6 = 0; + + /* "pynastran_io.pyx":218 + * for spc in spcs: + * name = "Subcase-%i_%s_%i"%(subcase_num, spc.type, i) + * SPCs[name.encode("utf-8")] = spc.nodes # <<<<<<<<<<<<<< + * i+=1 + * + */ + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_spc, __pyx_n_s_nodes); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 218, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_11 = __pyx_convert_vector_from_py_int(__pyx_t_6); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 218, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = PyUnicode_AsUTF8String(__pyx_v_name); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 218, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_12 = __pyx_convert_string_from_py_std__in_string(__pyx_t_6); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 218, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + (__pyx_v_SPCs[__pyx_t_12]) = __pyx_t_11; + + /* "pynastran_io.pyx":219 + * name = "Subcase-%i_%s_%i"%(subcase_num, spc.type, i) + * SPCs[name.encode("utf-8")] = spc.nodes + * i+=1 # <<<<<<<<<<<<<< + * + * return SPCs + */ + __pyx_t_6 = __Pyx_PyInt_AddObjC(__pyx_v_i, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 219, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF_SET(__pyx_v_i, __pyx_t_6); + __pyx_t_6 = 0; + + /* "pynastran_io.pyx":216 + * for subcase_num, spcs in model.myBDF.spcs.items(): + * i = 1 + * for spc in spcs: # <<<<<<<<<<<<<< + * name = "Subcase-%i_%s_%i"%(subcase_num, spc.type, i) + * SPCs[name.encode("utf-8")] = spc.nodes + */ + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "pynastran_io.pyx":221 + * i+=1 + * + * return SPCs # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __pyx_v_SPCs; + goto __pyx_L0; + + /* "pynastran_io.pyx":208 + * + * + * cdef public map[string, vector[int]] getSPCs(BDFModel model): # <<<<<<<<<<<<<< + * """ + * Create a map of subcase SPCs and the nodes that belong to that SPC. Useful for creating boundaries in libMesh. + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_WriteUnraisable("pynastran_io.getSPCs", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); + __Pyx_pretend_to_initialize(&__pyx_r); + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_subcase_num); + __Pyx_XDECREF(__pyx_v_spcs); + __Pyx_XDECREF(__pyx_v_i); + __Pyx_XDECREF(__pyx_v_spc); + __Pyx_XDECREF(__pyx_v_name); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "pynastran_io.pyx":224 * * * cdef perturbZeroLengthBushings(BDFModel model): # <<<<<<<<<<<<<< @@ -4152,7 +4396,7 @@ static PyObject *__pyx_f_12pynastran_io_perturbZeroLengthBushings(struct BDFMode double __pyx_t_11; __Pyx_RefNannySetupContext("perturbZeroLengthBushings", 0); - /* "pynastran_io.pyx":219 + /* "pynastran_io.pyx":235 * cdef int k * cdef double eps, nzero, L * eps=1.4901161193847656e-08 # <<<<<<<<<<<<<< @@ -4161,7 +4405,7 @@ static PyObject *__pyx_f_12pynastran_io_perturbZeroLengthBushings(struct BDFMode */ __pyx_v_eps = 1.4901161193847656e-08; - /* "pynastran_io.pyx":220 + /* "pynastran_io.pyx":236 * cdef double eps, nzero, L * eps=1.4901161193847656e-08 * nzero=1e-08 # <<<<<<<<<<<<<< @@ -4170,14 +4414,14 @@ static PyObject *__pyx_f_12pynastran_io_perturbZeroLengthBushings(struct BDFMode */ __pyx_v_nzero = 1e-08; - /* "pynastran_io.pyx":223 + /* "pynastran_io.pyx":239 * * # Get element IDs of bushing elements * data = model.myBDF.get_elements_properties_nodes_by_element_type() # <<<<<<<<<<<<<< * eids = [] * if "CBUSH" in data.keys(): */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_model->myBDF, __pyx_n_s_get_elements_properties_nodes_by); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 223, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_model->myBDF, __pyx_n_s_get_elements_properties_nodes_by); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 239, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { @@ -4191,32 +4435,32 @@ static PyObject *__pyx_f_12pynastran_io_perturbZeroLengthBushings(struct BDFMode } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 223, __pyx_L1_error) + if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 239, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_data = __pyx_t_1; __pyx_t_1 = 0; - /* "pynastran_io.pyx":224 + /* "pynastran_io.pyx":240 * # Get element IDs of bushing elements * data = model.myBDF.get_elements_properties_nodes_by_element_type() * eids = [] # <<<<<<<<<<<<<< * if "CBUSH" in data.keys(): * eids += (data["CBUSH"][0]).tolist() */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 224, __pyx_L1_error) + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 240, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_eids = __pyx_t_1; __pyx_t_1 = 0; - /* "pynastran_io.pyx":225 + /* "pynastran_io.pyx":241 * data = model.myBDF.get_elements_properties_nodes_by_element_type() * eids = [] * if "CBUSH" in data.keys(): # <<<<<<<<<<<<<< * eids += (data["CBUSH"][0]).tolist() * if "CBUSH1D" in data.keys(): */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_keys); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 225, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_keys); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { @@ -4230,27 +4474,27 @@ static PyObject *__pyx_f_12pynastran_io_perturbZeroLengthBushings(struct BDFMode } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 225, __pyx_L1_error) + if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_n_u_CBUSH, __pyx_t_1, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(1, 225, __pyx_L1_error) + __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_n_u_CBUSH, __pyx_t_1, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(1, 241, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = (__pyx_t_4 != 0); if (__pyx_t_5) { - /* "pynastran_io.pyx":226 + /* "pynastran_io.pyx":242 * eids = [] * if "CBUSH" in data.keys(): * eids += (data["CBUSH"][0]).tolist() # <<<<<<<<<<<<<< * if "CBUSH1D" in data.keys(): * eids += (data["CBUSH1D"][0]).tolist() */ - __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_CBUSH); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 226, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_CBUSH); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 242, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 226, __pyx_L1_error) + __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 242, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_tolist); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 226, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_tolist); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 242, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; @@ -4265,16 +4509,16 @@ static PyObject *__pyx_f_12pynastran_io_perturbZeroLengthBushings(struct BDFMode } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 226, __pyx_L1_error) + if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 242, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_eids, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 226, __pyx_L1_error) + __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_eids, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 242, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_eids, __pyx_t_2); __pyx_t_2 = 0; - /* "pynastran_io.pyx":225 + /* "pynastran_io.pyx":241 * data = model.myBDF.get_elements_properties_nodes_by_element_type() * eids = [] * if "CBUSH" in data.keys(): # <<<<<<<<<<<<<< @@ -4283,14 +4527,14 @@ static PyObject *__pyx_f_12pynastran_io_perturbZeroLengthBushings(struct BDFMode */ } - /* "pynastran_io.pyx":227 + /* "pynastran_io.pyx":243 * if "CBUSH" in data.keys(): * eids += (data["CBUSH"][0]).tolist() * if "CBUSH1D" in data.keys(): # <<<<<<<<<<<<<< * eids += (data["CBUSH1D"][0]).tolist() * if "CBUSH2D" in data.keys(): */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_keys); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 227, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_keys); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { @@ -4304,27 +4548,27 @@ static PyObject *__pyx_f_12pynastran_io_perturbZeroLengthBushings(struct BDFMode } __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 227, __pyx_L1_error) + if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_5 = (__Pyx_PySequence_ContainsTF(__pyx_n_u_CBUSH1D, __pyx_t_2, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(1, 227, __pyx_L1_error) + __pyx_t_5 = (__Pyx_PySequence_ContainsTF(__pyx_n_u_CBUSH1D, __pyx_t_2, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(1, 243, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = (__pyx_t_5 != 0); if (__pyx_t_4) { - /* "pynastran_io.pyx":228 + /* "pynastran_io.pyx":244 * eids += (data["CBUSH"][0]).tolist() * if "CBUSH1D" in data.keys(): * eids += (data["CBUSH1D"][0]).tolist() # <<<<<<<<<<<<<< * if "CBUSH2D" in data.keys(): * eids += (data["CBUSH2D"][0]).tolist() */ - __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_CBUSH1D); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 228, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_CBUSH1D); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 228, __pyx_L1_error) + __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_tolist); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 228, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_tolist); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; @@ -4339,16 +4583,16 @@ static PyObject *__pyx_f_12pynastran_io_perturbZeroLengthBushings(struct BDFMode } __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 228, __pyx_L1_error) + if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_eids, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 228, __pyx_L1_error) + __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_eids, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_eids, __pyx_t_1); __pyx_t_1 = 0; - /* "pynastran_io.pyx":227 + /* "pynastran_io.pyx":243 * if "CBUSH" in data.keys(): * eids += (data["CBUSH"][0]).tolist() * if "CBUSH1D" in data.keys(): # <<<<<<<<<<<<<< @@ -4357,14 +4601,14 @@ static PyObject *__pyx_f_12pynastran_io_perturbZeroLengthBushings(struct BDFMode */ } - /* "pynastran_io.pyx":229 + /* "pynastran_io.pyx":245 * if "CBUSH1D" in data.keys(): * eids += (data["CBUSH1D"][0]).tolist() * if "CBUSH2D" in data.keys(): # <<<<<<<<<<<<<< * eids += (data["CBUSH2D"][0]).tolist() * */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_keys); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 229, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_keys); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 245, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { @@ -4378,27 +4622,27 @@ static PyObject *__pyx_f_12pynastran_io_perturbZeroLengthBushings(struct BDFMode } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 229, __pyx_L1_error) + if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 245, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_n_u_CBUSH2D, __pyx_t_1, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(1, 229, __pyx_L1_error) + __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_n_u_CBUSH2D, __pyx_t_1, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(1, 245, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = (__pyx_t_4 != 0); if (__pyx_t_5) { - /* "pynastran_io.pyx":230 + /* "pynastran_io.pyx":246 * eids += (data["CBUSH1D"][0]).tolist() * if "CBUSH2D" in data.keys(): * eids += (data["CBUSH2D"][0]).tolist() # <<<<<<<<<<<<<< * * # Loop through all bushing elements */ - __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_CBUSH2D); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 230, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_CBUSH2D); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 246, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 230, __pyx_L1_error) + __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 246, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_tolist); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 230, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_tolist); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 246, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; @@ -4413,16 +4657,16 @@ static PyObject *__pyx_f_12pynastran_io_perturbZeroLengthBushings(struct BDFMode } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 230, __pyx_L1_error) + if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 246, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_eids, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 230, __pyx_L1_error) + __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_eids, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 246, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_eids, __pyx_t_2); __pyx_t_2 = 0; - /* "pynastran_io.pyx":229 + /* "pynastran_io.pyx":245 * if "CBUSH1D" in data.keys(): * eids += (data["CBUSH1D"][0]).tolist() * if "CBUSH2D" in data.keys(): # <<<<<<<<<<<<<< @@ -4431,77 +4675,77 @@ static PyObject *__pyx_f_12pynastran_io_perturbZeroLengthBushings(struct BDFMode */ } - /* "pynastran_io.pyx":233 + /* "pynastran_io.pyx":249 * * # Loop through all bushing elements * for k in range(len(eids)): # <<<<<<<<<<<<<< * eid = eids[k] * bushing = model.myBDF.elements[eid] */ - __pyx_t_6 = PyObject_Length(__pyx_v_eids); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(1, 233, __pyx_L1_error) + __pyx_t_6 = PyObject_Length(__pyx_v_eids); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(1, 249, __pyx_L1_error) __pyx_t_7 = __pyx_t_6; for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { __pyx_v_k = __pyx_t_8; - /* "pynastran_io.pyx":234 + /* "pynastran_io.pyx":250 * # Loop through all bushing elements * for k in range(len(eids)): * eid = eids[k] # <<<<<<<<<<<<<< * bushing = model.myBDF.elements[eid] * L = np.linalg.norm(bushing.nodes_ref[1].xyz - bushing.nodes_ref[0].xyz) */ - __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_eids, __pyx_v_k, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 234, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_eids, __pyx_v_k, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_XDECREF_SET(__pyx_v_eid, __pyx_t_2); __pyx_t_2 = 0; - /* "pynastran_io.pyx":235 + /* "pynastran_io.pyx":251 * for k in range(len(eids)): * eid = eids[k] * bushing = model.myBDF.elements[eid] # <<<<<<<<<<<<<< * L = np.linalg.norm(bushing.nodes_ref[1].xyz - bushing.nodes_ref[0].xyz) * if abs(L)myBDF, __pyx_n_s_elements); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 235, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_model->myBDF, __pyx_n_s_elements); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 251, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_v_eid); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 235, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_v_eid); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 251, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF_SET(__pyx_v_bushing, __pyx_t_1); __pyx_t_1 = 0; - /* "pynastran_io.pyx":236 + /* "pynastran_io.pyx":252 * eid = eids[k] * bushing = model.myBDF.elements[eid] * L = np.linalg.norm(bushing.nodes_ref[1].xyz - bushing.nodes_ref[0].xyz) # <<<<<<<<<<<<<< * if abs(L)0 and an x-axis can be defined by the geometry */ - __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 236, __pyx_L1_error) + __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_linalg); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 236, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_linalg); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_norm); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 236, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_norm); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_bushing, __pyx_n_s_nodes_ref); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 236, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_bushing, __pyx_n_s_nodes_ref); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_9 = __Pyx_GetItemInt(__pyx_t_3, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 236, __pyx_L1_error) + __pyx_t_9 = __Pyx_GetItemInt(__pyx_t_3, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_xyz); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 236, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_xyz); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_bushing, __pyx_n_s_nodes_ref); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 236, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_bushing, __pyx_n_s_nodes_ref); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); - __pyx_t_10 = __Pyx_GetItemInt(__pyx_t_9, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 236, __pyx_L1_error) + __pyx_t_10 = __Pyx_GetItemInt(__pyx_t_9, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_xyz); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 236, __pyx_L1_error) + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_xyz); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = PyNumber_Subtract(__pyx_t_3, __pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 236, __pyx_L1_error) + __pyx_t_10 = PyNumber_Subtract(__pyx_t_3, __pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; @@ -4518,14 +4762,14 @@ static PyObject *__pyx_f_12pynastran_io_perturbZeroLengthBushings(struct BDFMode __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_9, __pyx_t_10) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_10); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 236, __pyx_L1_error) + if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) __PYX_ERR(1, 236, __pyx_L1_error) + __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) __PYX_ERR(1, 252, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_L = __pyx_t_11; - /* "pynastran_io.pyx":237 + /* "pynastran_io.pyx":253 * bushing = model.myBDF.elements[eid] * L = np.linalg.norm(bushing.nodes_ref[1].xyz - bushing.nodes_ref[0].xyz) * if abs(L)0 and an x-axis can be defined by the geometry * i = bushing.cid_ref.i # <<<<<<<<<<<<<< * di = eps*i * absmindi = abs(di).min() */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_bushing, __pyx_n_s_cid_ref); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 239, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_bushing, __pyx_n_s_cid_ref); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 255, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_i_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 239, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_i_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 255, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_2); __pyx_t_2 = 0; - /* "pynastran_io.pyx":240 + /* "pynastran_io.pyx":256 * # Slightly perturb the second node so that L>0 and an x-axis can be defined by the geometry * i = bushing.cid_ref.i * di = eps*i # <<<<<<<<<<<<<< * absmindi = abs(di).min() * if absmindimyBDF, __pyx_n_s_nodes); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 244, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_model->myBDF, __pyx_n_s_nodes); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_bushing, __pyx_n_s_nodes); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 244, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_bushing, __pyx_n_s_nodes); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 244, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_t_10, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 244, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_t_10, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_xyz); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 244, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_xyz); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_10 = PyNumber_InPlaceAdd(__pyx_t_2, __pyx_v_di); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 244, __pyx_L1_error) + __pyx_t_10 = PyNumber_InPlaceAdd(__pyx_t_2, __pyx_v_di); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (__Pyx_PyObject_SetAttrStr(__pyx_t_1, __pyx_n_s_xyz, __pyx_t_10) < 0) __PYX_ERR(1, 244, __pyx_L1_error) + if (__Pyx_PyObject_SetAttrStr(__pyx_t_1, __pyx_n_s_xyz, __pyx_t_10) < 0) __PYX_ERR(1, 260, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "pynastran_io.pyx":245 + /* "pynastran_io.pyx":261 * di *= (eps/absmindi) * model.myBDF.nodes[bushing.nodes[1]].xyz += di * print("Perturbing GRID %i by %s to define x-axis of zero-length element."%(bushing.nodes[1], di)) # <<<<<<<<<<<<<< * * # Define the orientation of the bushing */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_bushing, __pyx_n_s_nodes); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 245, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_bushing, __pyx_n_s_nodes); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_10 = __Pyx_GetItemInt(__pyx_t_1, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 245, __pyx_L1_error) + __pyx_t_10 = __Pyx_GetItemInt(__pyx_t_1, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 245, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_10); @@ -4684,25 +4928,25 @@ static PyObject *__pyx_f_12pynastran_io_perturbZeroLengthBushings(struct BDFMode __Pyx_GIVEREF(__pyx_v_di); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_di); __pyx_t_10 = 0; - __pyx_t_10 = PyUnicode_Format(__pyx_kp_u_Perturbing_GRID_i_by_s_to_define, __pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 245, __pyx_L1_error) + __pyx_t_10 = PyUnicode_Format(__pyx_kp_u_Perturbing_GRID_i_by_s_to_define, __pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 245, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "pynastran_io.pyx":248 + /* "pynastran_io.pyx":264 * * # Define the orientation of the bushing * bushing.x = bushing.cid_ref.j.tolist() # <<<<<<<<<<<<<< */ - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_bushing, __pyx_n_s_cid_ref); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 248, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_bushing, __pyx_n_s_cid_ref); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_j); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 248, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_j); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tolist); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 248, __pyx_L1_error) + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tolist); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; @@ -4717,13 +4961,13 @@ static PyObject *__pyx_f_12pynastran_io_perturbZeroLengthBushings(struct BDFMode } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_10); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 248, __pyx_L1_error) + if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - if (__Pyx_PyObject_SetAttrStr(__pyx_v_bushing, __pyx_n_s_x, __pyx_t_1) < 0) __PYX_ERR(1, 248, __pyx_L1_error) + if (__Pyx_PyObject_SetAttrStr(__pyx_v_bushing, __pyx_n_s_x, __pyx_t_1) < 0) __PYX_ERR(1, 264, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "pynastran_io.pyx":237 + /* "pynastran_io.pyx":253 * bushing = model.myBDF.elements[eid] * L = np.linalg.norm(bushing.nodes_ref[1].xyz - bushing.nodes_ref[0].xyz) * if abs(L)obj = Py_None; __Pyx_INCREF(Py_None); __Pyx_GIVEREF(__pyx_v_info->obj); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":265 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":265 * * cdef int i, ndim * cdef int endian_detector = 1 # <<<<<<<<<<<<<< @@ -4823,7 +5067,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_endian_detector = 1; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":266 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":266 * cdef int i, ndim * cdef int endian_detector = 1 * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< @@ -4832,7 +5076,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":268 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":268 * cdef bint little_endian = ((&endian_detector)[0] != 0) * * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< @@ -4841,7 +5085,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 * ndim = PyArray_NDIM(self) * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -4855,7 +5099,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P goto __pyx_L4_bool_binop_done; } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":271 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":271 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< @@ -4866,7 +5110,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = __pyx_t_2; __pyx_L4_bool_binop_done:; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 * ndim = PyArray_NDIM(self) * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -4875,7 +5119,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ if (unlikely(__pyx_t_1)) { - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":272 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":272 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< @@ -4888,7 +5132,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(2, 272, __pyx_L1_error) - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 * ndim = PyArray_NDIM(self) * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -4897,7 +5141,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -4911,7 +5155,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P goto __pyx_L7_bool_binop_done; } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":275 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":275 * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< @@ -4922,7 +5166,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = __pyx_t_2; __pyx_L7_bool_binop_done:; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -4931,7 +5175,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ if (unlikely(__pyx_t_1)) { - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":276 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":276 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< @@ -4944,7 +5188,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(2, 276, __pyx_L1_error) - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -4953,7 +5197,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":278 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":278 * raise ValueError(u"ndarray is not Fortran contiguous") * * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< @@ -4962,7 +5206,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":279 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":279 * * info.buf = PyArray_DATA(self) * info.ndim = ndim # <<<<<<<<<<<<<< @@ -4971,7 +5215,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->ndim = __pyx_v_ndim; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":280 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":280 * info.buf = PyArray_DATA(self) * info.ndim = ndim * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< @@ -4981,7 +5225,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); if (__pyx_t_1) { - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":283 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":283 * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. * info.strides = PyObject_Malloc(sizeof(Py_ssize_t) * 2 * ndim) # <<<<<<<<<<<<<< @@ -4990,7 +5234,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->strides = ((Py_ssize_t *)PyObject_Malloc((((sizeof(Py_ssize_t)) * 2) * ((size_t)__pyx_v_ndim)))); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":284 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":284 * # This is allocated as one block, strides first. * info.strides = PyObject_Malloc(sizeof(Py_ssize_t) * 2 * ndim) * info.shape = info.strides + ndim # <<<<<<<<<<<<<< @@ -4999,7 +5243,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":285 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":285 * info.strides = PyObject_Malloc(sizeof(Py_ssize_t) * 2 * ndim) * info.shape = info.strides + ndim * for i in range(ndim): # <<<<<<<<<<<<<< @@ -5011,7 +5255,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { __pyx_v_i = __pyx_t_6; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":286 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":286 * info.shape = info.strides + ndim * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< @@ -5020,7 +5264,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":287 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":287 * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< @@ -5030,7 +5274,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]); } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":280 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":280 * info.buf = PyArray_DATA(self) * info.ndim = ndim * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< @@ -5040,7 +5284,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P goto __pyx_L9; } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":289 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":289 * info.shape[i] = PyArray_DIMS(self)[i] * else: * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< @@ -5050,7 +5294,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P /*else*/ { __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":290 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":290 * else: * info.strides = PyArray_STRIDES(self) * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< @@ -5061,7 +5305,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P } __pyx_L9:; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":291 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":291 * info.strides = PyArray_STRIDES(self) * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL # <<<<<<<<<<<<<< @@ -5070,7 +5314,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->suboffsets = NULL; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":292 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":292 * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< @@ -5079,7 +5323,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":293 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":293 * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< @@ -5088,7 +5332,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0)); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":296 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":296 * * cdef int t * cdef char* f = NULL # <<<<<<<<<<<<<< @@ -5097,7 +5341,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_f = NULL; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":297 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":297 * cdef int t * cdef char* f = NULL * cdef dtype descr = PyArray_DESCR(self) # <<<<<<<<<<<<<< @@ -5110,7 +5354,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_descr = ((PyArray_Descr *)__pyx_t_3); __pyx_t_3 = 0; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":300 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":300 * cdef int offset * * info.obj = self # <<<<<<<<<<<<<< @@ -5123,7 +5367,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = ((PyObject *)__pyx_v_self); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":302 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":302 * info.obj = self * * if not PyDataType_HASFIELDS(descr): # <<<<<<<<<<<<<< @@ -5133,7 +5377,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = ((!(PyDataType_HASFIELDS(__pyx_v_descr) != 0)) != 0); if (__pyx_t_1) { - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":303 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":303 * * if not PyDataType_HASFIELDS(descr): * t = descr.type_num # <<<<<<<<<<<<<< @@ -5143,7 +5387,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_4 = __pyx_v_descr->type_num; __pyx_v_t = __pyx_t_4; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":304 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":304 * if not PyDataType_HASFIELDS(descr): * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -5163,7 +5407,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P } __pyx_L15_next_or:; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":305 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":305 * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< @@ -5180,7 +5424,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = __pyx_t_2; __pyx_L14_bool_binop_done:; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":304 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":304 * if not PyDataType_HASFIELDS(descr): * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -5189,7 +5433,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ if (unlikely(__pyx_t_1)) { - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":306 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":306 * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< @@ -5202,7 +5446,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(2, 306, __pyx_L1_error) - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":304 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":304 * if not PyDataType_HASFIELDS(descr): * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -5211,7 +5455,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":307 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":307 * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< @@ -5224,7 +5468,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_UBYTE: - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":308 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":308 * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< @@ -5235,7 +5479,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_SHORT: - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":309 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":309 * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< @@ -5246,7 +5490,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_USHORT: - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":310 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":310 * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< @@ -5257,7 +5501,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_INT: - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":311 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":311 * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< @@ -5268,7 +5512,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_UINT: - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":312 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":312 * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< @@ -5279,7 +5523,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_LONG: - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":313 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":313 * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< @@ -5290,7 +5534,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_ULONG: - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":314 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":314 * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< @@ -5301,7 +5545,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_LONGLONG: - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":315 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":315 * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< @@ -5312,7 +5556,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_ULONGLONG: - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":316 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":316 * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< @@ -5323,7 +5567,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_FLOAT: - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":317 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":317 * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< @@ -5334,7 +5578,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_DOUBLE: - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":318 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":318 * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< @@ -5345,7 +5589,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_LONGDOUBLE: - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":319 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":319 * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< @@ -5356,7 +5600,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_CFLOAT: - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":320 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":320 * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<< @@ -5367,7 +5611,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_CDOUBLE: - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":321 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":321 * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<< @@ -5378,7 +5622,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_CLONGDOUBLE: - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":322 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":322 * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<< @@ -5389,7 +5633,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; case NPY_OBJECT: - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":323 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":323 * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< @@ -5400,7 +5644,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; default: - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":325 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":325 * elif t == NPY_OBJECT: f = "O" * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< @@ -5421,7 +5665,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":326 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":326 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f # <<<<<<<<<<<<<< @@ -5430,7 +5674,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->format = __pyx_v_f; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":327 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":327 * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f * return # <<<<<<<<<<<<<< @@ -5440,7 +5684,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_r = 0; goto __pyx_L0; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":302 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":302 * info.obj = self * * if not PyDataType_HASFIELDS(descr): # <<<<<<<<<<<<<< @@ -5449,7 +5693,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":329 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":329 * return * else: * info.format = PyObject_Malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< @@ -5459,7 +5703,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P /*else*/ { __pyx_v_info->format = ((char *)PyObject_Malloc(0xFF)); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":330 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":330 * else: * info.format = PyObject_Malloc(_buffer_format_string_len) * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<< @@ -5468,7 +5712,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ (__pyx_v_info->format[0]) = '^'; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":331 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":331 * info.format = PyObject_Malloc(_buffer_format_string_len) * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 # <<<<<<<<<<<<<< @@ -5477,7 +5721,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_offset = 0; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":332 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":332 * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 * f = _util_dtypestring(descr, info.format + 1, # <<<<<<<<<<<<<< @@ -5487,7 +5731,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 0xFF), (&__pyx_v_offset)); if (unlikely(__pyx_t_9 == ((char *)NULL))) __PYX_ERR(2, 332, __pyx_L1_error) __pyx_v_f = __pyx_t_9; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":335 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":335 * info.format + _buffer_format_string_len, * &offset) * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<< @@ -5497,7 +5741,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P (__pyx_v_f[0]) = '\x00'; } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":258 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":258 * # experimental exception made for __getbuffer__ and __releasebuffer__ * # -- the details of this may change. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< @@ -5529,7 +5773,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P return __pyx_r; } -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":337 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":337 * f[0] = c'\0' # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< @@ -5553,7 +5797,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s int __pyx_t_1; __Pyx_RefNannySetupContext("__releasebuffer__", 0); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":338 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":338 * * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< @@ -5563,7 +5807,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0); if (__pyx_t_1) { - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":339 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":339 * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): * PyObject_Free(info.format) # <<<<<<<<<<<<<< @@ -5572,7 +5816,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s */ PyObject_Free(__pyx_v_info->format); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":338 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":338 * * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< @@ -5581,7 +5825,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s */ } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":340 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":340 * if PyArray_HASFIELDS(self): * PyObject_Free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< @@ -5591,7 +5835,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); if (__pyx_t_1) { - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":341 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":341 * PyObject_Free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): * PyObject_Free(info.strides) # <<<<<<<<<<<<<< @@ -5600,7 +5844,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s */ PyObject_Free(__pyx_v_info->strides); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":340 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":340 * if PyArray_HASFIELDS(self): * PyObject_Free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< @@ -5609,7 +5853,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s */ } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":337 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":337 * f[0] = c'\0' # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< @@ -5621,7 +5865,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s __Pyx_RefNannyFinishContext(); } -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":821 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":821 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< @@ -5635,7 +5879,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":822 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":822 * * cdef inline object PyArray_MultiIterNew1(a): * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< @@ -5649,7 +5893,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":821 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":821 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< @@ -5668,7 +5912,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ return __pyx_r; } -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":824 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":824 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< @@ -5682,7 +5926,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":825 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":825 * * cdef inline object PyArray_MultiIterNew2(a, b): * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< @@ -5696,7 +5940,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":824 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":824 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< @@ -5715,7 +5959,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ return __pyx_r; } -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":827 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":827 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< @@ -5729,7 +5973,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":828 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":828 * * cdef inline object PyArray_MultiIterNew3(a, b, c): * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< @@ -5743,7 +5987,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":827 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":827 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< @@ -5762,7 +6006,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ return __pyx_r; } -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":830 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":830 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< @@ -5776,7 +6020,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":831 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":831 * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< @@ -5790,7 +6034,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":830 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":830 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< @@ -5809,7 +6053,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ return __pyx_r; } -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":833 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":833 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< @@ -5823,7 +6067,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ PyObject *__pyx_t_1 = NULL; __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":834 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":834 * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< @@ -5837,7 +6081,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":833 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":833 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< @@ -5856,7 +6100,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ return __pyx_r; } -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":836 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":836 * return PyArray_MultiIterNew(5, a, b, c, d, e) * * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< @@ -5870,7 +6114,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ int __pyx_t_1; __Pyx_RefNannySetupContext("PyDataType_SHAPE", 0); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":837 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":837 * * cdef inline tuple PyDataType_SHAPE(dtype d): * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< @@ -5880,7 +6124,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ __pyx_t_1 = (PyDataType_HASSUBARRAY(__pyx_v_d) != 0); if (__pyx_t_1) { - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":838 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":838 * cdef inline tuple PyDataType_SHAPE(dtype d): * if PyDataType_HASSUBARRAY(d): * return d.subarray.shape # <<<<<<<<<<<<<< @@ -5892,7 +6136,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape); goto __pyx_L0; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":837 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":837 * * cdef inline tuple PyDataType_SHAPE(dtype d): * if PyDataType_HASSUBARRAY(d): # <<<<<<<<<<<<<< @@ -5901,7 +6145,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ */ } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":840 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":840 * return d.subarray.shape * else: * return () # <<<<<<<<<<<<<< @@ -5915,7 +6159,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ goto __pyx_L0; } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":836 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":836 * return PyArray_MultiIterNew(5, a, b, c, d, e) * * cdef inline tuple PyDataType_SHAPE(dtype d): # <<<<<<<<<<<<<< @@ -5930,7 +6174,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__ return __pyx_r; } -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":842 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":842 * return () * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< @@ -5959,7 +6203,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx char *__pyx_t_9; __Pyx_RefNannySetupContext("_util_dtypestring", 0); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":847 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":847 * * cdef dtype child * cdef int endian_detector = 1 # <<<<<<<<<<<<<< @@ -5968,7 +6212,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_endian_detector = 1; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":848 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":848 * cdef dtype child * cdef int endian_detector = 1 * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< @@ -5977,7 +6221,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":851 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":851 * cdef tuple fields * * for childname in descr.names: # <<<<<<<<<<<<<< @@ -6000,7 +6244,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3); __pyx_t_3 = 0; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":852 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":852 * * for childname in descr.names: * fields = descr.fields[childname] # <<<<<<<<<<<<<< @@ -6017,7 +6261,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":853 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":853 * for childname in descr.names: * fields = descr.fields[childname] * child, new_offset = fields # <<<<<<<<<<<<<< @@ -6052,7 +6296,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4); __pyx_t_4 = 0; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":855 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":855 * child, new_offset = fields * * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< @@ -6069,7 +6313,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0); if (unlikely(__pyx_t_6)) { - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":856 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":856 * * if (end - f) - (new_offset - offset[0]) < 15: * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< @@ -6082,7 +6326,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(2, 856, __pyx_L1_error) - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":855 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":855 * child, new_offset = fields * * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< @@ -6091,7 +6335,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":858 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":858 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -6111,7 +6355,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx } __pyx_L8_next_or:; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":859 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":859 * * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< @@ -6128,7 +6372,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = __pyx_t_7; __pyx_L7_bool_binop_done:; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":858 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":858 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -6137,7 +6381,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ if (unlikely(__pyx_t_6)) { - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":860 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":860 * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< @@ -6150,7 +6394,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(2, 860, __pyx_L1_error) - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":858 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":858 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -6159,7 +6403,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":870 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":870 * * # Output padding bytes * while offset[0] < new_offset: # <<<<<<<<<<<<<< @@ -6175,7 +6419,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!__pyx_t_6) break; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":871 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":871 * # Output padding bytes * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< @@ -6184,7 +6428,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ (__pyx_v_f[0]) = 0x78; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":872 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":872 * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte * f += 1 # <<<<<<<<<<<<<< @@ -6193,7 +6437,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_f = (__pyx_v_f + 1); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":873 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":873 * f[0] = 120 # "x"; pad byte * f += 1 * offset[0] += 1 # <<<<<<<<<<<<<< @@ -6204,7 +6448,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1); } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":875 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":875 * offset[0] += 1 * * offset[0] += child.itemsize # <<<<<<<<<<<<<< @@ -6214,7 +6458,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_8 = 0; (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":877 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":877 * offset[0] += child.itemsize * * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< @@ -6224,7 +6468,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0); if (__pyx_t_6) { - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":878 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":878 * * if not PyDataType_HASFIELDS(child): * t = child.type_num # <<<<<<<<<<<<<< @@ -6236,7 +6480,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4); __pyx_t_4 = 0; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":879 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":879 * if not PyDataType_HASFIELDS(child): * t = child.type_num * if end - f < 5: # <<<<<<<<<<<<<< @@ -6246,7 +6490,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0); if (unlikely(__pyx_t_6)) { - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":880 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":880 * t = child.type_num * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< @@ -6259,7 +6503,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(2, 880, __pyx_L1_error) - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":879 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":879 * if not PyDataType_HASFIELDS(child): * t = child.type_num * if end - f < 5: # <<<<<<<<<<<<<< @@ -6268,7 +6512,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":883 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":883 * * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< @@ -6286,7 +6530,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":884 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":884 * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< @@ -6304,7 +6548,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":885 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":885 * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< @@ -6322,7 +6566,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":886 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":886 * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< @@ -6340,7 +6584,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":887 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":887 * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< @@ -6358,7 +6602,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":888 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":888 * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< @@ -6376,7 +6620,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":889 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":889 * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< @@ -6394,7 +6638,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":890 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":890 * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< @@ -6412,7 +6656,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":891 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":891 * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< @@ -6430,7 +6674,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":892 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":892 * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< @@ -6448,7 +6692,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":893 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":893 * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< @@ -6466,7 +6710,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":894 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":894 * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< @@ -6484,7 +6728,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":895 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":895 * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< @@ -6502,7 +6746,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":896 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":896 * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< @@ -6522,7 +6766,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":897 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":897 * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< @@ -6542,7 +6786,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":898 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":898 * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< @@ -6562,7 +6806,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":899 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":899 * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< @@ -6580,7 +6824,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":901 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":901 * elif t == NPY_OBJECT: f[0] = 79 #"O" * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< @@ -6599,7 +6843,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx } __pyx_L15:; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":902 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":902 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * f += 1 # <<<<<<<<<<<<<< @@ -6608,7 +6852,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_f = (__pyx_v_f + 1); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":877 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":877 * offset[0] += child.itemsize * * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< @@ -6618,7 +6862,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L13; } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":906 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":906 * # Cython ignores struct boundary information ("T{...}"), * # so don't output it * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< @@ -6631,7 +6875,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx } __pyx_L13:; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":851 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":851 * cdef tuple fields * * for childname in descr.names: # <<<<<<<<<<<<<< @@ -6641,7 +6885,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":907 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":907 * # so don't output it * f = _util_dtypestring(child, f, end, offset) * return f # <<<<<<<<<<<<<< @@ -6651,7 +6895,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_r = __pyx_v_f; goto __pyx_L0; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":842 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":842 * return () * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< @@ -6676,7 +6920,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx return __pyx_r; } -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1022 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1022 * int _import_umath() except -1 * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< @@ -6688,7 +6932,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("set_array_base", 0); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1023 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1023 * * cdef inline void set_array_base(ndarray arr, object base): * Py_INCREF(base) # important to do this before stealing the reference below! # <<<<<<<<<<<<<< @@ -6697,7 +6941,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a */ Py_INCREF(__pyx_v_base); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1024 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1024 * cdef inline void set_array_base(ndarray arr, object base): * Py_INCREF(base) # important to do this before stealing the reference below! * PyArray_SetBaseObject(arr, base) # <<<<<<<<<<<<<< @@ -6706,7 +6950,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a */ (void)(PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_base)); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1022 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1022 * int _import_umath() except -1 * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< @@ -6718,7 +6962,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a __Pyx_RefNannyFinishContext(); } -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1026 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1026 * PyArray_SetBaseObject(arr, base) * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< @@ -6733,7 +6977,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py int __pyx_t_1; __Pyx_RefNannySetupContext("get_array_base", 0); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1027 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1027 * * cdef inline object get_array_base(ndarray arr): * base = PyArray_BASE(arr) # <<<<<<<<<<<<<< @@ -6742,7 +6986,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py */ __pyx_v_base = PyArray_BASE(__pyx_v_arr); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1028 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1028 * cdef inline object get_array_base(ndarray arr): * base = PyArray_BASE(arr) * if base is NULL: # <<<<<<<<<<<<<< @@ -6752,7 +6996,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py __pyx_t_1 = ((__pyx_v_base == NULL) != 0); if (__pyx_t_1) { - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1029 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1029 * base = PyArray_BASE(arr) * if base is NULL: * return None # <<<<<<<<<<<<<< @@ -6763,7 +7007,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1028 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1028 * cdef inline object get_array_base(ndarray arr): * base = PyArray_BASE(arr) * if base is NULL: # <<<<<<<<<<<<<< @@ -6772,7 +7016,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py */ } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1030 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1030 * if base is NULL: * return None * return base # <<<<<<<<<<<<<< @@ -6784,7 +7028,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py __pyx_r = ((PyObject *)__pyx_v_base); goto __pyx_L0; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1026 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1026 * PyArray_SetBaseObject(arr, base) * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< @@ -6799,7 +7043,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py return __pyx_r; } -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1034 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1034 * # Versions of the import_* functions which are more suitable for * # Cython code. * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< @@ -6820,7 +7064,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("import_array", 0); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1035 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1035 * # Cython code. * cdef inline int import_array() except -1: * try: # <<<<<<<<<<<<<< @@ -6836,7 +7080,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1036 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1036 * cdef inline int import_array() except -1: * try: * _import_array() # <<<<<<<<<<<<<< @@ -6845,7 +7089,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { */ __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 1036, __pyx_L3_error) - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1035 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1035 * # Cython code. * cdef inline int import_array() except -1: * try: # <<<<<<<<<<<<<< @@ -6859,7 +7103,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { goto __pyx_L8_try_end; __pyx_L3_error:; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1037 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1037 * try: * _import_array() * except Exception: # <<<<<<<<<<<<<< @@ -6874,7 +7118,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_7); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1038 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1038 * _import_array() * except Exception: * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< @@ -6890,7 +7134,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { goto __pyx_L5_except_error; __pyx_L5_except_error:; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1035 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1035 * # Cython code. * cdef inline int import_array() except -1: * try: # <<<<<<<<<<<<<< @@ -6905,7 +7149,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { __pyx_L8_try_end:; } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1034 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1034 * # Versions of the import_* functions which are more suitable for * # Cython code. * cdef inline int import_array() except -1: # <<<<<<<<<<<<<< @@ -6928,7 +7172,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) { return __pyx_r; } -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1040 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1040 * raise ImportError("numpy.core.multiarray failed to import") * * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< @@ -6949,7 +7193,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("import_umath", 0); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1041 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1041 * * cdef inline int import_umath() except -1: * try: # <<<<<<<<<<<<<< @@ -6965,7 +7209,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1042 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1042 * cdef inline int import_umath() except -1: * try: * _import_umath() # <<<<<<<<<<<<<< @@ -6974,7 +7218,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { */ __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 1042, __pyx_L3_error) - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1041 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1041 * * cdef inline int import_umath() except -1: * try: # <<<<<<<<<<<<<< @@ -6988,7 +7232,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { goto __pyx_L8_try_end; __pyx_L3_error:; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1043 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1043 * try: * _import_umath() * except Exception: # <<<<<<<<<<<<<< @@ -7003,7 +7247,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_7); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1044 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1044 * _import_umath() * except Exception: * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< @@ -7019,7 +7263,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { goto __pyx_L5_except_error; __pyx_L5_except_error:; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1041 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1041 * * cdef inline int import_umath() except -1: * try: # <<<<<<<<<<<<<< @@ -7034,7 +7278,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { __pyx_L8_try_end:; } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1040 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1040 * raise ImportError("numpy.core.multiarray failed to import") * * cdef inline int import_umath() except -1: # <<<<<<<<<<<<<< @@ -7057,7 +7301,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) { return __pyx_r; } -/* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1046 +/* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1046 * raise ImportError("numpy.core.umath failed to import") * * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< @@ -7078,7 +7322,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("import_ufunc", 0); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1047 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1047 * * cdef inline int import_ufunc() except -1: * try: # <<<<<<<<<<<<<< @@ -7094,7 +7338,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { __Pyx_XGOTREF(__pyx_t_3); /*try:*/ { - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1048 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1048 * cdef inline int import_ufunc() except -1: * try: * _import_umath() # <<<<<<<<<<<<<< @@ -7103,7 +7347,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { */ __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(2, 1048, __pyx_L3_error) - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1047 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1047 * * cdef inline int import_ufunc() except -1: * try: # <<<<<<<<<<<<<< @@ -7117,7 +7361,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { goto __pyx_L8_try_end; __pyx_L3_error:; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1049 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1049 * try: * _import_umath() * except Exception: # <<<<<<<<<<<<<< @@ -7131,7 +7375,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_7); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1050 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1050 * _import_umath() * except Exception: * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< @@ -7145,7 +7389,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { goto __pyx_L5_except_error; __pyx_L5_except_error:; - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1047 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1047 * * cdef inline int import_ufunc() except -1: * try: # <<<<<<<<<<<<<< @@ -7160,7 +7404,7 @@ static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) { __pyx_L8_try_end:; } - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1046 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1046 * raise ImportError("numpy.core.umath failed to import") * * cdef inline int import_ufunc() except -1: # <<<<<<<<<<<<<< @@ -7588,6 +7832,125 @@ static PyObject *__pyx_convert_map_to_py_std_3a__3a_string____int(std::map __pyx_convert_vector_from_py_int(PyObject *__pyx_v_o) { + std::vector __pyx_v_v; + PyObject *__pyx_v_item = NULL; + std::vector __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; + PyObject *(*__pyx_t_3)(PyObject *); + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + __Pyx_RefNannySetupContext("__pyx_convert_vector_from_py_int", 0); + + /* "vector.from_py":47 + * cdef vector[X] __pyx_convert_vector_from_py_int(object o) except *: + * cdef vector[X] v + * for item in o: # <<<<<<<<<<<<<< + * v.push_back(item) + * return v + */ + if (likely(PyList_CheckExact(__pyx_v_o)) || PyTuple_CheckExact(__pyx_v_o)) { + __pyx_t_1 = __pyx_v_o; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; + __pyx_t_3 = NULL; + } else { + __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_o); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 47, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 47, __pyx_L1_error) + } + for (;;) { + if (likely(!__pyx_t_3)) { + if (likely(PyList_CheckExact(__pyx_t_1))) { + if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 47, __pyx_L1_error) + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 47, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + #endif + } else { + if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 47, __pyx_L1_error) + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 47, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + #endif + } + } else { + __pyx_t_4 = __pyx_t_3(__pyx_t_1); + if (unlikely(!__pyx_t_4)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(0, 47, __pyx_L1_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_4); + } + __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_4); + __pyx_t_4 = 0; + + /* "vector.from_py":48 + * cdef vector[X] v + * for item in o: + * v.push_back(item) # <<<<<<<<<<<<<< + * return v + * + */ + __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_item); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 48, __pyx_L1_error) + __pyx_v_v.push_back(((int)__pyx_t_5)); + + /* "vector.from_py":47 + * cdef vector[X] __pyx_convert_vector_from_py_int(object o) except *: + * cdef vector[X] v + * for item in o: # <<<<<<<<<<<<<< + * v.push_back(item) + * return v + */ + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "vector.from_py":49 + * for item in o: + * v.push_back(item) + * return v # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __pyx_v_v; + goto __pyx_L0; + + /* "vector.from_py":45 + * + * @cname("__pyx_convert_vector_from_py_int") + * cdef vector[X] __pyx_convert_vector_from_py_int(object o) except *: # <<<<<<<<<<<<<< + * cdef vector[X] v + * for item in o: + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("vector.from_py.__pyx_convert_vector_from_py_int", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_pretend_to_initialize(&__pyx_r); + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_item); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + static PyObject *__pyx_tp_new_12pynastran_io_BDFModel(PyTypeObject *t, PyObject *a, PyObject *k) { struct BDFModel *p; PyObject *o; @@ -7736,6 +8099,9 @@ DL_EXPORT(PyTypeObject) BDFModelType = { #if PY_VERSION_HEX >= 0x030400a1 0, /*tp_finalize*/ #endif + #if PY_VERSION_HEX >= 0x030800b1 + 0, /*tp_vectorcall*/ + #endif }; static PyMethodDef __pyx_methods[] = { @@ -7797,6 +8163,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_NotImplementedError, __pyx_k_NotImplementedError, sizeof(__pyx_k_NotImplementedError), 0, 0, 1, 1}, {&__pyx_kp_u_Perturbing_GRID_i_by_s_to_define, __pyx_k_Perturbing_GRID_i_by_s_to_define, sizeof(__pyx_k_Perturbing_GRID_i_by_s_to_define), 0, 1, 0, 0}, {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1}, + {&__pyx_kp_u_Subcase_i__s__i, __pyx_k_Subcase_i__s__i, sizeof(__pyx_k_Subcase_i__s__i), 0, 1, 0, 0}, {&__pyx_kp_u_Support_of_non_zero_offets_not_y, __pyx_k_Support_of_non_zero_offets_not_y, sizeof(__pyx_k_Support_of_non_zero_offets_not_y), 0, 1, 0, 0}, {&__pyx_kp_u_Support_of_non_zero_offsets_not, __pyx_k_Support_of_non_zero_offsets_not, sizeof(__pyx_k_Support_of_non_zero_offsets_not), 0, 1, 0, 0}, {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, @@ -7855,6 +8222,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_u_reject_count_s, __pyx_k_reject_count_s, sizeof(__pyx_k_reject_count_s), 0, 1, 0, 0}, {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1}, {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1}, + {&__pyx_n_s_spcs, __pyx_k_spcs, sizeof(__pyx_k_spcs), 0, 0, 1, 1}, {&__pyx_n_s_strip, __pyx_k_strip, sizeof(__pyx_k_strip), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {&__pyx_n_s_tolist, __pyx_k_tolist, sizeof(__pyx_k_tolist), 0, 0, 1, 1}, @@ -7927,7 +8295,7 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__6); __Pyx_GIVEREF(__pyx_tuple__6); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":272 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":272 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_ARRAY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< @@ -7938,7 +8306,7 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__7); __Pyx_GIVEREF(__pyx_tuple__7); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":276 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":276 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_ARRAY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< @@ -7949,7 +8317,7 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__8); __Pyx_GIVEREF(__pyx_tuple__8); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":306 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":306 * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< @@ -7960,7 +8328,7 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__9); __Pyx_GIVEREF(__pyx_tuple__9); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":856 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":856 * * if (end - f) - (new_offset - offset[0]) < 15: * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< @@ -7971,7 +8339,7 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__10); __Pyx_GIVEREF(__pyx_tuple__10); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":880 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":880 * t = child.type_num * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< @@ -7982,7 +8350,7 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__11); __Pyx_GIVEREF(__pyx_tuple__11); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1038 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1038 * _import_array() * except Exception: * raise ImportError("numpy.core.multiarray failed to import") # <<<<<<<<<<<<<< @@ -7993,7 +8361,7 @@ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__12); __Pyx_GIVEREF(__pyx_tuple__12); - /* "../../../../homebrew/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1044 + /* "../../../spack-mstc/spack/opt/spack/darwin-mojave-x86_64/clang-10.0.1-apple/python-3.7.4-hh7odiqwzpw2nnfdcfzjxvb3ggyzwvfk/lib/python3.7/site-packages/Cython/Includes/numpy/__init__.pxd":1044 * _import_umath() * except Exception: * raise ImportError("numpy.core.umath failed to import") # <<<<<<<<<<<<<< @@ -8014,6 +8382,7 @@ static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) { if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(1, 1, __pyx_L1_error); __pyx_float_0_0 = PyFloat_FromDouble(0.0); if (unlikely(!__pyx_float_0_0)) __PYX_ERR(1, 1, __pyx_L1_error) __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(1, 1, __pyx_L1_error) + __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(1, 1, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; @@ -8056,7 +8425,9 @@ static int __Pyx_modinit_type_init_code(void) { __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); /*--- Type init code ---*/ if (PyType_Ready(&BDFModelType) < 0) __PYX_ERR(1, 33, __pyx_L1_error) + #if PY_VERSION_HEX < 0x030800B1 BDFModelType.tp_print = 0; + #endif if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!BDFModelType.tp_dictoffset && BDFModelType.tp_getattro == PyObject_GenericGetAttr)) { BDFModelType.tp_getattro = __Pyx_PyObject_GenericGetAttr; } @@ -8284,10 +8655,9 @@ if (!__Pyx_RefNanny) { __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(1, 1, __pyx_L1_error) Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(1, 1, __pyx_L1_error) - __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(1, 1, __pyx_L1_error) - #if CYTHON_COMPILING_IN_PYPY Py_INCREF(__pyx_b); - #endif + __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(1, 1, __pyx_L1_error) + Py_INCREF(__pyx_cython_runtime); if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(1, 1, __pyx_L1_error); /*--- Initialize various global constants etc. ---*/ if (__Pyx_InitGlobals() < 0) __PYX_ERR(1, 1, __pyx_L1_error) @@ -8306,9 +8676,9 @@ if (!__Pyx_RefNanny) { } #endif /*--- Builtin init code ---*/ - if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(1, 1, __pyx_L1_error) + if (__Pyx_InitCachedBuiltins() < 0) goto __pyx_L1_error; /*--- Constants init code ---*/ - if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(1, 1, __pyx_L1_error) + if (__Pyx_InitCachedConstants() < 0) goto __pyx_L1_error; /*--- Global type/function init code ---*/ (void)__Pyx_modinit_global_init_code(); (void)__Pyx_modinit_variable_export_code(); @@ -8401,12 +8771,12 @@ if (!__Pyx_RefNanny) { if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "map.to_py":201 + /* "vector.from_py":45 * - * @cname("__pyx_convert_map_to_py_std_3a__3a_string____int") - * cdef object __pyx_convert_map_to_py_std_3a__3a_string____int(const map[X,Y]& s): # <<<<<<<<<<<<<< - * o = {} - * cdef const map[X,Y].value_type *key_value + * @cname("__pyx_convert_vector_from_py_int") + * cdef vector[X] __pyx_convert_vector_from_py_int(object o) except *: # <<<<<<<<<<<<<< + * cdef vector[X] v + * for item in o: */ /*--- Wrapped vars code ---*/ @@ -8714,7 +9084,7 @@ static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args return result; } #if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) { +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) { PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); PyObject *globals = PyFunction_GET_GLOBALS(func); PyObject *argdefs = PyFunction_GET_DEFAULTS(func); @@ -8785,12 +9155,12 @@ static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, } #if PY_MAJOR_VERSION >= 3 result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, - args, nargs, + args, (int)nargs, k, (int)nk, d, (int)nd, kwdefs, closure); #else result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, - args, nargs, + args, (int)nargs, k, (int)nk, d, (int)nd, closure); #endif @@ -9824,6 +10194,130 @@ static CYTHON_INLINE int __Pyx_dict_iter_next( PyObject_RichCompare(op1, op2, Py_NE)); } +/* PyIntBinop */ + #if !CYTHON_COMPILING_IN_PYPY +static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) { + (void)inplace; + (void)zerodivision_check; + #if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact(op1))) { + const long b = intval; + long x; + long a = PyInt_AS_LONG(op1); + x = (long)((unsigned long)a + b); + if (likely((x^a) >= 0 || (x^b) >= 0)) + return PyInt_FromLong(x); + return PyLong_Type.tp_as_number->nb_add(op1, op2); + } + #endif + #if CYTHON_USE_PYLONG_INTERNALS + if (likely(PyLong_CheckExact(op1))) { + const long b = intval; + long a, x; +#ifdef HAVE_LONG_LONG + const PY_LONG_LONG llb = intval; + PY_LONG_LONG lla, llx; +#endif + const digit* digits = ((PyLongObject*)op1)->ob_digit; + const Py_ssize_t size = Py_SIZE(op1); + if (likely(__Pyx_sst_abs(size) <= 1)) { + a = likely(size) ? digits[0] : 0; + if (size == -1) a = -a; + } else { + switch (size) { + case -2: + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { + lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case 2: + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { + lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case -3: + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { + lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case 3: + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { + lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case -4: + if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { + lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case 4: + if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { + lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + default: return PyLong_Type.tp_as_number->nb_add(op1, op2); + } + } + x = a + b; + return PyLong_FromLong(x); +#ifdef HAVE_LONG_LONG + long_long: + llx = lla + llb; + return PyLong_FromLongLong(llx); +#endif + + + } + #endif + if (PyFloat_CheckExact(op1)) { + const long b = intval; + double a = PyFloat_AS_DOUBLE(op1); + double result; + PyFPE_START_PROTECT("add", return NULL) + result = ((double)a) + (double)b; + PyFPE_END_PROTECT(result) + return PyFloat_FromDouble(result); + } + return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2); +} +#endif + /* DictGetItem */ #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { diff --git a/src/mesh/pynastran_io.h b/src/mesh/pynastran_io.h index d179215b..657998a0 100644 --- a/src/mesh/pynastran_io.h +++ b/src/mesh/pynastran_io.h @@ -1,4 +1,4 @@ -/* Generated by Cython 0.29.6 */ +/* Generated by Cython 0.29.13 */ #ifndef __PYX_HAVE__pynastran_io #define __PYX_HAVE__pynastran_io @@ -45,6 +45,7 @@ __PYX_EXTERN_C void printBDFStats(struct BDFModel *); __PYX_EXTERN_C std::vector > getNodes(struct BDFModel *); __PYX_EXTERN_C std::map > > getElements(struct BDFModel *); __PYX_EXTERN_C std::map getNumberOfElementTypes(struct BDFModel *); +__PYX_EXTERN_C std::map > getSPCs(struct BDFModel *); #endif /* !__PYX_HAVE_API__pynastran_io */ diff --git a/src/mesh/pynastran_io.pyx b/src/mesh/pynastran_io.pyx index d2b1a0e1..5a24bcf0 100644 --- a/src/mesh/pynastran_io.pyx +++ b/src/mesh/pynastran_io.pyx @@ -205,6 +205,22 @@ cdef public map[string, int] getNumberOfElementTypes(BDFModel model): return elementTypes +cdef public map[string, vector[int]] getSPCs(BDFModel model): + """ + Create a map of subcase SPCs and the nodes that belong to that SPC. Useful for creating boundaries in libMesh. + """ + cdef map[string, vector[int]] SPCs + + for subcase_num, spcs in model.myBDF.spcs.items(): + i = 1 + for spc in spcs: + name = "Subcase-%i_%s_%i"%(subcase_num, spc.type, i) + SPCs[name.encode("utf-8")] = spc.nodes + i+=1 + + return SPCs + + cdef perturbZeroLengthBushings(BDFModel model): """ As of November 18, 2019, MAST does not support the specification of the elemental x-axis which is required when From bf9bc4389f0e3fcf87fee49af7fce36354172045 Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Mon, 23 Dec 2019 16:49:03 -0500 Subject: [PATCH 030/111] NastranIO class refactoring and documentation updating. --- doc/Doxyfile.in | 2 +- src/mesh/nastran_io.cpp | 153 +++++++++++++++++++------------------- src/mesh/nastran_io.h | 160 +++++++++++++++++++++++++++++----------- 3 files changed, 198 insertions(+), 117 deletions(-) diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index b24b64b1..65217480 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -441,7 +441,7 @@ EXTRACT_ALL = YES # be included in the documentation. # The default value is: NO. -EXTRACT_PRIVATE = NO +EXTRACT_PRIVATE = YES # If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal # scope will be included in the documentation. diff --git a/src/mesh/nastran_io.cpp b/src/mesh/nastran_io.cpp index a322ba84..c2591075 100644 --- a/src/mesh/nastran_io.cpp +++ b/src/mesh/nastran_io.cpp @@ -7,108 +7,78 @@ #include #include #include -#include +// #include #include #include -#include +// #include // MAST includes. #include "mesh/nastran_io.h" #include "external/fort.hpp" -MAST::NastranIO::NastranIO (libMesh::MeshBase& mesh, const bool python_preinit): -{ - // Iterate through element types - for (const auto& item : elementMap) - { - libMesh::out << "Element Type: " << item.first << std::endl; - - // Iterate through elements - for (const auto& elem : item.second) - { - libMesh::out << "Element ID: " << elem[0] << "\tPID: " << elem[1] << "\tNodes: "; - // Iterate through nodes - for (uint j=2; j> nodes) -{ - // Iterate through nodes - for (const auto& node : nodes) - { - libMesh::out << "Node # " << node[0] << ":\t" << node[1] << "\t" << node[2] << "\t" << node[3] << "\t" << std::endl; - } -} - - +MAST::NastranIO::NastranIO(libMesh::MeshBase& mesh, const bool python_preinit): libMesh::MeshInput (mesh), -_pythonPreinitialized(python_preinit) +python_preinitialized(python_preinit) { // Initialize Python if it hasn't already been initialized. - if ((not pythonInitialized) and (not _pythonPreinitialized)) + if ((!python_initialized) && (!python_preinitialized)) { - initializePython(); + initialize_python(); } } -MAST::NastranIO::~NastranIO () +MAST::NastranIO::~NastranIO() { - if((pythonInitialized) and (not _pythonPreinitialized)) + if((python_initialized) && (!python_preinitialized)) { - finalizePython(); + finalize_python(); } } -std::map MAST::NastranIO::getNastran2libMeshNodeMap() +std::map MAST::NastranIO::get_nastran_to_libmesh_node_map() { - return nastran2libMeshNodeMap; + return nastran_to_libmesh_node_map; } -std::map MAST::NastranIO::getlibMesh2NastranNodeMap() +std::map MAST::NastranIO::get_libmesh_to_nastran_node_map() { - return libMesh2NastranNodeMap; + return libmesh_to_nastran_node_map; } -std::map MAST::NastranIO::getNastran2libMeshElemMap() + +std::map MAST::NastranIO::get_nastran_to_libmesh_elem_map() { - return nastran2libMeshElemMap; + return nastran_to_libmesh_elem_map; } -std::map MAST::NastranIO::getlibMesh2NastranElemMap() +std::map MAST::NastranIO::get_libmesh_to_nastran_elem_map() { - return libMesh2NastranElemMap; + return libmesh_to_nastran_elem_map; } -std::map> MAST::NastranIO::getPID2subdomainIDsMap() +std::map> MAST::NastranIO::get_nastran_property_to_libmesh_subdomains_map() { - std::map> pid2SubdomainIDsMap; - for (const auto& item : pid_elemType2subdomainMap) + std::map> property_id_to_subdomain_id_map; + for (const auto& item : nastran_pid_elemtype_to_libmesh_subdomain_map) { int pid = item.first.first; int sid = item.second; - pid2SubdomainIDsMap[pid].insert(sid); + property_id_to_subdomain_id_map[pid].insert(sid); } - return pid2SubdomainIDsMap; + return property_id_to_subdomain_id_map; } -std::map, int> MAST::NastranIO::getPIDElemtype2SubdomainIDMap() +std::map, int> MAST::NastranIO::get_nastran_pid_elemtype_to_libmesh_subdomain_map() { - return pid_elemType2subdomainMap; + return nastran_pid_elemtype_to_libmesh_subdomain_map; } void MAST::NastranIO::read_nodes(BDFModel* model, libMesh::MeshBase& the_mesh) @@ -126,8 +96,8 @@ void MAST::NastranIO::read_nodes(BDFModel* model, libMesh::MeshBase& the_mesh) double x=node[1], y=node[2], z=node[3]; uint64_t nid=node[0]; the_mesh.add_point(libMesh::Point(x, y, z), nid); - nastran2libMeshNodeMap[nid] = the_mesh.node_ptr(nid); - libMesh2NastranNodeMap[the_mesh.node_ptr(nid)] = nid; + nastran_to_libmesh_node_map[nid] = the_mesh.node_ptr(nid); + libmesh_to_nastran_node_map[the_mesh.node_ptr(nid)] = nid; i++; } @@ -151,13 +121,15 @@ void MAST::NastranIO::read_elements(BDFModel* model, libMesh::MeshBase& the_mesh { // Determine the appropriate libMesh element type libMesh::ElemType elem_type; - if (nastranToLibMeshElem.find(item.first) == nastranToLibMeshElem.end()) + if (nastran_to_libmesh_elem_type_map.find(item.first) == + nastran_to_libmesh_elem_type_map.end()) { - libmesh_error_msg("ERROR: " << item.first << " not found in nastranToLibMeshElem map in NastranIO.h"); + libmesh_error_msg("ERROR: " << item.first + << " not found in nastran_to_libmesh_elem_type_map map in nastran_io.h"); } else { - elem_type = nastranToLibMeshElem[item.first]; + elem_type = nastran_to_libmesh_elem_type_map[item.first]; } // Loop through all elements that belong to this element type on inner loop @@ -167,8 +139,8 @@ void MAST::NastranIO::read_elements(BDFModel* model, libMesh::MeshBase& the_mesh libMesh::Elem * elem = the_mesh.add_elem(libMesh::Elem::build(elem_type).release()); const libMesh::dof_id_type eid = item.second[i][0]; elem->set_id(k); - nastran2libMeshElemMap[eid] = the_mesh.elem_ptr(k); - libMesh2NastranElemMap[the_mesh.elem_ptr(k)] = eid; + nastran_to_libmesh_elem_map[eid] = the_mesh.elem_ptr(k); + libmesh_to_nastran_elem_map[the_mesh.elem_ptr(k)] = eid; elem->set_id(eid); // Determine element type and property ID @@ -178,21 +150,22 @@ void MAST::NastranIO::read_elements(BDFModel* model, libMesh::MeshBase& the_mesh // multiple element types in one subdomain. const libMesh::subdomain_id_type pid = item.second[i][1]; const int elemtype = int(elem->type()); - if (pid_elemType2subdomainMap.find({pid, elemtype}) == pid_elemType2subdomainMap.end()) + if (nastran_pid_elemtype_to_libmesh_subdomain_map.find({pid, elemtype}) == + nastran_pid_elemtype_to_libmesh_subdomain_map.end()) { // If the {pid, elemtype} pair is not yet defined in the map, define it. - pid_elemType2subdomainMap[{pid, elemtype}] = z; + nastran_pid_elemtype_to_libmesh_subdomain_map[{pid, elemtype}] = z; z++; } // Set the element subdomain - const libMesh::subdomain_id_type sid = pid_elemType2subdomainMap[{pid, elemtype}]; + const libMesh::subdomain_id_type sid = nastran_pid_elemtype_to_libmesh_subdomain_map[{pid, elemtype}]; elem->subdomain_id() = sid; // Set the nodes which belong to this element for (uint j=2; j<(item.second[i].size()); j++) { uint node_num = item.second[i][j]; - libMesh::dof_id_type nid = nastran2libMeshNodeMap[node_num]->id(); + libMesh::dof_id_type nid = nastran_to_libmesh_node_map[node_num]->id(); elem->set_node(j-2) = the_mesh.node_ptr(nid); } @@ -213,7 +186,7 @@ void MAST::NastranIO::read_node_boundaries(BDFModel* model, libMesh::MeshBase& t { for (uint i=0; iadd_node(nastran2libMeshNodeMap[spc.second[i]], j); + the_mesh.boundary_info->add_node(nastran_to_libmesh_node_map[spc.second[i]], j); } j++; } @@ -247,6 +220,7 @@ void MAST::NastranIO::read (const std::string& filename) the_mesh.prepare_for_use(); } + void MAST::NastranIO::read(BDFModel* model) { // Get a reference to the mesh we are reading @@ -265,9 +239,8 @@ void MAST::NastranIO::read(BDFModel* model) read_elements(model, the_mesh); } - - -void MAST::NastranIO::initializePython() + +void MAST::NastranIO::initialize_python() { // StackOverFlow, "Use generated header file from Cython" // - related to using multi-stage imports @@ -284,14 +257,14 @@ void MAST::NastranIO::initializePython() Py_Finalize(); libmesh_error_msg("ERROR: During Python initialization for pynastran_io."); } - pythonInitialized = true; + python_initialized = true; } -void MAST::NastranIO::finalizePython() +void MAST::NastranIO::finalize_python() { Py_Finalize(); - pythonInitialized = false; + python_initialized = false; } @@ -300,7 +273,7 @@ void MAST::NastranIO::print_pid_to_subdomain_id_map() { table << fort::header << "Nastran Property ID" << "libMesh/MAST Subdomain ID" << fort::endr; std::string sid_str; // must reduce std::set of libMesh subdomain IDs to string for table output. - for (const auto& id_pair: getPID2subdomainIDsMap()) { + for (const auto& id_pair: get_nastran_property_to_libmesh_subdomains_map()) { table << std::to_string(id_pair.first); for (const auto& sid: id_pair.second) { sid_str.append(std::to_string(sid) + " "); @@ -311,3 +284,35 @@ void MAST::NastranIO::print_pid_to_subdomain_id_map() { libMesh::out << table.to_string() << std::endl; } + +void MAST::printElementMap(std::map>> elementMap) +{ + // Iterate through element types + for (const auto& item : elementMap) + { + libMesh::out << "Element Type: " << item.first << std::endl; + + // Iterate through elements + for (const auto& elem : item.second) + { + libMesh::out << "Element ID: " << elem[0] << "\tPID: " << elem[1] << "\tNodes: "; + // Iterate through nodes + for (uint j=2; j> nodes) +{ + // Iterate through nodes + for (const auto& node : nodes) + { + libMesh::out << "Node # " << node[0] << ":\t" << node[1] << "\t" << node[2] << "\t" << node[3] << "\t" << std::endl; + } +} + diff --git a/src/mesh/nastran_io.h b/src/mesh/nastran_io.h index 5326a43c..6f488783 100644 --- a/src/mesh/nastran_io.h +++ b/src/mesh/nastran_io.h @@ -21,22 +21,26 @@ namespace MAST { - void printElementMap(std::map>> elementMap); - - void printNodeCoords(std::vector> nodes); - - /** - * Nastran BDF mesh input. - * The NastranIO class is a preliminary implementation for reading NASTRAN mesh information - * using pyNastran with BDF data as input. Currently nodes, elements, & node boundary condition - * definition are supported. - * - * Nodal BCs are mapped into libMesh node boundary sets based on - * SPC IDs and nodes assigned to them in the BDF file. - */ - class NastranIO : public libMesh::MeshInput - { +/** + * Nastran BDF mesh input. + * The NastranIO class is a preliminary implementation for reading NASTRAN mesh information + * using pyNastran with BDF data as input. Note that this class is not designed to be a complete + * Nastran BDF reader with solution & case control, but rather a way to get basic mesh data defined + * in BDF format into libMesh/MAST. We define basic mesh data as: + * - *nodes*: Nastran grids (only supports grid definition in global coordinate system) + * - *elements*: Nastran elements with nodal connectivity (property IDs mapped to subdomains) + * - *subdomains*: libMesh mesh subdomains are similar to property card assignment in Nastran + * (used to connect properties to elements) + * - *node boundary domains*: similar to SPC ID sets in Nastran. We don't use actual BC values + * assigned on SPC cards, but rather track which nodes are used in each + * SPC ID. These become node boundary domains in libMesh/MAST, to which + * different boundary conditions can be assigned. + * + * TODO: Unit tests for NastranIO class. + */ +class NastranIO : public libMesh::MeshInput { public: + /** * Constructor. * @param mesh a libMesh mesh object. @@ -48,48 +52,116 @@ namespace MAST { /** * Destructor. */ - virtual ~NastranIO (); + virtual ~NastranIO(); - virtual void read (const std::string & name) override; - virtual void read (BDFModel* model); + /** + * Read ASCII NASTRAN BDF given by filename. + * @param filename string path to Nastran BDF formatted file. + */ + virtual void read(const std::string & filename) override; - std::map getNastran2libMeshNodeMap(); - std::map getlibMesh2NastranNodeMap(); + /** + * Read data directly from BDFModel object. + * @param model pointer to BDFModel object. + */ + virtual void read(BDFModel* model); - std::map getNastran2libMeshElemMap(); - std::map getlibMesh2NastranElemMap(); + /** + * Returns mapping between Nastran BDF grid ID's and libMesh/MAST nodes. + * @return map between Nastran grid ID's and pointers to corresponding libMesh/MAST nodes. + */ + std::map get_nastran_to_libmesh_node_map(); + + /** + * Returns mapping between libMesh/MAST nodes and Nastran BDF grid ID's. + * @return map between pointers to libMesh/MAST nodes and corresponding Nastran grid ID's. + */ + std::map get_libmesh_to_nastran_node_map(); - std::map, int> getPIDElemtype2SubdomainIDMap(); - std::map> getPID2subdomainIDsMap(); + /** + * Returns mapping between Nastran BDF element ID's and libMesh/MAST elements. + * @return map between Nastran element ID's and pointers to corresponding + * libMesh/MAST elements. + */ + std::map get_nastran_to_libmesh_elem_map(); /** - * Print map between Nastran property ID's (PID) to libMesh subdomain - * ID's (SID) to libMesh::out. Note that some PID will correspond to - * multiple SID since libMesh requires all elements in a subdomain to - * be the same type, but Nastran allows property assignment to multiple - * element types from the same property card (ie. one PSHELL card - * providing properties to both CQUAD4 and CTRIA3). + * Returns mapping between libMesh/MAST elements and Nastran BDF element ID's. + * @return map between pointer to libMesh/MAST elements and corresponding Nastran + * element ID's. + */ + std::map get_libmesh_to_nastran_elem_map(); + + /** + * Provides mapping between Nastran property ID & element-type pairs and corresponding + * libMesh/MAST subdomain ID's. Note we must use a pair combining a Nastran property ID + * along with a specific element type to get a unique map key to libMesh/MAST subdomains. + * This is because Nastran allows one property ID to be assigned to elements of different + * type (ie. PSHELL to both CQUAD4 & CTRIA3), but libMesh does not allow elements of + * different type to belong to the same subdomain. + * @return map between Nastran property ID + element type pairs and corresponding + * libMesh/MAST subdomain ID's. + */ + std::map, int> get_nastran_pid_elemtype_to_libmesh_subdomain_map(); + + /** + * Returns mapping between Nastran property ID's and sets of libMesh/MAST subdomains. Note + * that one Nastran property ID can map to multiple libMesh/MAST subdomains because Nastran + * allows one property ID to be assigned to elements of different type (ie. PSHELL to both + * CQUAD4 & CTRIA3), but libMesh does not allow elements of different type to belong to + * the same subdomain. In this case, we use multiple subdomains to contain the different + * element types. + * @return map between Nastran property ID's and sets of corresponding libMesh/MAST + * subdomain ID's. + */ + std::map> get_nastran_property_to_libmesh_subdomains_map(); + + /** + * Print map between Nastran property ID's (PID) to libMesh subdomain ID's (SID) to + * libMesh::out. Note that some PID will correspond to multiple SID since libMesh requires + * all elements in a subdomain to be the same type, but Nastran allows property assignment + * to multiple element types from the same property card (ie. PSHELL to both CQUAD4 and + * CTRIA3). */ void print_pid_to_subdomain_id_map(); private: - const bool _pythonPreinitialized = false; - bool pythonInitialized = false; + /// Indicates if Python was initialized outside of NastranIO class. + const bool python_preinitialized = false; + /// Indicates is Python has been initialized. + bool python_initialized = false; - std::map nastran2libMeshNodeMap; - std::map libMesh2NastranNodeMap; - std::map nastran2libMeshElemMap; - std::map libMesh2NastranElemMap; - std::map, int> pid_elemType2subdomainMap = {}; + /// Mapping from Nastran grid IDs from BDF input to pointers to libMesh/MAST nodes. + std::map nastran_to_libmesh_node_map; + /// Mapping from libMesh/MAST node pointers to Nastran grid IDs from BDF input. + std::map libmesh_to_nastran_node_map; + /// Mapping from Nastran element IDs from BDF input to pointers to libMesh/MAST elements. + std::map nastran_to_libmesh_elem_map; + /// Mapping from libMesh/MAST element pointers to Nastran element IDs from BDF input. + std::map libmesh_to_nastran_elem_map; + + /** + * Mapping from Nastran property ID/element-type pair to libMesh/MAST subdomain. + * + * Note we must use a pair combining a Nastran property ID along with a specific element + * type to get a unique map key to libMesh/MAST subdomains. This is because Nastran allows + * one property ID to be assigned to elements of different type (ie. PSHELL to both CQUAD4 + * and CTRIA3), but libMesh does not allow elements of different type to belong to the + * same subdomain. In this case, we use multiple subdomains to contain the different + * element types and store this mapping for reference. + */ + std::map, int> nastran_pid_elemtype_to_libmesh_subdomain_map = {}; void read_nodes(BDFModel* model, libMesh::MeshBase& the_mesh); void read_elements(BDFModel* model, libMesh::MeshBase& the_mesh); void read_node_boundaries(BDFModel* model, libMesh::MeshBase& the_mesh); - // Map from NASTRAN Elements to Equivalent libMesh Elements - // TODO: Not yet complete, need to add all NASTRAN elements which we need support for. - std::map nastranToLibMeshElem = { + /** + * Map from Nastran elements to equivalent libMesh/MAST element types. + * TODO: Not yet complete, need to add all Nastran elements we need support for. + */ + std::map nastran_to_libmesh_elem_type_map = { // 0D Elements (i.e. Ground Springs) {"CELAS1_1", libMesh::NODEELEM}, {"CELAS2_1", libMesh::NODEELEM}, @@ -120,9 +192,13 @@ namespace MAST { {"CHEXA_8", libMesh::HEX8}, {"CHEXA_20", libMesh::HEX20} }; - void initializePython(); - void finalizePython(); + void initialize_python(); + void finalize_python(); }; + + // Utility functions. + void printElementMap(std::map>> elementMap); + void printNodeCoords(std::vector> nodes); } #endif // __mast_nastran_io_h__ From 6702532f924614b40bb4038f4ccd99a21edbd02b Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Fri, 27 Dec 2019 13:50:39 -0500 Subject: [PATCH 031/111] Removing doc/assets folder/files for conversion to submodule. --- .../structural/example_4/example_4_mesh.png | Bin 25047 -> 0 bytes .../example_4/example_4_uz_contour.png | Bin 40702 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 doc/assets/examples/structural/example_4/example_4_mesh.png delete mode 100644 doc/assets/examples/structural/example_4/example_4_uz_contour.png diff --git a/doc/assets/examples/structural/example_4/example_4_mesh.png b/doc/assets/examples/structural/example_4/example_4_mesh.png deleted file mode 100644 index d64dec1a42627654cf7ef17efee94d867311c278..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 25047 zcmeEu1y@_o7j1Bg_XowTrNy1#4h4$4yA#}9OM$j%ixqc=P~5E)cLD^L;_en8yzqZt z;C+C%fR&ZYTA6!i&e^l~*=O=iO+^kDiyR980N~1h`ltZ_AcZ3SurSdPS167?BOzW; zZ6%c@0f3r#>_>An#CuxHPa4VqfImF|5c&lGfFUl0?g0Q^oB+Uq82}*k3jiQ-&1_W{ zLHq;VLQ(D`;Q8ezx1%HxaRtLuURefX69bR%jd02b|3(17Y)Ss3q?YgEah6Z!d+io@ zj%Hc!R@MSe+tzzB9L&`U(rReHYZQO9Ypnm!P(Ko>y(W0YOw0HQ?=!8%+yf!qJGUY8 zh3*|=zOiwYqm%Euk8lC6@``}+wu%4}o8E_~KsC3DHivTCiGcA3vC~UrR7ryW|NH+o z1BIc=SGWYI=Q})J2l11u*)pcpgH?v&JJ+77w>cpj5W*nCzZp1afY0+M&E)(moD?W1 zaBAUWE90IPOj+4G9>iN7#nhI|XZYDVEJWBs_4FhF3^+UcxW;;pE`=0I+sG5_I*T&j z%=OD{u%{)%KOi=q6CE`y^zggI5OFn0|L4@G$nX-~N>5W#@_&~!L5@~qEFP*Jq-{jq zP4uvvZ)2D*gU8+Npxv6g4xYlB=oYK9xceU4i<6&YA}YcNB=QKlufOzm>%_mgtDvLn z$&3w$*H!2~U}tCYz+gNRM%u_?$m_6g@E>25Ly-ZJjtrRrHywIy<0Cr_ zo_l--*ueYr|9vJ#=2=AB`KSllW+qQbc3m&t&WGY5Zh5F*cIctomWRLRyRW^Z>#fL* zW9I3jUPd)}dRx`8aTm527*8cS)#s+cu(UtJax{iIll3Y+_fQ6y9K(Uc%j~(ui5;js z!kRd04TIhP?)s!VJ#i+QXURkFJ426M>$ek0p7+Qz3aXT&6llr_Kc8Z+HTs3*b(2&X z?{@6n|EhD&y8Rc;k(}~$&k-%lR-xH^f=2ix@RgJZfN4RogL2wMhW~V5(0ncz|G3L8 zY}mAOxmaI#_*o)X>)+rmubsg~ErDy8Mh%=d2C2^i&`;`_h1NL6PaJJArT5ksoC#-EXYC-T;H;I(w$JJVX5s>{!t|5`T8 z;eS4(-8ghTZ?^V;G=;;9MpQEP1{#eeU#3aYdw#hv{N(BJWn5F!v*&@>OjywKV^io!8=w~j(;}IZpD$`TS#iS?%F6@zpnEML+sx$8nG2hql zIhPJOS^GUe-S!YKc7qMLRl3?-w#frX5G;|lu70cN@)729zVcpnSzFG!7ZIMuNBsi8 z3Gd-1Q%aPCkSY`bTF1@w4aRO+h_`vul#U%lRJ*4`woz1Y@%0Itl>{>@_sKt#Is+bHWN(p5*PV- zX7zYkE65$sC9WH>&$VQt8&`K^7OImD-6k^NT?e1<)c-bYv0Ae5su?7yJiX1PCOzAA zoF{09RS(F{wO?I;@GNbSa!tO}s{v@gI(;EjZKmL8*8@&GPA6g8jsqw7acn*q@3vBA zbL96mvu@09%d_eOGDQmkRzl3y_1yC zHx5{6@Pj?Qvp?%*XQSoN4&Cf@o<{p|NEdq;71q}gdRWDR#sAhBK=VBBbhllt18Q2U zJuR#At_S~Soy+#jI>i=HIW`itM z3fj>3znpiE3!K2cTUt}?SLT0&{WA7$bRM*6SS>u9KKiSzz>tHlDI`T~7i2nz7pNMF zU3NEQ!|Un2H(7sv@Q${_9}}R!havrBAia1SlVdL{8@P7)H!{?6V-PdM+m6xKCa6pN zwkY-c2>fcdg>K=<%6w_b#e@6>WWO)?tkG=xbS+bb+;wfxy(DXZVFsV@zR)<@_YZMK zjox6Bv~KIVp*F9E-^9^KM!FLGq{yaVm`y1ww=$cMK9M4lXVrO}SZtuykDH|2)l?4z zp3;74_n9CJ+x*&N@r{F=3OAdA94p(PX*|TO$D!y=*ZuLojq!028nXNTjE4^@v@fW^ zQdF>s^>`50w7#u-6n;D3+gevAy~eTMI#zb=V~n>}4g7u?RK|WG(voo4%F1d;hD&wq z|8HO7hmIIlq4t%3UcpWy$Vl@0NaHE`TLcQhfx?IN3e<1jC(Y$}AVCSwjPS%0u)!d1(!9}n1p0&P(iy(o1r!T@ zC`>Mz3pj1Qnz@Z|HR3X0zSxd1O0c3 zy>vZw;Rv`GNol)$K0oXCV#q$TzC9!vNB{jV76#*I`QP&YYxf9=+#Xpu3JEH_T;j3) zwM&odr4EYyIc6RiYw`p4OW!-=u0y_6{gNtNVBMt-6BA@+-Ov0~QcsBw2OVO;iQDon zRiTzK%ZA^SQDNV{LreEQn1y0|T8$ZP5=fktRGtnop@$~c>A1lYsj$MNP7ZiVn7~n)9cbmV17e4Teue!-yYCx zT>R$omXk?@YKD2HxQwRI2@}N%gWEEBpZuG(lHeloZ8&^0%eM?!rMP0|14{8*3q`Il?l{Z>}< ze#*qZd>0jA?;WK}iU#6m+61&oBb5rh8Q$2psk4)_*0~+VQ3S}5v~1PGvNGxF`FAQniEOd_uIfY`O6D$zn?;4rO@`Z%$f`##okw71H{W~q zHD06aLTnbqupi{0&RjoLwE0s= zl7MhHAikZf>$%tD*YpDo&4TsrsMkW}T&gG4E_aDBN7dUetT1m+QacC8kD)<_Ak$nc zk9j-{d{j!gP>@||D^oJE9h2w%k3e9m%1Idr=lEENRZ*J0;H@RdEJg;4W@*P$4@4!qwC|x0Z_uKUM1^}P zL%_ejRP3nZ4%-{>jknV+0!a(a4~oRzDTmN<@-bUy-nXMeCi8DA+283J3PbbB^lb|A zJw=SQSlwc99tI;*2#SZy(hSBv`z)g{;f^tX2hd`onszL<-M~$8OqwA_F+or9@eU{0 zA&D=$hav00I(SJuT)X0^<7SQH76N8}nl#WYW(qByf(`hzXGVXb9}>(x47CRRX4P-k z#x=kGN<7t$Zd}o|3}m_0Dxvb?R>N*5*bKlY_oLM=Ad*R=KR}fN96mf@JR@k-kmyQ( ze{|R7{><9dM{}hY{{Cb1!PNa=J zxGG(*`Yd0j#m???o0Qt-zcO@?maaVW3SfrVO#)9UimH!0biFsrN}jzmyWsq2LP!LE zi3j;P+VOjPdkTH1R^bJ!CQl(VpXmX5^x?@rVQ*L)UKd@V!mMoXXwO!91eb z58hHa6b#F=KDVTt_MZeHh1$~&PupGy4CArsJ$ksve*C@G4YVHqkT{hv0`l@%oU*kY zKGl!6*~$*Zk>Ymhvxsy}?!fQ|(rbpFmMA)DuV_B!_l>_Q$>MstJ%!);-R;sbILDcW z^P_1Xz5Yx5mjr&xF7g~W^*F;2&?#iu>KA9u$phb2NGSukOV+XC#`SJAQyKxtrIUWD z`<)x1R8xJ3b}YQ+NVfXX;-5DMj8rO}<5G^a;F75M+d~?yf*Diu7odgpp)e(FZl%s` zN)W!9&VH(#r(u{D6Y1DUc_tEXX*Dx2SQ@XSg8?B0_UB6qG`Je88?_8S^beJY2A*C{ zq}^Sbb~fJ!ldYoep(277Ge>9#@9{D0dhxjF$opTMu)*5I4Ee!-Ny;;xqP2o?l$^Y{ zKeRmp0)ncu>V*&L`9|HE)RLopj0D5=AOy$#ylh#jKl0O%xzxJcD$;%JM{0-5*x0RF z2f0Tqxi?E##R=dC(2moU+wS$gwxdk9M$bOg|2&atzp{niQu|>C-#%<|1r0C8kEL51 zXN}mc$U|qR5!uoJ;1oFukCIlWRpT<%-4Jj;vMiwT8rqrEvpjBBLQAg7Cu1S`!9xZT z-|)MDV?>GEbxH(em~0TFe{2!RQis4Aqz=qv=}a^0D<+)5P10&=_7 zo)@~P*^HW(z-fPOgI$ko?$~@U^9TWwN}Mhs53#-%Lrv>22WUq?(+amwBb4;ur@^5q zR=#n?q1yuMb~F}Q$<LcitKP3@+R^( z6`R*2&}5xAhtP*-qvpwb$BFlr+fa^Q*y}%ay5O%O5V}-}R`}#jbUCos#Mj#Syu0Ie z7+znexyHXQ)bP70|JpXel1enb*A0zQICS@wQo2>-^%pC7tHpZ7b^*t|*zN41pN?3X zITUXiR}>&Zy=IKbzRdA&{bKk;7`Z^sf*vv)FS-ITZnAw`A{zQcqDsD|9z(Y8GMzRX4&x+o_aASi z<=Sn;f+ zNfigx>Q_lo?+aLmP>mxEyvBtHN(iC-fE{Ukqf4yn%CJ@9Gkx{eXZt=A51I_3n!U^g zk?Qh)o%zUAnH#oqhzeM5ws7pjI&~^C=#lV6aLhi;~gmIx@L zDfHY6gI9^ZHUP7zD3a+zHkcuLCe|O1XbdM!{jT#&r{g5(ww0!;?Wh~&VzsI%q_cq| z7&{!X*zH4s_b~ySE}fP^C-d1Z6Ti%ZXF2t@)N@&1|D&UBYa9D?qOaV+WaKtIEHEoo z^*R3Vd+CFoU{tx3^I~L~&BamdXZ>wj|F{iv8Zg5yxgMF|r(zvt6gwvZoZaq4uT`fI zf4i;9RTIl245(w)_nh}HL?&Z!H?ED)XRS`MZFA0eJpDsd>sCdzxf1&qI=ar8GZaos zKYy9UeA|M>(0nbdZeXM%>3inZ_}<(?9US!Bg5J`$dE~L}1qk!Ee-ndlRzLKz@R0FH z^A_cm#iH>mT^dzrQ8_u+#eutN|43l|vAny%$G?>CVNC)rYwhwM&C{u&+cS!3_bA9A zE{k`hRm8Gpyznq-uB$*=POQ3@o2(gd^z-O0A|X26NwJ{8U+@~(fFxlcEKTdS_w7JT zrzEPThIaZ2JIwV5RS5pr)`Fm1uRgllzkaXjrKr9g^ub8r($2Iv(@pz~7l@4Pl}RT5 znxOT>N}b|3{6NEZ)s%08-)tmY1%P@^?>a9G?%h zYS292K({RZv6GOHaFJB8HVrLphia#gTPaoR!Nqm&i6x6B^+~plOkwbjjrR^{T42^I zJntv)u^kk{Mnpp#K$xaj=!3)Obv6h8KR<@_}C z*7tn-&(iH8U4X7!RHN;*7l`DKhCHz;FB@ePDW684#}$ZVy$7KU zEL*r&CbtOt$TPth91_Q}-XfB2x$a+kuk_|eV&sZI9H~j|%>A@{N$}$;e)}{1<92mP zJskTtnlz$LvMPbIDSWq2<fJHAQ1t%PMqTLCJYDx{|cZ$t)ew z9PNA86{|j0B_X>jOOgK=ULmB-IlB8(1HQ$vkWZ8}{`lJBl0)F{IWN%rh{-+>A|#G^$T+cRAK zTXwS6zx!!Xk}N%9-XQyezb1W*{n{2&EJ@aGt%=C-G24_PbE~B1jZ^&iObFBg$Mn3z zN$x}+`+v{v3WuKbmTQ~9jpgc1MI7V~qtp9;9oV1|;IgY0B&nn5l7pTUi)fXsKYdU# z5<2ih{*ck@;kQ){VT}FBw+Dy~C$;>VDajj~M^Nl;q)R>vBCpuTDmRi{(lC&$ur-gA zHksxI5{dBmWCsl+P+iv~cs9{BlOf|_x=D%=?IS@(8bqZ915rNVRu!wctq?vkGqEBc z)d(rBKa`}+@2f;)bjxqvqU-8JYW2Rwjn_0Pj5M(%aTVW;c$YkZjQBvo(T>V>_27?j zn!G36b3v4-$-@Oepu-tDz|t~MzVy!Ts5D+Q9;%y@18Xqkc_Cap?#nek8`%N6zYSd$ zckdSJDjm4V=G22?XUec~@cgDYeR!2wRLCD}X@mUVXODjqcIA#_R4xE*%kan2cac48 z`zz$To9lSfpnTmbJU;ek=KTR9gUss=)Hrpzo&R^crP=AZ9)9X~D}H_^u4;E-xaObt zLiFk3m*UR7;a!0w#W!ejr@*CFzKmJ_pWsa+J`*o*gyu*LL37HG8`D!5)@McItb&1J z>OtgQSr^ao{63&`rM@Ib{oibn-eaI;(G1Y4y%i-%7elWZDfP|9z0sonB@C2rlPxpr zaHL()?vmqs@JBd>m7J*S;px08_{s3Y3ym4;URw31bMACw5P6)K@;R=NLx>GNr`^KC zgZ=sB>iARayX!kGNN4Sk|fGkEs5PPEM%k=opt z!JQsAtGe`l<^hGc5aNB@)z1=Vybg~vPyckKO>+c$S)cYIt6T~MawrLz***17Xjr@9v-gfq{38MfAi zO5#~&5mO0#5(}Qj9&nAw-5MY=T;j@ zLqYxB_iJ}rifd1EaW(rck_1aU&)+;I7T#R$q?)`Ra5e_2)DKY416$i$FN!6-R!bEL>ky$nrGQdyS39^V?r}bo;Qw1tTM$hN3zOj*B}@Hunr#c7gsde|vK4;2po(fQF8$V1LX6rgT}l z_hCEjp^;HRNeYz5$E`1~uO#Z)3-yGX7(?Sln(J%v8i>fT)K4W!ds%7cG_M>a6> zPXIT~464)rO2{jb*}G|1B&ky6&{hthrP-mf2G2IYn@$c*E>Tf>96DCYR9}InT=#S` z5(y@2I^xMdNixP9gBgc^9k|Z(r@8IlW_XyBeV?bTPsnVuJC@esL{HwdbKhnv!>HyL zUxX;zS>NVq|FW*rp{1OcF((3nJo|G=qBTC33I!)KWgO1w78e>nY7y$oMTI$*uBsPM z3UY*ixxbFs96n#i88Y)P=ILhimxU$`*%2hPxp>i}_nR$=XqRxQQEM;Q8Chi-OzY0N z(py)#r+nTVB+?n$=|jXQwyM~1S%7Ka>cHA_&2_xzvepY2DZ7s{I1ixU;~n@cw_c`t zFZVn;_ggq2TXRq|u&$FA&(uIQ*9x^Er9fqk0oOn?MFPw{bZK4Nr;BX+L3^O8gh>WC zq4LDiZa&JK)6<8H7sBa=n3-2G{JsufGR^2ee^5N8S@s_2Zn|0F-(7BujX@0j5(dhy zTWukq*PhR#e+hbBm)IWLnIwPgJak zLr9I9rrq;l9teQ0xo176R*c1%D1BHrV)nT3Gd^x*siH17v0S1w+h($g{hE_9?Tzk% z=SYfq60)-}egANj#qxO8daR1r3J`kuqXM4To{-4H^2XiywW8SXL-w?##fwEed1zk) zJaoDnJ1u3DfLv12Gn(L=`+vLs3~4MAVz>N&6XmBxCo04~^yBmD>fu?2 z>CtDw38J-DXm(ngu+UY9y>Uj;v>GUymLM-sgIMM8ezuUx%;Z#P+?w#$E|#58_&RcN z+1nf!)(zI=&ylx!=a+&aHNT9w#zucIAai6IPeLsDlwLEXzmom_SmvfoWj+wspJ zxW|BaoYcnfO!W%&3)jK5b9rWW?((ByH8?stM4;BJMr_S@-tnvG77RvXx zIlQ4RN>zQ5;lbQ`H@{-tjSt~-%b|#<<#DcGQVz)4eT9j4bz|`33#73~M7tX12u;jt zY$57h&NyGe817vY7B0g7>5kgqga=gw8v+Sq@}d7%UbJhfKL6#|>3nqY-J4)|xdl{& zzR1T*HN64A9y(5Z+B=S0nG$0s<}@w~LB$I0<3v*Ec+ic>UgX+oF#qClaoRid_t4jc zxA8_s#;I~Cgc@9l2adAA+v|8J|V8huv1D; ziSeZrIU#4}mwkvlGhn0V3aer;A0*Tw%+hrd-xkddx6RE-ICSoB;ObARk2g^HJt6Gqztb>3N7nAi zgs4E1D090qWWa7W>>9rE9B6f9h(Yy>!}!@!<8kIi+PrrimKX0k4HnPO@swH<9@tf`wp8u)rcT|6lJRSMtHa$^P zS>ds8br~4uiDo^kJu1j7YdHMJ&3eG?dZNv(;Cb?rBWZluO~+=PVhu(SYMTK+X<~Rm z8STK6<|Wr#(bSC{iY}kWabbO^Rb8bfE~~m=KvAB{3~h4bFA5iDjR^gT#B#E0zl9j$ z73p;P()#i=UuL=E9YGGCNgezcb!A%+gj@b%5_ntSm^1q{n0HK>IijiQwSuq-5v0B4 zrbc+QekU8g?MF)1VpjL;?C9{Kqe)LiFKiyKT`>Oj(^LuALyapl+y$NNuX!bD)fmx9 zDX=G3tY>CxNTOp!{m8u*%hz)~FFQJHdSB@mX)G|5yhd28$`u{Lw<1VOc-?;Y&xc1q z4L10g_c3yB(xJ5&f1-~7E;CtX(I zLy=rpG0$E0*Y=Q~qq|x`w94Vy3u;w24Xq~5?5DsuFS zy~J#J$bnhrRsy6Z?SBP#E2}9lmx@MK!%KDonPzQYBf=3A&^^PnyAcJYjN2YLe!5u@ z4$#$24OXjiP%OHL)8`dPR-i;iZmGl@u_$Xb%9w_welFFcL=8PgJu^b;O%k?FCh=Lh zLRripo5?@XMni@s)3K5lANhLlD@|G2^yK%R41(_N(B~-I zY?dsZ0B@T!;kBn6t!g@E#18KWH9EU~ID?T_KV_ZTJ)9&l?d$^C?zJ*y{mY1J$5p6W zGVx-$l8yl25f&R%Al7><-cQ9-UbXrPxpk12^7ApR#;F#@XB%N3s;F>m;1R!>5<2o* z05y!V>^wz2uJFw*WQ!F5Af?93_S@EeNXoJ?WEmHEkO9OO2D7P0+8`4yvDpUhQ@5X4 zFkPBHFSt3oRKsPAF%&iC?!qWPW>;Ir5g(d_w9&krC@w+iQzbp4v2o~#@e5;=d?r%%PbAY zhA{ehp47C__nXH!#@brTS@W|o&bn}!siKw?1HhtfD+Y4%hvvCnUHp2Bsbn-0WU}?} zj^fV3XaKYbGVZfzPDpzN`pG$Q`hYAg9bB&mRqz4wl(CQlO_Q^ydgBax&CdQz#oFIU z82C*1(=iVi(+nC&Jbo#Z*?)^Gl5l(AN2!!}Yr8}lQ*`*XA@npN_t-_K z8c41>CRnw9n$3ui+w&)P)z9rz;!g`CuJ=BjcS8s{bczrFSt(4jyhR#-w^q)^-qU>4 zks7S>(c!WNAyC4-6TaL-RwJAdOUe=G5Eu%qbKBkRXsMk z>*N^}vHfw67YIC}!$e(NikU%K7ge3F(D5V5@*Qp$HVLxMx;s7{T6fZX2^3vQw>!4G zOBx>;ms7d8WrR0_d*9B7iz({&C#&Uf2(8L$q^~Rc=Lcmjeg*u9pP#(m5ilCEmrCS% z@5gEY8*Ki~wd%O$Rw&M4YSr+Gb@?uL6ps#7(5Ce}BPWDuE92EEDGU9atI1SD4O@4Z zgYiF};P>hVuRjH?9{c?4S=tG;%Khuz3vM%tIs`AgsvfVyUkx}N70sf8tu}zEsIJY0 zDO)N{Jh(iK1eXh^-Wg5&e49>3>5VXq_6B#aTa7!%J_#g(tpUwH6I$JaYhYv<$u0;B z8j+^WMQ=}(${&L>f1RrH6~t!Hv7#dCdC#yKhJKaI8B3hN%cUIWn+gVdgttD=&N-%d zwt2Yvx#6(g7=NC_$450DK5hW*cS;de&9xeN{oO4sf49h?xtt+Si<6#2gNY{j{@mc_ zU_ITtj24~i|B@Wz0#&5tKd+)+fV15&3kk; zN>wbg&1&GNnlqJW6Be@i9_f)5xuM+xvw5F6W>hgFEk(;6p!hRkEy*xV0H#J1ybNncMM2L&9@Uw**HBI&1#0mOLInR@64?zowk4&!5?;GJi90Ojn}k7^ zW-F+U5KdqA35?zqj)fy1J?2_Nmsk^Z0BqM=Wj^+t=B$ZOcEW?E5sCVtFDupTC(z zxlGg4da{7^5a>Qg+ou|o@}bb$TFd`i`8y{beMBEepLTV?+T(Ou^>UqO4IBJwQXY~1 zg;6SizkDMBt3f>Q^E31(2JyuwmbTOEj`>qhE)3UXpuhG{hok!}P8(@-DQ! zj3w;kYzeWfxtjuU%dtHD>;9A}Obw6nVY%75>J_)$Ef)em8$Pd^@F+y{{<-!oHzQ@h z{CEaCT)jPQ4_G%ue7cuQ`!}4`RYru=a7=t0h;r^Rg~RZ@FJn((k4a4Z)@F84!lUTT z+5!J)GbYJH8jh0`$FeOq<0;onOCAkHXmWIjSanpa%{Fa;_qM&cvIAA#NnX>A-ZMVZ^L z)ju!#F&r*}*$eQc*rzj7NtBaWCV+#<{LDM$;H4>b8l=>fzYYDw$az%KvEU5>`MSti z3rBr(+TYuDvb>V4$0}_^i*kB43N5xw2xoS0Z?ZrNVYr<2a>dSuEL|}J<>^X6X+52nF-@>UutW_-8 zVI1qt`{<*kiAlRd7F>|RRE-X;Uw^!0%=;8hA2n6GU|}St*%62ixum2uftoS|^=W+7 z8M2L{*D`!8x)=J$8x+(Z0yTV`eP>5*KL<9d_v~-Ik>8oUv5Jwp*j2{bLT_bt3DV!8k&qqBcZdwL+`jU(i>3yC)M9e<9_2^lJ)e=Brq3Lq*fYagLj zcNyp)ivQv5wTK`$H(|!BZo%KqSw6d_&tm>N2*lm9)(xabaL){U1n?R1nu={wi#$2@ zh`>s-FKv|gC-^*5?5rSzmZry<16W9brhMkJ29MLQ>ygJmKawh00p2AaHF%0elc4O;n&`DL87}?r`xsrBbT;L{=7d?VFMEG3D6NoaM8 z5_O~f3vR#fUR016DqGr(98T>c`ZprXf7|`k5q+emk3cd{XUy#X@Ug|O$_jhSqCD&3 zTI6R#v1FldBXVt>U``^gW8BC&%>K4WCVIugd*Q<+ti?2-GL0j9KISDRrCI>pjEDOR z3nF`=h~5@`8@bc>K^k&Vd>?Y4#XGf*QI08N^-7JJ0a1Rws`0al^_HrK(TPbK>MFUi zdYmb6;Qm%D$SFBoLgf|2^CMMfgZJ*3K-e5CEk9?BaFZZ8e-EIQN*(XH#j6{Ee zKPMqci&1pi_ekxA#EX^Ry0{2GzN$11Fh79)mqCKaQq=PxfVAVy5mOq<%}9f4j*X|c z&tV4@)uI-3n@4D|fh>`pjE60H>^G|t7cSorP(RiAH=lG=5l9IFY^lRR4*SVwyRqXg zD}yIACS^3ytcn{Bzenx2#u*QA_C-KXGf z?rdWT(x8=xFJcb7rc+E6w9WJ#9yo>1%ef3xhXhEy+#(I)7Ad-m0R4citEZc+pDRwf zbsg2Zr)hj+nVAzcOf8fdX+!orb;KFY*7KetR+>13qQyNzxZ&GKzv6ng$AwE`HLKpU zbxHx^=m=a9RO=PQijkOtLk(09k3q7uluSA(ZNe;>U63;#)Q-^EM<(ySM6Ha$;gj%) z)gEj1;--g4Auz!+RuZz%Tn{aN%ybJhZD!H+OAUOO=GE;yJoA1&39u`Nenjw0yD&{8 zR6CcoUXiWbxW}Uf8#&YJRXPZdqXB!x*r3eUP`(FTASzF=xu=4IV+zvtq8*gsQZN zrm3NiL!99fpBTm}Q_5?~7l7*5Odp>Daag&VD~jI;+l{}StGsrG_0mL5WQi=W8U;}K zJvzQZV9|efRH19X%QSDB@C2KyoOW;uDoPA9W>&$ZcW`&9H5?mAfu4Rl)W%d6NT-bfG6yt3@xvkOJEQixUa1LGa| zl(nkG@{z;(_4*!?QItH;T`2hOLIMx=|Ger*9Q877TmR+B@qX2n5#Z>f6af~Gq-|DR z^N7zL4Suj$3Sa=O6!+0j{Bl+qvR;UB)LD9)XwJhLt=xc^ZXo9nr+!pk9iMSj*w-{v#Sq>=>?T- ze=89O`HYdaT$i)e0@2looQ3$kU5fFeD8l1_D4L{Yx9 z?P&L57kzN?@RF#u3Y1|sX;6!wjkRMlG#GF{}c;&wN2oEFvAG^XIh(ee2d z&^M9t?+Y#JZ?3C1!%h3@<6_@zG#DDd+GvJ#_Vf}pq(ER}G-PxcAb}3{Iy9fxX2< zofs;wuJO&%E?PC1BnaO7yyh2D{tHSPh}Tfd_N08nU6)cGPWq{u;JYS{u@V_d<|JRi z6b{*hTl_Hhvl=%99Qx0Da$c&?k4r5-uT^Eqr8ROZ9@Psatx#MkJ8uVE(1HQU) z>4M0T%hk~omv;8{l47;|zZ2oo`s^|%C-r+vbj-O8mmu{5KA&X|Hz2)ci@|Z9Z>jeK z;6T2rpv(dj736EZbyEJ*P%e;$Za)=f!DllGOS}6eY2wDXtiLB4yxnS!Wn(Q5VJKI{ zj-zuxm5r5H_xqz?GySyltpwZ* z%|y6=&`bvV+V!>ut@NzS`YnZhm8IX4#Sr@|8{n17EYwaH*@a%jL2-n2UgL{+*`s6+ zaEZKg!d~pv{8Elv`kdvtSf)(@m@d&EFH&=i>h&tzjX#anLIN*{bSiu+qi5IA{#|vQ znUS`;R4Vt!O@OkA5>v|1zSE}ad2p?UE8BbiwUf680rkG4}Jn^GD^}SnlXmZD^B|T zE^RLE&ijm@q^QGahP?@~R_AMPylOuMOe0U1RB6$=8s9I_6+G&yis%cJRX|AZZi=?f z>pn;$a26d6A!K#)59#_;7H2M8-RL@Dt)9sO_` zH-+C*FGjNN_2uSJeQVG$Z@ybj9@IeuVYBh%`d zyF(IofUA1>1RXs(7U1ozFzdZHJfR7j@NV{X}!3n@DBq(ACgDd&57s$%YaHO-;besUz{bVpD2KGJ1YjT8_2I)4EER4V8Mm=D z%~{>_3%sZ=+qsIvD+`*?b8NM)*+-!4|T)lglGX=MeO*LgLlcL-@Mp^c0l@kaq zx%-W;_$_1#EVpCP;C(t<`p#(DbTwUO&b7wfIBu$j*5EG%iT((7Ady5ZPULtxme@h| ztdtI0Y7Fso^A{c^h``3@-U-V&~gxK@=3eFhr)}+$e#bUi*Oio*gXX! zumP01641$+GKL||Pi%0I2IF-w!@ttgwOdpeY}AfUE#9W#;asB7=7u{q0`zw)!=Z0| z?D`|<-u>2rA@k}kUhH}(=q(?C960J3?8P=MPHi00@Oz}rt zv5caY2mZ%bN_pLR6s1eA1y6b+PB&VobByGK$P*FE$v*WCoH%UBcqTn9B4JiM zLm_DtycV%BFiuZmHdh69GSg4nDlOc~1;hf$A{&iU?|V5Q zFPv$tUJ+VBDTnJ3D4PE!yor_|@Y?<~J?ANKGosGcI+G&!VqvEG1ATT?Fl`LjqtbX6 zaiGm~ZK;Gtq)cv&AHLg=Nw>M>PL34;Xr<4mb1$F@3=HESLczgH7Ij8!(GY-Vhc}nz zlMHXn7Fy-a1lu$6h}M69^cyw$hYo=jAf-9fS~6TPi&Wp&6voubloVul|2LN83LmKP z-l>|@m#;}<3R<&ZqQdxnIhDzb{_R(N+AkP!sN3*>03$oac(7>Q2Z!%=ldhJnazc%M z1xcR-J6!W?VbF|+N%e#$b8%X`H=f-7@K%d~Eo*Q|@Lj#uKy!r3(>cE283q$v?Ad@ zdtp58G+ENDS^69{I;ME>KK4`)`!Y#y)i}=$Qw0`Lx&{82^%`FJ0rEa`o5{U6==$Bz zYOskk=z$g~_nC1m_TZrc^0kPVZC@b`t}9uTSN?z_P|b=uA{1t{u3au$)Mg|{n+i>c zk5yFifSrrzqYM?lLbM90jp;RxN$XeO$majEA{MLuHL7K->#!OMi?O+SXb|z8Ia#h9 z=EG+eDAe8rYIbXve1iTcD>`xJX&5C1Adbe-_?_HO@4{d)+qT(HSfSC7u3z)-=IN0E zfI!$U!}F#tl9&qi9M}q#4{(C_>S97iXMILx3iIt)laX$21&<@MJ#Au47e8$kQM$g; z=IN$Cvh(~$v|J1R@{<-JM0_$y6z3r1^7P&7npNR z^YQ}lRfVz{$kXTgbd=#apC!4=3FEio2$GQrayizkeS# zBWIZdrW^W=tIi>kW$%5O#y;KVN7ksNy`$(aC!S76(?yp~?ZE&nE;4J%gR*lr2baCY zQh{pi7eW7!2Jum`ERnGKYDbAkX($uF&kWyw!kkijtsP4liuWt!n~{o3Ip>m6+{z^y zpQG!KF*}5zpounUgWWvKK*G;TbZAh!S(=ZiUXieQtK3be@jSacKV|ofRA;8ak^VCz zTG9gi0`B`8d7AU5RG&Q`Cxm<4-g+KFGJeQ27viWWHY8S?d<~Z{b5w#CX}C|(a$)w7 z_-c<@owd88X!GzQNfhfG{U#f()E>d~8Mbav6~s*bu5qxiTC9sY;E$&3#p-6f&y_gB zXZvQ9^c_b~10=ci>8$f{5$O|@?D34e$U_yTV*gh3R7NmJXR|F{kvJg}{w5pU zKFGOFTFWs?`mYUo>5gOrSE<-W19x7<)X)d9bPco|S^{{v_G&W!%3{bl(!*{C%^HGt zR%JP{0|4EErk#W+D3ZHTVw1s3GiCh@2Tw(%f(Db@q%5dEswC79E0UM~V(a25z5Y>Q zQztp-Z8hDcquyfDlk8E(UBk-8Os!KWU4Jp5_S7i>i>xW!Ep7F^b`AYxts-`Vlcx1P zIXphl8EnYM>%a$CXgn%awx26kgTJ4_#zJGKcyQS#6&al&OH#44#?1{ z8H5^sdK1@6r>(`ZUx+wKmWESYCc~6r$6#9YsDAq)L>AO)Yp}VUkDH^**%{sZ#z%Fj z%w?8RU%{6$rEC_**Grsk+vu}^!<=tO&>n|$&gnjv&ht9?;=K!tVmSW^BX)P> z_m%0w2-j8abL#GRLp-7d+yDNGL;QOzMMwfX`aNPb77*XwAlH5=H0sxy&~k7=RlOS2 zGzxNmTTxwHCc9tG!{qJOfCaX+oX#Dstv|0FcPmRczjt0r0skDHZXqkT&c=nvYxCl^ z)NK#$dRo=7a;?mkW^ee5sBc5|1k0DjEV)Bv{O)OO_98FjKS5c-6NJLb+WmMYRNfS` zRopa>80^0vcuh*Zy>~L4TRow0O~vcbS?vD`NYC)&!y8BbYo4v$Gbl;tPTh?+^DwE3I_nkM0g>K|~s;v({PjVy`)8ui0mR_w#+84{Qazh@+oh89AL1Vz6c_wEQH~p)9NXix!L@ zzy5S=Ml}!NlT_Cuepr?~kRA0yxs&{ONP4l@ToHM1Akzywws$;W)>Cxc+kxHcjkzhN z44RMV>7W=3eRRt-gyXzIE(1g6%82?LX9M{r9cPHwQJ5{XX-~)g;(p|;^iA%VWO6?Hob$TL)*^SA78BEaoOAN|m!R}bztcv>!EE*HSx zAK(-?0GtBAbSClVylSETr#mff>;wBt=-C#dlo)<>0#BY$UWZc6!Uk+rJ}Uj$h50og@{cka`LD_)CxW!ou^ zaSKT~g;jAI!nEJmHFxhKHowD&`knD$*RYJDjB>}B!~guU>Q;Pdr^r7cZn@PTBVwmC zprAcc=Q&7|+~wCvZy?z^P~99uF2BURqzrIPyeB#dA~8>7H?vzlw6!5gU=D>QX+J#a z!mo*2j8X`U;QctF4_}*2;9!Aba*rp)5;4|^iu{+u?)vkUCHk8nb%`LgCs1v+rk{2; z+?jc5*2&}_eYk4kN(D3ch$~jw7bnFR$MDSfFAraCx6&7~V4Mf=sU4(Fi^u2YyIu$) zrp)-wRl{BB1T{pQY)1E{$~`l(_js^@XkMWXpXtMd} zcL7g{85q0O5AOVNFPft(Z0Gq+sC)&F6iFvqp~JlZh{C}(##7~*vP$ypgEnsz9ueu4 zI_PEhHGh5~pUGotA*x8kTlXXM%w(T&Y2TOxkR&@U)ehzl^r}#M=BIRogv;3vJ*1`# zO8{*qBr)*X;qD=k>BpFajNjt8bUN6SaXYxtmQ;i?Wt(bjHFrkQU~{9o3-X+L|6Mn5f&y zT8E@Pjl{GRg67}1^pYIi?Y)(|m7(O5>uM25nLnJb2I|_Z;6nxgDdH}DQ#MXlsx2b7 zq#>fwe@Y1Ex2WUH;?>qT^otibhns8lH$43)`PIA$@gOZmA%5obx>5|V!%q(JaEUQYIt~(Ik)CQcHF%6Mdkg>N&UN)CZ5`N>u9LTvN6B>oL3dMUk zpWDj3;r~>X{O4aSfdH?>#)tPXM$>2A+rJ0zfYL=BNez7X$n9Rh>wDixx{E*Lc*gYa zmVW6!0Zfxxa<;?D(oRwM_s}qMe7eCM()Pxz_V(y=pSnZk%A93A9L=?4_*7KSXA-*n z&9(r0vM-nSWoUEton%U`E8aPZloh1p@LS$8x+ua|gmns){k*&xYFr2%{9zN-1u{+| zM+aQ6DWKYW7*_gpdER{*tw#OWyA4}9xeL4?`8?0Pz>n4aaBC6G!L-8Av?_P~Y2|&r z+o+wJ@lSaf2#%fmehS{p(+N007GUwgo{>p4^F)*lv)XrkPVIlZbw9Z(z&Imaqk2x1j zt~Ek2R>btF>RKaFXDx(d1+5=10`zX)1myRa9?pR?h7d}snXZ}t<}(p}_qFx{@&P%8 zl$WbMxMhc1z(;}YbuegGy!|f5mL827=K&g$oi@~!yZ>3bb1+dvW^(@Oe?z1KQ(>n4 zLoMygnV1d1ryIwZ*!m(|b|W{v-g++L?3*&XI!17fvHrnp_B&%jR%Np`mbFuPEy?HK ztFG0Ol^-Rtl`j&MfA{5|U(~KMUSVO{x%LQ;ju%uFr6iT~vdNAf?!A-7w6(=F9O&Mb zv{59vgp-dOUv8` z_pt;o{j#o0Bq2O0rtd6@Z*GH{hNyu2b^A5#TBxCR4eXuNISxHojoj2&Ce(}cuMfpi*?7SFY^5G9+BZ#S7=KgtS~Pq>GFx59T)GgBE05++F4{ zn3G!=Nmk{FE_R=zJ16AQZx@#u4ywp)L+eg7OicqfDtT#dh{(mWM!S9j36pnf(fb`! z1!gjI0lgeVuHf<-n=ie!0m_W&j_-`tQB$tStPhTdGP&GShF|E`c86BiHxnkMaf z9YT?Xg=kUpq>lQmxJ9i)7ubus#Nnz1COPRoH53P*o6UsU=a@fBqyPHJniype zy@rqVD7UsM>ISb~J%6R5M8cvjHyv{;N=oorET^;(Xk^#uVh&V9BvIZ#q#-54w3_X= zE$Mqk+FUcRo=n$^P@s{VtSuY#)shi){QP=QUfc1eg>(sbDF}E|*N-=o(cy(xqpz)Q zUG++-nG%^$bPII)^LXzx{^B(_TGO(3ESS<8|5We#P;KvM#;fW}N)=y4oOEnJ9QA~c z#~CCBBcQ3=%S@a(vSJFJ4THwpua4!Rna`8H9%vULy%k&{L|RUYs4OyUY$IeNqGDM<7MZr&mPYhG4Qf&aXk zryJzsGnD;Sgkd7)+OZ%t=hJJ~r<8^`BOQ;nT78v*x=OH2QeR}dUX)al!QMFW@Lisl zUugh5jFE6a*OQV;;WG2?c@24n1F{{GIFs2rvE+X2FBe{NFl5(ILI~t|u>ZLwTF{|A z?!Q~r2T&WxqU(j#d=RPEwe{S_33Qd{Yw-Jf^l_8>->ARhvU4#L#J?bKs&DQI`kCvf z6C_j+byA;W19#k3Jx7(MO_ilQ69o9db5FQkNMN)rGM2bW34RRe8jzE0$!c1I1)J$~ zDVl)%#3vDV)lXw<#r!T`NV@5j2b$!knfV0L^6Cqq{yR)3RfJVxj{llYE?-inS9xT0 z4?%~jFfzy%mk!dmZ%gO8p{_#b{qjJhTQkYW-Bb1!f14+K?mY&4wu%gY6OnTxzlajo zeL=hsH4*w;NZ}nov_M%&%zYe*g`x}(p=~UC^)jJecD?RE!3Rwr#3b|fK3m1i#^ zo5_-#dXKAmWpZy;@%|D%(^Uxc-L~71F}12GYBD|x8uI(>!HFZS#$v9X{38S%mRjNE zASRMm_HXBI%=2Hu^XBZf}0tmqJmNpy2tb6Uoto9DxTvxuBBU>vN~e7ovz*z{1KLsvUf1 zc(?f#>&8`L>}K}2@vcM??htEv7_5po&Lh-^J~Tl~R?WDf;N5kZ6Z1H7%twSc)myoX8|JmMcz+$ zV4(`u8nB4UUy7KVXyT&BuMYz_Pjb^*^9rX!J^{IdqnKLz(UqFuv+ZcNn@gb+@+$m5<*qjsU&}r+-RHbT&Gk_oVRn4W+$Zl@cdu`z4cU}F?3PhTw z{mE87NGJKo<3QQmXpO0Tt15asSgstLYmgQqE>K#@xV^%A=$(@7&fYtsY}+L)Xs~}r z=0Y;#Ci3Sq%EZIM52K10b4*m@Is9_`jTgeO;XyTgFEa@4+lIoo#W1+rd47#e} zt2o|z8wd|IOO-9UXcELmA!dgW*;Q58>=f99$q4;g&Vh1co3XdmJc58@`s*~AYs&QT zzB%|M&aPqX%GqL=)Jhp@#3}zOd}KQ594TRQWzzX|c3REJ$F5|Y^cK%roUh>D%EB@m+@~Ds`-huJ7<7$F%jk%qm&VFc40NzF82WgPI=yuhe$la=5wq zqUls8KbQPTD<%sIhA<5(y1g}rG&w{(gB=k=q9F!T64$f$HyrinD?8u%63YR4Mm6SA zJ=I=i9B8S=Gd)Y0gqeIYYV&@0_Z>;**?_tWPscqOTiS!aQfpd{JJ-jk{xWhi>Xhca zPX$LYL~uSsa`nx|TFhL!HH181#2ng)X4pkPB$k5w%Xd!FnUnHBpTn?7nkk{T(>cvo zojuyeoo&9(;=NK^Pz!a~{_PgQU`E1_O+o!=$QRv{?3dfv3t@j=-qnXGSXFlSPUAWW zTy9i%R>z;Sm!yVlKeqiOh9mz>uphJhM3p2F4j(Zl8pAGeN`G5FAUDU)aI40(uv%Q41KfSb zO0Yw(%hc`tN)9ySY`fI7YlanFrrNP1brB6x-&OK)yTLpyFaymO%n^H^6a&GQoTsQl z+rXXz<-b#nM`4ZLIW!E6)RJ>p#8{_&>_KSkS}q;XyD)bP52~nWRNVb)QcG787&<4p z6fULP&x()pT&oUoi5X(l*~&|zncZ5xIO(0BquOgS{-I*Rog5pcC-5dmj@=R&6sq`Q zcjLlo9YVmJKSbn1ru+QxInQH0Tf$BO8Sw7mT#8F)kr6q;X4?&w1+T0BZVN(rbmY-o zv6*b`4zOo%b;iiwZ)E%5986x(`&b=!0x%=kO|s$nikk3zoNm!ny7vwc;bZ z?pL5?!8pykkg-uHblU+i{tJ9Jbqkye*Z`$pDjAWL?a*h4`;y5=HdpIkmig%L#J^Tp zh7>%<(U_7=Ou&8A9AfXZb$RJXu&PjOuT;S)p@R`uZ=04q^|=kAO(>mUk{%X;Bwfe%0xKloaA%b)b zXWhjS(5A*^Z}|y{aaK;`>;8;$>BSX_E7O`(g}Sr(l39wzDl-y4UTCO+uLf>pKyIu8 zb1cLlJ4=_Gc@4B#`Xc5$M24w3H}nZC5sr0X!0JliF-%pnd6VCbs16>k+gZ&3>LiB4 z6Zs`9IlT2_O-K%QEt_yH#<~m$jOkCg7L~wY!5D<93?g3J^B)?Sp9bX}Wj6E#hc{C; zJ=k&2R-Tb8L(#tlq@){GXgdlf6M}ta5~ETZl3L%C&BQi7cFPR8>p#VMK4&;gRdI3o zB`3!qV}Qn>@pGLxbQ&vp%i|iuiCAB?zCwVq|6i&hpufPVA-Kax$UWGxH`zOlg3tTy zF+`N{%Y5*+dC;jW$o5;P_WHATLukIMrd;}#i!U`E<7lSu#rzLRO$-p(9LUY1W&iv3 zt@kVaH*eT`y(X)vG!OTIlwy*co0>Nj=`5w%3q3j6#^W}lO-}N#cTd4Q5D2o<^TTh= zXKrz&4&pCcAeQ9jDlXp{YK0xa==m*{Ugx>{UpR8u>m_5i>MsD)99gF20!257SQ)Rx zczI-uCd2#mi{v@Zv%VJ~i}N7)`KNjcAi=$K5sx2KZi6wYs}piim${`c(ki*8t5$<^8JnxtLyG#_b#XWP28%fCg6z@0*W$pb& zpP*M4VCR>X<`hdvGxM#*4LK<%E9?gDtk>zyno(WNvGo0fPTA&7Q%c&s0f#JtHn_8oQ!;LYnO7;zScP# z-qA7811no_IefK&!qkf0V%_R1_22Q53h}bdV9Fh?fKU>??0xMdl>uqrNpJUbF{SiL z4pZdOZ(#_gNi$`nxA~cHDz}guBEU($ zT^)Q6f%fxwXFsSgod_5i0(m?U2^8Zan-6a{znZq}YhYSoak^o=pAluc-5klXHSdhwEk3eo zbJ+a4f0aU8f#FTvKP$h?FSqBy9@Ta(*W32A&A*rs_P3natm?s@nTx-3TJWJB;NJVbhtRZAYJ1rQ;df-bwH-EyRq(HhIQ z10>rK0?ZA32|EV{H@MVY6>Bq|NuDW3Z*>zDys8=DM==;n8x?A7waq%)7lW@*cYqd_ zlv;6zfZi_+S)rrYh<_2SPkjo$!+s&!lL=qOZ^_V%;{J=74T_@v7D5Q317Vwf0D-Cp z?5VT|270VcI=L5LdZ*MbpXUymei@>e+9yL^&F(+zFH> zdx?Y>kw9TcQ8Vs6Cx188Z6vqW8>^flq)xho>Fx)bXX=&%rD5)4p1y4%x8V*6b|J$6 zeS5xzUkSPY(|ml0K-U9iu*`bnS^nG?M<-kngqUOF-!zvIx8Da}g@;ZGb*jzHZ`Q)h z@3*w$i1{tgobkR9uRnYW&cX(8GwmCre@xf#f2L!#U;npwfwHi@T9Ke9vZ4a5k&&{{ zisD+)hWLW~Go&|#tyc;1u$f5}ecoljL%lou=T+#hk`zC;oIeb zGc1g@lx0?Nx4ibt?#E`}IM$QHa0 zV6Om`U-kPb)NC`wN?xMfh33f4&dnfPACDXAwy(xbr!^tL2qh=5rv|O!I#seRij0752>iI%Xs({$A2Pd7^1w&5$J2!? z^MFwmxfy!YW_3QHEKJBIj+;qR>{^`DD7+AkTHH2=`VN?c-`=k=G13E$ zVB*=DF0$@qvU}=BVe^Usy;$90fF`rQNniSoR{VD}OK|eoe<2!ck{YyANJZR`)+`S9 z=1eTGAM!6{!u^4^GzU}QsRz(qmnY4tnT6-AbZz!BwLV5)m6ihfTqpW2+adGo3@x)B z3z%sQA;3>ww6PEsYIXKw?)RK!_8xI3{9QiZDA!v0K2s|5$ErAq;_Vv%1J)&v8s0|> zV>Dn`eZ@Rh#*{VdIRJnE1}PwfJlD38jm>hh>(am0CPnWV zGIu>{Rs;3Ydfe|QRuWDt@PD@-Cw=GK1_D^$@&M2v{O>Byg-EZ}3cNSf@;+=*NDk`p zS-=9>dUd1cjUOIM+2w-u95knSSw)6jOC*wCFuDQq5EVpo?oUIh`0fsKJteLv6c8Wl z=}&3aq0s-JA?%Wy*%Bc_njdaWy+24*uV3s+J2M3ZzH>QD`D=y3m%clA6vq7j+2`X0 z8l#xXpX5G8$Quy%*?g3ZeC(`!?4@kI?12kNSWxIWpP&SvkeI%ppp>wXlo;?;OiEC2 jKMddR{~F-xZs+I_@c$l=zE(E^3;?MrYrU*ivU06D98M79>FM;O_43?(Xgm!8N$M1Q}d|28ZD8?rwt(Ect%Be{D@o&CGrE zYVNz;efsq2j#5&PL`EP$00RRF0S1Qal+&Ti_jv)vL{?G^ z?Bn07psW1n=L)Qww7fX%9xMtbHg6iGPs``cVA5j3YF?}7xt?tllJ1Xz>bc+6eK`S5 zv$U4*WKdtJf}tS5zh&geN$e9LkrEm4Mz9=8J84DIWUUADwXq3IR0?NOoYy;vI0<+wlgP9D>crJE;jz*y!(SK&O z6_lNLp-JYh6|#E#Lm~d=P8akE#0x$u7^PM6ZU)PCGsy=w3KyUc;T0l@03&CS1g{bY z+LJ0JhG1sKZ{~=&IW0Rzkw6d2gO6o z^3+cr<`+Up!%52-bqr)m*u+U)9G1fPa0jfi&iKWryGeOc zLHVO~V!R2A=+kT#4Xx#FGwO|Zv~x&L{n3>}?-DOdhU#hk*?bZwN2$xL@!;hI(>nLZ zu>jqe6ZUWG(x+LXU&8}O!cW7l-7gaS-`?kb>Jj>@Xz@4~YgnvsO><0WYqw}Her8PH!#AQt_0yn- zr*l!xa@Hjh3g#8FA{K3Z+rY-W7rKnS!R=f7vd3ui)-E9I7+*QK;r62M<_MeX#(6f& zU?=D4f(wm0ZjA*8_AX;6^y#6e*XG1C-YlLfJ^a2kg1+5oWs6;yBSbVg*9;d+5{dZv zG&3Z;D3IL5tC7k(hFPL}@#TU6)(&#f32ZPlZ0b{L%-<=6OnxBrZ!e7ZBc^Ziwg$$Zr!&pYL@JC9o3kGgpag;m6J5Kh=OG42g6RckgI}vTtan4ro zn&PACj!~5n;_j+-U$K3vSQ+dy)=a(je*tcQh=Fyd#&aKcAtSP#pY? z8*zffV8vKO;aG8SsUKU#cs%sH1En;o^kAw`RdxL5W9uQ-%6YA0eH{y=!fJCZo#emu z9hTX-hdGRE-JfbREcow_MYZ<2e&Q0{+H|uAuK&@9 zxC4qYecLzvg5j+_8X-Vb94iJdt@~}Se@n>5uY~DIBrdPb?Ke*HBL>3Pg-L#j(+yFh zR4JkOYSpio8O-7=#6EfeycdXZ0{8T9=Gs5U^2Q(11J57 z;~+kvk);3GwtFDLBd2rcomDVEc;9?R=tmr!l`wT<5-{dyRERspBXxs?wt#`k{6Xsg zLuF5gwnl(uhk>T)B7-0C(M&PA1Y-*AXIKYer(QTq-TT7nls}XIF6!mZM{=n06QuZC z$tOb7#WnZoKHuYS9gIA>Cs;$DXlEW3@UjPs*jz(WX< zc=veajewol@);&v{0Y_b!J~l#+1ZhFZ(uNz-m``|4n1N6F!9lRxclkiD(!S+Tu#uj zkCNH<{HF6LfWLRx7wj9j9J%-a)tPf$RD4<~7iYCh*#fuGl?j$xqaVhlfiKvijsG1$ zA2~-r6qUZ);~}p+=n!IW2PikLexZ{tZsCW4Sts*7dAqX-H_mP4o`0d}f+}?WF)0h& zwDAW|{{^7F1#wB`0R%B7g|+Dft!%1~`@JHqdK86r3Gdhmt-NAQu-+I^#~Tp{^LEMc5)S15pYMZFDe~th1Z<1`eqfj6d!BxrTzeKl zX3>g8$Ai4{j-Xi?7A=fxs>Sh(MIYd43fG;L`6wEYK?oK5nSn-ztb>3w3$1GZEf$RB zf-HevfmrMtP_u`RgL$%+d zG3a8khu}mQO$W>c8$_H;&HT-swY3t=$QI(DO}?Owxk-n!asjmRibmpwJ(?d?16e=* zY;At`6PTtB`popzq?c`n)_&Kw2{Ent0Z*)DI$fAByc5^V%-|QKU)mhUz&F)krKYxh zIT|H1gq^VR$Q=u50Y72Y!+PE^D9+>Wnpw?|WP5$KfR4Pp$!7JUAqEsv)8ZEL_ry;FRYZ~LD>xW3S69JR8S8LwISNOv!zBoJQo@?1;?!a5 z5u)5jnwB7|U#$zMr$fEMS%@VU3WAIa`h%dIT_vqFYU z17KzDmi|e8K)%p_aX5G_KDqLyGRd>AX<2hNDX>Ua{gGUtkeYBrS5iJ)6G%SdCN!K- zNr$H@QB=}Y1zDlbPr*|_IR7*$TZJ0z$|!#gvRsvXve>Ro!ld_2B3vBt<}0kpj{2(b zY3hD*R)Nk1Ec;9*Sx+HiP9!VTRB;QttZL0?2MG}v1>@4ysoJR}|9#M~|6Rx0$F00j zF<622KZ}}h0V5@yN6(XHWEDTow}=)u-qn;@D&sJ(5w){x1^4e50bsl9Gwe&+A22v~ zIKd+k0rxiI^)ADV=Aa|{RfFgV0+K!A;h}k`0M(11*7>!XQ_re!MQX5StHpbR-(RJX zLRLM@cT&QW&POz69$v)0dNRYZYN?Nm{W7uSxa$I3{T?P?HTb=k@A!83>1eM=S=gVM znhtCf*K2zQ*C}Fi5U8`33xYh!X5I=+hJ_05zZ+_QZyrC(zqS2kfJ}X1%qM)jgxQTR z37CF(H66y0Qez_at(X;=kE@Jj9lE`1`V*$Z)n$oBF+?%|XP48ju&=IxUHQm8u*R;2 z6-1+_FbOJ&rI4J~RQB`kcot3Izo+BP3mokXmH@~4k2TN*-6ec5<@dauUt%h}zaXwD zcle0)5>jo4PpK`FpudO9l8=gp^s09)!X0rTM)kuBt673zh2v8!_CYiK^`n=iCUU=Q zA*NIBN`JwboUPi@B;4`wAI{>de+xgOEx}y2#l*uUQSx%o<5qWPKJj}kzbp5DZg`S9 zT%gmql-z=y`3DRRrcI%aH<3T5_GWX3b2`g-KZJG&EmJ$eVUj1{k4?;#w0ehJE~v?< zUM^iPj47am4d|p0JC2hUM7>eYPfgK$E6(W>55e;Q5g}bJUzDh$f-W(lOYk_0oQ$l+ z>*t$O-At;Bo~!2KNc?6G87F(5il)FnoY&q)Ug7`4Nc-5=FLw?C0XxMS`JQhdUDSP7 zX6+GFY~UKP9YCh)vp>U@rbj1H)O_%am0qJj_aqzg!i_p zvN6n+*OIA9%w@Y0w^Z53S_9Mk?F&Yjkn z#Sz{SxioM8J8~21)6+GZrdNBhgr$`lGA^7*PDKqzy^HB>@1b(T6{!j(dv_NbR~27F z9c_dkEdtiXx9Y6!G6I|Del7?!ysH`ynyQ&d=tljIN3H+hy4rWV2KI1S?t$VzMiF&u z*!qJKMDS$u6X~L^k@W>zz~vc~S3Qnpny2*EDeqm}3{+4Y4oI2PZpot2OW(R1Y-twB zj5Em0x}26)*|RG#S1EB-zP(ZEOVu554KgiX45{y-r{1heu^eCxVq8+hmilgH0$z3v z-`*=fJoAwS2Z>7DrhGq{Wcg=V*yrLj(UE?$QVwF(oXRS<)9Kn<$t$OXkX1b=HpNDV z$#l(L?zP6F{wg?p$JPzd+R!G2JGU({Z&mY}F#qD?jYx(Zg)%BPBdi&Mw*Rz0RF3%# zE^34J=;|!7SCiwa=l*@W-7+=usv^lZlTgjJY+blMc2A9p- zj4>@TV`2B&POr<1^!(P7K*0Na+EvZHV$W33KNh$y;dQT_1rxN0n;&P-Ye&=C{p@fSRjfMDw)O;M^2w9@asCm-ZH`{)i0)`W;Jx9~-*7(Q^a5`_ z1wXl%IO*dZP7PDz`^A`m?O$0P_c39uUlwFYg|4MqE?n}*xK*&C+eg(7j65VAeQ-PU zPWfW6=dqS{h1h9FlE$40WKben;nPd#!2r0ikgl(>h~l#-v!jbWs$$wnz#ghI!&Iz6 zC`x6mk2~$7=&f^sOKeM$mqNmK_i;{*m-4OhnE@~Ywl-v^O?<<>6+q`1yr;k+=hUqz z<*%Gq?aNTu0Ht564CUd6!GF(_VxNcO>cgBiDg@J>Sx1Oez-u(3(O^)+BM5dDM^hs1 zk#b3eZFQ}ynkbX!bb`?LSBvw*tK)H$bWluD`!&`>s+6Vdkwa2a%kI@XEV0p`Yv-22 zgjkk~I2fRf6BjNS1*hW7d^-+VN!p(zadR6E#e2o+Kyz1f|Dj|n%ca}-ocG6)z)-%R z@ttZ}XBVbC*?{EjJLGB&0l1@Gch@~~fL8v>&k_y>wU-C$LhH*lY+*{)iixMpeX`H3 zQeo!>*Re%7o8s=GTu}G@hg@!S{fd3pYqOZfgnu9{fa%j>}Phkf3SfInIKf&1au z{hXwKiE>5Aw#P+Q;btewH-44-F0Oh&XGeci;=z+@O!T13%b3eQ5WosI9rVWkQvP{* z$hp&pAXFTJOCQ9=srEKmUa8S=#iCpnr*SZvSY&BLdBK=tC}xRh@Qu(4ZchUZET)wg z+(a71t;A~3z_8(Ck0#OUuXOM@h-J+GZ7b3@_t9$e`FUy7lMnP}>DGCZREE}X4vf38 zZastc%X;w&9zt}haZ*$h!fXF_k(vs*oEnalVh=U-bTgO{>|1FexV##qk%Cfv{mWL; zL`eosoJO^lt6B*KCVldBR_9e)Y)eea6uU3zWUjQyhq6_rT13a#0z^rc|7XgtlU;L)TxTWao92I3SE#&%kvCiq$ z!2iX6${e42*QcL~n+#s#tXuczb*T>XlN-zh9@8Q8$j5SM)6y7dVhGyQ5wwN6#2C%9 z#)aw+Pi(!YShIj>rWEW%lpmj2*zhkxAwL-yzgFdbpI1&HUoDrRLuZV4HvuhdwJkM0 zdfPuYs{7R#iN?`V&`dGYM@o&1)Di!8NOkLTb5tMWgIfa8ggyYhPgd6>T>LLE)s4Jn zy|Y)kUtfXxT{iE^UDe^t8sJ_cd(z@*x*4h{X`3e1|HL1f||DL->>fhm%q0W17ZDqO9S6PF#lnfM(>}g0JQv%eAiV)?`zGxM&pfh8zwx4>TFTz zhKX4oH(h4$^ObwK!kg0mpQ|nxV%!EwCI}2PL0rgDtECeewE2n{3X@3vwF2Kd(q%&U znM<(|<|k7v1ZE9&l9ru=<1C+iM%DWZrkvUIGSz%3vAQ5iU_o3jSNVpXyXk-&{xE~b ziPZNKAl-k3o-Uq4V}Z0(mb+&^NRU zqfIze7cU`jgd@OvG^*;#YxQcg-p1!2C77eYD~;UWQFP;f`eg05y=v!w95&H5)S`ScyAR(I{9@~8Tlg~FaG2R z{X)a$sJ7}QHL(J1X9Z!u!y9Jr7ERG6d$L_@5YU&)DFd5ddC5w8!R}zF_ZqJFcD!@d z?hqgv@EqUspIiM`v~S~x(fJ@I1TKHylQhOWN+j^uJa&ix8;OhqP~LJr9~WB!vu z+<67+j0CrwsTQVi5@;A@DaU}GfS04mon;*u^$vdNdOvG*wBSl8@b>%lUG!~i>I3rn zIraS+$ooIbqA7X}Xg);%avE>CJ)cLRjp-1FRXAPgw*Po&&_V67k=n#*bftklDp8IV zfH$QuKammZo5Za9-b`@ut$e)0W;pDJVRCB_;YnGE=Pur@m^Dv$(kSbk*(Qwz%0`C5 ze26h{knLz)=kqvqLN43!Y@v8xsy;ycTYi0>SMG0~!LI*-!c1GxXYhqP_16P-8%bWM zYJV@j&6J6H^69?lXl#&yD85F!oNd*%vAbL(+2(uj*0`5a(1O7$b6rZ*_b;&c)@B({ zM6(nz5wdwOOS$a1?ycLnT#!MTtxDo^ixk`GOQClI;2_u!$7nk1Rj_9r)R(!d+@_>d zu({GvWILjE`TBv)@|3wuFp@H@i7kLmv$Yw3&-KZN`vO(ZhyJ#r=F8C*<4pBGga~)K zT-n-XckDSz@)SJlM|`6OQfpu0jkuzcLkm|4xU))&=!jdO77r7UOQ{RB>cbbMX`w~&vYGvz=i|npK^Do#YDpmzZiny=c_6VQ zGfqj+q)jKO7q>@{ri&haREJ!ak@dLO_?UbBI6D$-pPLCBxJIcU0pzh})nI`m|Gx~t+${A}5A}JU!+|tAy+x4W%WYWaRhr-s)Mwue47i**s7{WTG z{4Dx1M|viuXh$?Yl*`@c|1UMgJ}2kC$S{+E2DJKYB|+ z%yT{ZImvTZWci#_?E782R{NCP?^@SppaJ$ZV*va@fhTLpQ0qgyu2~<`j^XXxS*VIN zc&fbV1+I9;pjVur63p%Ujp(3SXM$5R?9dF`zD!YyWVN3KZl_oP418!22chXSx$qGM za%9njOlFqMA%yrgZ)}<{u$q#SzV>-OqWh+CE5~C1F*xR*-vRztiG92DS+czD1_rAA z2H8jO*YM5>cBfrxFTi=VGRo^W+p7VHb_1lQ$Iyc-u}iE8NJ9x~^KPFpkBDzGj~k*E zn85U@nS%RR5g3)=SQ^$vy?!WQ6*nENO9@DSgH4@Ou{krDC03>zjNCCP84C}qfa*4u z)|~O{@trYWf((M|@t?~`|A9}o{Af5K2T940cj?SwDp6kJ914`E<$wbW~i?nG2B98L_g%Nnm z8XW5|`W}$2ETyJMMV2?>Rv}-U`>_)uaOYKH})MeYb`z*FuHYaR9 z?u#cbv$~J0TRZQ!csIPdn3e_FCcj=jtd`V2gcI8Pp1tH(g zVb-`I(ciB%iLU8a`*kPDeJx*qkrtzq8BLAQ&|pV6M<^`lxh|17Lu)*te4f|=uH=1t zZsA(g#qoXF9TW$>u4ucjv=H9XF?Mrp-fVnyxj1ihkT0~@Gr}HfzQC*;{m*N^UV3hl zI6bIGwB)@_Oa-1Ne!^v+4!}IHwV-FYY^@n$6EAoMBh|M;uYqYx7)({w-%kB@|1?<%3a%tHHX<1(y z8&6jU^Ew~~C|&PPJsUe8u$T1n_3!5L87`j&838AOY_SQi+~VbrmNvgkMDkv!vAsGEz;{Jxt)RX$pK()vT<`8(WW z?9o;w2ygSMkp~-FBh9Klm6knNZ<6uc5*2yin$8=c&%)`84PwV9 zg4C;@ZC$O2{!czm&(OYe*nGUvysaW3`DiOvTz*m)>qi%wO}OTh$Fc|oM$6Ml zuRAicFOWd-jgOH}`Q1*Guf@UQw7C;{Qy(N*5_b)9*lIAML2(C{U-R)7S-pVJOlA7p zzJnSZkcv&?aOgiDvceWU0ujRyeQ!tz_-?OCSn*jT^y|q-m=6}`T z#0cfLnsDs4r*qb`WsCmQPANs#Wf*(L&|=-JU)Stc{n>I$?AN$G%#6?=9txt0l@(+k zaPFOOb3{|DKya}C1c9{^^3u!-FuNS#>DAB&l3}tSdm=;E?%f%yJ`sTYCv)&yny_Wt zpAqFcFFD$MP3EEhP8%YG_T%Ao{P+PYk1De0rTze0G>`BQHw7LN|EPT>iQ=#$pcEs{Z!U->eqN}=l9N+e!~aP_v7KEN52oL+@mR1*3#C=I8VC&b@QMXiEm{D9*RBh z!V|vu_Z^x7-m6GQK))a&adn{z5jQm+vAf?d)p|6ZEUkkyh;t{I$SwE14wCLgJAKgp z#FEDzJkGQauiN3q7HlY7%k&+Xq>@4nbipw_fSUm;QqAg@On%L^A}^l}F&pbKm$3wh zDbu5q!i>!OlyUYXH50}In%`gj!&81j``|mY^L%E}uS)6NTgHR0?q8DiNR_dBsJW9m|exWd*~WfNE~( zE9`PAMC2q$tNC$RXU7rx@h(ACG zO!>Wb3;rTP04k(GZQCaLIQedV`M2aAb$`9)VNW%#yFRnvJbjM|ftl;H^RO0|-fS-Kux{3X**i{igtE;ly+A(fENd^Y=#s zefHomAKRrL$v z%(W!2VWkVO^E8Etr1Wt~X+QcCScbu9rG5tS#gD`pd31-O#SUZenRaHA!Rg{-hPFd` zsz@z+==Y^by$%Q^e-WK-=WKN4&Vv#}gPO!88P0N85|tTRXEnF7KL*;{ROtQS+saml z7D~%}%Cenn{e9ZJ1iAwTUek2n7*4g9I<~Jt{pU*fZF|px+xxy7I}_>=7hXQLzo=qy zGS5r*4?N@`y(-6la4pc*`d3&6+4i{X0}276q3VL_2dAX;FhqeKp|3 z5|{E!w?$?r!`1i|(VcL9s7YHaPGG{cBl~qkuiMa*#fz48Ft@i5Nj6-cX__E-Yp7tA z0;vY!by!h%r~jZx+KT7t;wtn2GO|_W+-rg!{e!O%`4o{tb|71jAiKKD76@t(Gs5Uu z%~o#1dsHM0dl+7)1K*C$Bl2F)n@{zxyl3sb={Af0ld^n!FDAX&@_pCzLFK>iHm2Zt zK!4kvg_lTM>CfVumUoQT~T*vVgbtRnf%rm+u`^f$t(yhEu^xL zPE`@3i-A(}GO*u)9oRyG_#~_?v(z-nzuPnv69zDtLbyQZp>EVY#&hr@VA zxW+<~6wGBy0}fBkIBL5%^DGlpkZvDvagFB+iSwvnAb8{1hw#F%p7Oq&d52KUg!Nr7 zmom9wj+(be#Rd~Ps(rltA$i#JIi65-0yOQuawpu%sw1W!R9 zuomjXRBSrGn~+32BPN(oj+T#wDcH!M3>m3OPNu%18^&;<)NZyQ7OYc48LGix!Ih=f zfR|Y7b*;)>zLG`JBy8hGtl%qI;LrE4d?3Bn#d3UppXM}#vWgL@HAzh@%X;<>2QTX& zwzh$T=u}B`@hdH0r{tWuW!d$-P}zE3aC`v>JZ4yZR-X^msomU;9FKsU(tk~^oOh!? zSAkBikJ7;Bl{H@5!z;4^D~K455Q=y>-cc))7`BmK4heW(cw=5+LhDSU46+|7H?HQ*m!(Up0dtHMt4S{LHci($O7R$3B-Qy8o($}7L% zw*1%&YjR)|9D^^8B^^tet!rC`v6gbp=Yk)-RUv=*3cc`r?CK7?2ngis7A*0LG({GX zo7if-ffvTp0Vn>E%w7c&-qFgk-d%REw!s!J1bgw9pHKFkc%otAEDvzKx!OI-@pC!y z1O)y`$jtu$q;_#Tg0sy&a$g_X%l@Fm3`8n3}ux` zJ`|{NAR$M}%inFaD_Cf=*=bvnK%`UiH{5}JCJiuZB9->%Q3XXU27Us&b!_?Y5Y|)- zSW{(N;xE%zX{pXHOS&I}#pw5Qi3+^LB}MVEbTt@QNH!SL9DCGL{Ih;|ve$Z~`jLt1 z8+TDf-^DMFH}|ioDv6(N!kwO93KzaZqb8~(nrBhWO#D6Y>K3w1XxbN`H9=q^FuQ!X zcTYD=>VA_})cT0IBYu&s?R>YV^Y`8S`k$;I*Ly*dSNC99K1t-f=(x3^)9fU(@JmA{ zxs*(Jt-(+ONaY-Pk3Fktn%0^4gAaI8twZ6I=3UFz$s;9lyH0-DeEmkmIKdpQL~Bpb z`eIeSjWvyTk$^tnEH1B8l5r^N#d#I(1%#tKp1b64 zF|`C$sveREQ%V+fHM$ca;AhmH4%z5?`}e4wOd4t9a=%^#u2m%wuVCX*t9eXPhLB21 zm9;@dX{;72EQrnA;VgB9F8`yb=jE+5op{`{2grwl^`FsfrnP~Z>mYB&-PtRm*Ac6S zw-xtreQly$@s*&<_6azf6be=10N%>x&4&UDA?>X;L~2CS#*kZzf~|yUA&x6;piCm_ zD>U55F4!B9DlJi!&bc)~P&t!I0(77xZDM24WEdCZfwQ$xIiVsF1?tpUXnAjA@YRg^ zfK#eb>KfabX09w;CaHTN)$NM&aqykYvzk`qBdmmiBeOw#clO1= z%jy2w$>KQDOWZ}lW@f0+I951oY`F)W@nH&SE7lO1y+3A(v3T;dSAK?*9=Tcj;@YnLNPgXddHUzs}r z`6t6%Y%rQgl}tlPMV!5TdoqqEIgm1(Gqh`W&`zemn^`Se(n5f<1LKZQ%o{?S*BbLL z1WQTNNRo3h#U7@%-;l3SU^#uPboEcgf|m2Z1mAzw;gA!|KDmS$KkLDT=vr!&D-fUr-m!FMm|BIG;rK&?=tlE3 ztZ0=wiDrL#-E(~_yx3q$I&fJxOqnF+uIT!e=w+XPuLx6y#K`yZ(!ljDUC@>|?jV3~ z=V|c~(cn72^-aDd;Xme|Qg;)3blr#=D7OBvKqaW(M@4b_K%-Bn5MH>dDRa}SmWsO6S2ZBb}%O%y@|z!F4* zaiJVdDcOj&wMCQI!%r?qjn|~rWCJovsbo_BL@2pQ;^y%E^T{x4$+!%GSruMzo7 zu`1?sU!InadB~+fn@N9;YrS+g*X00%i#k})B(x5;A$m*~dvMG$6|2m?EIC8S>+r+T z@95S-2V}${TRIWvX+Dx=_w6MTMaL$ z(I!y$Bo|fC3epbaA^>yLQgCzjs;& z8z>qE4yN570K6X11qJpV1@~5MKfJ^*|EwX%BNYfkM*KbE%Zd?v;QDwPej6s#CG^NA z=ZiyfEkQi|wO-!p&)&bpk-jBuKwh2Ct7s4Yvs$_oYGfDgESMXZq2C|0I86fUhYYPzXOy15CY0&fD&s3aN_;%M7 zHR}zj{`x!=KN`PZu`t#9^NUMqX5KBlsB{&jb@T7w-bofw!9|LCi~9282kebnL6sF= zc=4&A1GZprDb+@&1N9YKMz22H_ve1YiR;{t6+!sTN0`5#^RSR$0e{P01rymV-yZY& zI#z~ht?hn9JD=nR_ftzZIdcZ26sqL^CJ9FO%IinOqD6@+du`E{HFq~^`fMI4R~afE zTR>S8V6;$mnl=@?!r7RhhBCKD%$k_V)hlv!zzHf*Gh}!$(AmHB!r}_TeI}MVKLKZ! zSjk?qGsE^f31baiJBoUcXi7 zJ-w_I+H!%jHrcs6I=)a|_W9~r1JLh&k27F5d`fW2Z(CH+;Dqp&<39xlZ22v*X8pQ& zjyGcc>?n}9I#UplHmw=m%sFgJT1ZEjwipSYIyT6x)>ad&-)KS!5{Ur_hrb^gwb)bY zcP*06{iosqiNk%~Q`~f+X+8;CgibtV2n$c^Au~aR_>=i~5im}`7fo0o!jHIQJ9Ka@ zQJzSOU9#e;_@BQ(50s`#=N=etnt6Pctnpzvw$ct>`MTlivsyfNV zFe{3^nP5E5M|y7O@`3MLH^VJB1|LJiHTM@@+5cuxP<)8qD;OIN?v83#+%`YDmc>ry zGtfLT*@fk=H6XmtRcQG6>nfc61ic9oFE4cp3FxZO`1rRcTQh~p`llpWLaFnI;b!Nl zXra@M_1dVUnOMpe)%UQXsA({M?ZsiAvP?vE+!QFsDr2NR-|xXS3CYNQwBJr~`rRJ1XWhh^$HRm76Dk9P zMlbgup-MQ?W*4bg4LO7Y`Lp3fIC$iI6WU7ymFqhY!;ox%NRAX$PPE}JknEr{QFRyj za41}zr4xRYo~!z>oQ)GVC_{!6agx^^gWj~}QYSLvdPXdR@%M7$`9RYkwdek^yfpxL zj`$rC@VRZ@ z_Ou!MZA;+{$wb1DSS2q=m92#Wfk@jS6E18HU}=+N3FNxie3dFoaI;(uB`)kGPJa;g zN1cBp(H^-;3F{vXFBzSo@_qIya+glM9Km%YNkSbcG*0D)L@b34R= z>1@p>1-{vr?P|suDJIjJy;d!TuJVt&n%#%>hJhoZ-4p7XJ-02LCy!*G&CovKn8_%{ z!;P&czO9d%0AaV|Nh5^ahX>x2)X+))-x@ZaYQM3@lm$j;4?;i3ItiJu zy>g*aq4%95$Nc4#L+Hp7L=#tGvMX^{wJ~(c{t|r8XW_LZ=p=Qi%xdL}H_;O$Fy&%M zU`YH%21itwE&Q@Ns~*0;0L`vF(&o;=Xltr zx~8S0*Crz4`~4N;ipl#?=TwimV>JkFyej@vVg?)7VdO_{UgmZ_tlkRX)@pVVp_v)% zsAeT$A?YF1RN=^7GcSzWl3_StMdGo;4tVvem!FP8S4k)hM<6w{L%zL>+3fpvH=T(( z_J=xH0fOi3=$emx@t`VF(X0zcxz%xlO{vq|ITB2yy!u;v;4PPkk;KqK9H&GgeUr8O z>*9tgYs<8$&Y$^R@AbRLqdA+na=)~~6v|ND@0N;LI*-%l<-W8(4SnSwFBJnUhO-rT z>QmnrU{UEkrn&}i)ht3`VDUOE`QvRjfwuT|tMBwWqwr%wC>675RNzfNa`;xe0Kt3@ zGcHokO8gx15V4jtByQ&U{bf2fP*B`sZQkL*OvBmHHx@V>Z&@X{Gx=9&z^^Wp8(N*E z(m`;y;FQh3c+=C&+7n_M`W`fgtw@)W>49je&hC4d>DcD`$KI0NRKRv6TkhZP-$4Qs zlZW>{i(Qb#;d;K~D?hmd13J6-b^z>lTX}(pogbaoExdUv{Kw&fY{J_xu#_wsxq(C* zzB$fmt=7Xo@8%`BRM_yBZM64z?BNyToIr@x*<$5n0lsWbyl~St!DD`JGK*-XN3dM(r`b3j`wdzff(ot=drlSGmMz zP9M`JxEextlrG0_vK1uYg!9&Z(B0iFmL5KbOg~)2?U7*~H)ORB`z}rRAJx9u_B@$? zxDS6>%JO}%CFxY*+!6@?6z{o?r}=^PcCX7M5)r@8SsBe9`oD$M)5Kc`oi?LM7|jM5 z{e2Va#jei5V5(h-dc4nYp|*iB%UEcM!n*V#M_$Da#~!~%2PzS5r_(w4hr^|q+bUuF ze5Jq4>btXlsU+E7#8!8P#7{3}t7Mk<*1ODVWu%<1iZ1HNA9EF48@Q<=4!iQjE0%Nt zrn=yBS6ZyKthYE}2@J(*JZhx&$r}T6vQ>N9o_6;SsPdOP9z$>qx@KFq1w#LAy@GTt z-{J+8v7q_j+I65~C8A11%9mh90nL8;?n~^vnZIn_H&NXix)O%tS?eIfhJbMqV#*oz zFsnaAzQHmK#yPdz24F+&5wWhQ$cRJhu8O8gPjmbs3L&F>YtL1N*B?h-0rB@ppYeN& z@D1_wtAx@Q$-j3Z%3?Kcquk)JI7BFk(IXdtP%KUEBdd)1ZS)Og|r*za@JR`*VIaG#*{QR8NU zINZ?7p(0vxQ)GuG_8m`7{yVeG*QJi2+5!%|8dubCcRKlBWYl@(3WahneksJd&oeo7 zheUjiF4LUxlH9%_y?>CN0_}={;n1)8&v_58tvVVs^ED_ohg|0Mz3|g{<#rq z$sgR_CfT!9^R0JjT7u(86Fv;ORZ4$gcw9EuMa>0-d2=%y#H{T{P+bOClvYX}am>=ly7wubMP;Ex(c#)8DX`QW=3L|4XO|iy zR$f>`jk7m4sPoYR;i)1B?$m^KfGr~LUdItq?MRmhtA{j8T9rB?Efu&FTVv)?m1)y_ zv;Es)VW;&QKn`ZB9HCwR2`k>f-^G4rX_GAgcEnXwg$C)T3fhlBguXv_VSkZi*t)uR zhX@x0LHp&PC5KI-@4sIeQHVb=U;I;SC&GfuYsr>xY6v2QD|uK3MBo_LQ+go zG(X~BBGR%YB9?iuM)SqC%BT6E+0*1qF@ap}QhVIMCb8h9u;%??;b{<_kV)N{t%%e} zuMYQn33_twm{uwb={L?YVFF!kyK_AJ!+mR^ycF6bIvM(lR{AgEaSw*2QCdGYqB?7Q z=?evkP3S9fi_JL#3>8>`4V~1{6nBV+x`Hn^yNH~2a4n$GY?46T4U<>OEK;XXNa9LjwDcoBO{Mcu$wZAtjlP&<=^HAr<7Af>DmpzP!zuJQ7AM`F!wb zplO|&b_%U7rlheI3bG=rDXpCJncfkqEzAQlJ-KV{&^nYOj5W8(Ui{e$EH^Qu-KI2by-)IndOzE>f6db= z89UeX%K?6UF+HvQo}1kX|D2@vhI>NPFsN-Da9Ox?6_9gtU(h-#6!{HY#HOTt2)YVA z5o$yMVjfO~oJl)q=>)YQq=YGwNi+=KO1j&YAh>VB)2>k4DyD6$vRFd;O@ogcQBv0J zGNB}Y(O!HD;^L5zNx-2(4gor}(}B@#jI@9qcf zRp_`LOjvMn(!J61?|OQp3fS?(J-eozwBh5arv1|azGp`Yp`+iD%%;~XGy$$sC?uih z-L|dg)pak)JNMbqrJlR45!AQ%f?N|Zd0d7g1+p<)|4p8Fv~J|{_z7LUDSk8<$Azy? zV-^U5h3?$=;CaGS=wCv)gJ-X*IfrR zh(Q$0jk*9i!<#o;{==;R(An$t#TDPHMo%*e)IW(4_PfT%7rwheryJ*^xk(ZeoHaCy z3Q|d!oP*viFHr(Q}^3UbX2Xwdd2)JT7`8Z8HFreq#;U1!{= zUr4hno@wRJVV8$gF*-*UcQNO`^)*5q{q&hrfL$Y{O1>F!r~(S_Q%r>idnX>H7Vg;F zA)l`?qz71&hbf|peO99DOZQD4!Uk0aW#yoQ!%K240}`+xde#&6B@4&bK*x^D#wqW` z@~7+`Tdsh#7z^m>?cTvXi=EbC$L;v^?sR0=VKS%^aEij_w|am)<+YB`F!~Tcddmk~d!T>&E{}=3{N#iLy*|xG)8nJDH zoFP%Q-W?p8dsWH}qex#kLm8u(&y0rG8mXTqDho@4_UP{`I?I@3squ*bTT0q+-C z9x|6&UgL`l$7>D1= zpf%LMb>D--zcc4+Th9Zj-Di)yY~KrDU`dhq&K<6EUUPbL8QX(;z3>u(pKg)D2+CC8 zR3mj48PLlzrrSf4(a_D|jE6=xk%TZ%!dz-zDc}>|mFi>7L3lgsqN9m>k_2KYUyHC1 zTsm@Dy=tH!c=HpnCj-IFINVjCo`Vc4CYw!NrZ@_m_kO*O1JsFj7nB6%zp(x!{`+O= z{{R+2>AswcEKxob>7K1T(!za%00V@0Cw$G-}}vP z<5!(@V(Z4|KEKKMxhZHAK!XDh_jo3}?{6gUcve_Yq!!aDc0T@@&s?ZZNd zF;)PHZVXh&+60KiM+n;sV37V;9-}Q=rcWT*fHq#j5KzG0voJPqB<>W7_E)^cCyx}b43?6zeDBDI!# zUC>tm#7omb3u9vsvfBqHSl4ca;I$KsqmK}Jn3^f#2;n&e7Iq6O%l!O)d68BPzthKlO~#eAB2Q3kc6SY z^Q6v%9jNQB6xY9S>ev2js(BQzrA56oKPHJjeCpF5X zjN;=D$msS=_@;r)*;zbr-D3un4{55&_acL5PtDw`jG#ceWlQ?@cfR}D4?N-#XX;OX z=4rRtt#zQHQ2-4N96Y`Szc^+Cx4-(m%p}K+Iajo_3ZRoSOfxAdh$I{e{jzcpK%gxp zLZFB97-1=)g)4^2d|TDqnvfX;n0^F7ZYig0_Jdm?l#0s=jEvR77NK<#$468mr^|hG z61ZYBX{&y_acwqFS)o`mx^WJn>iGfutjhyi&*12pqcE5OVOw{Z89aNN?x{6q`}X`} z-}&yspWNwAQ^|+^x?%UcCD15<1_uUCcrASMV{pl;=dfwcrhQi3JN;;w23p;xCB%Vs z4I!L@C~eAvG=!;mG?g@tK>1cM#-Xh#kfzqsHutb@>DJe5x{2V(k0@WXq(T!Yp<@_2rLEVRQ*F6m17bsWwwG?4n88;=} zbH|SSKYsf2{>zR$BHH!lw>;q%zkLo?G(q472L{gn89eI`PT;OrTtI*~midzl8}JP? ztli@xkj4Huv{cZd$muC((Q7N{TbYeY8kb7i&Y%Tk5_Ye`9o*e@I5hgzGD0 zbr`SVZte4FhapO9;=LejE3f2k?ZxpcPC2=??P<^a=}O;e2NW6w&|v?^ z-7kQ@JYVwv-g^O3oJ1Bl7mG{z#HDz)GKRvvwB?@l@rN1qFQG^GXTCiyC}j;5n=tnM zb_T5!@&FbhjF)4g6yYhmph$fL#^&-fE>tD9=YVkOmvyO^gDa0iWRzL*wwiH+%%3M1811CIm|njox4)fOfx;@kM!)Fgh6e< zGL;3u{DQvpvdfZ}oPD3EOaAcjTYUU_$p+x=uhm*bCy zD6{_dOj^s`hk^B9-o})J816I1`up1nwaNoyT}PpIo3i>N^`P%4k;4p=_=s*i(fTi3 zNJ|x$833mw2=XP8oG%%2R%Dzq5b9wrww1 z>6`6~hbo?_h0wXFLOuZNft8TjAahZPl*_BVtkrJH|+e$|X+> zV*qJrAEOCnR!Z72?INwzg&v9mGvC16lvN^u8U~H2_|_fu15pMrF-Bl|Eoh}9TtTKr zp6Y&U(4KN4qycF^zU;>6%ts|fGn>(PK@oVqCy(SF>+V56w){RbGyXuR=eeODTV-Gj zjtSH%gI<5{*gezKEM9eW_WI{O|NEc5{L-8+e(9Mjd!HSkXcRz${THj=2JieT`1&zy zo___t8K!*}iXiiC0M|H4=P?xS#s!93xpS^pl!Fmgc?`0KYMdhd$SMcVj0cX3PUTv{ zOn;bWn)~+jo)xf`Hz*tt>;*>F8WklmKqXkLT`s?tj>oQfI+19TD?O6IBc)5%bkq--%iS;N9z0JhJL4zMO@8fl*?T_zi5>5K z(0QBH$3F42mA=ysSTqWt!TyV_-<(bg2MWcFkptWK<-KJ%@+#z-r$ z6Dx=bYZ!Eduz_I@oBCO2{pX&|1Zqvl9KscydBz5qeQlM6z^)pKRMN}`&tOVD2dWs7 z%az(eGQ8X>37x2}5^CnunUB%KHkgBt?uyMspawk#bU)(3;S;$1%;_YlS~7#DoV%Z8 zhJ^)%^dL>mVE?3JwT2sR$p8LZ-&uIW@yEA%@BhG)SNbkHpwTFR2Ky)O^eXt`-@+xE zU&5x|laWQjJ`An%zzT2QS?7Uv`TQRALRbu8DzgH*E-f?-oNK4f`j^minL)+sVNhA@ zY6z5PT~M8LbZ$>WnA_{h0@yuebN;2l$QsILu*yQ1`U>QdFf}fh-%P4hF2*6y{mAwz zsH+YJ8)WtsL>Wh`(|FXH$0M{)yS@B$Po)g&)&;a84=Ewd?8+d^wEZev(-^REf}K0_ zumAMt{TFXOJlydof7bN#y|vKty{%Y3^IG-z#c0qJVHfUXzE#F`$1q?m-ZLI;UcxPptr2d<69p*>lSVE z__$?1U65iz%RdAlv_ND&a;m>%){o^W@)6z9an<&XR-yQoR>IR`b5-Z{^A`8(oKHt~ z30v%Sx+m@$!cY>1_Nz!U$M@6I_`VwVH z!#0?8;{gl%}PB|&~ z$s7K38`oa<=PPx09aLym01fspwEha7@I|=ejt8IqW~K0KREhN;M@NKm#%*%hsDoD7D@Loc#M53 z$b*s{JV^VL(D!W&KvZqrVt)YBnRN~M#?=z|cE5*B3k_U;|CrD&rH;1qVO>C-=e}QJ z9i6Bo0;>SJ$tWvnHI-C(_O)w1U&UzJXXFCVib*Jx%5?t_o)kTkW7e;y-cdA)J+XUM zp_EbAU6;N8pZ|6DJMMqKHTlOr@kh7GZPZ|hMgcU~$FT*Tek0_M339BoWv@EB87AzvU7Cv(fP~giNj&b$w`7e z30zdPYW-J~MO8@%Tq>!nODIxF7uuK_it4dgLGIa3WvwNssNGPb1?Ogu;=E1wMEZLc z{(DOWtu<`FG5?4E{lDHHAAMA`_!ocqq!qr;4o>XZN!OskZI1td|NLus<6T1<(8_04L7IYB%HCO!Lrb~rcNfM+Gy9(PuM0D}pVI!RlyRTEdp;jB zpoj2mdL&W}=gcG@xOCPQM2Sl;O)X0( zl~{oR7Tbs@MY(>QWz4R5Y1h%g9O?ObD2?96RHz3{v=H+njw|2SP4^QCtw>z7c&OVUo><)DDLkNtc zk96*smasx{E`%h3+zH}Aqn8S&PwWj-GAkMJcE4};*BuLXW#KVw8<|SzwX6`2GV4-_ zeOKruN~CcWAz$zYO$s0vN+JuP6Hgf9u3Hy#RCn^V8OeR@DjMOxa%dDl zgOx-0=a2%YGQ-1@liB>1b6A@{fN6C*+GagI!sgKX3~8E`%d3}Gkj{9pJAefZtv)E@ zx^b1P|ICTDpp

&KkPdauE5LXzbI6guWiBN&b8~gdbq5tiqHvYNapgJ~ zJzwlwH`R!esEk2d_m9tTT&S#DDR)I|3lYZ8A;>UEi0IfR_jL}ZQUwL4Ww+<-4fn8o zK*sgt4M1z#^kuPUR}g{Y|LJx;JWnji1X^HmQD1%e73oW#{zn^r`LIV`M3TH{rSHOn z8jS*IaNFXDx5L$1^2F9gPT~wU>az*dz3J#vStr)el7Q#RTO}9;q9pW{2bqRMgI3n^ zUX#NHW3As^0VF8|&OKwCJEdK=?n{E%NVk6iRdlg>7)$$f)m5Rb&Sh6*-&<^3TInFS z`^yDjNl>#2sT7YX0V=2{iJDDI8zi18uMz-U@Y+wE;__hk3}}IAWrJ3c<+GQ!AZzpR z=wYmFO`*+bMv;_)PFv7+6c0OhWmb_m9-tstni4ur%?r|)-@=Ed!B1nukr~)Nt$Znz`=_XoA2EZh43&gZVU^`@w1M*gcWMXXDr@0WG;dLmDu@*rZ3C^wS^9w^QuA}WA~1UNINVCXxP6I%9l(4J-M+QTMa3Vl zfkkQgfJBYI9s`U1P>@dy>iSke$VyN-_UxmttODpH!+>?&mb=wRw;Du-5v8SEI_p$_ zxL-_|vme^)Y9&^BYj=*!v+swg`%Vqh=^Fm5{RZy5?qrmyR{&tsJ&l2Or8Yn*Ly~CH z%pfJSB1sTPv_W5YUG{-5erfk>H*O624Z+*KgGK=~xMgtq-@y$xc--%hLpUrrjYGrx zazt<+ra6t4S%a^|KtPuTx6n>#E4vCv-Q%LN0&10pu6FL6lCU2U`c6rtPVgJ&8j5l& za2GYqDbR`I_i@6t=h<;#RVcgtnXoI5Zd$(|V>5@OaTUFFt{QBhI`%9jbeNB34wVJ` zLSVa!4RZ7+2=&F#xtTJSQ~=7=By{`Z`wdnJq`nO%`za3<591YwJ*}3$p+K5y@_cf- zrx13LmSvhGv18}v^uJ#C>-d718Gpwc-t@SYzEc~N(71pa+%(A7gWf8*$33Pwed>4) z4er9)6YkAw?@n~(kwBXe=gx6L*+?w?g7fVw0a*^I%V?26DC{w7JuB4v3g$Glg>`2L zH^;y=DpRr4;2VkvoQ}$TMU@oNB514x8|IGUk?S8! z;Co}f{{ne#NHarsiClkU%EWJy?c4M3{_w{OuiAWgYsYI}|Lv8&Ya3M1D1Zjb#2>-4 zo(%u>tB^acKAgj&Ggx=~`!M6*m1%i09l3@`2m)6zE3p|lvl=1+9p75(Iac6j+6rLb zhn8oBwJ7z+>QM@)WGr(Dq<^1UG6} zy;$*|mqMe7`y7MVK&iiQ;U6EQeJw$g;7BV1pRkjv8VqMIiviammR%blurVX%}KuXubE%+=u zLTTktD2&Jjx>Mga&|Pd>zkZ=JwI7 z^6xYbSIpn}bz?u|-=x z)-B|@ctGKr&x{q|K32F7Ttj-eQV1mk(kg*@=VA)=FkLkB?D$Z@v~&LmhRViBoMy4Y zcD;ZsvWj4r0-ZYwhB^h{6wAOpR0#Jv7fi82s8$yjs~yKrG?UpCNalEg(!d^94p=9C zse-s#L{@U~7%GYaCTA2GZr8s9XCHc}LD5$g{aE4qf*@F)@XvFTU3*>juD8DJ+D|?0 zsh{8zpM2U%-{lRKK$8V@Fd=vsWSL;|^lDC6eH5#LGw67Cr6bQIlE)E=wFJT&SoqQr zq7}m1!wUJ_3Gl)qEUf&Z@%`8xmT`VA1u7>#rd!34E|}5g72|gOednKo*s)iLruy+P7IdWw%f{Wxg;@CDt{R zms~@hwC~}9#34h0U5*Q&OO?Pys;JxT30N&*jkJP1SN6K3F2w{~FjzQOlXgvGQr|xJ zT*_#GP3bfqBrVt-+Nxqd9SZVTma>s*+&blkG~NlqDb0LqLrD zzv#X3lvCOZuYT=gSNadoU>Rr>z=49`&5$L6%}2J`&^eTDa02b;-kwO_37^vmI3(XvHJ(^p@R2E4!L=H$_nhZ2Hy#NCGEb%D+zsNl}E6_=GMXT^=H0g6oR~e>(WDc^z^wzfsZztD3U~xB+CtRvpMtgIU6>HXl<4i_}#r*{otbC z#;-W>g!Ttad}g|9Skpa{>DEa^-W>?!nFQi^0&xhw zXdw{;w+oaERyh>%IaU}8804-O!aDGVg4!$1kz<8d=-FWGLT-h+FNP}xffZnpbOO7a zB3cR>dji_NT^-D8H_ojNGN+^hY%ag=m*N3s*N(Hsi}*n5>Ibx25uojyEf)}$f)T!< zB8XfllcGqi<&N7Ozz$;x=d`Y&a(3s4y3++)X7yU|AbDR-nmKGN@asvt0+^X;k!70sd4=bRG51gz3k&+vOD{`a ze(!rtUHY_VT|pebVWs~d4VH;U0qpZQ1lR`Ay93s*Sw$y2jL1KM@S&#>$kUMKBm_qg z`7;F4uNC&y|E)3B>Mq|A}7Bj@Cz?TF-KXp6e|UT71pz$g zbu`iTb4eFWUaKH&!K`n2hWxyw2()#-Xjxeyc$E+8vUK)D30(j zTlZD!)w`3%0@RA5vt#*#)%V2nM$>g@K!oc zR^y3aV6+OXrJEH3$Dt73rW7O`RHwRNt?${ut#qlInYO8x1nyGODj-gw~;M_az+R~DHsHg&NN!Zx3*PCeQ8y90J#RCR$0hcm5a1k;5Y+Y$T zn{er(v0D+e+$w>R)i1PT*VI;!=5FptSzo*~Lpj=Uy$E_f%;i=Q1g_dPmX>&JBr~X@ zg_W@GsCHcia%Gi}`4dR!ur8q>vzGr{%PNFWxl@-{9is}sQvr_*?$6=fH6zx4T{HJ0 zYj@xt%53A8xStb-5+PW)`kL%b&wtUEzxbX1xes6e#sw?=2WqgFXtID-1V@4Q5m5gp z=^oml)mldo9EmTF26H;C=y-g2Jf1iVPprZd{)n)bHJboy9UJTSmN3W;k=XYNq3@Mk zG1W~w;ZgYL3rgc+wIHzqKXAGEz8F2eST$rW^|DAAEmjW71(SsfBDbVfK;>0OdA{7m zDng)*6X?nc{Uo=~rLh7rG;Xy}@CFr|TRG&)RuiKvbEtF*FLnE*6Z(O&R==prL@IF@ zX$?IMv$^Fi@^afx*pviy)%qWh%Pm0)hp{|Gp0n;Leg9QOU<@nHHhFR0kcmG7Q0=Tsy zKLq+pNo#YPu(Jl=KMdbH4!Qd{yxX0C6vyC+!;xYmo@j&dtdRGH>bY$ER$V8?SfN_} zvuDcs=0nd4{z9l$jncB5Dqag=t@}CGV7%oyf$s#lUs4|BLa_2&5*s^E8g@BB6gmYI z3i~{i!}$9i+(`N z?xb{{I~Rs1c|Odjz!$iRPbUyPG4!u%=Uyq#T?g%4Hiba&u!1^rmAhc)mSQNVp+3c2 z>1MN~=~^{`5%c-|G(LM|+HQxf!r#w`5(x`++9>-Pk# zmBShUU1Sp#KSm+!OIl7i#gdh1C5mFR)j6!wwvkIgIA_vfQ<#F%VyrO@)GC75hgP+L z&7`zX*T=YMLFpOmUW%|WgvFL)JWaWWK9jqyIv!mT{%NZBI^A>U&it#tyfA+Ksi(H* zU-pW}+!lYZ2DcI#1+Z+K2K)xZ>wM(KE?#R5A~*!;9gg&lLj1we2=7Qd?@)v|1k755 z=^{N3Pl~aw+e zp|T4GWBup8OWmY&o+9{bN?AWXcCNzW9|VDob(5sRrFt^1L~yZ%;u?K1%peL&D~}>u zD00^{(k{{|1tna)fb*x1R2G+9L%N6$INyF$N-G^$`qIWD%0hoy4c%P^s~n_))xy$C z%=xgGfk>^pClw_gpQ_M@fv_*qL;do&2`h!9)Poqx7h~OGEj{2IS~I(e$E?3Et-wb+ z#l9SN&njkT)lV<}UGnnNPHkQHq^DlKGJnMew-_1)FhB${2K_t_acqQ~nu1^r!dnL% ziVTlJ$fFVRD18Mv!jP42 zOs;M4wCz>{#teCbia>B7*voSj#bpxvU3Ofm=e)5B#g`>I3HRZB&yK5B7Mrq=S2oBT zy7)lq0>whRE@Uo99O?0ZJ@{X0XDya;?MDQ?d-R;;FGa;QR0vz==BWmPMRER8ET9-uxP@?8IgvNCT;(3N z;#!N~veu4(&9@mp<-Gpt=GD9|=F6Qj@q}dsEiC-%e0zE>aQXhZopV}Pg168(rcqrI z_T?1PazM88d1~V-c)^|j zsB@Y4BHrw-&q&AUE30Yy|HR2o3?c z4k1^8=z?(dprt=U`F|mtg=caQ{%D3BFcwKItoefS0EQN`bOdN+K`$!jtGa}Q%K=vk z@SJg2O2w=Sdnw1=L&Y&k$t6@p5nnK+d5f4p;6da&PfMkWxF$Je@Hqx)qnbfld>~*t z7=A~_eF23mE5`z=&vDnN+)~BI&Lzxn72(6s(l25IqGYYRK(1E9x&ejDd6ckO+wVHj zc54-dUzPOHk@$eH!ak{{k-ES&()Q%t6XvHtvSo%KJ+=e1i>3ZU1reGXkg zp7J>_yF07&6ltdMeL=6cckG^NX8KoOlfC(QFTD73|NX7GM))5<*w0n~ZvxH&t~m+X zX8{{PIN>fffLIS=4agZM*xMiiM(lNk{r8BGl=%_V1x}0nYNM?Z5G8ASB#4X4e-|}E zz8LR~3T7&gW$S+=f8T)0U1p3o9{3#`Q<_88JlDz|8#qBx)Cmj(eko;i(&|7vpJ!goi-;9pD{q-&;zLnaXPq7g@Ddn^@|Y(x1sc@qZbgPq@w#vkNddxx(04*bxH%Y)1(bd8Ff>+mNm!&A#8{V5 zAcx9C)*N5@=p(TKDP134W#R>Xi&aZOCo!*vlo5r{H*UUAj8-Yv zWfDpEd9+I#O@)m$AZ#!^b-`iJ#TdF?C52QBS0e=hT}xR-6Dyc^ipLXnuGC#bs9;)` z;sZXT>8O>*NWew`am%g%6)57xBWXra+Y zI=yX}pU-Kvyd`O#wSn#1^MCrk?=QantUGm*KYQyFXmDU*`QiV40^b4d3tX@j92mX(;5RrWP%^nk+(u^nlmjJTEV0SYvzsUFYaxf{l5*%)k+O2$;#{SSnqo5yvxq|9TKWcezKS52^z{{PqO3@v#IbxD zE64{5MX<-{VmX*yxQpg8Sa4iDq00a&<}8!e)w!F>-?1kkHn2Uj)x^GM6-dWD`eO9A z8(Th=R&m8jP6^nBRRn>wF^7&@-H1u^RF-sw(U7@Kdf*3EvE>X`Vk3UR!bK)+b#O;l z&cWz7XIMNSzY~vHcPFF=Nup88Fg@)PMYgk7KUO4(wqIAJ5xg<5YiIu7zx-AF!efsK zZ+Ok?t^>YGg98iunF0X#Pv9fK?606b1K!<+lBS$8R~G8!Egu~xJi84mkL;uLhJV%( zVE_YRZ=97l@;@y}qQZSq1R_o0LUMzRcIPRbPnHDzQu4EKGZjr(a0+3tF;pg==Qddq z_Jw;&43$Hjz%CR??gV~rhDsywTx`GzXk~^Sy!HfbY>+f|ZWiUN+Kz9n^I{%PPL6R> zdCZK>d&Z!H3dvWrdlTU2_{p*SyHX~;=LEZSQOY7NP@F=RghP?SiKxUFwA&}^jnQhX zpzyI5=Q73yrvu+IWqPG^)ybo3OkfZfaAtVH3OW)O5cP3^rRFJ^LCe1WV$}k}U~u59 z=`#6TVV2|torE`>s~SHjRyl>MC=#Po)5S5$SXY&grIe5rBcYrLl)B(BdRS%amt95f zxWp;1Ko5!L2AM_9|F4vD7de9?bbfxXhH9dqm*^WyFOfUKIZs;!lnECku89#0?tg>O z@N{)HPe0_Y-^WYsh{_mi~lqGI0a9D}*s@0RG{ilCUU@2q@dtO99C=h`X0Z$?)Og-c0e z1*~vN4d;6413hEu8a!!Z2c06oJ;9LhUHWP+?D4`WJuR%Se$hQjX_Zb#SWY8R)|}PV zf^#Vq)Ypj*v2dNkRB2T}>DbX9;>2V#&tG#NI({%<_pG{js*sKcD9_pbn~VA{f5ofM z`_j{%_Cvn?o#!s&zt~`Z#eS>+{u{U}aP$u7T?YOGKuqubJkAv(wEJULg?zCw{Nsv3 zz`K}0kwGd76Sf);aF1odKcWP%mSw@CZ%V?xIB%g;ydoY^a#a)xVL-tk$3EiV0>RCQ#>ClNV3|&R39@00Y&N6TLLtditb?@P48MvhkmR@03HVi-)@rJMzZp4+BA86Au``37_&xqAor+ zNVzP<15Bw3w1^uBe|a&1vG|{RL#d%a)FolBO({rPN+m7F1q#8hU9eYHElh?2zZ?wC z3oG4a{{)^D{8GAp11wMQgPk{ZIrwEI(sl*co*dF+7$yt;@^fwMilL{h(3dz`Xs1lt zeyLhpEN|0T*G$hn2Evibl`MH#BjD?lK#>)uB=kMocQ|v^((AOPm=L~gIHQ=L2;lDN ziTu&Jv&d5G=MTf0->>c~S4Lldeg45OeP#A-_qs$-IXAla0~P^azx14OL0`4h%Mf)h^w1hFluB997ZVnlJvf)qz-@#b zBT52JOgbkMTt&w62!V?Sl!CxT5!#-Fap9WDOI$OBn2_8ZTdD!C#aw zp->7!xsT{F0tLq`r%SPR9{6E<^bB;%+?325OIiRbzW3mY768^;{#j&C^yBYdkQMic?e zq*J`8b6*bir_lylt>p=SV_^Gs_0K>2@#1TaJ-Rjj=kI9PJr5Qf015!$%fKTP^nL=- z@erIkD&UtJ6OcA|Co21Dm4FM9mRA<0yuv6f>WZK*E10SfF8g=O8Ac;Ypr}P~N~PSW zy-+NkXZ^=eT1715Yb=i`Tsqo7oH{FB3sA~Z$J67!va~3oasz!Qki#W> z`NaxAx;R6@?pch>T_#WwBLF*R%L#q2GA9g!+ljGULVih67S}ou`tCl7ij>mw*wRhn zxfOsG(0A__0eT^=+bNUQ(vRIe(Gt+5lvY~3SKaY#?759^6^6F=;zRZAdC=5JsJ&qK z1lYApefPp&^Ocy-gv{b0g=SO_)=mjZX#1?eAye>C`K-K1%>hiwJ|BR+oi)pFZ4USN*R5Vu1J0Pa3Y(ux);W%gpsVxK z59$L-K6qKO@(RfDw}vU9-gqprJYKl5uOO?t18s=hZ&pRBfs zECgP)BDn0WC<4==S5Hbea!$iY)>6SKmq?R85|%N;szstKyK; z;*;HMe`)fJ$3J$>*Z$y9SMdEGJbQTuHaK8#fGGfg z4*)L!KKpbC-w#YJogOkFJ3|<2l@W{&-(!7%gDeEBH+)?*QJ1A_8JxNZ!j{}a5?3%L z$Ay25i+W563|27OQc(DgR=RLURO<%B9v%zfTXgCw3*{otQH&i3d{HmdixojAhcwf5 zn<%XwiqBPa7Asr%xpRpX4e2Kd{Ibw5=2h;x%l!w0b0F?l9_3LSy?|x zV&<>dlDzoY7yRKT9`W$M;|pJGg#W>a15g2g4GQ-HSoda#Ud>2yeAN%K1f(kzt9r_6 zEq+P@w|I0bi9t|Tj0*Zf*pD2~_@&As;93NasaFD3;<(~kB`y|F_}WVr{GJ4U-6O^^ zlQOyzC z22PDuu{sPuf;NW5MO8FurytwzY$=|fJU8i8S7(3r?)P5*_B)>0&Hw(Be{}QyZVmQZ z9H0sSY^AVT1Ji#4!J}{TG!vCT$&FH`PadoUij{;Y33hLMwNP~jO;iFf@HKmqTK@lm z@7^h!au0&4r9Q|AV$TA9;^%ZqDe_&W3rh?8NkY3&0tG8*;ma?ogsTjqb#si(=afg0 znNzgLG{z|#F%Pg9TQN9cA5jwedx{lQUJGLtU{4XHaI_b4 zcQwV`y%~;;+H?ZXwl*HbJS^f^TYc27clu|UA&wP72wH84Ck5NL=l}kLAN8KIaf7%0 z)qniBz57cvIN)#qWdYUUdf?bgVeyq9DnVhh#8$vbn*5$08^0dYKWfYXr z#x->*j~UG4vT+I?o&tq%L}0s;6&X3+FjEG`=M<&KvABh_f-21`D+)KZAYvP&E;5>x zQ_^D>&g3n!4n|tUkr$lYm zbbXKlZ47EqC^$r#YLs5OpKlNdg1{$DHN8c}?417L<(H?gKJkQT`*WUm$zJ}K8XSl? zz*hhOe+9e{_{=lFe?QP27xGnSc+FQMU|1ti`O_^K6R6HHkeqHzN$C_;Jk$q+MRgt+ zX)aU!DCOhItBG=~z_@urf0$oi=cixNMdY3rUC)A|pslEKo*?j-auFF9XQ(!uDUT}@ zW}#d>F)YNYTKUFUB^8KaY+z5T3CxhsNHPo%2hQ?0ShtYCarYFTc?q|V6Z#@otnV4l z%mdC!LrxMQN3U+-`&Q`Jl~oidh}*g)cF(0C1kBE<-~aGOi%+@Fy=H#+%;#Rhl~=xe z&j&U*;BgQr0Dunx^8svrGeoblQu8K205WH^1r_zeeqc?PYY2+KY$5RdJq!A!Tt!tS zP#!ZeC@e-d;j&!@aRITkke{@#IG1v1k3p$|w+IZ&33Kc*K+G^eJZLXj1czOmAe8li z=j!WR58X_m7$3Ks0I@Km#}(8SEnyqX*9D2u2&GsRD^Bej?wmK#MRZyoovyd6 zf1^@nS?r!=^!s|-rI#hoe*TL#f9d}B`vu?n_VaGi?cd{9ZvEm+B!kMY(!7cVk*58j2C3IWz8lDwJI6=JBNcu7!0uh4YG|uFp7sr{S@S z9uL$$CrFQJUy$b-BS3n4?$N6?^!v+W_bia6X5q@Kve#blg1`UApZ|0%U;BE)?%807 zgJcB&@J8T7_C6?FEfgyXwsOV`#Y9PXmcH6aE~0_oeL2Nq#p_bRSYZVh9mV{BVZDIZ zJJ--apE);IImf>oh#s7u(KtbMHWq)UlR$#(b90|Jm-v5aioCN9f{`)r+>vD6Idxj-%(6-Izg=>Fa~-( zo9?+>cF#OF`PJ8CZ+qWg-SB5;oZikp{`XC~XM<53L<#`lJ-{)*;@Qyplnn}(g?pK> zZBm?|2*%=;_NAb3F|;-dh`m<=<;L^nR8J_maNNX$T7g0VusnfZw_m%)y;2N?ebHud zkOfpxFiXV+aDuy9JzQ2UMb5u8OUDXw7iXwe5HID=FV0akvd6ea^>UcmQ}h&AGB#kA zJV&H7o70?A`Wg3X!70;{)qxfG1BQzwocmdBNMi7OpH9acaq-lpdoBg7;reaaN5A#$ zg_mvI=+8I(d>ho^AX5MU?*m=}eCinxydOk&^y{eGCO{hJ4!Rji02p?sl0&61Py*!` zff${mnsQnwi>eY>O5m4|8)Q1cfYmf8g2U7c_&q6rf$-I?!Hn~B4T`+XF!z7Cv4Xk^ z;yS;7IbI-f0pj93m9d!{SFIu*%v}=xr4Uf0HAiU0nL=^rP;)}dl6dC1A&8bw$6Q8| z7_v+dwR~DFk2uj7JvrU83S;2L9r;&&@{`^(H*D~)fBCB#g0}|sIKb0D>+n+Szjy9a zaO?>XzKQ`?!(Ku=KleZhIMk+s7XIs+lv7<;+6qk3U`CAl{wd8n;QOcKzA427j5lPy zEJGPa$lnISy7(+&s62|GZnYmlC44Z*dYrVsxb9vubP4&QL`zZnuF7O^vhr9wFW5y3 zKYrv~OhpQ9VdW39f=VqV%jYP*ONmtq+Sv5dVl^=0+HsqLDAgQ+;!H2+&TYeq(}LBJ zKuS5t7*!hjeMOQg+O5g{{Q===aVu!>d@x2cHyd;PHo?qvz}mF|%f;-h`pIuEj$eMl z3GM4&`iigLgd4lT!GeQu1yJDQK)wcMZeFD@Fj_5K^_5rF{38?)l@-PqcM#)(wsJe;kic0=ETsQQ(T9vIY-%guT~B(wGtS_3rg;^!e!)%;p?E3in&xwV5yaWz@~O8 z?F78AKS5BWYA)d-n)JGu6YOfhx8Gl=6-P?VnUUhoUCoJ8h0q_CAXFiQEyn7{8s8JN zTGGYZ4N46kb7j!V4C2dH7YjVEh&c;9&!^q?_ZTQ%SkPDe?vnVace(TQ_n!Bni@ET^ zm))#eyTO5tgIEE)4mcIaj)(4ERti_Fc!9Ov1q>6bs)6CkS3S`kv?nDn$<{sdwJSXtW!Qt|pS!Re62m-4J>KH%!vA*&0%hL-kc)@9(JLmr2;lICi!SZkE1_vb$ zVg&&3X5b89?rdm(3Z$zPUT&3eNm>cPu&?kk3dNRuzfK91{6Vrt;KFFUV9+nvU6YV| z7V>)v8f&-Gk#clZQMixFG!b=qWhQpRrD3jQKFOGunx7kF-Qm?Xybh;I+w zLQ4gP%P{WvEElv~e4s#@n%{3S3oy1&-PQIEk&;1*BNE`q-0YTzZ@JyICfdWsX zB%O|r5JFvZZT6nO|J2Sm9)Dbv{PjnkvUd|UIB3x*0Kh7Nxd4uRGqfCi^i70-(Hemg zYK48dVz?yqpyadn88BLxT|j$^1B~dak`kC?_19Gn7Z&%Rw!r!EjTyFWyeSHx{MtIi zhuKDwVdM8bxrpi>F|Ha}T18M+06-`;8@!xj!;HIbf>YPRhPKr~dEt|HHE}lHENmT} z6wX~^?hGI%{Zv@%91vVLDL z?4C8d`my}l)+@8uPj%()H~h)tZ}P3%;NU}}00y`PgTjNAKuPKh0-~iNt};ekHzmnE z$iw%BbC>l>RjDlbx}*f^x`Gu7rY!8silVwQFxoYn7kj4wMp|r|(eaT#WGG#ZuwQC5 zkh{1{An}dj&>-jZ)j6lH(;T-N{9F_GFg@erdBU|*7K7(f*8AfJ-=@p-DHu7ITb(<& zO@!n1iM8$d-m=}iEDe%DDY7g#3t4J*rJ325B<7la-)!yo^<@hSdh6W0zV_N{v+dvc z-r|nKHnrm){rEqDf4f_=h-Af;w? zpgE?UaoRe?v8y!4tQD-Ek%WOjcmg2=S*EQe-;#vk-udJU6fT`G6tpH3YE23h=ZZYf z%;Nll-o1NwzAXsEwMvQ0dwqSy;-a~7ZcbgZeY?8hcbBBQfBe%Oy)63=1rGrJbnh;* zL4z7J3Sb0p$I?ZVD}}3AZg9A;inVp&EXy54jsL!MUdgBusCD@i6cLpa)WW(KMN&JC zuZEkq0fVBkL7HeO3#mAF5ih9HOV_O$>f!=Rb)9EWQ$f4OlK`OykRlzaqJW0pLlaOs z(wlTdKstopi_%3vdJzGogkGd2AcAyIA#{RDjSvv&1a5r4+ zo_&6Q^6=lX^1UubWIONcPK}AXXLIay$yB;}PGG^zo&H&3 zu`|ltzp_==KW;m-bbb5okxn0O!d@VP@11Yzc;7xTj&%>*eJp+X>*--v#Ch}c{B z{hS_T2AKL7M6mm(i|Cuc5)qR4nwVZ;{4wpVdlcPqO1;;Wg3-~GLp_L5GFAr9>^kg- zENQCwFDRk`Ed)sDk5J}XOWnYa=Kn75#2n_{@ZPHyOE=&TT+<%!Z2K`Mne-Yhq-R+# zyX~DmW8@$hb<&@&pSk8{_YrpXc2DO{xu5fSPjT^btM+qBP;fwTfzU;GvvXrr`@|%+ z2EJ#!h?vXVJ)chBWD4Aka0aJ?V8}~Kk0}h3MmfOkz}}8KDz&0?|AuOWzMxph1KqWw zrYz;P-aA{Yg{2~hD%y@0=dxJq2kSGc7UaLDf7~a1Nm=o8!q!;yY-NS=vhyTq5^Dv| z&PeclFXPbq<5z0FxD=b741?4d*;|7QzI;AO>0vJ0QgiBucfj8%<4es(wiIqph>5?c z+(_UPMGw5}ZCaJK3Q_C{h)}WZ32pDaBKU=T@4>ju;r=R1E$He@z(zY3+%82pL_t@A z0>^u~=&yl7jX{i$<{np50cOj-@lf^$lCV0sPOlyFMiH&$`KW8ZQy7Ga! z_Z*cCEVLXjxMZ0yW#qB-iycX>x9TDDT-@Uc%{Pwdte>V4#fu}0Q1g75x_b>+;o#Ss z1Ad2Yh*dN6MekBhrS%LBE7H?D-`P-FztE~}6G@<{rV>I$E|;hmk%fKsgKb>T2~p>& zz$a3@f0%c@t1HRvOh*EkbD8S)q(CRpn zgjHfLkq}G3e_$$XGtf_1EAs_u3gbGOByCfO(?BAe;R%4wR@oUj@*8z5#j)9a^A$Upj)?NfdlA}u ziI#GW#c{>Ic`ujHk!}-4fb>(^eFaRje)LxCt*YIN_y^TkZi7l(t!Q}i->J@!W>I?) zjS|!NEk1r|ZdGN6JM;~6r|*byo_gC<<{pa%sEM92`ri2MB2>vVyWfi+zj!5Ya{)Cu zcZ4qusI0FoJi`xEFpq_5R96@utjk&y7sLyT%fJ5ap`D<5_2;vCv-9Ze--TW2YPR}r zv4V@w@rxIa5#KD4-u#~L2nCcS6wu-n+OYMh%!~LsAjkbwcz|UB7~3 z^v{^X700Z?RKpX)JUNF47B8kpr9!^ojPNhC$uCs)+vc9Ss^% zZBa4aPA6sZiVZDSA#BX1g3P60R8BQ^%Zc0}m*dwv>>s=Te$Z8@r&!-mTDwHV4FP<4)p4fX`5f^@7Nc_-Ne0iF^NzZRgV4RMPafkyr#IfDzVo9ss*3{;` zox<>7{g;&4%5N?4H}>=eBFT#3XGiF#R)^NsUGD87FV5F!ysXFmpoO?yqRtjiVFb7( zih%XWNks#yh~`D7@WQ9?t~0;cJ3!G+Thp*3XDV|T>G0u12@a>S^=9S0wi*ZfW@q<9 zS(pav+lS48*)E6N`9IUA*drO(!K z#_ASJP*eydI86OPgh$90(j=xoRMlpxqkEESS^9O-gaBh|Hg|){M)eKmJj4&CY6e+t z+i%a&Y-PsZj77A!#_N? zsvipsyH4~wln=Ci)z6BVG(8`3|3}?U1$8_+g+g(kHl$TgNE;B?eHwO_&?)4%Z!2sMccb+HQN`hHK<8wdWf-qoNw5s9b1^;i=MQ;QNz|h z)phUDm`SqYsI9mc(BSk579P}&p-uK-4PYYOYlDlMZ(c_-9ho_P|%qu z^w5IL+Te5}qJjcV=X`drK)XIFw++miJRGm>qh)ck6b9Zn5mECy0}`_Esg}9{?>{drY5LJG7{JY1@Y2E?VrH$ zR_z7`%oGP^*;IHQ;vq-7N3d=FfJ`*3K@@B1FyV^F^&HjNicJT}H=Rx}_fd zO*OME8jtu{(2U=N)zw`8;-FZBG^-FGs=TZu-pvP3F!QLJ$6|urw*@_H?H8kL9;Rl= z9ftQXtGl6%%~qk}b@fl0HN1*;c1BGnbL+&#Hx@iKy}aVx+MzvH_L>An{xf8H6%1!< zdamt8kR*o@f~=Q#2*VWS)0(8p+PVWR)U@=b%5H+c{EM3SFZHhK8%ggg+S(S+B;C>P z+0tYbR>OZBQ1+Z$AF=%@TEvYkP%Bw(-!CJS@PdUxEPbdeCAn~k6#2_W!H+L?<13UT%o4RGlxMQC$r zdu%W3cT)qaTdNfFGZ~(-pNqWlpfG4__8`)Ho91h&N^C4a45ve#Fi!>a^|RdaBHg+B zus(4GG6$o%&hKwTq0P=!37HeTo8W4!?6v=)1*ktj8AaL5A+|%O7x1P-A(-?iF2Hry z*PBNDa&Q|ZP;WbE6Un>ZKz@<5it9qPn_?DNC0rZ0?7^oj`}c)kpZ<^F=lgs}GB6g+C|o+pb=D{!Z?dI`6B`~J*S5(i&8;#V#SALTc_(c{D)~zu>)a|HE{V8L~wU5!DBjTuUVAri5cawN1ec-m?2#dj~!!Wami<2642Z?2tWm zwkMDHG`x3VgM8zsv=Bao3qY^@b0BuEe#_(AAJJ8g@oLi|gF_UvC5|LEU#3jXjB77` zQeeuIM|&cbYWKr_#Q7nB5vi?nluM9Pk$w7FMvkoGI`9+nFQ(AlTgqJ z+Hcg_zu5DeT|3+Bl5xMkp~%|hc1Gi2fFyLzf84LOxB-e2PE%AgV}H7xD}KXM=*uhL z!SKt-L`F;LO}Qs=0fq|E2Y;~3=ICVb1TbyLrG)`a^eIj0tXQv&SfMui8m_#tVnx}_ ze#((keU$$-i0G0N+jM4DtLl|@6ZH)r!@7RCB7oOU#7EXIBbHSq;WYK`$mN{-u9Jn`e5 zA7xFi9z#*8>pkU-s`!3I_6v9T^9$C>XfvQRhzrv;S?Shr^Iy#5BC8*Ytx@&5z9CQP zI)&PE#h5`gEK~A#Czfi7e_dm|ok2od`p;jB;?^f)jkn{2wDIs{@N8)3@%j%@iRjh; zNO5~xy`}YF#hM0-OUZ9qdd!Y~*DY*MZeK^agZ7APUy~+bZ6>arfNWWN zdUMF)b@Hzwdk1Nu%y6*O&#jHSV!Md&BzuFNq}0(%NZR1w{VURfkwrT$O#)eCDMtoW z@XdB3HAJb))r0ft50DefH% z1-rgo`Qb1re1I$k=FQyiJS7L;6+GQs)>kW#y4{(#NB(n0ag<_?XuAI@x(p@%41^>w zH3?Y9wg*Y$ZzAuhxrd9Jx_UYCc(kX+U<_n;+b@hwC(8Jq*I zbl+J$eC8G#LB3cq#M*U3(t5>Q)>wbhS5R@9Nyz9yB5q(-hMhW$mW|WaBy3A`%3Q|sny6LPemOfbySJ}m%J#FkCw_6rM3Uc@{ zwiRP6h4}||8<_TSjTGBGb0(@Rz**ZXq7YMcgb9SEq^z&a&Jq18f5_lVXomVsK3PvZfJj>G|(29F_aZ4^a|vUbJS z7Ohw1-=DOYkL(3*;?IUoI5xKY>-YA$x(@Mtua|>2i{L8+m0slLgV^m{CoA#jUDt*y zwWf*cU%6} zEbHbi@oz51JU>|Y3b|DJt61qXP>TsJzSlK>7GmO*ZNGbpg)5(n4p>E#+K>JbIr=94 zZHUhBrmCwNO^~(O=A#j41zn!zO6AFC3`G6jd<0wd;x~?+J8~u`enD%=EE48VGk?mn zr%G$3Rfx{(!IS#dGd5Oc0_8KryZ@RuGl<8~oG9d~=$(V?=%+?R4}A|Sd!g9)bX~7gX|LXE|2#ebcbGb(1L4XXh|7^h*0szbH~{ z|3WZn0pf=p{C@ZTtqAe|B4KGi zB?0rbHVlJ*W26l()E(vcm!VS@DC3n;W&z0**W8Yf$sKiNO|rE(TGh7la-`UPs_5W5 zd7@lk%Yn?ewagFHiv*T~6jO)9N>)dm=cU!cBE%ZhBmHfI%;GvM!h|2;vCW8&qJvac z;N*`LEsx6|C6YPk>uDaWS!IYfitoJQuFoKDiQgMqK1p~b=pIB>eSJu=&QBpG_zEkS zMYPX@c=U~))!`J$kQEaQ;|tWGKnSe-)hN(I&F{ z+BGCbN12{X!jkx%hN7GHDZ^d)eRx*mxgmr@ONM-=Iv6Y&Y?0dJxfyum*yF@~m#b0W ztVi-ac_{bVGro}wn^+#ZVr7z5J$+mYM79!mQVt{6FOTjKPg70ZD^X<`b~h+5VSJ7<+awfH8M5DsDFD-SEl_t-F8U7_fSN zFK79lXn3!$@ZM|>W%j-d#HReSEA&braq`(#arccoZ1htYr06^nR6gC>%QEBH1Ymyr z5TL_n;04T}U@@lJolROlLe(3-YSl_pX?2~bHjfZyjeCTsjzL*4th*o(zo~V!I`Tua$~1OZ;y7J*q=k59&k7%DO=%i7VjzmEpxI^ zYr48&Y=@B7{o$p4;#`q;4*3pg{u&ufeM5r@plF8*18@^h=}srPrAPondEWLn;6R4k zP|&k*8WUlqs1{W4mc399Oj96ID7maBA*o7Ne??z4_K$<{ty=E+JsN}0qgqx6T?TA@ zhZ*5W6qRvvWs_51rPHd*V_{CSkzOaRE-~laV)~4!I$?!&BJzDzuf%f0>}fbJ8~(*F zTph!xfmxF5sjsb;L#JfYUj7UUV;|!EDdRb|d8ipj`(@Ln z!#g8GQ!#S0EHO;v>v+Ly=r)$n)Qpv|JmVxM_uZKCgq zGQF@Qo}1}d4ia6&LXSZrcvWkf-N+;NiIza{`YVgdqFCK97AMYAx}@pI85RH zsH7lfL>``U?G$JAyFv;gZURI^pq}jdgQC)LsENwT#97rWQdXiCb@fC2_Iq1;%<^DU zn9p*6*La~+-Lw9;>Yt{r@(k07X$avk+>%MSKBy~B*g+sM--6H7!shr*Y}+NA}-~KI!|)29|Nw@J8i$DLXQ}r=cVMLi`2%o+g75dRN&fsu4I?A9qlN zDr7HQZh+&G65re}=~>(BLIWw^3O3P{!duGcb}O=!yqgVb@$|zNMz6-DlEHYhXy+_x z4vQEBR>_cZKooUTkOo`$QsPqGf7!JgW%=uiVwaNz(|m!gegy7W)}%pxTnlZhOW57r z*9tnPw|qBZ5Et2~r-BJ~8d;O45wWWN_bV=87Ey0|TzJ>ta-2~uWSXVi7}YCRNOa`! z7SNJw0c;V0`6yiHoBo_|djlRF42qYX)m^xfdzU&$(Ha%r2rOmeMbb;Pf8v4%`u|?W z53<3-&KKNm$qh>4^72=FXp)fEBw8IKZxivW46U6cUp|~TzMHOpKs{Ae1`J^hk-@35 zhAUgH=?=G<@!rO53x4~1eD~tOHY?OX*75YFmcqr|KO)_6;1l|3OfyY<&dN)NAujdi zS2Sf*UrnBsVC?&cU5^84Iw8`f2#3+>u{!9fm-?_BTgGvu;s}vNVr>Ubv$;D|{;Y0Q z0K1$l*17m9#s_frLWe8E?R0%bp~d-y+yuA$*%cgo1s_w%mWNB?bS!*D{U1ynEKAVX z1&IPHW=f*;@XfCK_a)RzlG$6*4O%{MCARFdd?~($QecI459E30_rjbigR>kCkBbcw zUHG2zU!2R0$VKG5-Np!F3Z0O08Ify1Ynt~}DQXKRC3lqIIF-r{%~vQTqC1ooIdNon z;4}u^gF|ma?W8_m{1SygcoFYd$PZo{woHNfn5*+b(=|7GP3DyBQbY%t9sm3C?fOC1 zP+Y+Rck-wt&0TB5Nh%485%qSwRqI~SU`+0^tY0{xxNgtxNp~%e?%44>+Gx;1?@nyHe>wS+ zp@sIsZoswmZH3mV@e+99hMP%}gSwsOfZS*SfzEY`FA-6DaAI+_BIUp9R9zbDXHJ}f zk@CBE(I`R<446RJ=#Am`Dk&ehS?#b4UpjrTm_87S>Q;>bdZ_%{3f*gvV|4QC>w2Bg zr&M-8J8+iI@aT6Q3qIm8OrN3hAhS`qIe^(wC)EK+Frs8qI6#2<2~g?>bjp&4$b)Es zkb}_xAwLOGZ(eV|1$hT>A#)a)%YU2t|5)BJWbhgo9ilPTeka2a008j&tDE~f+50=o zIr=&iZU8Z;sH_N7T0~UR7z&jW6P1%BJW9$zp<6K&f&Z1@xtG&3m*D?DLEdW92q6LB Nk-FXkgsNT4{{Txcc`5(^ From 36402d4c4a370c4b1def2b2a518d7389cbad0be8 Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Fri, 27 Dec 2019 13:56:01 -0500 Subject: [PATCH 032/111] Git submodule setup for doc/assets. Procedure according to https://stackoverflow.com/questions/12514197/convert-a-git-folder-to-a-submodule-retrospectively --- .gitmodules | 3 +++ README.md | 11 +++++++++++ doc/assets | 1 + 3 files changed, 15 insertions(+) create mode 100644 .gitmodules create mode 160000 doc/assets diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..b85de9d5 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "doc/assets"] + path = doc/assets + url = https://github.com/MASTmultiphysics/mast-assets.git diff --git a/README.md b/README.md index 51095565..737b5398 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,14 @@ This code was developed under funding from the Air Force Research Laboratory. MAST was cleared for public release on 08 Nov 2016 with case number 88ABW-2016-5689. Documentation for the code is available at [https://mastmultiphysics.github.io](https://mastmultiphysics.github.io). + +## Submodules +To keep the size of this main MAST repository smaller, a git submodule is used +to store larger media/assets such as images and animations used for the documentation +in a separate repo (doc/assets). To build the documentation locally, you must update +the submodule. To do this, simply run the following commands from inside the root +level of this main repository: +``` +git submodule init +git submodule update +``` \ No newline at end of file diff --git a/doc/assets b/doc/assets new file mode 160000 index 00000000..ebe756bb --- /dev/null +++ b/doc/assets @@ -0,0 +1 @@ +Subproject commit ebe756bb7c65db55720ac741a2ed50449a506670 From 0baa69540d6799a8bacda136f18a3072fc321249 Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Fri, 27 Dec 2019 14:41:17 -0500 Subject: [PATCH 033/111] Added example for structural modal analysis with NastranIO mesh input. --- .gitignore | 5 - CMakeLists.txt | 6 +- doc/.gitignore | 3 + doc/tutorials.dox | 1 + examples/structural/CMakeLists.txt | 2 +- examples/structural/example_7/CMakeLists.txt | 12 + examples/structural/example_7/example_7.cpp | 315 ++++++++++++++++++ .../example_7/example_7_acoss_mesh.bdf | 168 ++++++++++ 8 files changed, 503 insertions(+), 9 deletions(-) create mode 100644 doc/.gitignore create mode 100644 examples/structural/example_7/CMakeLists.txt create mode 100644 examples/structural/example_7/example_7.cpp create mode 100644 examples/structural/example_7/example_7_acoss_mesh.bdf diff --git a/.gitignore b/.gitignore index 454df28a..7b3266dc 100644 --- a/.gitignore +++ b/.gitignore @@ -6,11 +6,6 @@ build # Files generated by CMake. src/base/mast_config.h -# Files generated by Python example/documentation preprocessor. -doc/example_1.dox -doc/example_2.dox -doc/example_3.dox - # CLion IDE files. .idea/ cmake-build*/ diff --git a/CMakeLists.txt b/CMakeLists.txt index acea44c0..3f17f773 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,9 +109,6 @@ endif() # MAIN TARGETS add_subdirectory(src) -# EXAMPLES -add_subdirectory(examples) - # DOCUMENTATION if(BUILD_DOC) add_subdirectory(doc) @@ -121,3 +118,6 @@ endif() enable_testing() add_subdirectory(tests) +# EXAMPLES +add_subdirectory(examples) + diff --git a/doc/.gitignore b/doc/.gitignore new file mode 100644 index 00000000..0d39232a --- /dev/null +++ b/doc/.gitignore @@ -0,0 +1,3 @@ +# This .gitignore file is used to ignore the *.dox files that are created for the example files when the documentation +# is generated. +*_example*.dox \ No newline at end of file diff --git a/doc/tutorials.dox b/doc/tutorials.dox index 26e18e9e..634b55da 100644 --- a/doc/tutorials.dox +++ b/doc/tutorials.dox @@ -12,6 +12,7 @@ - \subpage structural_example_4 - \subpage structural_example_5 - \subpage structural_example_6 + - \subpage structural_example_7 - \subpage fluid_example_1 - \subpage fsi_example_1 diff --git a/examples/structural/CMakeLists.txt b/examples/structural/CMakeLists.txt index 328339d3..e00b0049 100644 --- a/examples/structural/CMakeLists.txt +++ b/examples/structural/CMakeLists.txt @@ -4,4 +4,4 @@ add_subdirectory(example_3) # thermoelastic plate bending add_subdirectory(example_4) # tie-constraints add_subdirectory(example_5) # 2D topology optimization add_subdirectory(example_6) # 2D SIMP topology optimization - +add_subdirectory(example_7) # NastranIO input for Nastran BDF mesh diff --git a/examples/structural/example_7/CMakeLists.txt b/examples/structural/example_7/CMakeLists.txt new file mode 100644 index 00000000..1f761cd5 --- /dev/null +++ b/examples/structural/example_7/CMakeLists.txt @@ -0,0 +1,12 @@ +add_executable(structural_example_7 + example_7.cpp) + +target_link_libraries(structural_example_7 mast) + +install(TARGETS structural_example_7 + RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/examples) + +configure_file(${CMAKE_CURRENT_LIST_DIR}/example_7_acoss_mesh.bdf ${CMAKE_CURRENT_BINARY_DIR} COPYONLY) + +add_test(NAME structural_example_7_mpi + COMMAND ${MPIEXEC_EXECUTABLE} -np 2 $ -ksp_type "preonly" -pc_type "lu") \ No newline at end of file diff --git a/examples/structural/example_7/example_7.cpp b/examples/structural/example_7/example_7.cpp new file mode 100644 index 00000000..8489c689 --- /dev/null +++ b/examples/structural/example_7/example_7.cpp @@ -0,0 +1,315 @@ +// C/C++ includes. +#include +#include + +// libMesh includes. +#include +#include +#include +#include +#include +#include + +// MAST includes. +#include "mesh/nastran_io.h" +#include "base/nonlinear_system.h" +#include "elasticity/structural_system_initialization.h" +#include "elasticity/structural_modal_eigenproblem_assembly.h" +#include "base/physics_discipline_base.h" +#include "boundary_condition/dirichlet_boundary_condition.h" +#include "solver/slepc_eigen_solver.h" +#include "base/parameter.h" +#include "base/constant_field_function.h" +#include "property_cards/isotropic_material_property_card.h" +#include "property_cards/solid_1d_section_element_property_card.h" +#include "base/eigenproblem_assembly.h" +#include "external/fort.hpp" + + +int main(int argc, const char** argv) { + // BEGIN_TRANSLATE Modal analysis of space-frame with Nastran mesh input + // + // # Problem Overview + // This example introduces how to use the NastranIO class to read mesh information defined using + // Nastran bulk data format (BDF). This example requires that MAST is compiled with the option + // `ENABLE_NASTRANIO=ON` and requires a Python interpreter with the pyNastran package be + // detectable by the MAST CMake build process on your system. + // + // The mesh data that is read from the BDF input includes nodes, elements, subdomains for + // assigning properties, and node boundary domains for assigning boundary conditions. + // + // The geometry used in this example is a modified version of the of ACOSS-II (Active Control + // of Space Structures - Model 2) described in references [1] and [2], which has a compact + // BDF input suitable for use as a tutorial example. The ACOSS-II model has historical relevance + // as a demo case for optimal control of flexible structures and structural optimization with + // frequency constraints throughout the 1980's. + // + // The mesh used in the example is taken from the ASTROS applications manual [3] and differs + // slightly from that in [2]. The basic geometry of the model is shown below: + // + //

+ // + // + //
ACOSS-II (Active Control of Space Structures - Model 2)
\image html ./assets/examples/structural/example_7/acoss-model-ii.png width=333px + // \image html ./assets/examples/structural/example_7/acoss-model-ii-fem.png width=250px + // \image html ./assets/examples/structural/example_7/acoss-model-ii-mast-fem.png width=333px + //
(a) ACOSS-II configuration (from [2]) + // (b) ACOSS-II FEM representation (from [2]) + // (c) ACOSS-II MAST finite element model + //
+ // + // We assume that the structure is modeled with beam elements and is made of a graphite epoxy + // material having Young's modulus 18.5x10 psi and mass density of 0.55 lb/in^3. We also assume + // currently that all elements have square cross section with dimensions 3.16 in by 3.16 in. + // + // In the source listing below, we utilize components from the MAST library to setup a modal + // analysis of the modified ACOSS-II structure and calculate the first 10 vibration frequencies + // (eigenvalues) and mode shapes (eigenvectors). The structural mesh is read into libMesh/MAST + // using the NastranIO class. + // + // The Nastran BDF mesh is located in the MAST source at: + // `examples/structural/example_7/example_7_acoss_mesh.bdf`. + // + // To run this example with a direct solver (when linear solves are required inside the + // eigenvalue solver) use: + // `mpirun -np #procs structural_example_7 -ksp_type preonly -pc_type lu`. + // + // TODO: Update this example to use actual truss elements with non-rectangular cross-section. + // + // References: + // 1. Henderson, T.C., "Active Control of Space Structures (ACOSS) model 2," Draper Laboratory, + // Inc., Cambridge, MA., Technical Report C-5437. + // 2. Grandhi, R.V. and Venkayya, V.B., "Structural Optimization with Frequency Constraints," + // AIAA Journal, Vol. 26, No. 7, 1988., pp. 858-866. + // 3. Johnson, E.H. and Neill, D.J., "Automated Structural Optimization System (ASTROS) - Volume + // III Applications Manual," AFWAL-TR-88-3028. + // + // # Documented Source Listing + + // Initialize libMesh library. + libMesh::LibMeshInit init(argc, argv); + + // Create Mesh object on default MPI communicator. + // -- note that currently, NastranIO only works with ReplicatedMesh. + libMesh::ReplicatedMesh mesh(init.comm()); + + // Create a NastranIO object and read in the mesh from the specified .bdf. Print out some + // diagnostic info for the mesh/boundary to see what was read in. + MAST::NastranIO nastran_io(mesh); + nastran_io.read("./example_7_acoss_mesh.bdf"); + nastran_io.print_pid_to_subdomain_id_map(); + mesh.print_info(); + mesh.boundary_info->print_info(); + + // Create EquationSystems object (a container for multiple systems of equations that are defined + // on a given mesh) and add a nonlinear system named "structural" to it. Set the eigen-problem + // type for the system so MAST knows we are eventually going to execute that solver. Also create + // a finite element type for the new system. Here we will use 1st order Lagrange-type elements + // and attach it to an initialization object, which provides the state variable setup for the + // equations corresponding to structural analysis. + libMesh::EquationSystems equation_systems(mesh); + auto& system = equation_systems.add_system("structural"); + system.set_eigenproblem_type(libMesh::GHEP); + libMesh::FEType fetype(libMesh::FIRST, libMesh::LAGRANGE); + MAST::StructuralSystemInitialization structural_system(system, system.name(), fetype); + + // Initialize a new discipline, which we will utilize to attach boundary conditions. + MAST::PhysicsDisciplineBase discipline(equation_systems); + + // Create and add boundary conditions to the structural system. We use a Dirichlet BC to fix all + // of the nodes in SPC ID 1 in the .bdf file, which have been placed in a libMesh/MAST node + // boundary condition set with id of 1. Note that boundary condition application is not taken + // directly from the BDF definition, but simply the identification of which nodes are placed + // in the libMesh/MAST node boundary set. We specify which degrees-of-freedom for these nodes + // with `DirichletBoundaryCondition.init(, )`. + MAST::DirichletBoundaryCondition dirichlet_bc; + dirichlet_bc.init(1, structural_system.vars()); // Fix all variables in the system for + discipline.add_dirichlet_bc(1, dirichlet_bc); // all the nodes in SPC ID 1. + discipline.init_system_dirichlet_bc(system); + + // Initialize the equation systems. + equation_systems.init(); + equation_systems.print_info(); + + // Initialize the eigen-problem and eigenvalue solver. Specify the number of eigenvalues that we + // want to compute. + system.eigen_solver->set_position_of_spectrum(libMesh::LARGEST_MAGNITUDE); + system.set_exchange_A_and_B(true); + system.set_n_requested_eigenvalues(10); + + // Create parameters. + MAST::Parameter thickness_y("thy", 3.16); // in + MAST::Parameter thickness_z("thz", 3.16); // in + MAST::Parameter E("E", 18.5e6); // lbf/in^2 + MAST::Parameter nu("nu", 0.3); // no unit + MAST::Parameter rho("rho", 0.000142); // lbf*s^2/in^4 (0.055 lb/in^3 * 0.00259) + MAST::Parameter zero("zero", 0.0); + + // Create ConstantFieldFunctions used to spread parameters throughout the model. + MAST::ConstantFieldFunction thy_f("hy", thickness_y); + MAST::ConstantFieldFunction thz_f("hz", thickness_z); + MAST::ConstantFieldFunction E_f("E", E); + MAST::ConstantFieldFunction nu_f("nu", nu); + MAST::ConstantFieldFunction rho_f("rho", rho); + MAST::ConstantFieldFunction hyoff_f("hy_off", zero); + MAST::ConstantFieldFunction hzoff_f("hz_off", zero); + + // Create the material property card ("card" is NASTRAN lingo) and add the relevant field + // functions to it. An isotropic material in dynamics needs elastic modulus (E), + // Poisson ratio (nu), and density (rho) to describe its behavior. + MAST::IsotropicMaterialPropertyCard material; + material.add(E_f); + material.add(nu_f); + material.add(rho_f); + + // Create the section property card. Attach all the required field functions to it. A 1D + // structural beam-type element with square cross-section requires two thickness dimensions and + // two offset dimensions. Here we assume the offsets are zero, which aligns the bending + // stiffness along the center axis of the element. + MAST::Solid1DSectionElementPropertyCard section; + section.add(thy_f); + section.add(thz_f); + section.add(hyoff_f); + section.add(hzoff_f); + + // Specify a section orientation point and add it to the section. + // -- Currently this orientation is arbitrary and we assume all beam sections are oriented + // in the same direction. + RealVectorX orientation = RealVectorX::Zero(3); + orientation(0) = 0.3583339; + orientation(1) = 0.8641283; + orientation(2) = 0.3583339; + section.y_vector() = orientation; + + // Attach the material to the section property, initialize the section, and then assign it to + // the subdomain in the mesh that it applies to. We note that we can reference the map between + // Nastran property IDs and libMesh/MAST subdomain IDs identify specific subdomains. + section.set_material(material); + section.init(); + discipline.set_property_for_subdomain(1, section); + + // Create the structural modal assembly/element operations objects and initialize the + // condensed DOFs. + MAST::EigenproblemAssembly assembly; + MAST::StructuralModalEigenproblemAssemblyElemOperations elem_ops; + assembly.set_discipline_and_system(discipline, structural_system); + elem_ops.set_discipline_and_system(discipline, structural_system); + system.initialize_condensed_dofs(discipline); + + // Solve eigenvalue problem. + system.eigenproblem_solve(elem_ops, assembly); + assembly.clear_discipline_and_system(); + + // Post-process the eigenvalue results. + // Get number of converged eigen pairs and variables to hold them. + unsigned int nconv_pairs = std::min(system.get_n_converged_eigenvalues(), + system.get_n_requested_eigenvalues()); + + // Pre-allocate storage for calculations using the eigenvalues as well as storage for the + // eigenvector solution. + Real re = 0.0; + Real im = 0.0; + Real omega = 0.0; + Real freq = 0.0; + std::vector solution; + equation_systems.build_solution_vector(solution); + + // Setup table for eigenvalue/frequency console output. + fort::table eigenval_out; + eigenval_out << fort::header << "Mode No." << "Eigenvalue" + << "Frequency (rad/s)" << "Frequency (Hz)" << fort::endr; + + // Setup output files to save frequency data and mode shapes. + std::ofstream freq_csv; + if (init.comm().rank() == 0) { + freq_csv.open("freq_data.csv"); + freq_csv << "Mode Number, Real Eigenvalue, Angular Frequency (rad/s), Frequency (Hz)" << std::endl; + freq_csv << std::scientific; + } + + // Exodus output file for mode shapes. + libMesh::ExodusII_IO exodus_writer(mesh); + + // Loop over and process data for each vibration mode. + for (unsigned int i = 0; i < nconv_pairs; i++) { + // Get eigenvalue/eigenvector pair. + system.get_eigenpair(i, re, im, *system.solution); + + // Get eigenvector on Rank 0 solution. + system.solution->localize_to_one(solution); + + // Calculate frequency for current eigenvalue. + omega = sqrt(re); + freq = omega/2.0/M_PI; + + // Add data to console output table. + eigenval_out << std::to_string(i + 1) << std::to_string(re) + << std::to_string(omega) << std::to_string(freq) << fort::endr; + + // Write frequency results to text file (only from rank 0 processor). + if (init.comm().rank() == 0) { + freq_csv << i + 1 << ", " << re << ", " << omega << ", " << freq << std::endl; + } + + // Write currently active eigenvalue into Exodus file. + exodus_writer.write_timestep("mode_shapes.exo", equation_systems, i + 1, i); + } + + // Output eigenvalue/frequency table to console. + libMesh::out << eigenval_out.to_string() << std::endl; + + // # Results + // Successful execution of the example should produce both console output and files. Tabular + // output showing eigenvalues, angular frequencies (in rad/s), and frequencies (in Hz) + // correpsonding to the first 10 vibration modes should be output to the console. This output + // should be similar to the following values: + // + // | Mode No. | Eigenvalue | Frequency (rad/s) | Frequency (Hz) | + // |----------|--------------|-------------------|----------------| + // | 1 | 520.408008 | 22.812453 | 3.630715 | + // | 2 | 2263.881979 | 47.580269 | 7.572635 | + // | 3 | 3475.185118 | 58.950701 | 9.382295 | + // | 4 | 7543.959254 | 86.855968 | 13.823557 | + // | 5 | 7824.872647 | 88.458310 | 14.078577 | + // | 6 | 11756.804335 | 108.428798 | 17.256979 | + // | 7 | 13055.444785 | 114.260425 | 18.185111 | + // | 8 | 53884.048267 | 232.129378 | 36.944538 | + // | 9 | 63204.791232 | 251.405631 | 40.012449 | + // | 10 | 86174.214772 | 293.554449 | 46.720642 | + // + // In addition, two output files should be produced. `freq_data.csv` contains console output in + // .csv format that is suitable for external post-processing. `mode_shapes.exo` contains the + // mode shape data in the Exodus-ii format, which can be opened for visualization in Paraview. + // + // The mode shapes corresponding to the first 9 vibration modes are shown below: + // + // + // + // + // + // + // + // + //
Vibration Mode Shapes
\image html ./assets/examples/structural/example_7/mode1.gif width=333px + // \image html ./assets/examples/structural/example_7/mode2.gif width=333px + // \image html ./assets/examples/structural/example_7/mode3.gif width=333px + //
Mode 1 + // Mode 2 + // Mode 3 + //
\image html ./assets/examples/structural/example_7/mode4.gif width=333px + // \image html ./assets/examples/structural/example_7/mode5.gif width=333px + // \image html ./assets/examples/structural/example_7/mode6.gif width=333px + //
Mode 4 + // Mode 5 + // Mode 6 + //
\image html ./assets/examples/structural/example_7/mode7.gif width=333px + // \image html ./assets/examples/structural/example_7/mode8.gif width=333px + // \image html ./assets/examples/structural/example_7/mode9.gif width=333px + //
Mode 7 + // Mode 8 + // Mode 9 + //
+ // + // END_TRANSLATE + return 0; +} diff --git a/examples/structural/example_7/example_7_acoss_mesh.bdf b/examples/structural/example_7/example_7_acoss_mesh.bdf new file mode 100644 index 00000000..3a1e48cf --- /dev/null +++ b/examples/structural/example_7/example_7_acoss_mesh.bdf @@ -0,0 +1,168 @@ +$ MAST NastranIO class example input file. +$ Adapted from application problem "acoss.d" +$ from Astros version 12p5. +$ pyNastran requires SOL and CEND statements, but NastranIO does not utilize solution control data. The Nastran case +$ control section is not required. +SOL 101 +CEND +$ BEGIN BULK bulk data keywords are required by pyNastran. +BEGIN BULK +$ Node/grid definitions. +GRID 1 -275.591 0. 0. +GRID 2 -157.48 196.85 0. +GRID 3 -157.48 -196.85 0. +GRID 4 0. 196.85 0. +GRID 5 157.48 196.85 0. +GRID 6 157.48 -196.85 0. +GRID 7 275.591 0. 0. +GRID 8 -275.591 0. 78.74 +GRID 9 -157.48 196.85 78.74 +GRID 10 -157.48 -196.85 78.74 +GRID 11 157.48 196.85 78.74 +GRID 12 157.48 -196.85 78.74 +GRID 13 275.591 0. 78.74 +GRID 14 -236.22 0. 472.441 +GRID 15 -157.48 157.48 472.441 +GRID 16 -157.48 -157.48 472.441 +GRID 17 157.48 157.48 472.441 +GRID 18 157.48 -157.48 472.441 +GRID 19 236.22 0. 472.441 +GRID 20 -196.85 0. 866.142 +GRID 21 -157.48 118.11 866.142 +GRID 22 -157.48 -118.11 866.142 +GRID 23 157.48 118.11 866.142 +GRID 24 157.48 -118.11 866.142 +GRID 25 196.85 0. 866.142 +GRID 26 -157.48 393.701 866.142 +GRID 27 157.48 393.701 866.142 +GRID 28 -157.48-393.701 866.142 +GRID 29 157.48-393.701 866.142 +GRID 30 -157.48 118.11 944.882 +GRID 31 -157.48 -118.11 944.882 +GRID 32 157.48 118.11 944.882 +GRID 33 157.48 -118.11 944.882 +$ Element definitions. +CBAR 1 10001 1 2.3583339.8641283.3533823 +CBAR 2 10001 1 3.3583339.8641283.3533823 +CBAR 3 10001 2 3.3583339.8641283.3533823 +CBAR 4 10001 2 4.3583339.8641283.3533823 +CBAR 5 10001 3 4.3583339.8641283.3533823 +CBAR 6 10001 4 5.3583339.8641283.3533823 +CBAR 7 10001 4 6.3583339.8641283.3533823 +CBAR 8 10001 3 6.3583339.8641283.3533823 +CBAR 9 10001 5 6.3583339.8641283.3533823 +CBAR 10 10001 5 7.3583339.8641283.3533823 +CBAR 11 10001 6 7.3583339.8641283.3533823 +CBAR 12 10001 1 8.3583339.8641283.3533823 +CBAR 13 10001 2 9.3583339.8641283.3533823 +CBAR 14 10001 3 10.3583339.8641283.3533823 +CBAR 15 10001 5 11.3583339.8641283.3533823 +CBAR 16 10001 6 12.3583339.8641283.3533823 +CBAR 17 10001 7 13.3583339.8641283.3533823 +CBAR 18 10001 3 8.3583339.8641283.3533823 +CBAR 19 10001 2 8.3583339.8641283.3533823 +CBAR 20 10001 3 9.3583339.8641283.3533823 +CBAR 21 10001 4 9.3583339.8641283.3533823 +CBAR 22 10001 4 11.3583339.8641283.3533823 +CBAR 23 10001 5 12.3583339.8641283.3533823 +CBAR 24 10001 5 13.3583339.8641283.3533823 +CBAR 25 10001 6 13.3583339.8641283.3533823 +CBAR 26 10001 3 12.3583339.8641283.3533823 +CBAR 27 10001 6 10.3583339.8641283.3533823 +CBAR 28 10001 8 9.3583339.8641283.3533823 +CBAR 29 10001 8 10.3583339.8641283.3533823 +CBAR 30 10001 9 10.3583339.8641283.3533823 +CBAR 31 10001 9 12.3583339.8641283.3533823 +CBAR 32 10001 10 11.3583339.8641283.3533823 +CBAR 33 10001 9 11.3583339.8641283.3533823 +CBAR 34 10001 10 12.3583339.8641283.3533823 +CBAR 35 10001 11 12.3583339.8641283.3533823 +CBAR 36 10001 11 13.3583339.8641283.3533823 +CBAR 37 10001 12 13.3583339.8641283.3533823 +CBAR 38 10001 14 15.3583339.8641283.3533823 +CBAR 39 10001 14 16.3583339.8641283.3533823 +CBAR 40 10001 15 16.3583339.8641283.3533823 +CBAR 41 10001 17 18.3583339.8641283.3533823 +CBAR 42 10001 17 19.3583339.8641283.3533823 +CBAR 43 10001 18 19.3583339.8641283.3533823 +CBAR 44 10001 8 14.3583339.8641283.3533823 +CBAR 45 10001 10 14.3583339.8641283.3533823 +CBAR 46 10001 10 16.3583339.8641283.3533823 +CBAR 47 10001 9 16.3583339.8641283.3533823 +CBAR 48 10001 9 15.3583339.8641283.3533823 +CBAR 49 10001 11 17.3583339.8641283.3533823 +CBAR 50 10001 8 15.3583339.8641283.3533823 +CBAR 51 10001 11 18.3583339.8641283.3533823 +CBAR 52 10001 12 18.3583339.8641283.3533823 +CBAR 53 10001 12 19.3583339.8641283.3533823 +CBAR 54 10001 13 19.3583339.8641283.3533823 +CBAR 55 10001 13 17.3583339.8641283.3533823 +CBAR 56 10001 14 20.3583339.8641283.3533823 +CBAR 57 10001 14 22.3583339.8641283.3533823 +CBAR 58 10001 16 22.3583339.8641283.3533823 +CBAR 59 10001 16 21.3583339.8641283.3533823 +CBAR 60 10001 15 21.3583339.8641283.3533823 +CBAR 61 10001 15 20.3583339.8641283.3533823 +CBAR 62 10001 17 23.3583339.8641283.3533823 +CBAR 63 10001 18 23.3583339.8641283.3533823 +CBAR 64 10001 18 24.3583339.8641283.3533823 +CBAR 65 10001 19 24.3583339.8641283.3533823 +CBAR 66 10001 19 25.3583339.8641283.3533823 +CBAR 67 10001 17 25.3583339.8641283.3533823 +CBAR 68 10001 15 26.3583339.8641283.3533823 +CBAR 69 10001 16 28.3583339.8641283.3533823 +CBAR 70 10001 17 27.3583339.8641283.3533823 +CBAR 71 10001 18 29.3583339.8641283.3533823 +CBAR 72 10001 20 21.3583339.8641283.3533823 +CBAR 73 10001 20 22.3583339.8641283.3533823 +CBAR 74 10001 21 22.3583339.8641283.3533823 +CBAR 75 10001 23 24.3583339.8641283.3533823 +CBAR 76 10001 23 25.3583339.8641283.3533823 +CBAR 77 10001 24 25.3583339.8641283.3533823 +CBAR 78 10001 21 23.3583339.8641283.3533823 +CBAR 79 10001 21 24.3583339.8641283.3533823 +CBAR 80 10001 22 24.3583339.8641283.3533823 +CBAR 81 10001 21 30.3583339.8641283.3533823 +CBAR 82 10001 22 31.3583339.8641283.3533823 +CBAR 83 10001 24 33.3583339.8641283.3533823 +CBAR 84 10001 23 32.3583339.8641283.3533823 +CBAR 85 10001 23 30.3583339.8641283.3533823 +CBAR 86 10001 21 31.3583339.8641283.3533823 +CBAR 87 10001 22 33.3583339.8641283.3533823 +CBAR 88 10001 24 32.3583339.8641283.3533823 +CBAR 89 10001 30 31.3583339.8641283.3533823 +CBAR 90 10001 31 33.3583339.8641283.3533823 +CBAR 91 10001 32 33.3583339.8641283.3533823 +CBAR 92 10001 30 32.3583339.8641283.3533823 +CBAR 93 10001 31 32.3583339.8641283.3533823 +CBAR 94 10001 20 26.3583339.8641283.3533823 +CBAR 95 10001 21 26.3583339.8641283.3533823 +CBAR 96 10001 21 27.3583339.8641283.3533823 +CBAR 97 10001 23 27.3583339.8641283.3533823 +CBAR 98 10001 25 27.3583339.8641283.3533823 +CBAR 99 10001 26 27.3583339.8641283.3533823 +CBAR 100 10001 20 28.3583339.8641283.3533823 +CBAR 101 10001 22 28.3583339.8641283.3533823 +CBAR 102 10001 24 28.3583339.8641283.3533823 +CBAR 103 10001 24 29.3583339.8641283.3533823 +CBAR 104 10001 25 29.3583339.8641283.3533823 +CBAR 105 10001 28 29.3583339.8641283.3533823 +CBAR 106 10001 26 30.3583339.8641283.3533823 +CBAR 107 10001 27 32.3583339.8641283.3533823 +CBAR 108 10001 28 31.3583339.8641283.3533823 +CBAR 109 10001 29 33.3583339.8641283.3533823 +CBAR 110 10001 20 31.3583339.8641283.3533823 +CBAR 111 10001 20 30.3583339.8641283.3533823 +CBAR 112 10001 25 33.3583339.8641283.3533823 +CBAR 113 10001 25 32.3583339.8641283.3533823 +$ Property definitions. Note that property cards are only utilized by NastranIO to assign elements to subdomains. +PBAR 10001 1 10.8.3333338.333333 14.0625 +$ pyNastran requires valid material cards for all property cards, but they are not utilized by NastranIO. +MAT1 1 1.85+7 0. .000142 +$ SPC definitions are used by NastranIO only to assign nodes to boundary IDs in libMesh/MAST. The DOF IDs specified +$ in the SPC defition are not utilized by NastranIO. +SPC1 1 123456 1 2 3 4 5 6 + 7 +$ The ENDDATA bulk data entry is not required by pyNastran or NastranIO, but we include it to indicate the end of +$ bulk data input entry. +ENDDATA \ No newline at end of file From 94378b12c38e6740dd810b9ddd69c7171eb090ca Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Fri, 3 Jan 2020 18:09:42 -0500 Subject: [PATCH 034/111] Fixed missing include for libmesh-v1.3.1 compatibility in struct ex 7. --- examples/structural/example_7/example_7.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/structural/example_7/example_7.cpp b/examples/structural/example_7/example_7.cpp index 8489c689..52db1e7d 100644 --- a/examples/structural/example_7/example_7.cpp +++ b/examples/structural/example_7/example_7.cpp @@ -9,6 +9,7 @@ #include #include #include +#include // MAST includes. #include "mesh/nastran_io.h" From 5b61795ad166bbc05e6ff2e2038812f241ef907c Mon Sep 17 00:00:00 2001 From: Manav Bhatia Date: Mon, 13 Jan 2020 21:15:50 -0600 Subject: [PATCH 035/111] fixed the indefinite mass matrix for beam element. Thanks to John Neiferd for identifying the issue. (#54) --- ...solid_1d_section_element_property_card.cpp | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/property_cards/solid_1d_section_element_property_card.cpp b/src/property_cards/solid_1d_section_element_property_card.cpp index b46afd13..635ad658 100644 --- a/src/property_cards/solid_1d_section_element_property_card.cpp +++ b/src/property_cards/solid_1d_section_element_property_card.cpp @@ -928,14 +928,16 @@ InertiaMatrix::operator() (const libMesh::Point& p, m(3,3) = Ip; // rotational velocities - m(0,4) = Ay; m(4,0) = Ay; // w-displacement - m(0,5) = -Az; m(5,0) = -Az; // v-displacement - - // bending rotation inertia - for (unsigned int i=0; i<2; i++) - for (unsigned int j=0; j<2; j++) - m(4+i,4+j) = I(i,j)*1.e-6; - + // theta-y rotation + m(0,4) = Ay; m(4,0) = Ay; + m(4,4) = I(1,1); // I11 is defined about y-y axis for theta-y + + // theta-z rotation + m(0,5) = Az; m(5,0) = Az; + m(5,5) = I(0,0); // I00 is defined about z-z axis for theta-z + + m(4,5) = m(5,4) = I(0,1); + m *= rho; } @@ -972,18 +974,21 @@ InertiaMatrix::derivative ( const MAST::FunctionBase& f, dm(3,3) = dIp; // rotational velocities - m(0,4) = Ay; m(4,0) = Ay; // w-displacement - dm(0,4) = dAy; dm(4,0) = dAy; // w-displacement - m(0,5) = -Az; m(5,0) = -Az; // v-displacement - dm(0,5) = -dAz; m(5,0) = -dAz; // v-displacement - - // bending rotation inertia - for (unsigned int i=0; i<2; i++) - for (unsigned int j=0; j<2; j++) { - m(4+i,4+j) = I(i,j)*1.e-6; - dm(4+i,4+j) = dI(i,j)*1.e-6; - } - + // theta-y rotation + m(0,4) = Ay; m(4,0) = Ay; + m(4,4) = I(1,1); + dm(0,4) = dAy; dm(4,0) = dAy; + dm(4,4) = dI(1,1); + + // theta-z rotation + m(0,5) = Az; m(5,0) = Az; + m(5,5) = I(0,0); + dm(0,5) = dAz; dm(5,0) = dAz; // v-displacement + dm(5,5) = dI(0,0); + + m(4,5) = m(5,4) = I(0,1); + dm(4,5) = dm(5,4) = dI(0,1); + m *= drho; m += rho*dm; } From 6930531dc0c90f3670bd5af86e6a69911cdf83a1 Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Tue, 14 Jan 2020 16:02:04 -0500 Subject: [PATCH 036/111] Re-organized external/contrib source. Reorganized external libfort code into a contrib folder as suggested by Manav in https://github.com/MASTmultiphysics/mast-multiphysics/pull/50 --- CMakeLists.txt | 5 +++++ contrib/CMakeLists.txt | 1 + {src/external => contrib}/README.md | 0 {src/external => contrib/libfort}/CMakeLists.txt | 6 ------ {src/external => contrib/libfort}/fort.c | 0 {src/external => contrib/libfort}/fort.h | 0 {src/external => contrib/libfort}/fort.hpp | 0 examples/structural/example_7/example_7.cpp | 2 +- src/CMakeLists.txt | 9 ++++++++- src/mesh/nastran_io.cpp | 2 +- 10 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 contrib/CMakeLists.txt rename {src/external => contrib}/README.md (100%) rename {src/external => contrib/libfort}/CMakeLists.txt (58%) rename {src/external => contrib/libfort}/fort.c (100%) rename {src/external => contrib/libfort}/fort.h (100%) rename {src/external => contrib/libfort}/fort.hpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f17f773..ef5cad9b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,6 +106,11 @@ if (ENABLE_NASTRANIO) endif() endif() +# THIRD PARTY/CONTRIB +# - This directory contains files developed by third parties and are included in the +# MAST source for convenience. +add_subdirectory(contrib) + # MAIN TARGETS add_subdirectory(src) diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt new file mode 100644 index 00000000..66bad566 --- /dev/null +++ b/contrib/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(libfort) \ No newline at end of file diff --git a/src/external/README.md b/contrib/README.md similarity index 100% rename from src/external/README.md rename to contrib/README.md diff --git a/src/external/CMakeLists.txt b/contrib/libfort/CMakeLists.txt similarity index 58% rename from src/external/CMakeLists.txt rename to contrib/libfort/CMakeLists.txt index c6c3965a..4e1519a1 100644 --- a/src/external/CMakeLists.txt +++ b/contrib/libfort/CMakeLists.txt @@ -1,9 +1,3 @@ -target_sources(mast - PUBLIC - ${CMAKE_CURRENT_LIST_DIR}/fort.c - ${CMAKE_CURRENT_LIST_DIR}/fort.h - ${CMAKE_CURRENT_LIST_DIR}/fort.hpp) - # Install MAST headers for this directory. install(DIRECTORY ./ DESTINATION include/external FILES_MATCHING PATTERN "*.h") diff --git a/src/external/fort.c b/contrib/libfort/fort.c similarity index 100% rename from src/external/fort.c rename to contrib/libfort/fort.c diff --git a/src/external/fort.h b/contrib/libfort/fort.h similarity index 100% rename from src/external/fort.h rename to contrib/libfort/fort.h diff --git a/src/external/fort.hpp b/contrib/libfort/fort.hpp similarity index 100% rename from src/external/fort.hpp rename to contrib/libfort/fort.hpp diff --git a/examples/structural/example_7/example_7.cpp b/examples/structural/example_7/example_7.cpp index 52db1e7d..a764cec9 100644 --- a/examples/structural/example_7/example_7.cpp +++ b/examples/structural/example_7/example_7.cpp @@ -24,7 +24,7 @@ #include "property_cards/isotropic_material_property_card.h" #include "property_cards/solid_1d_section_element_property_card.h" #include "base/eigenproblem_assembly.h" -#include "external/fort.hpp" +#include "libfort/fort.hpp" int main(int argc, const char** argv) { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f19c3a7e..3833d1d9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,6 +10,7 @@ add_library(mast SHARED) # Add include directories. target_include_directories(mast PUBLIC + ${CMAKE_SOURCE_DIR}/contrib ${CMAKE_CURRENT_LIST_DIR} ${MPI_CXX_INCLUDE_PATH} ${PETSc_INCLUDE_DIRS} @@ -48,7 +49,6 @@ add_subdirectory(base) add_subdirectory(boundary_condition) add_subdirectory(coordinates) add_subdirectory(elasticity) -add_subdirectory(external) add_subdirectory(fluid) add_subdirectory(heat_conduction) add_subdirectory(level_set) @@ -67,6 +67,13 @@ add_subdirectory(utility) # code that is using it. (There is a documented limitation with CMake # that prevents this with using add_subdirectory). +# Add third party contrib folder sources. +target_sources(mast + PUBLIC + ${CMAKE_SOURCE_DIR}/contrib/libfort/fort.c + ${CMAKE_SOURCE_DIR}/contrib/libfort/fort.h + ${CMAKE_SOURCE_DIR}/contrib/libfort/fort.hpp) + # MAST library installation. install(TARGETS mast LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/src/mesh/nastran_io.cpp b/src/mesh/nastran_io.cpp index c2591075..1be1f654 100644 --- a/src/mesh/nastran_io.cpp +++ b/src/mesh/nastran_io.cpp @@ -14,7 +14,7 @@ // MAST includes. #include "mesh/nastran_io.h" -#include "external/fort.hpp" +#include "libfort/fort.hpp" MAST::NastranIO::NastranIO(libMesh::MeshBase& mesh, const bool python_preinit): From cdfe27c5d76f6b4ba4324142b90510341f1665a3 Mon Sep 17 00:00:00 2001 From: Josh Deaton Date: Wed, 15 Jan 2020 12:32:26 -0500 Subject: [PATCH 037/111] Fix documentation deployment error due to Travis-CI cache. Refactoring done in commit 65ecace2b9a02a2153c1d75371b0471905048d6b seems to have introduced an error related to the caching step that Travis-CI does. This commit fixes the problem. --- ci/deploy_docs.sh | 9 +++++---- ci/prepare_docs.sh | 25 ++++++++++++++++--------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/ci/deploy_docs.sh b/ci/deploy_docs.sh index c5428fd5..a55f6c97 100755 --- a/ci/deploy_docs.sh +++ b/ci/deploy_docs.sh @@ -3,15 +3,16 @@ # Deploy organized HTML documentation to Github for hosting. # # This script deploys organized HTML documentation produced by `prepare_docs.sh` to a repository in the MAST Team -# GitHub repository for hosting. It is meant to be called during the Travis-CI `deploy` stage and requires the -# GH_TOKEN environment variable be set in the Travis-CI job from an account that can push -# to https://github.com/MASTmultiphysics/MASTmultiphysics.github.io +# GitHub repository for hosting using a simple git push. It is meant to be called during the Travis-CI +# `deploy` stage and requires the GH_TOKEN environment variable be set in the Travis-CI job from +# an account that can push to https://github.com/MASTmultiphysics/MASTmultiphysics.github.io. The GH_TOKEN variable +# is specified in the Travis-CI web interface as a secret variable so it is not displayed publically. # # Contents of this script (and `prepare_docs.sh`) were inspired in part # by https://gist.github.com/willprice/e07efd73fb7f13f917ea. # Set git remote URL. Force push to GitHub website repository. # Update git remote URL to include ${GH_TOKEN} key. Push files back to GitHub website repository. -git remote add origin https://${GH_TOKEN}@github.com/MASTmultiphysics/MASTmultiphysics.github.io.git || exit +cd ${TRAVIS_BUILD_DIR}/website || exit git push --force origin master || exit diff --git a/ci/prepare_docs.sh b/ci/prepare_docs.sh index 6fe968f5..e0242fa9 100755 --- a/ci/prepare_docs.sh +++ b/ci/prepare_docs.sh @@ -1,12 +1,13 @@ #!/usr/bin/env bash -# Prepare/organized Doxygen generated HTML documentation to Github for hosting by `deploy_docs.sh`. +# Prepare/organize Doxygen generated HTML documentation to be hosted on Github. # -# This script organizes the Doxygen generated HTML documentation and commits it to local .git repository. -# Doxygen generated HTML documentation to the MAST Github repository for hosting. This script should be called -# during the Travis-CI 'script' phase after documentation is built so that if an error occurs we can catch it -# on a non-master build (the 'deploy' stage only runs for commits on the `master` branch). We currently call it -# inside of `ci/build_mast.sh` on the worker that satisfies ${CI_BUILD_DOCS}=true. +# This script organizes the Doxygen generated HTML documentation and commits it to a local .git repository. +# This script should be called during the Travis-CI 'script' phase after documentation is built so that +# if an error occurs we can catch it on a non-master build (the 'deploy' stage only runs for commits on the +# `master` branch). We currently call it inside of `ci/build_mast.sh` on the worker that satisfies +# the condition ${CI_BUILD_DOCS}=true. To actually deploy the documentation (after running this script) +# call `ci/deploy_docs.sh`. # # Contents of this script (and `deploy_docs.sh`) were inspired in part by # https://gist.github.com/willprice/e07efd73fb7f13f917ea. @@ -15,8 +16,10 @@ git config --global user.email "travis@travis-ci.org" || exit git config --global user.name "Travis CI" || exit -# Organize website content. First delete all current contents (except .git directory) and then copy generated -# HTML and other desired files. +# Organize website content. First make sure we delete any existing website contents (these may exist from +# a previous Travis-CI cache) and then copy generated HTML and other desired files. +rm -rf ${TRAVIS_BUILD_DIR}/website # Don't `|| exit` here. Its not a failure if this directory doesn't exist when + # we try to delete it. mkdir ${TRAVIS_BUILD_DIR}/website || exit cd ${TRAVIS_BUILD_DIR}/website || exit rsync -r ${TRAVIS_BUILD_DIR}/build_rel/doc/doxygen/html/ . || exit @@ -24,4 +27,8 @@ rsync -r ${TRAVIS_BUILD_DIR}/build_rel/doc/doxygen/html/ . || exit # Initialize empty git repository. Add all files. Commit. git init || exit git add . || exit -git commit --quiet --message "Travis build ${TRAVIS_BUILD_NUMBER}, mast-multiphysics commit ${TRAVIS_COMMIT}" || exit \ No newline at end of file +git commit --quiet --message "Travis build ${TRAVIS_BUILD_NUMBER}, mast-multiphysics commit ${TRAVIS_COMMIT}" || exit + +# Add remote where we will push website to on actual deployment. GH_TOKEN environment variable is set automatically +# in the Travis-CI, but must from an account that can push to https://github.com/MASTmultiphysics/MASTmultiphysics.github.io +git remote add origin https://${GH_TOKEN}@github.com/MASTmultiphysics/MASTmultiphysics.github.io.git || exit \ No newline at end of file From 04f33896eeb827b04a2d1c5c63674e3f8238fd80 Mon Sep 17 00:00:00 2001 From: Manav Bhatia Date: Wed, 29 Jan 2020 18:23:03 -0600 Subject: [PATCH 038/111] Topology optimization with homogenized level set (#58) * -- Added two classes for subelement refinement that look for element intersection with level set boundary and add new elements to the mesh inside each subelement. * -- Bug-fixes for sub element refinement. * -- Modifying the behavior of if_elem_has_positive_phi_region() in level set elem intersection. * -- Bug-fix for stress assembly. * removing commented code from level set nonlinear implicit assembly class. * -- Bug-fixes for sub element refinement. * -- Modified example 5 to use the sub-element refinement class. * -- Added methods to compute topology sensitivity callable from nonlinear implicit assembly. -- Modifications in elem operation classes to support this. * -- Added nanoFlann KD-tree based geometry filter initialization * -- Added iteration counter to function evaluation. * -- Minor fix * -- refactored topology optimization examples by moving each model to an independent file and making the driver functions in the example templated so that the models can be easily switched out. * -- Added reference volume calculation to the topology models. * -- Added structural null-space vector to SIMP topology optimization so that AMG solvers can be used. -- Added problem_type in SIM topology optimization example so that objective/constraint function can be modified using user options. * -- Added null space vector object to level-set topology optimization example -- Added problem_type to level-set topology optimization example. * -- Removed unnecessary output call from FunctionEvaluation::evaluate * Removing errors introduced during merging of master. * Added a dof-constraint for the hanging node created with element intersection. * -- Bug-fix for sub-element hanging node constraint. * -- Added ability to specify element subdomain ids that will be excluded in the global assembly routines. * Added level-set interface point search and normal computation at a point on level-set function. * -- Minor fixes. * -- Added traction shifted boundary condition to all topology optimization examples -- Added method in level-set topology optimization example to mark shifted boundaries for application of traction boundary condition. -- Added traction boundary condition in structural analysis. Currently only implemented for 2D inplane structural analysis. -- Added a shifted boundary application of traction boundary condition. Currently only implemented for 2D inplane structural analysis. -- Added option for computation of second order spatial derivative for side integration. -- Damped the Newton-step for identification of point on shifted boundary. -- Added method in level-set element intersection class to identify the sides of the element on material. -- Bug-fixes in sub-element mesh refinement class. * -- Minor fixes. * -- added methods to compute sensitivity of shifted boundary traction. -- added supporting methods in level-set boundary velocity object and mesh function. * -- Added sensitivity of shifted boundary traction residual for 2D elements. * -- Bug-fix for volume sensitivity in compliance minimization part of example 5 * -- bug-fix * -- Bug-fixes for example 5. * Minor edit in example 5. * Minor fix in structural element 2D. * Added damping factor to boundary point search. * -- Changed Node to Point in plot utility. * The level set boundary point search can lack convergence in regions of high curvature when the searched point moves from one element to another since the gradient of the level-set function can be very different between the two adjacent elements. In this case the point is searched starting from the most recent unconverged point. This is allowed only once. * -- bug-fix for sensitivity of surface normal on level set boundary. * -- bug-fixes in topology optimization examples. * -- Bug-fixes for 2d structural elem. * -- Added methods to remove side and volume loads in physics discipline. * -- Bug-fixes in example 5. * -- Bug-fix in sensitivity of boundary normal computed in level set boundary velocity class -- Added a Hessian approximation in interface point search to improve robustness of point search when the search point ends up in a different element with jump in slope (in regions of high curvature). * -- Added the ability to obtain nearest intersection points on an element based on the intersection computed on an element. * Removing shifted boundary initializations from example 5. * -- Removed _assembly as a member of the ElemBase class. * -- Added classes to compute homogenized element volume fraction from level set function. * added example 7 for homogenized level-set based topology optimization * various bug-fixes for homogenized level-set-based topology optimization. * Fixes for memory errors in example 7. * -- Level-set-based Homogenized volume fraction sensitivity initialization now uses the geometric filter information to improve the computational efficiency. * -- Bug-fix in heaviside function based homogenization -- Modified the element modulus function in example 7 to use a penalty parameter similar to SIMP. * -- Updated example 7 for homogenized level-set-based topology optimization with different penalization of modulus of elasticity for static analysis and stress analysis. -- Updated smoothing width for approximate Heaviside to 0.1. -- Minor fixes for compatibility with libMesh changes to parallel communicator API. * integrating homogenized level-set topology optimization example as example 8 * reintegrated commits lost during rebase. Nastran example is enabled only if NastranIO is enabled. * commiting files missed in previous commit * -- Minor changes to the topology example titles. * adding fix for timpi * -- Bug-fixes for compilation of nastranIO with conditional compilation of mast with pynastran -- Modified upper/lower limit of level-set in example 8 to +/- 10 * removing pynastran_io.cpp and pynastran_io.h from repository since these are created by cython during each compilation. * undoing the previous change of removing the pynastran_io* files in src/mesh. * -- Fixes for backwards compatibility to libMesh. * -- Fix for lib mesh backwards compatibility. * -- More fixes for backwards compatibility. --- CMakeLists.txt | 4 + cmake/FindlibMesh.cmake | 34 +- doc/tutorials.dox | 1 + examples/structural/CMakeLists.txt | 5 +- examples/structural/base/bracket_2d_model.h | 646 ++++ examples/structural/base/eyebar_2d_model.h | 550 +++ examples/structural/base/inplane_2d_model.h | 506 +++ .../structural/base/level_set_nucleation.h | 143 + examples/structural/base/truss_2d_model.h | 547 +++ examples/structural/example_5/example_5.cpp | 1827 +++------- examples/structural/example_6/example_6.cpp | 1151 +----- examples/structural/example_7/CMakeLists.txt | 20 +- examples/structural/example_8/CMakeLists.txt | 16 + examples/structural/example_8/example_8.cpp | 1651 +++++++++ src/CMakeLists.txt | 2 + src/base/assembly_base.cpp | 11 +- src/base/assembly_base.h | 7 + src/base/assembly_elem_operation.cpp | 52 + src/base/assembly_elem_operation.h | 11 + src/base/boundary_condition_base.h | 5 +- .../eigenproblem_assembly_elem_operations.h | 9 + src/base/elem_base.cpp | 2 - src/base/elem_base.h | 13 - src/base/mast_config.h.in | 2 + src/base/mesh_field_function.cpp | 32 + src/base/mesh_field_function.h | 11 +- src/base/nonlinear_implicit_assembly.cpp | 140 +- ...linear_implicit_assembly_elem_operations.h | 9 + src/base/output_assembly_elem_operations.h | 9 + src/base/physics_discipline_base.cpp | 34 + src/base/physics_discipline_base.h | 15 +- src/elasticity/bending_structural_element.cpp | 3 +- src/elasticity/bending_structural_element.h | 1 - src/elasticity/compliance_output.cpp | 42 +- src/elasticity/compliance_output.h | 9 + ...uid_structure_assembly_elem_operations.cpp | 2 +- src/elasticity/smooth_ramp_stress_output.cpp | 1 + src/elasticity/solid_element_3d.cpp | 7 +- src/elasticity/solid_element_3d.h | 50 +- src/elasticity/stress_assembly.cpp | 4 + src/elasticity/stress_output_base.cpp | 30 +- src/elasticity/stress_output_base.h | 10 + ..._buckling_eigenproblem_elem_operations.cpp | 2 +- src/elasticity/structural_element_1d.cpp | 7 +- src/elasticity/structural_element_1d.h | 51 +- src/elasticity/structural_element_2d.cpp | 3127 ++++++++++++----- src/elasticity/structural_element_2d.h | 97 +- src/elasticity/structural_element_base.cpp | 52 +- src/elasticity/structural_element_base.h | 48 +- ...structural_modal_eigenproblem_assembly.cpp | 61 +- .../structural_modal_eigenproblem_assembly.h | 10 + .../structural_nonlinear_assembly.cpp | 45 +- .../structural_nonlinear_assembly.h | 9 + .../structural_transient_assembly.cpp | 2 +- src/fluid/conservative_fluid_element_base.cpp | 21 +- src/fluid/conservative_fluid_element_base.h | 1 - .../conservative_fluid_transient_assembly.cpp | 2 +- ...ncy_domain_linearized_complex_assembly.cpp | 2 +- ...ain_linearized_conservative_fluid_elem.cpp | 7 +- ...omain_linearized_conservative_fluid_elem.h | 1 - src/fluid/integrated_force_output.cpp | 2 +- src/fluid/integrated_force_output.h | 11 + .../heat_conduction_elem_base.cpp | 27 +- .../heat_conduction_elem_base.h | 1 - .../heat_conduction_nonlinear_assembly.cpp | 38 +- .../heat_conduction_nonlinear_assembly.h | 9 + .../heat_conduction_transient_assembly.cpp | 2 +- src/level_set/CMakeLists.txt | 12 +- src/level_set/filter_base.cpp | 227 +- src/level_set/filter_base.h | 1 + ...heaviside_elem_homogenization_function.cpp | 175 + .../heaviside_elem_homogenization_function.h | 58 + .../homogenized_density_function_base.cpp | 131 + .../homogenized_density_function_base.h | 102 + ...tersected_elem_homogenization_function.cpp | 118 + ...intersected_elem_homogenization_function.h | 58 + src/level_set/level_set_boundary_velocity.cpp | 355 +- src/level_set/level_set_boundary_velocity.h | 66 +- src/level_set/level_set_elem_base.cpp | 83 +- src/level_set/level_set_elem_base.h | 23 +- src/level_set/level_set_intersected_elem.cpp | 4 +- src/level_set/level_set_intersected_elem.h | 1 + src/level_set/level_set_intersection.cpp | 180 +- src/level_set/level_set_intersection.h | 62 +- .../level_set_nonlinear_implicit_assembly.h | 20 - src/level_set/level_set_perimeter_output.cpp | 25 +- src/level_set/level_set_perimeter_output.h | 19 +- .../level_set_transient_assembly.cpp | 2 +- src/level_set/level_set_volume_output.cpp | 14 +- src/level_set/level_set_volume_output.h | 15 +- src/level_set/sub_cell_fe.cpp | 1 + src/level_set/sub_elem_mesh_refinement.cpp | 727 ++++ src/level_set/sub_elem_mesh_refinement.h | 122 + src/level_set/sub_elem_node_map.cpp | 59 + src/level_set/sub_elem_node_map.h | 89 + src/mesh/fe_base.h | 2 + src/mesh/geom_elem.cpp | 4 +- src/mesh/geom_elem.h | 1 + src/mesh/nastran_io.cpp | 4 + src/mesh/nastran_io.h | 4 + src/optimization/function_evaluation.cpp | 8 +- src/optimization/function_evaluation.h | 3 + .../first_order_newmark_transient_solver.cpp | 9 + .../first_order_newmark_transient_solver.h | 9 + .../second_order_newmark_transient_solver.cpp | 9 + .../second_order_newmark_transient_solver.h | 8 + ...first_order_transient_sensitivity_solver.h | 7 + src/utility/plot.cpp | 6 +- src/utility/plot.h | 2 +- tests/fluid/base/fluid_elem_initialization.h | 1 - 110 files changed, 10665 insertions(+), 3420 deletions(-) create mode 100644 examples/structural/base/bracket_2d_model.h create mode 100644 examples/structural/base/eyebar_2d_model.h create mode 100644 examples/structural/base/inplane_2d_model.h create mode 100644 examples/structural/base/level_set_nucleation.h create mode 100644 examples/structural/base/truss_2d_model.h create mode 100644 examples/structural/example_8/CMakeLists.txt create mode 100644 examples/structural/example_8/example_8.cpp create mode 100644 src/level_set/heaviside_elem_homogenization_function.cpp create mode 100644 src/level_set/heaviside_elem_homogenization_function.h create mode 100644 src/level_set/homogenized_density_function_base.cpp create mode 100644 src/level_set/homogenized_density_function_base.h create mode 100644 src/level_set/intersected_elem_homogenization_function.cpp create mode 100644 src/level_set/intersected_elem_homogenization_function.h create mode 100644 src/level_set/sub_elem_mesh_refinement.cpp create mode 100644 src/level_set/sub_elem_mesh_refinement.h create mode 100644 src/level_set/sub_elem_node_map.cpp create mode 100644 src/level_set/sub_elem_node_map.h diff --git a/CMakeLists.txt b/CMakeLists.txt index ef5cad9b..1993421c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,6 +104,10 @@ if (ENABLE_NASTRANIO) else() message(STATUS " Numpy package found") endif() + + set (MAST_ENABLE_NASTRANIO 1) +else() + set (MAST_ENABLE_NASTRANIO 0) endif() # THIRD PARTY/CONTRIB diff --git a/cmake/FindlibMesh.cmake b/cmake/FindlibMesh.cmake index 9ffa67b3..1f6e1db1 100644 --- a/cmake/FindlibMesh.cmake +++ b/cmake/FindlibMesh.cmake @@ -19,12 +19,35 @@ find_library(libMesh_dbg_LIBRARY NAMES mesh_dbg HINTS ${libMesh_DIR}/lib) +find_library(timpi_opt_LIBRARY + NAMES timpi_opt + HINTS ${libMesh_DIR}/lib) + +find_library(timpi_dbg_LIBRARY + NAMES timpi_dbg + HINTS ${libMesh_DIR}/lib) + +if (NOT timpi_opt_LIBRARY) + find_library(timpi_opt_LIBRARY + NAMES mesh_opt + HINTS ${libMesh_DIR}/lib) +endif() + +if (NOT timpi_dbg_LIBRARY) + find_library(timpi_dbg_LIBRARY + NAMES mesh_dbg + HINTS ${libMesh_DIR}/lib) +endif() + # If debug library is not available then set it to the optimized library if(NOT libMesh_dbg_LIBRARY) message("-- WARN: Did not find libmesh_dbg using libmesh_opt for debug version.") find_library(libMesh_dbg_LIBRARY NAMES mesh_opt HINTS ${libMesh_DIR}/lib) + find_library(timpi_dbg_LIBRARY + NAMES timpi_opt + HINTS ${libMesh_DIR}/lib) endif() @@ -52,15 +75,24 @@ endif() # Set variables. include(FindPackageHandleStandardArgs) find_package_handle_standard_args(libMesh - REQUIRED_VARS libMesh_dbg_LIBRARY libMesh_opt_LIBRARY libMesh_INCLUDE_DIR + REQUIRED_VARS + libMesh_dbg_LIBRARY + libMesh_opt_LIBRARY + timpi_dbg_LIBRARY + timpi_opt_LIBRARY + libMesh_INCLUDE_DIR VERSION_VAR libMesh_VERSION) mark_as_advanced(libMesh_INCLUDE_DIR libMesh_dbg_LIBRARY libMesh_opt_LIBRARY + timpi_dbg_LIBRARY + timpi_opt_LIBRARY libMesh_VERSION libMesh_FOUND) set(libMesh_dbg_LIBRARIES ${libMesh_dbg_LIBRARY}) set(libMesh_opt_LIBRARIES ${libMesh_opt_LIBRARY}) +set(timpi_dbg_LIBRARIES ${timpi_dbg_LIBRARY}) +set(timpi_opt_LIBRARIES ${timpi_opt_LIBRARY}) set(libMesh_INCLUDE_DIRS ${libMesh_INCLUDE_DIR}) diff --git a/doc/tutorials.dox b/doc/tutorials.dox index 634b55da..5a4756ad 100644 --- a/doc/tutorials.dox +++ b/doc/tutorials.dox @@ -12,6 +12,7 @@ - \subpage structural_example_4 - \subpage structural_example_5 - \subpage structural_example_6 + - \subpage structural_example_8 - \subpage structural_example_7 - \subpage fluid_example_1 - \subpage fsi_example_1 diff --git a/examples/structural/CMakeLists.txt b/examples/structural/CMakeLists.txt index e00b0049..ece23aa2 100644 --- a/examples/structural/CMakeLists.txt +++ b/examples/structural/CMakeLists.txt @@ -2,6 +2,7 @@ add_subdirectory(example_1) # bar extension add_subdirectory(example_2) # continuation solver add_subdirectory(example_3) # thermoelastic plate bending add_subdirectory(example_4) # tie-constraints -add_subdirectory(example_5) # 2D topology optimization -add_subdirectory(example_6) # 2D SIMP topology optimization +add_subdirectory(example_5) # topology optimization +add_subdirectory(example_6) # SIMP topology optimization add_subdirectory(example_7) # NastranIO input for Nastran BDF mesh +add_subdirectory(example_8) # Homogenized level-set topology optimization diff --git a/examples/structural/base/bracket_2d_model.h b/examples/structural/base/bracket_2d_model.h new file mode 100644 index 00000000..42df44c5 --- /dev/null +++ b/examples/structural/base/bracket_2d_model.h @@ -0,0 +1,646 @@ +/* + * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit + * Copyright (C) 2013-2019 Manav Bhatia + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __mast_topology_2d_bracket_model__ +#define __mast_topology_2d_bracket_model__ + +// MAST includes +#include "base/mast_data_types.h" +#include "examples/base/input_wrapper.h" +#include "examples/structural/base/level_set_nucleation.h" +#include "base/boundary_condition_base.h" +#include "base/field_function_base.h" +#include "base/physics_discipline_base.h" +#include "boundary_condition/dirichlet_boundary_condition.h" +#include "level_set/level_set_parameter.h" + +// libMesh includes +#include "libmesh/system.h" +#include "libmesh/unstructured_mesh.h" +#include "libmesh/fe_type.h" +#include "libmesh/string_to_enum.h" +#include "libmesh/mesh_generation.h" +#include "libmesh/elem.h" +#include "libmesh/node.h" + + + +namespace MAST { + +// Forward declerations +class DisciplineBase; +class BoundaryConditionBase; +class FunctionBase; +class Parameter; + +namespace Examples { +struct Bracket2DModel { + + template + static Real reference_volume(Opt& opt); + + template + static void init_analysis_mesh(Opt& opt, libMesh::UnstructuredMesh& mesh); + + template + static void init_level_set_mesh(Opt& opt, libMesh::UnstructuredMesh& mesh); + + template + static void init_analysis_dirichlet_conditions(Opt& opt); + + template + static void init_indicator_dirichlet_conditions(Opt& opt); + + template + static void init_structural_loads(Opt& opt); + + template + static MAST::BoundaryConditionBase& + init_structural_shifted_boudnary_load(Opt& opt, unsigned int bid); + + template + static void init_indicator_loads(Opt& opt); + + template + static void init_level_set_dvs(Opt& opt); + + template + static void initialize_level_set_solution(Opt& opt); + + template + static void init_simp_dvs(Opt& opt); + + template + static void _delete_elems_from_bracket_mesh(Opt& opt, libMesh::MeshBase &mesh); + + class BracketLoad: + public MAST::FieldFunction { + public: + BracketLoad(const std::string& nm, Real p, Real l1, Real fraction): + MAST::FieldFunction(nm), _p(p), _l1(l1), _frac(fraction) { } + ~BracketLoad() {} + void operator() (const libMesh::Point& p, const Real t, Real& v) const { + if (fabs(p(0) >= _l1*(1.-_frac))) v = _p; + else v = 0.; + } + void derivative(const MAST::FunctionBase& f, const libMesh::Point& p, const Real t, Real& v) const { + v = 0.; + } + protected: + Real _p, _l1, _frac; + }; +}; + +} +} + + +template +Real +MAST::Examples::Bracket2DModel:: +reference_volume(Opt& opt) { + + Real + length = opt._input("length", "length of domain along x-axis", 0.3), + height = opt._input("height", "length of domain along y-axis", 0.3); + + return length * height; +} + + + +template +void +MAST::Examples::Bracket2DModel:: +init_analysis_mesh(Opt& opt, + libMesh::UnstructuredMesh& mesh) { + + Real + length = opt._input("length", "length of domain along x-axis", 0.3), + height = opt._input("height", "length of domain along y-axis", 0.3); + + unsigned int + nx_divs = opt._input("nx_divs", "number of elements along x-axis", 20), + ny_divs = opt._input("ny_divs", "number of elements along y-axis", 20); + + if (nx_divs%10 != 0 || ny_divs%10 != 0) libmesh_error(); + + std::string + t = opt._input("elem_type", "type of geometric element in the mesh", "quad4"); + + libMesh::ElemType + e_type = libMesh::Utility::string_to_enum(t); + + // + // if high order FE is used, libMesh requires atleast a second order + // geometric element. + // + if (opt._fetype.order > 1 && e_type == libMesh::QUAD4) + e_type = libMesh::QUAD9; + else if (opt._fetype.order > 1 && e_type == libMesh::TRI3) + e_type = libMesh::TRI6; + + // + // initialize the mesh with one element + // + libMesh::MeshTools::Generation::build_square(mesh, + nx_divs, ny_divs, + 0, length, + 0, height, + e_type); + + _delete_elems_from_bracket_mesh(opt, mesh); +} + + +template +void +MAST::Examples::Bracket2DModel:: +init_level_set_mesh(Opt& opt, + libMesh::UnstructuredMesh& mesh) { + + Real + length = opt._input("length", "length of domain along x-axis", 0.3), + height = opt._input("height", "length of domain along y-axis", 0.3); + + unsigned int + nx_divs = opt._input("level_set_nx_divs", "number of elements of level-set mesh along x-axis", 10), + ny_divs = opt._input("level_set_ny_divs", "number of elements of level-set mesh along y-axis", 10); + + if (nx_divs%10 != 0 || ny_divs%10 != 0) libmesh_error(); + + libMesh::ElemType + e_type = libMesh::QUAD4; + + // initialize the mesh with one element + libMesh::MeshTools::Generation::build_square(mesh, + nx_divs, ny_divs, + 0, length, + 0, height, + e_type); + + _delete_elems_from_bracket_mesh(opt, mesh); +} + + + +template +void +MAST::Examples::Bracket2DModel:: +init_analysis_dirichlet_conditions(Opt& opt) { + + MAST::DirichletBoundaryCondition + *dirichlet = new MAST::DirichletBoundaryCondition; // bottom boundary + dirichlet->init(0, opt._sys_init->vars()); + opt._discipline->add_dirichlet_bc(0, *dirichlet); + opt._boundary_conditions.insert(dirichlet); + + opt._discipline->init_system_dirichlet_bc(*opt._sys); +} + + + +template +void +MAST::Examples::Bracket2DModel:: +init_indicator_dirichlet_conditions(Opt& opt) { + + MAST::DirichletBoundaryCondition + *dirichlet = new MAST::DirichletBoundaryCondition; // bottom boundary + dirichlet->init(0, opt._indicator_sys_init->vars()); + opt._indicator_discipline->add_dirichlet_bc(0, *dirichlet); + opt._boundary_conditions.insert(dirichlet); + + opt._indicator_discipline->init_system_dirichlet_bc(*opt._indicator_sys); + opt._dirichlet_bc_ids.insert(0); +} + + + +template +void +MAST::Examples::Bracket2DModel::init_structural_loads(Opt& opt) { + + Real + length = opt._input("length", "length of domain along x-axis", 0.3), + frac = opt._input("loadlength_fraction", "fraction of boundary length on which pressure will act", 0.125), + p_val = opt._input("pressure", "pressure on side of domain", 5.e7); + + BracketLoad + *press_f = new BracketLoad( "pressure", p_val, length, frac); + + // + // initialize the load + // + MAST::BoundaryConditionBase + *p_load = new MAST::BoundaryConditionBase(MAST::SURFACE_PRESSURE); + + p_load->add(*press_f); + opt._discipline->add_side_load(5, *p_load); + opt._boundary_conditions.insert(p_load); + + opt._field_functions.insert(press_f); +} + + +template +MAST::BoundaryConditionBase& +MAST::Examples::Bracket2DModel::init_structural_shifted_boudnary_load(Opt& opt, + unsigned int bid) { + + class ZeroTraction: public MAST::FieldFunction { + public: + ZeroTraction(): MAST::FieldFunction("traction") {} + virtual ~ZeroTraction() {} + virtual void operator() (const libMesh::Point& pt, const Real t, RealVectorX& v) const {v.setZero(3);} + virtual void derivative(const MAST::FunctionBase& f, const libMesh::Point& pt, const Real t, RealVectorX& v) const + {v.setZero(3);} + }; + + ZeroTraction + *trac_f = new ZeroTraction; + + MAST::BoundaryConditionBase + *load = new MAST::BoundaryConditionBase(MAST::SURFACE_TRACTION_SHIFTED_BOUNDARY); + + load->add(*opt._level_set_vel); + load->add(*trac_f); + opt._discipline->add_side_load(bid, *load); + opt._boundary_conditions.insert(load); + + opt._field_functions.insert(trac_f); + return *load; +} + + +template +void +MAST::Examples::Bracket2DModel::init_indicator_loads(Opt& opt) { + + Real + length = opt._input("length", "length of domain along x-axis", 0.3), + frac = opt._input("loadlength_fraction", "fraction of boundary length on which pressure will act", 0.125); + + BracketLoad + *flux_f = new BracketLoad("heat_flux", -2.e6, length, frac); + + // + // initialize the load + // + MAST::BoundaryConditionBase + *f_load = new MAST::BoundaryConditionBase(MAST::HEAT_FLUX); + + f_load->add(*flux_f); + opt._indicator_discipline->add_side_load(5, *f_load); + opt._boundary_conditions.insert(f_load); + + opt._field_functions.insert(flux_f); +} + + + +template +void +MAST::Examples::Bracket2DModel::init_level_set_dvs(Opt& opt) { + + libmesh_assert(opt._initialized); + // + // this assumes that level set is defined using lagrange shape functions + // + libmesh_assert_equal_to(opt._level_set_fetype.family, libMesh::LAGRANGE); + + Real + tol = 1.e-12, + l_frac = 0.4,//_input("length_fraction", "fraction of length along x-axis that is in the bracket", 0.4), + h_frac = 0.4,//_input( "height_fraction", "fraction of length along y-axis that is in the bracket", 0.4), + length = opt._input("length", "length of domain along x-axis", 0.3), + height = opt._input("height", "length of domain along y-axis", 0.3), + x_lim = length * l_frac, + y_lim = height * (1.-h_frac), + frac = opt._input("loadlength_fraction", "fraction of boundary length on which pressure will act", 0.125), + filter_radius = opt._input("filter_radius", "radius of geometric filter for level set field", 0.015); + + unsigned int + dof_id = 0, + n_vars = 0; + + Real + val = 0.; + + // + // all ranks will have DVs defined for all variables. So, we should be + // operating on a replicated mesh + // + libmesh_assert(opt._level_set_mesh->is_replicated()); + + std::vector local_phi(opt._level_set_sys->solution->size()); + opt._level_set_sys->solution->localize(local_phi); + + // + // iterate over all the node values + // + libMesh::MeshBase::const_node_iterator + it = opt._level_set_mesh->nodes_begin(), + end = opt._level_set_mesh->nodes_end(); + + // + // maximum number of dvs is the number of nodes on the level set function + // mesh. We will evaluate the actual number of dvs + // + opt._dv_params.reserve(opt._level_set_mesh->n_nodes()); + n_vars = 0; + + for ( ; it!=end; it++) { + + const libMesh::Node& n = **it; + + dof_id = n.dof_number(0, 0, 0); + + if ((n(1)-filter_radius) <= y_lim && + (n(0)+filter_radius) >= length*(1.-frac)) { + + // + // set value at the constrained points to a small positive number + // material here + // + if (dof_id >= opt._level_set_sys->solution->first_local_index() && + dof_id < opt._level_set_sys->solution->last_local_index()) + opt._level_set_sys->solution->set(dof_id, 1.e0); + } + else { + + std::ostringstream oss; + oss << "dv_" << n_vars; + val = local_phi[dof_id]; + + // + // on the boundary, set everything to be zero, so that there + // is always a boundary there that the optimizer can move + // + if (n(0) < tol || // left boundary + std::fabs(n(0) - length) < tol || // right boundary + std::fabs(n(1) - height) < tol || // top boundary + (n(0) >= x_lim && n(1) <= y_lim)) { + + if (dof_id >= opt._level_set_sys->solution->first_local_index() && + dof_id < opt._level_set_sys->solution->last_local_index()) + opt._level_set_sys->solution->set(dof_id, -1.0); + val = -1.0; + } + + opt._dv_params.push_back(std::pair()); + opt._dv_params[n_vars].first = dof_id; + opt._dv_params[n_vars].second = new MAST::LevelSetParameter(oss.str(), val, &n); + opt._dv_params[n_vars].second->set_as_topology_parameter(true); + opt._dv_dof_ids.insert(dof_id); + + n_vars++; + } + } + + opt.set_n_vars(n_vars); + + opt._level_set_sys->solution->close(); +} + + +template +void +MAST::Examples::Bracket2DModel::init_simp_dvs(Opt& opt) { + + libmesh_assert(opt._initialized); + + // + // this assumes that density variable has a constant value per element + // + libmesh_assert_equal_to(opt._density_fetype.family, libMesh::LAGRANGE); + + Real + tol = 1.e-12, + l_frac = 0.4,//_input("length_fraction", "fraction of length along x-axis that is in the bracket", 0.4), + h_frac = 0.4,//_input( "height_fraction", "fraction of length along y-axis that is in the bracket", 0.4), + length = opt._input("length", "length of domain along x-axis", 0.3), + height = opt._input("height", "length of domain along y-axis", 0.3), + x_lim = length * l_frac, + y_lim = height * (1.-h_frac), + frac = opt._input("loadlength_fraction", "fraction of boundary length on which pressure will act", 0.125), + filter_radius = opt._input("filter_radius", "radius of geometric filter for level set field", 0.015); + + unsigned int + sys_num = opt._density_sys->number(), + dof_id = 0, + n_vars = 0; + + Real + val = 0.; + + // + // all ranks will have DVs defined for all variables. So, we should be + // operating on a replicated mesh + // + libmesh_assert(opt._mesh->is_replicated()); + + std::vector local_phi(opt._density_sys->solution->size()); + opt._density_sys->solution->localize(local_phi); + + // iterate over all the element values + libMesh::MeshBase::const_node_iterator + it = opt._mesh->nodes_begin(), + end = opt._mesh->nodes_end(); + + // + // maximum number of dvs is the number of nodes on the level set function + // mesh. We will evaluate the actual number of dvs + // + opt._dv_params.reserve(opt._mesh->n_elem()); + + for ( ; it!=end; it++) { + + const libMesh::Node& n = **it; + + dof_id = n.dof_number(sys_num, 0, 0); + + if ((n(1)-filter_radius) <= y_lim && (n(0)+filter_radius) >= length*(1.-frac)) { + + // + // set value at the constrained points to a small positive number + // material here + // + if (dof_id >= opt._density_sys->solution->first_local_index() && + dof_id < opt._density_sys->solution->last_local_index()) + opt._density_sys->solution->set(dof_id, 1.e0); + } + else { + + std::ostringstream oss; + oss << "dv_" << n_vars; + val = local_phi[dof_id]; + + // + // on the boundary, set everything to be zero, so that there + // is always a boundary there that the optimizer can move + // + if (n(0) < tol || // left boundary + std::fabs(n(0) - length) < tol || // right boundary + std::fabs(n(1) - height) < tol || // top boundary + (n(0) >= x_lim && n(1) <= y_lim)) { + + if (dof_id >= opt._density_sys->solution->first_local_index() && + dof_id < opt._density_sys->solution->last_local_index()) + opt._density_sys->solution->set(dof_id, opt._rho_min); + val = opt._rho_min; + } + + opt._dv_params.push_back(std::pair()); + opt._dv_params[n_vars].first = dof_id; + opt._dv_params[n_vars].second = new MAST::LevelSetParameter(oss.str(), val, &n); + opt._dv_params[n_vars].second->set_as_topology_parameter(true); + opt._dv_dof_ids.insert(dof_id); + + n_vars++; + } + } + + opt.set_n_vars(n_vars); + opt._density_sys->solution->close(); + +} + + + +template +void +MAST::Examples::Bracket2DModel:: +_delete_elems_from_bracket_mesh(Opt& opt, + libMesh::MeshBase &mesh) { + + Real + tol = 1.e-12, + x = -1., + y = -1., + l_frac = 0.4, + w_frac = 0.4, + length = opt._input("length", "length of domain along x-axis", 0.3), + height = opt._input("height", "length of domain along y-axis", 0.3), + x_lim = length * l_frac, + y_lim = height * (1.-w_frac); + + // + // now, remove elements that are outside of the L-bracket domain + // + libMesh::MeshBase::element_iterator + e_it = mesh.elements_begin(), + e_end = mesh.elements_end(); + + for ( ; e_it!=e_end; e_it++) { + + libMesh::Elem* elem = *e_it; + x = length; + y = 0.; + for (unsigned int i=0; in_nodes(); i++) { + const libMesh::Node& n = elem->node_ref(i); + if (x > n(0)) x = n(0); + if (y < n(1)) y = n(1); + } + + // + // delete element if the lowest x,y locations are outside of the bracket + // domain + // + if (x >= x_lim && y<= y_lim) + mesh.delete_elem(elem); + } + + mesh.prepare_for_use(); + + // + // add the two additional boundaries to the boundary info so that + // we can apply loads on them + // + bool + facing_right = false, + facing_down = false; + + e_it = mesh.elements_begin(); + e_end = mesh.elements_end(); + + for ( ; e_it != e_end; e_it++) { + + libMesh::Elem* elem = *e_it; + + if (!elem->on_boundary()) continue; + + for (unsigned int i=0; in_sides(); i++) { + + if (elem->neighbor_ptr(i)) continue; + + std::unique_ptr s(elem->side_ptr(i).release()); + + const libMesh::Point p = s->centroid(); + + facing_right = true; + facing_down = true; + for (unsigned int j=0; jn_nodes(); j++) { + const libMesh::Node& n = s->node_ref(j); + + if (n(0) < x_lim || n(1) > y_lim) { + facing_right = false; + facing_down = false; + } + else if (std::fabs(n(0) - p(0)) > tol) + facing_right = false; + else if (std::fabs(n(1) - p(1)) > tol) + facing_down = false; + } + + if (facing_right) mesh.boundary_info->add_side(elem, i, 4); + if (facing_down) mesh.boundary_info->add_side(elem, i, 5); + } + } + + mesh.boundary_info->sideset_name(4) = "facing_right"; + mesh.boundary_info->sideset_name(5) = "facing_down"; +} + + + +template +void +MAST::Examples::Bracket2DModel::initialize_level_set_solution(Opt& opt) { + + Real + length = opt._input("length", "length of domain along x-axis", 0.3), + height = opt._input("height", "length of domain along y-axis", 0.3); + + unsigned int + nx_h = opt._input("initial_level_set_n_holes_in_x", + "number of holes along x-direction for initial level-set field", 6), + ny_h = opt._input("initial_level_set_n_holes_in_y", + "number of holes along y-direction for initial level-set field", 6), + nx_m = opt._input("level_set_nx_divs", "number of elements of level-set mesh along x-axis", 10), + ny_m = opt._input("level_set_ny_divs", "number of elements of level-set mesh along y-axis", 10); + + MAST::Examples::LevelSetNucleationFunction + phi(0., 0., length, height, nx_m, ny_m, nx_h, ny_h); + + opt._level_set_sys_init->initialize_solution(phi); +} + + +#endif // __mast_topology_2d_bracket_model__ diff --git a/examples/structural/base/eyebar_2d_model.h b/examples/structural/base/eyebar_2d_model.h new file mode 100644 index 00000000..9c602a6e --- /dev/null +++ b/examples/structural/base/eyebar_2d_model.h @@ -0,0 +1,550 @@ +/* + * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit + * Copyright (C) 2013-2019 Manav Bhatia + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __mast_topology_2d_eyebar_model__ +#define __mast_topology_2d_eyebar_model__ + +// MAST includes +#include "base/mast_data_types.h" +#include "base/boundary_condition_base.h" +#include "base/field_function_base.h" +#include "base/physics_discipline_base.h" +#include "examples/base/input_wrapper.h" +#include "examples/structural/base/level_set_nucleation.h" +#include "examples/fluid/meshing/cylinder.h" +#include "boundary_condition/dirichlet_boundary_condition.h" +#include "level_set/level_set_parameter.h" + +// libMesh includes +#include "libmesh/system.h" +#include "libmesh/unstructured_mesh.h" +#include "libmesh/fe_type.h" +#include "libmesh/string_to_enum.h" +#include "libmesh/mesh_generation.h" +#include "libmesh/elem.h" +#include "libmesh/node.h" + + + + +namespace MAST { + +// Forward declerations +class DisciplineBase; +class BoundaryConditionBase; +class FunctionBase; +class Parameter; + +namespace Examples { + +struct Eyebar2DModel { + + template + static Real reference_volume(Opt& opt); + + template + static void init_analysis_mesh(Opt& opt, libMesh::UnstructuredMesh& mesh); + + template + static void init_level_set_mesh(Opt& opt, libMesh::UnstructuredMesh& mesh); + + template + static void + init_analysis_dirichlet_conditions(Opt& opt); + + template + static void + init_indicator_dirichlet_conditions(Opt& opt); + + + template + static MAST::BoundaryConditionBase& + init_structural_shifted_boudnary_load(Opt& opt, unsigned int bid); + + template + static void + init_structural_loads(Opt& opt); + + template + static void + init_indicator_loads(Opt& opt); + + template + static void + init_level_set_dvs(Opt& opt); + + template + static void + initialize_level_set_solution(Opt& opt); + + template + static void + init_simp_dvs(Opt& opt); + + class EyebarLoad: + public MAST::FieldFunction { + public: + EyebarLoad(): + MAST::FieldFunction("pressure") { } + ~EyebarLoad() {} + void operator() (const libMesh::Point& p, const Real t, Real& v) const { + if (p(0) <= 0.) v = (-std::pow(p(1), 2) + std::pow(1.5, 2))*1.e6; + else v = 0.; + } + void derivative(const MAST::FunctionBase& f, const libMesh::Point& p, const Real t, Real& v) const { + v = 0.; + } + }; +}; + +} +} + + +template +Real +MAST::Examples::Eyebar2DModel:: +reference_volume(Opt& opt) { + + return 16.*8. - acos(-1.) * 1.5*1.5; +} + + + + +template +void +MAST::Examples::Eyebar2DModel:: +init_analysis_mesh(Opt& opt, libMesh::UnstructuredMesh& mesh) { + + // + // identify the element type from the input file or from the order + // of the element + // + unsigned int + n_radial_divs = opt._input("n_radial_divs", "number of elements along radial direction", 20), + n_quarter_divs = opt._input("n_quarter_divs", "number of elements along height", 20); + + Real + //length = 16., + height = 8., + radius = 1.5, + h_ratio = opt._input("h_ratio", "ratio of radial element size at cylinder and at edge", 2); + + std::string + t = opt._input("elem_type", "type of geometric element in the mesh", "quad4"); + + libMesh::ElemType + e_type = libMesh::Utility::string_to_enum(t); + + // + // if high order FE is used, libMesh requires atleast a second order + // geometric element. + // + if (opt._fetype.order > 1 && e_type == libMesh::QUAD4) + e_type = libMesh::QUAD9; + else if (opt._fetype.order > 1 && e_type == libMesh::TRI3) + e_type = libMesh::TRI6; + + MAST::Examples::CylinderMesh2D cylinder; + cylinder.mesh(radius, height/2., + n_radial_divs, n_quarter_divs, h_ratio, + mesh, e_type, + true, height, n_quarter_divs*2); + + // + // add the boundary ids for Dirichlet conditions + // + libMesh::MeshBase::const_element_iterator + e_it = mesh.elements_begin(), + e_end = mesh.elements_end(); + + Real + tol = radius * 1.e-8; + + for (; e_it != e_end; e_it++) { + + libMesh::Elem* elem = *e_it; + + std::unique_ptr edge(elem->side_ptr(1)); + libMesh::Point p = edge->centroid(); + + if (std::fabs(p(0)-height*1.5) < tol && + std::fabs(p(1)) <= 1.) // on the right edge + mesh.boundary_info->add_side(elem, 1, 0); + + // check for the circumference of the circle where load will be + // applied + edge.reset(elem->side_ptr(3).release()); + p = edge->centroid(); + + if ((std::fabs(p.norm()-radius) < 1.e-2) && + p(0) < 0.) // left semi-circle + mesh.boundary_info->add_side(elem, 3, 5); + } + + mesh.boundary_info->sideset_name(0) = "dirichlet"; + mesh.boundary_info->sideset_name(5) = "load"; + + +} + + +template +void +MAST::Examples::Eyebar2DModel:: +init_level_set_mesh(Opt& opt, libMesh::UnstructuredMesh& mesh) { + + Real + //length = 16., + height = 8., + radius = 1.5, + h_ratio = opt._input("h_ratio", "ratio of radial element size at cylinder and at edge", 2); + + unsigned int + n_radial_divs = opt._input("level_set_n_radial_divs", "number of elements along radial direction", 10), + n_quarter_divs = opt._input("level_set_n_quarter_divs", "number of elements along height", 10); + + libMesh::ElemType + e_type = libMesh::QUAD4; + + MAST::Examples::CylinderMesh2D cylinder; + cylinder.mesh(radius, height/2, + n_radial_divs, n_quarter_divs, h_ratio, + mesh, e_type, + true, height, n_quarter_divs*2); +} + + + +template +void +MAST::Examples::Eyebar2DModel::init_analysis_dirichlet_conditions(Opt& opt) { + + MAST::DirichletBoundaryCondition + *dirichlet = new MAST::DirichletBoundaryCondition; // right boundary + dirichlet->init(0, opt._sys_init->vars()); + opt._discipline->add_dirichlet_bc(0, *dirichlet); + opt._boundary_conditions.insert(dirichlet); + + opt._discipline->init_system_dirichlet_bc(*opt._sys); + opt._dirichlet_bc_ids.insert(0); +} + + + +template +void +MAST::Examples::Eyebar2DModel::init_indicator_dirichlet_conditions(Opt& opt) { + + MAST::DirichletBoundaryCondition + *dirichlet = new MAST::DirichletBoundaryCondition; // right boundary + dirichlet->init(0, opt._indicator_sys_init->vars()); + opt._indicator_discipline->add_dirichlet_bc(0, *dirichlet); + opt._boundary_conditions.insert(dirichlet); + + opt._indicator_discipline->init_system_dirichlet_bc(*opt._indicator_sys); +} + + + + +template +MAST::BoundaryConditionBase& +MAST::Examples::Eyebar2DModel::init_structural_shifted_boudnary_load(Opt& opt, + unsigned int bid) { + + class ZeroTraction: public MAST::FieldFunction { + public: + ZeroTraction(): MAST::FieldFunction("traction") {} + virtual ~ZeroTraction() {} + virtual void operator() (const libMesh::Point& pt, const Real t, RealVectorX& v) const + {v.setZero(3);} + virtual void derivative(const MAST::FunctionBase& f, const libMesh::Point& pt, const Real t, RealVectorX& v) const + {v.setZero(3);} + }; + + ZeroTraction + *trac_f = new ZeroTraction; + + MAST::BoundaryConditionBase + *load = new MAST::BoundaryConditionBase(MAST::SURFACE_TRACTION_SHIFTED_BOUNDARY); + + load->add(*opt._level_set_vel); + load->add(*trac_f); + opt._discipline->add_side_load(bid, *load); + opt._boundary_conditions.insert(load); + + opt._field_functions.insert(trac_f); + return *load; +} + + +template +void +MAST::Examples::Eyebar2DModel::init_structural_loads(Opt& opt) { + + EyebarLoad + *press_f = new EyebarLoad(); + + // initialize the load + MAST::BoundaryConditionBase + *p_load = new MAST::BoundaryConditionBase(MAST::SURFACE_PRESSURE); + + p_load->add(*press_f); + opt._discipline->add_side_load(5, *p_load); + opt._boundary_conditions.insert(p_load); + + opt._field_functions.insert(press_f); +} + + +template +void +MAST::Examples::Eyebar2DModel::init_indicator_loads(Opt& opt) { + +} + + + +template +void +MAST::Examples::Eyebar2DModel::init_level_set_dvs(Opt& opt) { + + libmesh_assert(opt._initialized); + // + // this assumes that level set is defined using lagrange shape functions + // + libmesh_assert_equal_to(opt._level_set_fetype.family, libMesh::LAGRANGE); + + Real + tol = 1.e-6, + height = 8., + filterradius = opt._input("filterradius", "radius of geometric filter for level set field", 0.015); + + unsigned int + dof_id = 0, + n_vars = 0; + + Real + val = 0.; + + // + // all ranks will have DVs defined for all variables. So, we should be + // operating on a replicated mesh + // + libmesh_assert(opt._level_set_mesh->is_replicated()); + + std::vector local_phi(opt._level_set_sys->solution->size()); + opt._level_set_sys->solution->localize(local_phi); + + // + // iterate over all the node values + // + libMesh::MeshBase::const_node_iterator + it = opt._level_set_mesh->nodes_begin(), + end = opt._level_set_mesh->nodes_end(); + + // + // maximum number of dvs is the number of nodes on the level set function + // mesh. We will evaluate the actual number of dvs + // + opt._dv_params.reserve(opt._level_set_mesh->n_nodes()); + n_vars = 0; + + for ( ; it!=end; it++) { + + const libMesh::Node& n = **it; + + dof_id = n.dof_number(0, 0, 0); + + if (((n.norm() <= 1.5+filterradius) && n(0) <= 0.) || // circle + (std::fabs(n(0)-height*1.5) < filterradius && // right edge + std::fabs(n(1)) <= 1.+filterradius)) { // dirichlet constraint + + // + // set value at the constrained points to a small positive number + // material here + // + if (dof_id >= opt._level_set_sys->solution->first_local_index() && + dof_id < opt._level_set_sys->solution->last_local_index()) + opt._level_set_sys->solution->set(dof_id, 1.e0); + } + else { + + std::ostringstream oss; + oss << "dv_" << n_vars; + val = local_phi[dof_id]; + + // + // on the boundary, set everything to be zero, so that there + // is always a boundary there that the optimizer can move + // + if (std::fabs(n(0)+height*0.5) < tol || // left boundary + std::fabs(n(1)-height*0.5) < tol || // top boundary + std::fabs(n(1)+height*0.5) < tol || // bottom boundary + std::fabs(n(0)-height*1.5) < tol) { // right boundary + + if (dof_id >= opt._level_set_sys->solution->first_local_index() && + dof_id < opt._level_set_sys->solution->last_local_index()) + opt._level_set_sys->solution->set(dof_id, -1.); + val = -1.; + } + + opt._dv_params.push_back(std::pair()); + opt._dv_params[n_vars].first = dof_id; + opt._dv_params[n_vars].second = new MAST::LevelSetParameter(oss.str(), val, &n); + opt._dv_params[n_vars].second->set_as_topology_parameter(true); + opt._dv_dof_ids.insert(dof_id); + + n_vars++; + } + } + + opt.set_n_vars(n_vars); + opt._level_set_sys->solution->close(); +} + + +template +void +MAST::Examples::Eyebar2DModel::init_simp_dvs(Opt& opt) { + + libmesh_assert(opt._initialized); + + // + // this assumes that density variable has a constant value per element + // + libmesh_assert_equal_to(opt._density_fetype.family, libMesh::LAGRANGE); + + Real + tol = 1.e-6, + height = 8., + filterradius = opt._input("filterradius", "radius of geometric filter for level set field", 0.015); + + unsigned int + sys_num = opt._density_sys->number(), + dof_id = 0, + n_vars = 0; + + Real + val = 0.; + + // + // all ranks will have DVs defined for all variables. So, we should be + // operating on a replicated mesh + // + libmesh_assert(opt._mesh->is_replicated()); + + std::vector local_phi(opt._density_sys->solution->size()); + opt._density_sys->solution->localize(local_phi); + + // iterate over all the element values + // iterate over all the element values + libMesh::MeshBase::const_node_iterator + it = opt._mesh->nodes_begin(), + end = opt._mesh->nodes_end(); + + // + // maximum number of dvs is the number of nodes on the level set function + // mesh. We will evaluate the actual number of dvs + // + opt._dv_params.reserve(opt._mesh->n_elem()); + n_vars = 0; + + for ( ; it!=end; it++) { + + const libMesh::Node& n = **it; + + dof_id = n.dof_number(sys_num, 0, 0); + + + + if (((n.norm() <= 1.5+filterradius) && n(0) <= 0.) || // circle + (std::fabs(n(0)-height*1.5) < filterradius && // right edge + std::fabs(n(1)) <= 1.+filterradius)) { // dirichlet constraint + + // + // set value at the constrained points to material + // + if (dof_id >= opt._density_sys->solution->first_local_index() && + dof_id < opt._density_sys->solution->last_local_index()) + opt._density_sys->solution->set(dof_id, 1.e0); + } + else { + + std::ostringstream oss; + oss << "dv_" << n_vars; + val = local_phi[dof_id]; + + // + // on the boundary, set everything to be zero, so that there + // is always a boundary there that the optimizer can move + // + if (std::fabs(n(0)+height*0.5) < tol || // left boundary + std::fabs(n(1)-height*0.5) < tol || // top boundary + std::fabs(n(1)+height*0.5) < tol || // bottom boundary + std::fabs(n(0)-height*1.5) < tol) { // right boundary + + if (dof_id >= opt._density_sys->solution->first_local_index() && + dof_id < opt._density_sys->solution->last_local_index()) + opt._density_sys->solution->set(dof_id, opt._rho_min); + val = opt._rho_min; + } + + opt._dv_params.push_back(std::pair()); + opt._dv_params[n_vars].first = dof_id; + opt._dv_params[n_vars].second = new MAST::LevelSetParameter(oss.str(), val, &n); + opt._dv_params[n_vars].second->set_as_topology_parameter(true); + opt._dv_dof_ids.insert(dof_id); + + n_vars++; + } + } + + opt.set_n_vars(n_vars); + opt._density_sys->solution->close(); +} + + + +template +void +MAST::Examples::Eyebar2DModel::initialize_level_set_solution(Opt& opt) { + + Real + height = 8., + length = 16.; + + unsigned int + nx_h = opt._input("initial_level_set_n_holes_in_x", + "number of holes along x-direction for initial level-set field", 6), + ny_h = opt._input("initial_level_set_n_holes_in_y", + "number of holes along y-direction for initial level-set field", 6), + nx_m = opt._input("level_set_nx_divs", "number of elements of level-set mesh along x-axis", 10), + ny_m = opt._input("level_set_ny_divs", "number of elements of level-set mesh along y-axis", 10); + + MAST::Examples::LevelSetNucleationFunction + phi(-0.5*height, -0.5*height, length, height, nx_m, ny_m, nx_h, ny_h); + + opt._level_set_sys_init->initialize_solution(phi); +} + + +#endif // __mast_topology_2d_eyebar_model__ diff --git a/examples/structural/base/inplane_2d_model.h b/examples/structural/base/inplane_2d_model.h new file mode 100644 index 00000000..a609628a --- /dev/null +++ b/examples/structural/base/inplane_2d_model.h @@ -0,0 +1,506 @@ +/* + * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit + * Copyright (C) 2013-2019 Manav Bhatia + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __mast_topology_2d_inplane_model__ +#define __mast_topology_2d_inplane_model__ + +// MAST includes +#include "base/mast_data_types.h" +#include "examples/base/input_wrapper.h" +#include "base/boundary_condition_base.h" +#include "base/field_function_base.h" +#include "base/physics_discipline_base.h" +#include "boundary_condition/dirichlet_boundary_condition.h" +#include "level_set/level_set_parameter.h" + +// libMesh includes +#include "libmesh/system.h" +#include "libmesh/unstructured_mesh.h" +#include "libmesh/fe_type.h" +#include "libmesh/string_to_enum.h" +#include "libmesh/mesh_generation.h" +#include "libmesh/elem.h" +#include "libmesh/node.h" + + + + +namespace MAST { + +// Forward declerations +class DisciplineBase; +class BoundaryConditionBase; +class FunctionBase; +class Parameter; + +namespace Examples { + + +struct Inplane2DModel { + + template + static Real reference_volume(Opt& opt); + + template + static void init_analysis_mesh(Opt& opt, libMesh::UnstructuredMesh& mesh); + + template + static void init_level_set_mesh(Opt& opt, libMesh::UnstructuredMesh& mesh); + + template + static void + init_analysis_dirichlet_conditions(Opt& opt); + + template + static void + init_indicator_dirichlet_conditions(Opt& opt); + + + template + static MAST::BoundaryConditionBase& + init_structural_shifted_boudnary_load(Opt& opt, unsigned int bid); + + template + static void + init_structural_loads(Opt& opt); + + template + static void + init_indicator_loads(Opt& opt); + + template + static void + init_level_set_dvs(Opt& opt); + + template + static void + initialize_level_set_solution(Opt& opt); + + template + static void + init_simp_dvs(Opt& opt); + + class FluxLoad: + public MAST::FieldFunction { + public: + FluxLoad(const std::string& nm, Real p, Real l1, Real fraction): + MAST::FieldFunction(nm), _p(p), _l1(l1), _frac(fraction) { } + ~FluxLoad() {} + void operator() (const libMesh::Point& p, const Real t, Real& v) const { + if (fabs(p(0)-_l1*0.5) <= 0.5*_frac*_l1) v = _p; + else v = 0.; + } + void derivative(const MAST::FunctionBase& f, const libMesh::Point& p, const Real t, Real& v) const { + v = 0.; + } + protected: + Real _p, _l1, _frac; + }; + +}; + +} +} + + +template +Real +MAST::Examples::Inplane2DModel:: +reference_volume(Opt& opt) { + + Real + length = opt._input("length", "length of domain along x-axis", 0.3), + height = opt._input("height", "length of domain along y-axis", 0.3); + + return length * height; +} + + + +template +void +MAST::Examples::Inplane2DModel:: +init_analysis_mesh(Opt& opt, libMesh::UnstructuredMesh& mesh) { + + Real + length = opt._input("length", "length of domain along x-axis", 0.3), + height = opt._input("height", "length of domain along y-axis", 0.3); + + unsigned int + nx_divs = opt._input("nx_divs", "number of elements along x-axis", 20), + ny_divs = opt._input("ny_divs", "number of elements along y-axis", 20); + + std::string + t = opt._input("elem_type", "type of geometric element in the mesh", "quad4"); + + libMesh::ElemType + e_type = libMesh::Utility::string_to_enum(t); + + // + // if high order FE is used, libMesh requires atleast a second order + // geometric element. + // + if (opt._fetype.order > 1 && e_type == libMesh::QUAD4) + e_type = libMesh::QUAD9; + else if (opt._fetype.order > 1 && e_type == libMesh::TRI3) + e_type = libMesh::TRI6; + + // + // initialize the mesh with one element + // + libMesh::MeshTools::Generation::build_square(mesh, + nx_divs, ny_divs, + 0, length, + 0, height, + e_type); +} + + +template +void +MAST::Examples::Inplane2DModel:: +init_level_set_mesh(Opt& opt, libMesh::UnstructuredMesh& mesh) { + + Real + length = opt._input("length", "length of domain along x-axis", 0.3), + height = opt._input("height", "length of domain along y-axis", 0.3); + + unsigned int + nx_divs = opt._input("level_set_nx_divs", "number of elements of level-set mesh along x-axis", 10), + ny_divs = opt._input("level_set_ny_divs", "number of elements of level-set mesh along y-axis", 10); + + if (nx_divs%10 != 0 || ny_divs%10 != 0) libmesh_error(); + + libMesh::ElemType + e_type = libMesh::QUAD4; + + // initialize the mesh with one element + libMesh::MeshTools::Generation::build_square(mesh, + nx_divs, ny_divs, + 0, length, + 0, height, + e_type); +} + + + +template +void +MAST::Examples::Inplane2DModel::init_analysis_dirichlet_conditions(Opt& opt) { + + MAST::DirichletBoundaryCondition + *dirichlet = new MAST::DirichletBoundaryCondition; // right boundary + dirichlet->init(1, opt._sys_init->vars()); + opt._discipline->add_dirichlet_bc(1, *dirichlet); + opt._boundary_conditions.insert(dirichlet); + + dirichlet = new MAST::DirichletBoundaryCondition; // right boundary + dirichlet->init(3, opt._sys_init->vars()); + opt._discipline->add_dirichlet_bc(3, *dirichlet); + opt._boundary_conditions.insert(dirichlet); + + opt._discipline->init_system_dirichlet_bc(*opt._sys); + opt._dirichlet_bc_ids.insert(1); + opt._dirichlet_bc_ids.insert(3); +} + + + +template +void +MAST::Examples::Inplane2DModel::init_indicator_dirichlet_conditions(Opt& opt) { + + MAST::DirichletBoundaryCondition + *dirichlet = new MAST::DirichletBoundaryCondition; // right boundary + dirichlet->init(1, opt._indicator_sys_init->vars()); + opt._indicator_discipline->add_dirichlet_bc(1, *dirichlet); + opt._boundary_conditions.insert(dirichlet); + + dirichlet = new MAST::DirichletBoundaryCondition; // left boundary + dirichlet->init(3, opt._indicator_sys_init->vars()); + opt._indicator_discipline->add_dirichlet_bc(3, *dirichlet); + opt._boundary_conditions.insert(dirichlet); + + opt._indicator_discipline->init_system_dirichlet_bc(*opt._indicator_sys); +} + + +template +MAST::BoundaryConditionBase& +MAST::Examples::Inplane2DModel::init_structural_shifted_boudnary_load(Opt& opt, + unsigned int bid) { + + class ZeroTraction: public MAST::FieldFunction { + public: + ZeroTraction(): MAST::FieldFunction("traction") {} + virtual ~ZeroTraction() {} + virtual void operator() (const libMesh::Point& pt, const Real t, RealVectorX& v) const + {v.setZero(3);} + virtual void derivative(const MAST::FunctionBase& f, const libMesh::Point& pt, const Real t, RealVectorX& v) const + {v.setZero(3);} + }; + + ZeroTraction + *trac_f = new ZeroTraction; + + MAST::BoundaryConditionBase + *load = new MAST::BoundaryConditionBase(MAST::SURFACE_TRACTION_SHIFTED_BOUNDARY); + + load->add(*opt._level_set_vel); + load->add(*trac_f); + opt._discipline->add_side_load(bid, *load); + opt._boundary_conditions.insert(load); + + opt._field_functions.insert(trac_f); + return *load; +} + + +template +void +MAST::Examples::Inplane2DModel::init_structural_loads(Opt& opt) { + + Real + length = opt._input("length", "length of domain along x-axis", 0.3), + frac = opt._input("loadlength_fraction", "fraction of boundary length on which pressure will act", 0.2), + p_val = opt._input("pressure", "pressure on side of domain", 2.e4); + + FluxLoad + *press_f = new FluxLoad( "pressure", p_val, length, frac); + + // initialize the load + MAST::BoundaryConditionBase + *p_load = new MAST::BoundaryConditionBase(MAST::SURFACE_PRESSURE); + + p_load->add(*press_f); + opt._discipline->add_side_load(2, *p_load); + opt._boundary_conditions.insert(p_load); + + opt._field_functions.insert(press_f); +} + + +template +void +MAST::Examples::Inplane2DModel::init_indicator_loads(Opt& opt) { + + Real + length = opt._input("length", "length of domain along x-axis", 0.3), + frac = opt._input("loadlength_fraction", "fraction of boundary length on which pressure will act", 0.2); + + FluxLoad + *flux_f = new FluxLoad("heat_flux", -2.e6, length, frac); + + // initialize the load + MAST::BoundaryConditionBase + *f_load = new MAST::BoundaryConditionBase(MAST::HEAT_FLUX); + + f_load->add(*flux_f); + opt._indicator_discipline->add_side_load(2, *f_load); + opt._boundary_conditions.insert(f_load); + + opt._field_functions.insert(flux_f); +} + + + +template +void +MAST::Examples::Inplane2DModel::init_level_set_dvs(Opt& opt) { + + // + // this assumes that level set is defined using lagrange shape functions + // + libmesh_assert_equal_to(opt._level_set_fetype.family, libMesh::LAGRANGE); + + Real + length = opt._input("length", "length of domain along x-axis", 0.3), + height = opt._input("height", "length of domain along y-axis", 0.3), + frac = opt._input("loadlength_fraction", "fraction of boundary length on which pressure will act", 0.2), + filter_radius = opt._input("filter_radius", "radius of geometric filter for level set field", 0.015); + + unsigned int + dof_id = 0, + n_vars = 0; + + Real + val = 0.; + + // + // all ranks will have DVs defined for all variables. So, we should be + // operating on a replicated mesh + // + libmesh_assert(opt._level_set_mesh->is_replicated()); + + std::vector local_phi(opt._level_set_sys->solution->size()); + opt._level_set_sys->solution->localize(local_phi); + + // iterate over all the node values + libMesh::MeshBase::const_node_iterator + it = opt._level_set_mesh->nodes_begin(), + end = opt._level_set_mesh->nodes_end(); + + // + // maximum number of dvs is the number of nodes on the level set function + // mesh. We will evaluate the actual number of dvs + // + opt._dv_params.reserve(opt._level_set_mesh->n_nodes()); + n_vars = 0; + + for ( ; it!=end; it++) { + + const libMesh::Node& n = **it; + + dof_id = n.dof_number(0, 0, 0); + + // only if node is not on the upper edge + if ((n(1)+filter_radius >= height) && + (n(0)-filter_radius <= length*.5*(1.+frac)) && + (n(0)+filter_radius >= length*.5*(1.-frac))) { + + // set value at the material points to a small positive number + if (dof_id >= opt._level_set_sys->solution->first_local_index() && + dof_id < opt._level_set_sys->solution->last_local_index()) + opt._level_set_sys->solution->set(dof_id, 1.e0); + } + else { + + std::ostringstream oss; + oss << "dv_" << n_vars; + val = local_phi[dof_id]; + + opt._dv_params.push_back(std::pair()); + opt._dv_params[n_vars].first = dof_id; + opt._dv_params[n_vars].second = new MAST::LevelSetParameter(oss.str(), val, &n); + opt._dv_params[n_vars].second->set_as_topology_parameter(true); + opt._dv_dof_ids.insert(dof_id); + + n_vars++; + } + } + + opt.set_n_vars(n_vars); + opt._level_set_sys->solution->close(); +} + + +template +void +MAST::Examples::Inplane2DModel::init_simp_dvs(Opt& opt) { + + // + // this assumes that density variable has a constant value per element + // + libmesh_assert_equal_to(opt._density_fetype.family, libMesh::LAGRANGE); + + Real + length = opt._input("length", "length of domain along x-axis", 0.3), + height = opt._input("height", "length of domain along y-axis", 0.3), + frac = opt._input("loadlength_fraction", "fraction of boundary length on which pressure will act", 0.2), + filter_radius = opt._input("filter_radius", "radius of geometric filter for level set field", 0.015); + + unsigned int + sys_num = opt._density_sys->number(), + dof_id = 0, + n_vars = 0; + + Real + val = 0.; + + // + // all ranks will have DVs defined for all variables. So, we should be + // operating on a replicated mesh + // + libmesh_assert(opt._mesh->is_replicated()); + + std::vector local_phi(opt._density_sys->solution->size()); + opt._density_sys->solution->localize(local_phi); + + // iterate over all the element values + libMesh::MeshBase::const_node_iterator + it = opt._mesh->nodes_begin(), + end = opt._mesh->nodes_end(); + + // + // maximum number of dvs is the number of nodes on the level set function + // mesh. We will evaluate the actual number of dvs + // + opt._dv_params.reserve(opt._mesh->n_elem()); + n_vars = 0; + + for ( ; it!=end; it++) { + + const libMesh::Node& n = **it; + + dof_id = n.dof_number(sys_num, 0, 0); + + // only if node is not on the upper edge + if ((n(1)+filter_radius >= height) && + (n(0)-filter_radius <= length*.5*(1.+frac)) && + (n(0)+filter_radius >= length*.5*(1.-frac))) { + + // set value at the material points to a small positive number + if (dof_id >= opt._density_sys->solution->first_local_index() && + dof_id < opt._density_sys->solution->last_local_index()) + opt._density_sys->solution->set(dof_id, 1.e0); + } + else { + + std::ostringstream oss; + oss << "dv_" << n_vars; + val = local_phi[dof_id]; + + opt._dv_params.push_back(std::pair()); + opt._dv_params[n_vars].first = dof_id; + opt._dv_params[n_vars].second = new MAST::LevelSetParameter(oss.str(), val, &n); + opt._dv_params[n_vars].second->set_as_topology_parameter(true); + opt._dv_dof_ids.insert(dof_id); + + n_vars++; + } + } + + opt.set_n_vars(n_vars); + opt._density_sys->solution->close(); +} + + +template +void +MAST::Examples::Inplane2DModel::initialize_level_set_solution(Opt& opt) { + + Real + length = opt._input("length", "length of domain along x-axis", 0.3), + height = opt._input("height", "length of domain along y-axis", 0.3); + + unsigned int + nx_h = opt._input("initial_level_set_n_holes_in_x", + "number of holes along x-direction for initial level-set field", 6), + ny_h = opt._input("initial_level_set_n_holes_in_y", + "number of holes along y-direction for initial level-set field", 6), + nx_m = opt._input("level_set_nx_divs", "number of elements of level-set mesh along x-axis", 10), + ny_m = opt._input("level_set_ny_divs", "number of elements of level-set mesh along y-axis", 10); + + MAST::Examples::LevelSetNucleationFunction + phi(0., 0., length, height, nx_m, ny_m, nx_h, ny_h); + + opt._level_set_sys_init->initialize_solution(phi); +} + +#endif // __mast_topology_2d_inplane_model__ diff --git a/examples/structural/base/level_set_nucleation.h b/examples/structural/base/level_set_nucleation.h new file mode 100644 index 00000000..83eaf26d --- /dev/null +++ b/examples/structural/base/level_set_nucleation.h @@ -0,0 +1,143 @@ +/* + * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit + * Copyright (C) 2013-2019 Manav Bhatia + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __mast_topology_level_set_nucleation__ +#define __mast_topology_level_set_nucleation__ + +// MAST includes +#include "base/mast_data_types.h" + + +namespace MAST { + +namespace Examples { + +class LevelSetNucleationFunction: +public MAST::FieldFunction { + +public: + LevelSetNucleationFunction(Real x0, + Real y0, + Real l1, + Real l2, + Real nx_mesh, + Real ny_mesh, + Real nx_holes, + Real ny_holes): + MAST::FieldFunction("Phi"), + _x0 (x0), + _y0 (y0), + _l1 (l1), + _l2 (l2), + _nx_mesh (nx_mesh), + _ny_mesh (ny_mesh), + _nx_holes (nx_holes), + _ny_holes (ny_holes), + _pi (acos(-1.)) { + + Real + dx = _l1/(1.*_nx_holes); + + for (unsigned int i=0; i<_nx_holes; i++) + _x_axis_hole_locations.insert(_x0+(i+.5)*dx); + + // + // now, along the y-axis + // + dx = _l2/(1.*_ny_holes); + for (unsigned int i=0; i<_ny_holes; i++) + _y_axis_hole_locations.insert(_y0+(i+0.5)*dx); + } + + virtual ~LevelSetNucleationFunction() {} + + virtual void operator()(const libMesh::Point& p, + const Real t, + RealVectorX& v) const { + + libmesh_assert_less_equal(t, 1); + libmesh_assert_equal_to(v.size(), 1); + + // + // the libMesh solution projection routine for Lagrange elements + // will query the function value at the nodes. So, we figure + // out which nodes should have zero values set to them. + // if there is one hole in any direction, it will be in the + // center of the domain. If there are more than 1, then two of + // the holes will be on the boundary and others will fill the + // interior evenly. + // + const Real + dx_mesh = _l1/(1.*_nx_holes), + dy_mesh = _l2/(1.*_ny_holes); + + std::set::const_iterator + x_it_low = _x_axis_hole_locations.lower_bound(p(0)-dx_mesh), + y_it_low = _y_axis_hole_locations.lower_bound(p(1)-dy_mesh); + + unsigned int + n = 0; + // + // see if the x-location needs a hole + // + for ( ; x_it_low != _x_axis_hole_locations.end(); x_it_low++) { + if (std::fabs(*x_it_low - p(0)) <= dx_mesh*0.25) { + n++; + break; + } + } + + // + // now check the y-location + // + for ( ; y_it_low != _y_axis_hole_locations.end(); y_it_low++) { + if (std::fabs(*y_it_low - p(1)) <= dy_mesh*0.25) { + n++; + break; + } + } + + if (n == 2) + v(0) = -1.e0; + else + v(0) = 1.e0; + } + + +protected: + Real + _x0, + _y0, + _l1, + _l2, + _nx_mesh, + _ny_mesh, + _nx_holes, + _ny_holes, + _pi; + std::set _x_axis_hole_locations; + std::set _y_axis_hole_locations; +}; + + +} +} + + +#endif // __mast_topology_level_set_nucleation__ diff --git a/examples/structural/base/truss_2d_model.h b/examples/structural/base/truss_2d_model.h new file mode 100644 index 00000000..9d7912eb --- /dev/null +++ b/examples/structural/base/truss_2d_model.h @@ -0,0 +1,547 @@ +/* + * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit + * Copyright (C) 2013-2019 Manav Bhatia + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __mast_topology_2d_truss_model__ +#define __mast_topology_2d_truss_model__ + +// MAST includes +#include "base/mast_data_types.h" +#include "examples/base/input_wrapper.h" +#include "examples/structural/base/level_set_nucleation.h" +#include "base/boundary_condition_base.h" +#include "base/field_function_base.h" +#include "base/physics_discipline_base.h" +#include "boundary_condition/dirichlet_boundary_condition.h" +#include "level_set/level_set_parameter.h" + +// libMesh includes +#include "libmesh/system.h" +#include "libmesh/unstructured_mesh.h" +#include "libmesh/fe_type.h" +#include "libmesh/string_to_enum.h" +#include "libmesh/mesh_generation.h" +#include "libmesh/elem.h" +#include "libmesh/node.h" + + + + +namespace MAST { + +// Forward declerations +class DisciplineBase; +class BoundaryConditionBase; +class FunctionBase; +class Parameter; + +namespace Examples { + +struct Truss2DModel { + + template + static Real reference_volume(Opt& opt); + + template + static void init_analysis_mesh(Opt& opt, libMesh::UnstructuredMesh& mesh); + + template + static void init_level_set_mesh(Opt& opt, libMesh::UnstructuredMesh& mesh); + + template + static void + init_analysis_dirichlet_conditions(Opt& opt); + + template + static void + init_indicator_dirichlet_conditions(Opt& opt); + + + template + static MAST::BoundaryConditionBase& + init_structural_shifted_boudnary_load(Opt& opt, unsigned int bid); + + template + static void + init_structural_loads(Opt& opt); + + template + static void + init_indicator_loads(Opt& opt); + + template + static void + init_level_set_dvs(Opt& opt); + + template + static void + initialize_level_set_solution(Opt& opt); + + template + static void + init_simp_dvs(Opt& opt); + + class FluxLoad: + public MAST::FieldFunction { + public: + FluxLoad(const std::string& nm, Real p, Real l1, Real fraction): + MAST::FieldFunction(nm), _p(p), _l1(l1), _frac(fraction) { } + ~FluxLoad() {} + void operator() (const libMesh::Point& p, const Real t, Real& v) const { + if (fabs(p(0)-_l1*0.5) <= 0.5*_frac*_l1) v = _p; + else v = 0.; + } + void derivative(const MAST::FunctionBase& f, const libMesh::Point& p, const Real t, Real& v) const { + v = 0.; + } + protected: + Real _p, _l1, _frac; + }; + +}; + +} +} + + + +template +Real +MAST::Examples::Truss2DModel:: +reference_volume(Opt& opt) { + + Real + length = opt._input("length", "length of domain along x-axis", 0.3), + height = opt._input("height", "length of domain along y-axis", 0.3); + + return length * height; +} + + + +template +void +MAST::Examples::Truss2DModel:: +init_analysis_mesh(Opt& opt, libMesh::UnstructuredMesh& mesh) { + + Real + length = opt._input("length", "length of domain along x-axis", 0.3), + height = opt._input("height", "length of domain along y-axis", 0.3); + + unsigned int + nx_divs = opt._input("nx_divs", "number of elements along x-axis", 20), + ny_divs = opt._input("ny_divs", "number of elements along y-axis", 20); + + std::string + t = opt._input("elem_type", "type of geometric element in the mesh", "quad4"); + + libMesh::ElemType + e_type = libMesh::Utility::string_to_enum(t); + + // + // if high order FE is used, libMesh requires atleast a second order + // geometric element. + // + if (opt._fetype.order > 1 && e_type == libMesh::QUAD4) + e_type = libMesh::QUAD9; + else if (opt._fetype.order > 1 && e_type == libMesh::TRI3) + e_type = libMesh::TRI6; + + // + // initialize the mesh with one element + // + libMesh::MeshTools::Generation::build_square(mesh, + nx_divs, ny_divs, + 0, length, + 0, height, + e_type); + + Real + dirichletlength_fraction = + opt._input("truss_dirichletlength_fraction", + "length fraction of the truss boundary where dirichlet condition is applied", + 0.05); + + // identify the boundaries for dirichlet condition + libMesh::MeshBase::const_element_iterator + e_it = opt._mesh->elements_begin(), + e_end = opt._mesh->elements_end(); + + for ( ; e_it != e_end; e_it++) { + + const libMesh::Elem* e = *e_it; + + if ((*e->node_ptr(0))(1) < 1.e-8 && + e->centroid()(0) <= length*dirichletlength_fraction) + opt._mesh->boundary_info->add_side(e, 0, 6); + else if ((*e->node_ptr(1))(1) < 1.e-8 && + e->centroid()(0) >= length*(1.-dirichletlength_fraction)) + opt._mesh->boundary_info->add_side(e, 0, 7); + + if ((*e->node_ptr(0))(0) < 1.e-8 && + (*e->node_ptr(0))(1) < 1.e-8 && + e->centroid()(0) <= length*dirichletlength_fraction) + opt._mesh->boundary_info->add_side(e, 0, 8); + } + + opt._mesh->boundary_info->sideset_name(6) = "left_dirichlet"; + opt._mesh->boundary_info->sideset_name(7) = "right_dirichlet"; +} + + +template +void +MAST::Examples::Truss2DModel:: +init_level_set_mesh(Opt& opt, libMesh::UnstructuredMesh& mesh) { + + Real + length = opt._input("length", "length of domain along x-axis", 0.3), + height = opt._input("height", "length of domain along y-axis", 0.3); + + unsigned int + nx_divs = opt._input("level_set_nx_divs", "number of elements of level-set mesh along x-axis", 10), + ny_divs = opt._input("level_set_ny_divs", "number of elements of level-set mesh along y-axis", 10); + + if (nx_divs%10 != 0 || ny_divs%10 != 0) libmesh_error(); + + libMesh::ElemType + e_type = libMesh::QUAD4; + + // initialize the mesh with one element + libMesh::MeshTools::Generation::build_square(mesh, + nx_divs, ny_divs, + 0, length, + 0, height, + e_type); +} + + + +template +void +MAST::Examples::Truss2DModel::init_analysis_dirichlet_conditions(Opt& opt) { + + std::vector vars = {1, 2, 3, 4, 5}; + MAST::DirichletBoundaryCondition + *dirichlet = new MAST::DirichletBoundaryCondition; // left support + dirichlet->init(6, vars); + opt._discipline->add_dirichlet_bc(6, *dirichlet); + opt._boundary_conditions.insert(dirichlet); + + dirichlet = new MAST::DirichletBoundaryCondition; // right support + dirichlet->init(7, vars); + opt._discipline->add_dirichlet_bc(7, *dirichlet); + opt._boundary_conditions.insert(dirichlet); + + vars = {0}; + dirichlet = new MAST::DirichletBoundaryCondition; // left support + dirichlet->init(8, vars); + opt._discipline->add_dirichlet_bc(8, *dirichlet); + opt._boundary_conditions.insert(dirichlet); + + opt._discipline->init_system_dirichlet_bc(*opt._sys); + opt._dirichlet_bc_ids.insert(6); + opt._dirichlet_bc_ids.insert(7); + opt._dirichlet_bc_ids.insert(8); +} + + + +template +void +MAST::Examples::Truss2DModel::init_indicator_dirichlet_conditions(Opt& opt) { + + MAST::DirichletBoundaryCondition + *dirichlet = new MAST::DirichletBoundaryCondition; // right boundary + dirichlet->init(6, opt._indicator_sys_init->vars()); + opt._indicator_discipline->add_dirichlet_bc(6, *dirichlet); + opt._boundary_conditions.insert(dirichlet); + + dirichlet = new MAST::DirichletBoundaryCondition; // left boundary + dirichlet->init(7, opt._indicator_sys_init->vars()); + opt._indicator_discipline->add_dirichlet_bc(7, *dirichlet); + opt._boundary_conditions.insert(dirichlet); + + opt._indicator_discipline->init_system_dirichlet_bc(*opt._indicator_sys); +} + + + +template +MAST::BoundaryConditionBase& +MAST::Examples::Truss2DModel::init_structural_shifted_boudnary_load(Opt& opt, + unsigned int bid) { + + class ZeroTraction: public MAST::FieldFunction { + public: + ZeroTraction(): MAST::FieldFunction("traction") {} + virtual ~ZeroTraction() {} + virtual void operator() (const libMesh::Point& pt, const Real t, RealVectorX& v) const + {v.setZero(3);} + virtual void derivative(const MAST::FunctionBase& f, const libMesh::Point& pt, const Real t, RealVectorX& v) const + {v.setZero(3);} + }; + + ZeroTraction + *trac_f = new ZeroTraction; + + MAST::BoundaryConditionBase + *load = new MAST::BoundaryConditionBase(MAST::SURFACE_TRACTION_SHIFTED_BOUNDARY); + + load->add(*opt._level_set_vel); + load->add(*trac_f); + opt._discipline->add_side_load(bid, *load); + opt._boundary_conditions.insert(load); + + opt._field_functions.insert(trac_f); + return *load; +} + + +template +void +MAST::Examples::Truss2DModel::init_structural_loads(Opt& opt) { + + Real + length = opt._input("length", "length of domain along x-axis", 0.3), + frac = opt._input("loadlength_fraction", "fraction of boundary length on which pressure will act", 0.2), + p_val = opt._input("pressure", "pressure on side of domain", 2.e4); + + FluxLoad + *press_f = new FluxLoad( "pressure", p_val, length, frac); + + // initialize the load + MAST::BoundaryConditionBase + *p_load = new MAST::BoundaryConditionBase(MAST::SURFACE_PRESSURE); + + p_load->add(*press_f); + opt._discipline->add_side_load(2, *p_load); + opt._boundary_conditions.insert(p_load); + + opt._field_functions.insert(press_f); +} + + +template +void +MAST::Examples::Truss2DModel::init_indicator_loads(Opt& opt) { + + Real + length = opt._input("length", "length of domain along x-axis", 0.3), + frac = opt._input("loadlength_fraction", "fraction of boundary length on which pressure will act", 0.2); + + FluxLoad + *flux_f = new FluxLoad("heat_flux", -2.e6, length, frac); + + // initialize the load + MAST::BoundaryConditionBase + *f_load = new MAST::BoundaryConditionBase(MAST::HEAT_FLUX); + + f_load->add(*flux_f); + opt._indicator_discipline->add_side_load(2, *f_load); + opt._boundary_conditions.insert(f_load); + + opt._field_functions.insert(flux_f); +} + + + +template +void +MAST::Examples::Truss2DModel::init_level_set_dvs(Opt& opt) { + + // + // this assumes that level set is defined using lagrange shape functions + // + libmesh_assert_equal_to(opt._level_set_fetype.family, libMesh::LAGRANGE); + + Real + length = opt._input("length", "length of domain along x-axis", 0.3), + frac = opt._input("loadlength_fraction", "fraction of boundary length on which pressure will act", 0.2), + filter_radius = opt._input("filter_radius", "radius of geometric filter for level set field", 0.015); + + unsigned int + dof_id = 0, + n_vars = 0; + + Real + val = 0.; + + // + // all ranks will have DVs defined for all variables. So, we should be + // operating on a replicated mesh + // + libmesh_assert(opt._level_set_mesh->is_replicated()); + + std::vector local_phi(opt._level_set_sys->solution->size()); + opt._level_set_sys->solution->localize(local_phi); + + // iterate over all the node values + libMesh::MeshBase::const_node_iterator + it = opt._level_set_mesh->nodes_begin(), + end = opt._level_set_mesh->nodes_end(); + + // + // maximum number of dvs is the number of nodes on the level set function + // mesh. We will evaluate the actual number of dvs + // + opt._dv_params.reserve(opt._level_set_mesh->n_nodes()); + n_vars = 0; + + for ( ; it!=end; it++) { + + const libMesh::Node& n = **it; + + dof_id = n.dof_number(0, 0, 0); + + // only if node is not on the upper edge + if ((n(1)-filter_radius <= 0.) && + (n(0)-filter_radius <= length*.5*(1.+frac)) && + (n(0)+filter_radius >= length*.5*(1.-frac))) { + + // set value at the material points to a small positive number + if (dof_id >= opt._level_set_sys->solution->first_local_index() && + dof_id < opt._level_set_sys->solution->last_local_index()) + opt._level_set_sys->solution->set(dof_id, 1.e0); + } + else { + + std::ostringstream oss; + oss << "dv_" << n_vars; + val = local_phi[dof_id]; + + opt._dv_params.push_back(std::pair()); + opt._dv_params[n_vars].first = dof_id; + opt._dv_params[n_vars].second = new MAST::LevelSetParameter(oss.str(), val, &n); + opt._dv_params[n_vars].second->set_as_topology_parameter(true); + opt._dv_dof_ids.insert(dof_id); + + n_vars++; + } + } + + opt.set_n_vars(n_vars); + opt._level_set_sys->solution->close(); +} + + + +template +void +MAST::Examples::Truss2DModel::initialize_level_set_solution(Opt& opt) { + + Real + length = opt._input("length", "length of domain along x-axis", 0.3), + height = opt._input("height", "length of domain along y-axis", 0.3); + + unsigned int + nx_h = opt._input("initial_level_set_n_holes_in_x", + "number of holes along x-direction for initial level-set field", 6), + ny_h = opt._input("initial_level_set_n_holes_in_y", + "number of holes along y-direction for initial level-set field", 6), + nx_m = opt._input("level_set_nx_divs", "number of elements of level-set mesh along x-axis", 10), + ny_m = opt._input("level_set_ny_divs", "number of elements of level-set mesh along y-axis", 10); + + MAST::Examples::LevelSetNucleationFunction + phi(0., 0., length, height, nx_m, ny_m, nx_h, ny_h); + + opt._level_set_sys_init->initialize_solution(phi); +} + + +template +void +MAST::Examples::Truss2DModel::init_simp_dvs(Opt& opt) { + + // + // this assumes that density variable has a constant value per element + // + libmesh_assert_equal_to(opt._density_fetype.family, libMesh::LAGRANGE); + + Real + length = opt._input("length", "length of domain along x-axis", 0.3), + frac = opt._input("loadlength_fraction", "fraction of boundary length on which pressure will act", 0.2), + filter_radius = opt._input("filter_radius", "radius of geometric filter for level set field", 0.015); + + unsigned int + sys_num = opt._density_sys->number(), + dof_id = 0, + n_vars = 0; + + Real + val = 0.; + + // + // all ranks will have DVs defined for all variables. So, we should be + // operating on a replicated mesh + // + libmesh_assert(opt._mesh->is_replicated()); + + std::vector local_phi(opt._density_sys->solution->size()); + opt._density_sys->solution->localize(local_phi); + + // iterate over all the element values + libMesh::MeshBase::const_node_iterator + it = opt._mesh->nodes_begin(), + end = opt._mesh->nodes_end(); + + // + // maximum number of dvs is the number of nodes on the level set function + // mesh. We will evaluate the actual number of dvs + // + opt._dv_params.reserve(opt._mesh->n_elem()); + n_vars = 0; + + for ( ; it!=end; it++) { + + const libMesh::Node& n = **it; + + dof_id = n.dof_number(sys_num, 0, 0); + + // only if node is not on the upper edge + if ((n(1)-filter_radius <= 0.) && + (n(0)-filter_radius <= length*.5*(1.+frac)) && + (n(0)+filter_radius >= length*.5*(1.-frac))) { + + // set value at the material points to a small positive number + if (dof_id >= opt._density_sys->solution->first_local_index() && + dof_id < opt._density_sys->solution->last_local_index()) + opt._density_sys->solution->set(dof_id, 1.e0); + } + else { + + std::ostringstream oss; + oss << "dv_" << n_vars; + val = local_phi[dof_id]; + + opt._dv_params.push_back(std::pair()); + opt._dv_params[n_vars].first = dof_id; + opt._dv_params[n_vars].second = new MAST::LevelSetParameter(oss.str(), val, &n); + opt._dv_params[n_vars].second->set_as_topology_parameter(true); + opt._dv_dof_ids.insert(dof_id); + + n_vars++; + } + } + + opt.set_n_vars(n_vars); + opt._density_sys->solution->close(); +} + + +#endif // __mast_topology_2d_truss_model__ diff --git a/examples/structural/example_5/example_5.cpp b/examples/structural/example_5/example_5.cpp index 22c78892..b661858e 100644 --- a/examples/structural/example_5/example_5.cpp +++ b/examples/structural/example_5/example_5.cpp @@ -22,13 +22,10 @@ // MAST includes #include "examples/base/input_wrapper.h" -#include "examples/fluid/meshing/cylinder.h" #include "level_set/level_set_discipline.h" #include "level_set/level_set_system_initialization.h" #include "level_set/level_set_eigenproblem_assembly.h" -#include "level_set/level_set_transient_assembly.h" #include "level_set/level_set_nonlinear_implicit_assembly.h" -#include "level_set/level_set_reinitialization_transient_assembly.h" #include "level_set/level_set_volume_output.h" #include "level_set/level_set_perimeter_output.h" #include "level_set/level_set_boundary_velocity.h" @@ -37,6 +34,7 @@ #include "level_set/level_set_intersection.h" #include "level_set/filter_base.h" #include "level_set/level_set_parameter.h" +#include "level_set/sub_elem_mesh_refinement.h" #include "elasticity/structural_nonlinear_assembly.h" #include "elasticity/structural_modal_eigenproblem_assembly.h" #include "elasticity/ks_stress_output.h" @@ -44,6 +42,7 @@ #include "elasticity/level_set_stress_assembly.h" #include "elasticity/compliance_output.h" #include "elasticity/structural_system_initialization.h" +#include "elasticity/structural_near_null_vector_space.h" #include "heat_conduction/heat_conduction_system_initialization.h" #include "heat_conduction/heat_conduction_nonlinear_assembly.h" #include "base/constant_field_function.h" @@ -57,6 +56,10 @@ #include "optimization/gcmma_optimization_interface.h" #include "optimization/npsol_optimization_interface.h" #include "optimization/function_evaluation.h" +#include "examples/structural/base/bracket_2d_model.h" +#include "examples/structural/base/inplane_2d_model.h" +#include "examples/structural/base/truss_2d_model.h" +#include "examples/structural/base/eyebar_2d_model.h" // libMesh includes @@ -64,7 +67,6 @@ #include "libmesh/serial_mesh.h" #include "libmesh/equation_systems.h" #include "libmesh/string_to_enum.h" -#include "libmesh/mesh_generation.h" #include "libmesh/dof_map.h" #include "libmesh/exodusII_io.h" #include "libmesh/petsc_nonlinear_solver.h" @@ -91,7 +93,7 @@ _optim_con(int* mode, int* nstate); // -// BEGIN_TRANSLATE 2D Level-set topology optimization +// BEGIN_TRANSLATE Level-set topology optimization // // \tableofcontents // @@ -147,16 +149,17 @@ public MAST::AssemblyBase::ElemParameterDependence { }; -class TopologyOptimizationLevelSet2D: +template +class TopologyOptimizationLevelSet: public MAST::FunctionEvaluation { -protected: +public: bool _initialized; MAST::Examples::GetPotWrapper& _input; - - Real _length; - Real _height; + + std::string _problem; + Real _volume; Real _obj_scaling; Real _stress_penalty; Real _perimeter_penalty; @@ -168,6 +171,8 @@ public MAST::FunctionEvaluation { libMesh::UnstructuredMesh* _mesh; libMesh::UnstructuredMesh* _level_set_mesh; + MAST::SubElemMeshRefinement* _mesh_refinement; + libMesh::EquationSystems* _eq_sys; libMesh::EquationSystems* _level_set_eq_sys; @@ -180,15 +185,17 @@ public MAST::FunctionEvaluation { MAST::LevelSetSystemInitialization* _level_set_sys_init_on_str_mesh; MAST::LevelSetSystemInitialization* _level_set_sys_init; MAST::HeatConductionSystemInitialization* _indicator_sys_init; - + + MAST::StructuralNearNullVectorSpace* _nsp; + MAST::PhysicsDisciplineBase* _discipline; MAST::PhysicsDisciplineBase* _indicator_discipline; MAST::LevelSetDiscipline* _level_set_discipline; MAST::FilterBase* _filter; - MAST::MaterialPropertyCardBase* _m_card; - MAST::ElementPropertyCardBase* _p_card; + MAST::MaterialPropertyCardBase *_m_card1, *_m_card2; + MAST::ElementPropertyCardBase *_p_card1, *_p_card2; PhiMeshFunction* _level_set_function; MAST::LevelSetBoundaryVelocity* _level_set_vel; @@ -197,311 +204,19 @@ public MAST::FunctionEvaluation { libMesh::FEType _fetype; libMesh::FEType _level_set_fetype; + MAST::BoundaryConditionBase* _shifted_boundary_load; std::vector _params_for_sensitivity; std::map _parameters; std::set _field_functions; std::set _boundary_conditions; std::set _dv_dof_ids; + std::set _dirichlet_bc_ids; std::vector> _dv_params; -public: - - // \section ex_5_init_mesh Mesh Generation - // This creates the mesh for the specified problem type. - // - void _init_mesh() { - - // The mesh is created using classes written in MAST. The particular - // mesh to be used can be selected using the input parameter - // ` mesh=val `, where `val` can be one of the following: - // - `inplane` inplane structure with load on top and left and right boundaries constrained - // - `bracket` L-bracket - // - std::string - s = _input("mesh", "type of mesh to be analyzed {inplane, bracket}", "inplane"); - - if (s == "inplane" || s == "truss") - _init_mesh_inplane(); - else if (s == "bracket") - _init_mesh_bracket(); - else if (s == "eye_bar") - _init_mesh_eye_bar(); - else - libmesh_error(); - } - - // - // \subsection ex_5_inplane_mesh Inplane problem - // - void _init_mesh_inplane() { - - _mesh = new libMesh::SerialMesh(this->comm()); - - // - // identify the element type from the input file or from the order - // of the element - // - unsigned int - nx_divs = _input("nx_divs", "number of elements along x-axis", 20), - ny_divs = _input("ny_divs", "number of elements along y-axis", 20); - - _length = _input("length", "length of domain along x-axis", 0.3), - _height = _input("height", "length of domain along y-axis", 0.3); - - std::string - t = _input("elem_type", "type of geometric element in the mesh", "quad4"); - - libMesh::ElemType - e_type = libMesh::Utility::string_to_enum(t); - - // - // if high order FE is used, libMesh requires atleast a second order - // geometric element. - // - if (_fetype.order > 1 && e_type == libMesh::QUAD4) - e_type = libMesh::QUAD9; - else if (_fetype.order > 1 && e_type == libMesh::TRI3) - e_type = libMesh::TRI6; - - // - // initialize the mesh with one element - // - libMesh::MeshTools::Generation::build_square(*_mesh, - nx_divs, ny_divs, - 0, _length, - 0, _height, - e_type); - - // - // mesh on which the level-set function is defined - // - _level_set_mesh = new libMesh::SerialMesh(this->comm()); - - nx_divs = _input("level_set_nx_divs", "number of elements of level-set mesh along x-axis", 10); - ny_divs = _input("level_set_ny_divs", "number of elements of level-set mesh along y-axis", 10); - e_type = libMesh::QUAD4; - - // initialize the mesh with one element - libMesh::MeshTools::Generation::build_square(*_level_set_mesh, - nx_divs, ny_divs, - 0, _length, - 0, _height, - e_type); - } - - // - // \subsection ex_5_bracket_mesh Bracket - // - void _init_mesh_bracket() { - - { - unsigned int - nx_divs = _input("nx_divs", "number of elements along x-axis", 20), - ny_divs = _input("ny_divs", "number of elements along y-axis", 20); - - if (nx_divs%10 != 0 || ny_divs%10 != 0) libmesh_error(); - } - - { - unsigned int - nx_divs = _input("level_set_nx_divs", "number of elements of level-set mesh along x-axis", 10), - ny_divs = _input("level_set_ny_divs", "number of elements of level-set mesh along y-axis", 10); - - if (nx_divs%10 != 0 || ny_divs%10 != 0) libmesh_error(); - - } - - _init_mesh_inplane(); - _delete_elems_from_bracket_mesh(*_mesh); - _delete_elems_from_bracket_mesh(*_level_set_mesh); - } - - void _delete_elems_from_bracket_mesh(libMesh::MeshBase &mesh) { - - Real - tol = 1.e-12, - x = -1., - y = -1., - length = _input("length", "length of domain along x-axis", 0.3), - width = _input( "height", "length of domain along y-axis", 0.3), - l_frac = 0.4, - w_frac = 0.4, - x_lim = length * l_frac, - y_lim = width * (1.-w_frac); - - // - // now, remove elements that are outside of the L-bracket domain - // - libMesh::MeshBase::element_iterator - e_it = mesh.elements_begin(), - e_end = mesh.elements_end(); - - for ( ; e_it!=e_end; e_it++) { - - libMesh::Elem* elem = *e_it; - x = length; - y = 0.; - for (unsigned int i=0; in_nodes(); i++) { - const libMesh::Node& n = elem->node_ref(i); - if (x > n(0)) x = n(0); - if (y < n(1)) y = n(1); - } - - // - // delete element if the lowest x,y locations are outside of the bracket - // domain - // - if (x >= x_lim && y<= y_lim) - mesh.delete_elem(elem); - } - - mesh.prepare_for_use(); - - // - // add the two additional boundaries to the boundary info so that - // we can apply loads on them - // - bool - facing_right = false, - facing_down = false; - - e_it = mesh.elements_begin(); - e_end = mesh.elements_end(); - - for ( ; e_it != e_end; e_it++) { - - libMesh::Elem* elem = *e_it; - - if (!elem->on_boundary()) continue; - - for (unsigned int i=0; in_sides(); i++) { - - if (elem->neighbor_ptr(i)) continue; - - std::unique_ptr s(elem->side_ptr(i).release()); - - const libMesh::Point p = s->centroid(); - - facing_right = true; - facing_down = true; - for (unsigned int j=0; jn_nodes(); j++) { - const libMesh::Node& n = s->node_ref(j); - - if (n(0) < x_lim || n(1) > y_lim) { - facing_right = false; - facing_down = false; - } - else if (std::fabs(n(0) - p(0)) > tol) - facing_right = false; - else if (std::fabs(n(1) - p(1)) > tol) - facing_down = false; - } - - if (facing_right) mesh.boundary_info->add_side(elem, i, 4); - if (facing_down) mesh.boundary_info->add_side(elem, i, 5); - } - } - - mesh.boundary_info->sideset_name(4) = "facing_right"; - mesh.boundary_info->sideset_name(5) = "facing_down"; - } - // - // \subsection ex_5_eyebar_mesh Eyebar - // - void _init_mesh_eye_bar() { - - _mesh = new libMesh::SerialMesh(this->comm()); - - // - // identify the element type from the input file or from the order - // of the element - // - unsigned int - n_radial_divs = _input("n_radial_divs", "number of elements along radial direction", 20), - n_quarter_divs = _input("n_quarter_divs", "number of elements along height", 20); - - Real - radius = 1.5, - h_ratio = _input("h_ratio", "ratio of radial element size at cylinder and at edge", 2); - _height = 8.; - _length = _height*2; - - std::string - t = _input("elem_type", "type of geometric element in the mesh", "quad4"); - - libMesh::ElemType - e_type = libMesh::Utility::string_to_enum(t); - - // - // if high order FE is used, libMesh requires atleast a second order - // geometric element. - // - if (_fetype.order > 1 && e_type == libMesh::QUAD4) - e_type = libMesh::QUAD9; - else if (_fetype.order > 1 && e_type == libMesh::TRI3) - e_type = libMesh::TRI6; - - MAST::Examples::CylinderMesh2D cylinder; - cylinder.mesh(radius, _height/2., - n_radial_divs, n_quarter_divs, h_ratio, - *_mesh, e_type, - true, _height, n_quarter_divs*2); - - // - // add the boundary ids for Dirichlet conditions - // - libMesh::MeshBase::const_element_iterator - e_it = _mesh->elements_begin(), - e_end = _mesh->elements_end(); - - Real - tol = radius * 1.e-8; - - for (; e_it != e_end; e_it++) { - - libMesh::Elem* elem = *e_it; - - std::unique_ptr edge(elem->side_ptr(1)); - libMesh::Point p = edge->centroid(); - - if (std::fabs(p(0)-_height*1.5) < tol && - std::fabs(p(1)) <= 1.) // on the right edge - _mesh->boundary_info->add_side(elem, 1, 0); - - // check for the circumference of the circle where load will be - // applied - edge.reset(elem->side_ptr(3).release()); - p = edge->centroid(); - - if ((std::fabs(p.norm()-radius) < 1.e-2) && - p(0) < 0.) // left semi-circle - _mesh->boundary_info->add_side(elem, 3, 5); - } - - _mesh->boundary_info->sideset_name(0) = "dirichlet"; - _mesh->boundary_info->sideset_name(5) = "load"; - - // mesh on which the level-set function is defined - _level_set_mesh = new libMesh::SerialMesh(this->comm()); - - n_radial_divs = _input("level_set_n_radial_divs", "number of elements along radial direction", 10), - n_quarter_divs = _input("level_set_n_quarter_divs", "number of elements along height", 10); - e_type = libMesh::QUAD4; - - // - // initialize the mesh with one element - // - cylinder.mesh(radius, _height/2, - n_radial_divs, n_quarter_divs, h_ratio, - *_level_set_mesh, e_type, - true, _height, n_quarter_divs*2); - } - - // - // \section ex_5_system_discipline System and Discipline + // \section ex_5_system_discipline System and Discipline // void _init_system_and_discipline() { @@ -521,6 +236,9 @@ public MAST::FunctionEvaluation { // _sys = &(_eq_sys->add_system("structural")); _sys->set_eigenproblem_type(libMesh::GHEP); + + _mesh_refinement = new MAST::SubElemMeshRefinement(*_mesh, *_sys); + _sys->attach_constraint_object(*_mesh_refinement); // // initialize the system to the right set of variables @@ -567,980 +285,169 @@ public MAST::FunctionEvaluation { _indicator_discipline = new MAST::PhysicsDisciplineBase(*_eq_sys); } - - void _init_eq_sys() { - - _eq_sys->init(); - _sys->eigen_solver->set_position_of_spectrum(libMesh::LARGEST_MAGNITUDE); - _sys->set_exchange_A_and_B(true); - - _level_set_eq_sys->init(); - } - - - // - // variables added to the mesh - // - void _init_fetype() { - - // FEType to initialize the system. Get the order and type of element. - std::string - order_str = _input("fe_order", "order of finite element shape basis functions", "first"), - family_str = _input("fe_family", "family of finite element shape functions", "lagrange"); - - libMesh::Order - o = libMesh::Utility::string_to_enum(order_str); - libMesh::FEFamily - fe = libMesh::Utility::string_to_enum(family_str); - _fetype = libMesh::FEType(o, fe); - } - - - - // - // \section ex_5_dirichlet Dirichlet Constraints - // - void _init_dirichlet_conditions() { - - std::string - s = _input("mesh", "type of mesh to be analyzed {inplane, truss, bracket, eye_bar}", "inplane"); - - if (s == "inplane") - _init_dirichlet_conditions_inplane(); - else if (s == "truss") - _init_dirichlet_conditions_truss(); - else if (s == "bracket") - _init_dirichlet_conditions_bracket(); - else if (s == "eye_bar") - _init_dirichlet_conditions_eye_bar(); - else - libmesh_error(); - } - - // - // \subsection ex_5_inplane_dirichlet Inplane - // - void _init_dirichlet_conditions_inplane() { - - /////////////////////////////////////////////////////////////////////// - // initialize Dirichlet conditions for structural system - /////////////////////////////////////////////////////////////////////// - MAST::DirichletBoundaryCondition - *dirichlet = new MAST::DirichletBoundaryCondition; // right boundary - dirichlet->init(1, _sys_init->vars()); - _discipline->add_dirichlet_bc(1, *dirichlet); - - dirichlet = new MAST::DirichletBoundaryCondition; // right boundary - dirichlet->init(3, _sys_init->vars()); - _discipline->add_dirichlet_bc(3, *dirichlet); - - _discipline->init_system_dirichlet_bc(*_sys); - - /////////////////////////////////////////////////////////////////////// - // initialize Dirichlet conditions for indicator system - /////////////////////////////////////////////////////////////////////// - dirichlet = new MAST::DirichletBoundaryCondition; // right boundary - dirichlet->init(1, _indicator_sys_init->vars()); - _indicator_discipline->add_dirichlet_bc(1, *dirichlet); - _boundary_conditions.insert(dirichlet); - - dirichlet = new MAST::DirichletBoundaryCondition; // left boundary - dirichlet->init(3, _indicator_sys_init->vars()); - _indicator_discipline->add_dirichlet_bc(3, *dirichlet); - _boundary_conditions.insert(dirichlet); - - _indicator_discipline->init_system_dirichlet_bc(*_indicator_sys); - } - - // - // \subsection ex_5_truss_dirichlet Truss - // - void _init_dirichlet_conditions_truss() { - - Real - dirichlet_length_fraction = _input("truss_dirichlet_length_fraction", "length fraction of the truss boundary where dirichlet condition is applied", 0.05); - - // identify the boundaries for dirichlet condition - libMesh::MeshBase::const_element_iterator - e_it = _mesh->elements_begin(), - e_end = _mesh->elements_end(); - - for ( ; e_it != e_end; e_it++) { - - const libMesh::Elem* e = *e_it; - - if ((*e->node_ptr(0))(1) < 1.e-8 && - e->centroid()(0) <= _length*dirichlet_length_fraction) - _mesh->boundary_info->add_side(e, 0, 6); - else if ((*e->node_ptr(1))(1) < 1.e-8 && - e->centroid()(0) >= _length*(1.-dirichlet_length_fraction)) - _mesh->boundary_info->add_side(e, 0, 7); - - if ((*e->node_ptr(0))(0) < 1.e-8 && - (*e->node_ptr(0))(1) < 1.e-8 && - e->centroid()(0) <= _length*dirichlet_length_fraction) - _mesh->boundary_info->add_side(e, 0, 8); - } - - _mesh->boundary_info->sideset_name(6) = "left_dirichlet"; - _mesh->boundary_info->sideset_name(7) = "right_dirichlet"; - - /////////////////////////////////////////////////////////////////////// - // initialize Dirichlet conditions for structural system - /////////////////////////////////////////////////////////////////////// - std::vector vars = {1, 2, 3, 4, 5}; - MAST::DirichletBoundaryCondition - *dirichlet = new MAST::DirichletBoundaryCondition; // left support - dirichlet->init(6, vars); - _discipline->add_dirichlet_bc(6, *dirichlet); - - dirichlet = new MAST::DirichletBoundaryCondition; // right support - dirichlet->init(7, vars); - _discipline->add_dirichlet_bc(7, *dirichlet); - - vars = {0}; - dirichlet = new MAST::DirichletBoundaryCondition; // left support - dirichlet->init(8, vars); - _discipline->add_dirichlet_bc(8, *dirichlet); - - _discipline->init_system_dirichlet_bc(*_sys); - - /////////////////////////////////////////////////////////////////////// - // initialize Dirichlet conditions for indicator system - /////////////////////////////////////////////////////////////////////// - dirichlet = new MAST::DirichletBoundaryCondition; // right boundary - dirichlet->init(6, _indicator_sys_init->vars()); - _indicator_discipline->add_dirichlet_bc(6, *dirichlet); - _boundary_conditions.insert(dirichlet); - - dirichlet = new MAST::DirichletBoundaryCondition; // left boundary - dirichlet->init(7, _indicator_sys_init->vars()); - _indicator_discipline->add_dirichlet_bc(7, *dirichlet); - _boundary_conditions.insert(dirichlet); - - _indicator_discipline->init_system_dirichlet_bc(*_indicator_sys); - } - - - // - // \subsection ex_5_bracket_dirichlet Bracket - // - void _init_dirichlet_conditions_bracket() { - - /////////////////////////////////////////////////////////////////////// - // initialize Dirichlet conditions for structural system - /////////////////////////////////////////////////////////////////////// - MAST::DirichletBoundaryCondition - *dirichlet = new MAST::DirichletBoundaryCondition; // bottom boundary - dirichlet->init(0, _sys_init->vars()); - _discipline->add_dirichlet_bc(0, *dirichlet); - - _discipline->init_system_dirichlet_bc(*_sys); - - /////////////////////////////////////////////////////////////////////// - // initialize Dirichlet conditions for indicator system - /////////////////////////////////////////////////////////////////////// - dirichlet = new MAST::DirichletBoundaryCondition; // bottom boundary - dirichlet->init(0, _indicator_sys_init->vars()); - _indicator_discipline->add_dirichlet_bc(0, *dirichlet); - _boundary_conditions.insert(dirichlet); - - _indicator_discipline->init_system_dirichlet_bc(*_indicator_sys); - } - - - // - // \subsection ex_5_eyebar_dirichlet Eyebar - // - void _init_dirichlet_conditions_eye_bar() { - - /////////////////////////////////////////////////////////////////////// - // initialize Dirichlet conditions for structural system - /////////////////////////////////////////////////////////////////////// - MAST::DirichletBoundaryCondition - *dirichlet = new MAST::DirichletBoundaryCondition; // right boundary - dirichlet->init(0, _sys_init->vars()); - _discipline->add_dirichlet_bc(0, *dirichlet); - - _discipline->init_system_dirichlet_bc(*_sys); - - /////////////////////////////////////////////////////////////////////// - // initialize Dirichlet conditions for indicator system - /////////////////////////////////////////////////////////////////////// - dirichlet = new MAST::DirichletBoundaryCondition; // right boundary - dirichlet->init(0, _indicator_sys_init->vars()); - _indicator_discipline->add_dirichlet_bc(0, *dirichlet); - _boundary_conditions.insert(dirichlet); - - _indicator_discipline->init_system_dirichlet_bc(*_indicator_sys); - } - - - - // - // \section ex_5_loading Loading - // - // - void _init_loads() { - - std::string - s = _input("mesh", "type of mesh to be analyzed {inplane, truss, bracket, eye_bar}", "inplane"); - - if (s == "inplane" || s == "truss") - _init_loads_inplane(); - else if (s == "bracket") - _init_loads_bracket(); - else if (s == "eye_bar") - _init_loads_eye_bar(); - else - libmesh_error(); - } - - - // \subsection ex_5_inplane_loading Inplane - // - class FluxLoad: - public MAST::FieldFunction { - public: - FluxLoad(const std::string& nm, Real p, Real l1, Real fraction): - MAST::FieldFunction(nm), _p(p), _l1(l1), _frac(fraction) { } - virtual ~FluxLoad() {} - virtual void operator() (const libMesh::Point& p, const Real t, Real& v) const { - if (fabs(p(0)-_l1*0.5) <= 0.5*_frac*_l1) v = _p; - else v = 0.; - } - virtual void derivative(const MAST::FunctionBase& f, const libMesh::Point& p, const Real t, Real& v) const { - v = 0.; - } - protected: - Real _p, _l1, _frac; - }; - - - void _init_loads_inplane() { - - Real - frac = _input("load_length_fraction", "fraction of boundary length on which pressure will act", 0.2), - p_val = _input("pressure", "pressure on side of domain", 2.e4); - - FluxLoad - *press_f = new FluxLoad( "pressure", p_val, _length, frac), - *flux_f = new FluxLoad("heat_flux", -2.e6, _length, frac); - - // initialize the load - MAST::BoundaryConditionBase - *p_load = new MAST::BoundaryConditionBase(MAST::SURFACE_PRESSURE), - *f_load = new MAST::BoundaryConditionBase(MAST::HEAT_FLUX); - - p_load->add(*press_f); - _discipline->add_side_load(2, *p_load); - - f_load->add(*flux_f); - _indicator_discipline->add_side_load(2, *f_load); - - _field_functions.insert(press_f); - _field_functions.insert(flux_f); - } - - - // - // \subsection ex_5_bracket_loading Bracket - // - class BracketLoad: - public MAST::FieldFunction { - public: - BracketLoad(const std::string& nm, Real p, Real l1, Real fraction): - MAST::FieldFunction(nm), _p(p), _l1(l1), _frac(fraction) { } - virtual ~BracketLoad() {} - virtual void operator() (const libMesh::Point& p, const Real t, Real& v) const { - if (fabs(p(0) >= _l1*(1.-_frac))) v = _p; - else v = 0.; - } - virtual void derivative(const MAST::FunctionBase& f, const libMesh::Point& p, const Real t, Real& v) const { - v = 0.; - } - protected: - Real _p, _l1, _frac; - }; - - - - void _init_loads_bracket() { - - Real - length = _input("length", "length of domain along x-axis", 0.3), - frac = _input("load_length_fraction", "fraction of boundary length on which pressure will act", 0.125), - p_val = _input("pressure", "pressure on side of domain", 5.e7); - - BracketLoad - *press_f = new BracketLoad( "pressure", p_val, length, frac), - *flux_f = new BracketLoad("heat_flux", -2.e6, length, frac); - - // - // initialize the load - // - MAST::BoundaryConditionBase - *p_load = new MAST::BoundaryConditionBase(MAST::SURFACE_PRESSURE), - *f_load = new MAST::BoundaryConditionBase(MAST::HEAT_FLUX); - - p_load->add(*press_f); - _discipline->add_side_load(5, *p_load); - - f_load->add(*flux_f); - _indicator_discipline->add_side_load(5, *f_load); - - _field_functions.insert(press_f); - _field_functions.insert(flux_f); - } - - - // - // \subsection ex_5_eyebar_loading Eyebar - // - class EyebarLoad: - public MAST::FieldFunction { - public: - EyebarLoad(): - MAST::FieldFunction("pressure") { } - virtual ~EyebarLoad() {} - virtual void operator() (const libMesh::Point& p, const Real t, Real& v) const { - if (p(0) <= 0.) v = (-std::pow(p(1), 2) + std::pow(1.5, 2))*1.e6; - else v = 0.; - } - virtual void derivative(const MAST::FunctionBase& f, const libMesh::Point& p, const Real t, Real& v) const { - v = 0.; - } - }; - - - - void _init_loads_eye_bar() { - - EyebarLoad - *press_f = new EyebarLoad(); - - // initialize the load - MAST::BoundaryConditionBase - *p_load = new MAST::BoundaryConditionBase(MAST::SURFACE_PRESSURE); - - p_load->add(*press_f); - _discipline->add_side_load(5, *p_load); - - _field_functions.insert(press_f); - } - - - // - // \section ex_5_properties Properties - // - // - // - // \subsection ex_5_material_properties Material Properties - // - - void _init_material() { - - Real - Eval = _input("E", "modulus of elasticity", 72.e9), - rhoval = _input("rho", "material density", 2700.), - nu_val = _input("nu", "Poisson's ratio", 0.33), - kappa_val = _input("kappa", "shear correction factor", 5./6.), - kval = _input("k", "thermal conductivity", 1.e-2), - cpval = _input("cp", "thermal capacitance", 864.); - - - MAST::Parameter - *E = new MAST::Parameter("E", Eval), - *rho = new MAST::Parameter("rho", rhoval), - *nu = new MAST::Parameter("nu", nu_val), - *kappa = new MAST::Parameter("kappa", kappa_val), - *k = new MAST::Parameter("k", kval), - *cp = new MAST::Parameter("cp", cpval); - - MAST::ConstantFieldFunction - *E_f = new MAST::ConstantFieldFunction( "E", *E), - *rho_f = new MAST::ConstantFieldFunction( "rho", *rho), - *nu_f = new MAST::ConstantFieldFunction( "nu", *nu), - *kappa_f = new MAST::ConstantFieldFunction("kappa", *kappa), - *k_f = new MAST::ConstantFieldFunction( "k_th", *k), - *cp_f = new MAST::ConstantFieldFunction( "cp", *cp); - - _parameters[ E->name()] = E; - _parameters[ rho->name()] = rho; - _parameters[ nu->name()] = nu; - _parameters[kappa->name()] = kappa; - _parameters[ k->name()] = k; - _parameters[ cp->name()] = cp; - _field_functions.insert(E_f); - _field_functions.insert(rho_f); - _field_functions.insert(nu_f); - _field_functions.insert(kappa_f); - _field_functions.insert(k_f); - _field_functions.insert(cp_f); - - _m_card = new MAST::IsotropicMaterialPropertyCard; - _m_card->add(*E_f); - _m_card->add(*rho_f); - _m_card->add(*nu_f); - _m_card->add(*kappa_f); - _m_card->add(*k_f); - _m_card->add(*cp_f); - } - - - // - // \subsection ex_5_section_properties Section Properties - // - - void _init_section_property(){ - - - - Real - th_v = _input("th", "thickness of 2D element", 0.001); - - MAST::Parameter - *th = new MAST::Parameter("th", th_v), - *zero = new MAST::Parameter("zero", 0.); - - MAST::ConstantFieldFunction - *th_f = new MAST::ConstantFieldFunction("h", *th), - *hoff_f = new MAST::ConstantFieldFunction("off", *zero); - - - _parameters[th->name()] = th; - _parameters[zero->name()] = zero; - _field_functions.insert(th_f); - _field_functions.insert(hoff_f); - - MAST::Solid2DSectionElementPropertyCard - *p_card = new MAST::Solid2DSectionElementPropertyCard; - - _p_card = p_card; - - // set nonlinear strain if requested - bool - nonlinear = _input("if_nonlinear", "flag to turn on/off nonlinear strain", false); - if (nonlinear) p_card->set_strain(MAST::NONLINEAR_STRAIN); - - p_card->add(*th_f); - p_card->add(*hoff_f); - p_card->set_material(*_m_card); - _discipline->set_property_for_subdomain(0, *p_card); - _indicator_discipline->set_property_for_subdomain(0, *p_card); - } - - - // - // \section ex_5_initial_solution Initial Level Set - // - // - class Phi: - public MAST::FieldFunction { - - public: - Phi(Real x0, - Real y0, - Real l1, - Real l2, - Real nx_mesh, - Real ny_mesh, - Real nx_holes, - Real ny_holes): - MAST::FieldFunction("Phi"), - _x0 (x0), - _y0 (y0), - _l1 (l1), - _l2 (l2), - _nx_mesh (nx_mesh), - _ny_mesh (ny_mesh), - _nx_holes (nx_holes), - _ny_holes (ny_holes), - _pi (acos(-1.)) { - - Real - dx = _l1/(1.*_nx_holes); - - for (unsigned int i=0; i<_nx_holes; i++) - _x_axis_hole_locations.insert(_x0+(i+.5)*dx); - - // - // now, along the y-axis - // - dx = _l2/(1.*_ny_holes); - for (unsigned int i=0; i<_ny_holes; i++) - _y_axis_hole_locations.insert(_y0+(i+0.5)*dx); - } - virtual ~Phi() {} - virtual void operator()(const libMesh::Point& p, - const Real t, - RealVectorX& v) const { - - libmesh_assert_less_equal(t, 1); - libmesh_assert_equal_to(v.size(), 1); - - // - // the libMesh solution projection routine for Lagrange elements - // will query the function value at the nodes. So, we figure - // out which nodes should have zero values set to them. - // if there is one hole in any direction, it will be in the - // center of the domain. If there are more than 1, then two of - // the holes will be on the boundary and others will fill the - // interior evenly. - // - const Real - dx_mesh = _l1/(1.*_nx_holes), - dy_mesh = _l2/(1.*_ny_holes); - - std::set::const_iterator - x_it_low = _x_axis_hole_locations.lower_bound(p(0)-dx_mesh), - y_it_low = _y_axis_hole_locations.lower_bound(p(1)-dy_mesh); - - unsigned int - n = 0; - // - // see if the x-location needs a hole - // - for ( ; x_it_low != _x_axis_hole_locations.end(); x_it_low++) { - if (std::fabs(*x_it_low - p(0)) <= dx_mesh*0.25) { - n++; - break; - } - } - - // - // now check the y-location - // - for ( ; y_it_low != _y_axis_hole_locations.end(); y_it_low++) { - if (std::fabs(*y_it_low - p(1)) <= dy_mesh*0.25) { - n++; - break; - } - } - - if (n == 2) - v(0) = -1.e0; - else - v(0) = 1.e0; - } - protected: - Real - _x0, - _y0, - _l1, - _l2, - _nx_mesh, - _ny_mesh, - _nx_holes, - _ny_holes, - _pi; - std::set _x_axis_hole_locations; - std::set _y_axis_hole_locations; - }; - - - void initialize_solution() { - - // - // initialize solution of the level set problem - // - unsigned int - nx_h = _input("initial_level_set_n_holes_in_x", - "number of holes along x-direction for initial level-set field", 6), - ny_h = _input("initial_level_set_n_holes_in_y", - "number of holes along y-direction for initial level-set field", 6), - nx_m = _input("level_set_nx_divs", "number of elements of level-set mesh along x-axis", 10), - ny_m = _input("level_set_ny_divs", "number of elements of level-set mesh along y-axis", 10); - - std::string - s = _input("mesh", "type of mesh to be analyzed {inplane, truss, bracket, eyebar}", "inplane"); - - std::unique_ptr phi; - - if (s == "inplane" || s == "truss" || s == "bracket") - phi.reset(new Phi(0., 0., _length, _height, nx_m, ny_m, nx_h, ny_h)); - else if (s == "eye_bar") - phi.reset(new Phi(-0.5*_height, -0.5*_height, _length, _height, nx_m, ny_m, nx_h, ny_h)); - else - libmesh_error(); - - _level_set_sys_init->initialize_solution(*phi); - } - - - void _init_phi_dvs() { - - std::string - s = _input("mesh", "type of mesh to be analyzed {inplane, truss, bracket, eye_bar}", "inplane"); - - if (s == "inplane" || s == "truss") - _init_phi_dvs_inplane(); - else if (s == "bracket") - _init_phi_dvs_bracket(); - else if (s == "eye_bar") - _init_phi_dvs_eye_bar(); - else - libmesh_error(); - - Real - filter_radius = _input("filter_radius", "radius of geometric filter for level set field", 0.015); - _filter = new MAST::FilterBase(*_level_set_sys, filter_radius, _dv_dof_ids); - libMesh::NumericVector& vec = _level_set_sys->add_vector("base_values"); - vec = *_level_set_sys->solution; - vec.close(); - } - - // - // \subsection ex_5_inplane_initial_level_set Inplane - // - void _init_phi_dvs_inplane() { - - // - // this assumes that level set is defined using lagrange shape functions - // - libmesh_assert_equal_to(_level_set_fetype.family, libMesh::LAGRANGE); - - Real - frac = _input("load_length_fraction", "fraction of boundary length on which pressure will act", 0.2), - filter_radius = _input("filter_radius", "radius of geometric filter for level set field", 0.015); - - unsigned int - dof_id = 0; - - Real - val = 0.; - - // - // all ranks will have DVs defined for all variables. So, we should be - // operating on a replicated mesh - // - libmesh_assert(_level_set_mesh->is_replicated()); - - std::vector local_phi(_level_set_sys->solution->size()); - _level_set_sys->solution->localize(local_phi); - - // iterate over all the node values - libMesh::MeshBase::const_node_iterator - it = _level_set_mesh->nodes_begin(), - end = _level_set_mesh->nodes_end(); - - // - // maximum number of dvs is the number of nodes on the level set function - // mesh. We will evaluate the actual number of dvs - // - _dv_params.reserve(_level_set_mesh->n_nodes()); - _n_vars = 0; - - for ( ; it!=end; it++) { - - const libMesh::Node& n = **it; - - dof_id = n.dof_number(0, 0, 0); - - // only if node is not on the upper edge - if ((n(1)+filter_radius >= _height) && - (n(0)-filter_radius <= _length*.5*(1.+frac)) && - (n(0)+filter_radius >= _length*.5*(1.-frac))) { - - // set value at the material points to a small positive number - if (dof_id >= _level_set_sys->solution->first_local_index() && - dof_id < _level_set_sys->solution->last_local_index()) - _level_set_sys->solution->set(dof_id, 1.e0); - } - else { - - std::ostringstream oss; - oss << "dv_" << _n_vars; - val = local_phi[dof_id]; - - _dv_params.push_back(std::pair()); - _dv_params[_n_vars].first = dof_id; - _dv_params[_n_vars].second = new MAST::LevelSetParameter(oss.str(), val, &n); - _dv_params[_n_vars].second->set_as_topology_parameter(true); - _dv_dof_ids.insert(dof_id); - - _n_vars++; - } - } - - _level_set_sys->solution->close(); - } - - // - // \subsection ex_5_truss_initial_level_set Truss - // - void _init_phi_dvs_truss() { - - // - // this assumes that level set is defined using lagrange shape functions - // - libmesh_assert_equal_to(_level_set_fetype.family, libMesh::LAGRANGE); - - Real - frac = _input("load_length_fraction", "fraction of boundary length on which pressure will act", 0.2), - filter_radius = _input("filter_radius", "radius of geometric filter for level set field", 0.015); - - unsigned int - dof_id = 0; - - Real - val = 0.; - - // - // all ranks will have DVs defined for all variables. So, we should be - // operating on a replicated mesh - // - libmesh_assert(_level_set_mesh->is_replicated()); - - std::vector local_phi(_level_set_sys->solution->size()); - _level_set_sys->solution->localize(local_phi); - - // iterate over all the node values - libMesh::MeshBase::const_node_iterator - it = _level_set_mesh->nodes_begin(), - end = _level_set_mesh->nodes_end(); - - // - // maximum number of dvs is the number of nodes on the level set function - // mesh. We will evaluate the actual number of dvs - // - _dv_params.reserve(_level_set_mesh->n_nodes()); - _n_vars = 0; - - for ( ; it!=end; it++) { - - const libMesh::Node& n = **it; - - dof_id = n.dof_number(0, 0, 0); - - // only if node is not on the upper edge - if ((n(1)-filter_radius <= 0.) && - (n(0)-filter_radius <= _length*.5*(1.+frac)) && - (n(0)+filter_radius >= _length*.5*(1.-frac))) { - - // set value at the material points to a small positive number - if (dof_id >= _level_set_sys->solution->first_local_index() && - dof_id < _level_set_sys->solution->last_local_index()) - _level_set_sys->solution->set(dof_id, 1.e0); - } - else { - - std::ostringstream oss; - oss << "dv_" << _n_vars; - val = local_phi[dof_id]; - - _dv_params.push_back(std::pair()); - _dv_params[_n_vars].first = dof_id; - _dv_params[_n_vars].second = new MAST::LevelSetParameter(oss.str(), val, &n); - _dv_params[_n_vars].second->set_as_topology_parameter(true); - _dv_dof_ids.insert(dof_id); - - _n_vars++; - } - } + + void _init_eq_sys() { + + _eq_sys->init(); + _sys->eigen_solver->set_position_of_spectrum(libMesh::LARGEST_MAGNITUDE); + _sys->set_exchange_A_and_B(true); - _level_set_sys->solution->close(); + _level_set_eq_sys->init(); } + // - // \subsection ex_5_bracket_initial_level_set Bracket + // variables added to the mesh // - void _init_phi_dvs_bracket() { - - libmesh_assert(_initialized); - // - // this assumes that level set is defined using lagrange shape functions - // - libmesh_assert_equal_to(_level_set_fetype.family, libMesh::LAGRANGE); + void _init_fetype() { - Real - tol = 1.e-12, - length = _input("length", "length of domain along x-axis", 0.3), - height = _input("height", "length of domain along y-axis", 0.3), - l_frac = 0.4,//_input("length_fraction", "fraction of length along x-axis that is in the bracket", 0.4), - h_frac = 0.4,//_input( "height_fraction", "fraction of length along y-axis that is in the bracket", 0.4), - x_lim = length * l_frac, - y_lim = height * (1.-h_frac), - frac = _input("load_length_fraction", "fraction of boundary length on which pressure will act", 0.125), - filter_radius = _input("filter_radius", "radius of geometric filter for level set field", 0.015); + // FEType to initialize the system. Get the order and type of element. + std::string + order_str = _input("fe_order", "order of finite element shape basis functions", "first"), + family_str = _input("fe_family", "family of finite element shape functions", "lagrange"); - unsigned int - dof_id = 0; + libMesh::Order + o = libMesh::Utility::string_to_enum(order_str); + libMesh::FEFamily + fe = libMesh::Utility::string_to_enum(family_str); + _fetype = libMesh::FEType(o, fe); + } + + + // + // \section ex_5_properties Properties + // + // + // + // \subsection ex_5_material_properties Material Properties + // + + void _init_material() { Real - val = 0.; - - // - // all ranks will have DVs defined for all variables. So, we should be - // operating on a replicated mesh - // - libmesh_assert(_level_set_mesh->is_replicated()); - - std::vector local_phi(_level_set_sys->solution->size()); - _level_set_sys->solution->localize(local_phi); + Eval = _input("E", "modulus of elasticity", 72.e9), + rhoval = _input("rho", "material density", 2700.), + nu_val = _input("nu", "Poisson's ratio", 0.33), + kappa_val = _input("kappa", "shear correction factor", 5./6.), + kval = _input("k", "thermal conductivity", 1.e-2), + cpval = _input("cp", "thermal capacitance", 864.); - // - // iterate over all the node values - // - libMesh::MeshBase::const_node_iterator - it = _level_set_mesh->nodes_begin(), - end = _level_set_mesh->nodes_end(); - // - // maximum number of dvs is the number of nodes on the level set function - // mesh. We will evaluate the actual number of dvs - // - _dv_params.reserve(_level_set_mesh->n_nodes()); - _n_vars = 0; + MAST::Parameter + *E = new MAST::Parameter("E", Eval), + *E_v = new MAST::Parameter("E_v", 0.), + *rho = new MAST::Parameter("rho", rhoval), + *nu = new MAST::Parameter("nu", nu_val), + *kappa = new MAST::Parameter("kappa", kappa_val), + *k = new MAST::Parameter("k", kval), + *cp = new MAST::Parameter("cp", cpval); - for ( ; it!=end; it++) { - - const libMesh::Node& n = **it; - - dof_id = n.dof_number(0, 0, 0); - - if ((n(1)-filter_radius) <= y_lim && (n(0)+filter_radius) >= length*(1.-frac)) { - - // - // set value at the constrained points to a small positive number - // material here - // - if (dof_id >= _level_set_sys->solution->first_local_index() && - dof_id < _level_set_sys->solution->last_local_index()) - _level_set_sys->solution->set(dof_id, 1.e0); - } - else { - - std::ostringstream oss; - oss << "dv_" << _n_vars; - val = local_phi[dof_id]; - - // - // on the boundary, set everything to be zero, so that there - // is always a boundary there that the optimizer can move - // - if (n(0) < tol || // left boundary - std::fabs(n(0) - length) < tol || // right boundary - std::fabs(n(1) - height) < tol || // top boundary - (n(0) >= x_lim && n(1) <= y_lim)) { - - if (dof_id >= _level_set_sys->solution->first_local_index() && - dof_id < _level_set_sys->solution->last_local_index()) - _level_set_sys->solution->set(dof_id, -1.0); - val = -1.0; - } - - _dv_params.push_back(std::pair()); - _dv_params[_n_vars].first = dof_id; - _dv_params[_n_vars].second = new MAST::LevelSetParameter(oss.str(), val, &n); - _dv_params[_n_vars].second->set_as_topology_parameter(true); - _dv_dof_ids.insert(dof_id); - - _n_vars++; - } - } + MAST::ConstantFieldFunction + *E_f = new MAST::ConstantFieldFunction( "E", *E), + *E_v_f = new MAST::ConstantFieldFunction( "E", *E_v), + *rho_f = new MAST::ConstantFieldFunction( "rho", *rho), + *nu_f = new MAST::ConstantFieldFunction( "nu", *nu), + *kappa_f = new MAST::ConstantFieldFunction("kappa", *kappa), + *k_f = new MAST::ConstantFieldFunction( "k_th", *k), + *cp_f = new MAST::ConstantFieldFunction( "cp", *cp); - _level_set_sys->solution->close(); + _parameters[ E->name()] = E; + _parameters[ E_v->name()] = E_v; + _parameters[ rho->name()] = rho; + _parameters[ nu->name()] = nu; + _parameters[kappa->name()] = kappa; + _parameters[ k->name()] = k; + _parameters[ cp->name()] = cp; + _field_functions.insert(E_f); + _field_functions.insert(E_v_f); + _field_functions.insert(rho_f); + _field_functions.insert(nu_f); + _field_functions.insert(kappa_f); + _field_functions.insert(k_f); + _field_functions.insert(cp_f); + + _m_card1 = new MAST::IsotropicMaterialPropertyCard; + _m_card2 = new MAST::IsotropicMaterialPropertyCard; + _m_card1->add(*E_f); + _m_card1->add(*rho_f); + _m_card1->add(*nu_f); + _m_card1->add(*kappa_f); + _m_card1->add(*k_f); + _m_card1->add(*cp_f); + + // material for void + _m_card2->add(*E_v_f); + _m_card2->add(*rho_f); + _m_card2->add(*nu_f); + _m_card2->add(*kappa_f); + _m_card2->add(*k_f); + _m_card2->add(*cp_f); } - + // - // \subsection ex_5_eyebar_initial_level_set Eyebar + // \subsection ex_5_section_properties Section Properties // - void _init_phi_dvs_eye_bar() { + + void _init_section_property(){ + - libmesh_assert(_initialized); - // - // this assumes that level set is defined using lagrange shape functions - // - libmesh_assert_equal_to(_level_set_fetype.family, libMesh::LAGRANGE); Real - tol = 1.e-6, - filter_radius = _input("filter_radius", "radius of geometric filter for level set field", 0.015); + th_v = _input("th", "thickness of 2D element", 0.001); - unsigned int - dof_id = 0; + MAST::Parameter + *th = new MAST::Parameter("th", th_v), + *zero = new MAST::Parameter("zero", 0.); - Real - val = 0.; + MAST::ConstantFieldFunction + *th_f = new MAST::ConstantFieldFunction("h", *th), + *hoff_f = new MAST::ConstantFieldFunction("off", *zero); - // - // all ranks will have DVs defined for all variables. So, we should be - // operating on a replicated mesh - // - libmesh_assert(_level_set_mesh->is_replicated()); - std::vector local_phi(_level_set_sys->solution->size()); - _level_set_sys->solution->localize(local_phi); + _parameters[th->name()] = th; + _parameters[zero->name()] = zero; + _field_functions.insert(th_f); + _field_functions.insert(hoff_f); - // - // iterate over all the node values - // - libMesh::MeshBase::const_node_iterator - it = _level_set_mesh->nodes_begin(), - end = _level_set_mesh->nodes_end(); + MAST::Solid2DSectionElementPropertyCard + *p_card1 = new MAST::Solid2DSectionElementPropertyCard, + *p_card2 = new MAST::Solid2DSectionElementPropertyCard; - // - // maximum number of dvs is the number of nodes on the level set function - // mesh. We will evaluate the actual number of dvs - // - _dv_params.reserve(_level_set_mesh->n_nodes()); - _n_vars = 0; + _p_card1 = p_card1; + _p_card2 = p_card2; + + // set nonlinear strain if requested + bool + nonlinear = _input("if_nonlinear", "flag to turn on/off nonlinear strain", false); + if (nonlinear) _p_card1->set_strain(MAST::NONLINEAR_STRAIN); + _p_card2->set_strain(MAST::LINEAR_STRAIN); + + p_card1->add(*th_f); + p_card1->add(*hoff_f); + p_card1->set_material(*_m_card1); + + // property card for void + p_card2->add(*th_f); + p_card2->add(*hoff_f); + p_card2->set_material(*_m_card2); - for ( ; it!=end; it++) { - - const libMesh::Node& n = **it; - - dof_id = n.dof_number(0, 0, 0); - - if (((n.norm() <= 1.5+filter_radius) && n(0) <= 0.) || // circle - (std::fabs(n(0)-_height*1.5) < filter_radius && // right edge - std::fabs(n(1)) <= 1.+filter_radius)) { // dirichlet constraint - - // - // set value at the constrained points to a small positive number - // material here - // - if (dof_id >= _level_set_sys->solution->first_local_index() && - dof_id < _level_set_sys->solution->last_local_index()) - _level_set_sys->solution->set(dof_id, 1.e0); - } - else { - - std::ostringstream oss; - oss << "dv_" << _n_vars; - val = local_phi[dof_id]; - - // - // on the boundary, set everything to be zero, so that there - // is always a boundary there that the optimizer can move - // - if (std::fabs(n(0)+_height*0.5) < tol || // left boundary - std::fabs(n(1)-_height*0.5) < tol || // top boundary - std::fabs(n(1)+_height*0.5) < tol || // bottom boundary - std::fabs(n(0)-_height*1.5) < tol) { // right boundary - - if (dof_id >= _level_set_sys->solution->first_local_index() && - dof_id < _level_set_sys->solution->last_local_index()) - _level_set_sys->solution->set(dof_id, -1.); - val = -1.; - } - - _dv_params.push_back(std::pair()); - _dv_params[_n_vars].first = dof_id; - _dv_params[_n_vars].second = new MAST::LevelSetParameter(oss.str(), val, &n); - _dv_params[_n_vars].second->set_as_topology_parameter(true); - _dv_dof_ids.insert(dof_id); - - _n_vars++; - } - } + _discipline->set_property_for_subdomain(0, *p_card1); + _discipline->set_property_for_subdomain(1, *p_card1); - _level_set_sys->solution->close(); - } + // inactive + _discipline->set_property_for_subdomain(3, *p_card2); - + // negative level set + _discipline->set_property_for_subdomain(6, *p_card2); + _discipline->set_property_for_subdomain(7, *p_card2); + + _indicator_discipline->set_property_for_subdomain(0, *p_card1); + _indicator_discipline->set_property_for_subdomain(1, *p_card1); + _indicator_discipline->set_property_for_subdomain(3, *p_card2); + _indicator_discipline->set_property_for_subdomain(4, *p_card2); + } + // // \subsection ex_5_design_variable_init Design Variables // @@ -1604,6 +511,8 @@ public MAST::FunctionEvaluation { } } + + class ElemFlag: public libMesh::MeshRefinement::ElementFlagging { public: ElemFlag(libMesh::MeshBase& mesh, MAST::FieldFunction& phi, unsigned int max_h): @@ -1642,7 +551,87 @@ public MAST::FunctionEvaluation { MAST::FieldFunction& _phi; unsigned int _max_h; }; + + + void mark_shifted_boundary(unsigned int b_id) { + + // remove the previous information for boundary id + _mesh->boundary_info->remove_id(b_id); + + MAST::LevelSetIntersection intersection; + + libMesh::MeshBase::element_iterator + it = _mesh->active_local_elements_begin(), + end = _mesh->active_local_elements_end(); + + std::set sides; + std::vector bids; + + std::map neighbor_side_pairs; + neighbor_side_pairs[0] = 2; + neighbor_side_pairs[1] = 3; + neighbor_side_pairs[2] = 0; + neighbor_side_pairs[3] = 1; + + for ( ; it != end; it++) { + + libMesh::Elem* elem = *it; + + // begin by setting all subdomain id to 0. + elem->subdomain_id() = 0; + + intersection.init(*_level_set_function, *elem, 0., + _mesh->max_elem_id(), + _mesh->max_node_id()); + if (intersection.if_intersection_through_elem()) { + // set the shifted boundary to one which is + // completely inside the material without any intersection + // on the edge + + sides.clear(); + intersection.get_material_sides_without_intersection(sides); + + // add this side in the boundary info object + std::set::const_iterator + it = sides.begin(), + end = sides.end(); + for (; it != end; it++) { + + bids.clear(); + _mesh->boundary_info->boundary_ids(elem, *it, bids); + + // if this side has been identied as a dirichlet condition + // then we do not include it in the set + bool set_id = true; + //for (unsigned int i=0; ineighbor_ptr(*it); + // the side may be on the boundary, in which case + // no boundary should be set. + if (e) + _mesh->boundary_info->add_side(e, neighbor_side_pairs[*it], b_id); + } + } + + // any element with an intersection will be included in the void + // set since its interaction is included using the sifted boundary + // method. + elem->subdomain_id() = 3; + } + else if (intersection.if_elem_on_negative_phi()) + elem->subdomain_id() = 3; + intersection.clear(); + } + } // // \subsection ex_5_function_evaluation Function Evaluation @@ -1669,6 +658,25 @@ public MAST::FunctionEvaluation { _filter->compute_filtered_values(base_phi, *_level_set_sys->solution); _level_set_function->init(*_level_set_sys_init, *_level_set_sys->solution); _sys->solution->zero(); + + _level_set_vel->init(*_level_set_sys_init, + *_level_set_function, + *_level_set_sys->solution, nullptr); + + /*if (_mesh_refinement->initialized()) { + + _mesh_refinement->clear_mesh(); + _eq_sys->reinit(); + } + + if (_mesh_refinement->process_mesh(*_level_set_function, + true, // strong discontinuity + 0., + 6, // negative_level_set_subdomain_offset + 3, // inactive_subdomain_offset + 8)) // level_set_boundary_id + _eq_sys->reinit();*/ + //********************************************************************* // DO NOT zero out the gradient vector, since GCMMA needs it for the * @@ -1751,7 +759,6 @@ public MAST::FunctionEvaluation { level_set_assembly.set_level_set_velocity_function(*_level_set_vel); nonlinear_elem_ops.set_discipline_and_system(*_discipline, *_sys_init); modal_elem_ops.set_discipline_and_system(*_discipline, *_sys_init); - //nonlinear_assembly.plot_sub_elems(true, false, true); libMesh::MeshRefinement refine(*_mesh); @@ -1762,7 +769,7 @@ public MAST::FunctionEvaluation { bool continue_refining = true; Real - threshold = 0.05; + threshold = _input("refinement_threshold","threshold for element to be refined", 0.1); unsigned int n_refinements = 0, max_refinements = _input("max_refinements","maximum refinements", 3); @@ -1795,10 +802,17 @@ public MAST::FunctionEvaluation { else continue_refining = false; } + /*if (_mesh_refinement->process_mesh(*_level_set_function, + true, // strong discontinuity + 0., + 6, // negative_level_set_subdomain_offset + 3, // inactive_subdomain_offset + 8)) // level_set_boundary_id + _eq_sys->reinit();*/ - MAST::LevelSetVolume volume(level_set_assembly.get_intersection()); - MAST::LevelSetPerimeter perimeter(level_set_assembly.get_intersection()); + MAST::LevelSetVolume volume; + MAST::LevelSetPerimeter perimeter; MAST::StressStrainOutputBase stress; MAST::ComplianceOutput compliance; volume.set_discipline_and_system(*_level_set_discipline, *_level_set_sys_init); @@ -1833,12 +847,11 @@ public MAST::FunctionEvaluation { return; } - nonlinear_assembly.calculate_output(*_sys->solution, stress); - //nonlinear_assembly.calculate_output(*_sys->solution, compliance); - ////////////////////////////////////////////////////////////////////// - // evaluate the objective + // evaluate the functions ////////////////////////////////////////////////////////////////////// + + level_set_assembly.set_evaluate_output_on_negative_phi(false); level_set_assembly.calculate_output(*_level_set_sys->solution, volume); level_set_assembly.set_evaluate_output_on_negative_phi(true); @@ -1846,26 +859,43 @@ public MAST::FunctionEvaluation { level_set_assembly.set_evaluate_output_on_negative_phi(false); Real - max_vm = stress.get_maximum_von_mises_stress(), - vm_agg = stress.output_total(), - vf = _input("volume_fraction", "volume fraction", 0.3), + max_vm = 0., + vm_agg = 0., vol = volume.output_total(), per = perimeter.output_total(), - comp = compliance.output_total(); - - obj = _obj_scaling * (vol + _perimeter_penalty * per); - //_obj_scaling * (vol+ _perimeter_penalty * per) + - //_stress_penalty * (vm_agg);///_stress_lim - 1.); - - fvals[0] = stress.output_total()/_stress_lim - 1.; // g = sigma/sigma0-1 <= 0 - //fvals[0] = stress.output_total()/_length/_height; // g <= 0 for the smooth ramp function - //fvals[0] = vol/_length/_height - vf; // vol/vol0 - a <= - libMesh::out << "volume: " << vol << " perim: " << per << std::endl; - libMesh::out << "max: " << max_vm << " constr: " << vm_agg/_stress_lim - 1. - << std::endl; - libMesh::out << "compliance: " << comp << std::endl; + comp = 0.; - if (_n_eig_vals) { + libMesh::out << "volume: " << vol << " perim: " << per << std::endl; + + // evaluate the output based on specified problem type + if (_problem == "compliance_volume") { + + Real + vf = _input("volume_fraction", "volume fraction", 0.3); + + // if the shifted boundary is implementing a traction-free condition + // compliance does not need contribution from shifted boundary load + nonlinear_assembly.calculate_output(*_sys->solution, compliance); + comp = compliance.output_total(); + obj = _obj_scaling * (comp + _perimeter_penalty * per); + fvals[0] = vol/_volume - vf; // vol/vol0 - a <= + libMesh::out << "compliance: " << comp << std::endl; + } + else if (_problem == "volume_stress") { + + // set the elasticity penalty for stress evaluation + nonlinear_assembly.calculate_output(*_sys->solution, stress); + max_vm = stress.get_maximum_von_mises_stress(); + vm_agg = stress.output_total(); + obj = _obj_scaling * (vol + _perimeter_penalty * per); + fvals[0] = stress.output_total()/_stress_lim - 1.; // g = sigma/sigma0-1 <= 0 + //fvals[0] = stress.output_total()/_length/_height; // g <= 0 for the smooth ramp function + libMesh::out + << " max: " << max_vm + << " constr: " << vm_agg + << std::endl; + } + else if (_problem == "volume_eigenvalue" && _n_eig_vals) { ////////////////////////////////////////////////////////////////////// // evaluate the eigenvalue constraint @@ -1891,24 +921,39 @@ public MAST::FunctionEvaluation { for (unsigned int i=0; i<_n_eig_vals; i++) fvals[i+1] = -eig[i]/_ref_eig_val + 1.; } - + else + libmesh_error(); + ////////////////////////////////////////////////////////////////////// // evaluate the objective sensitivities, if requested ////////////////////////////////////////////////////////////////////// if (eval_obj_grad) { - std::vector - grad1(obj_grad.size(), 0.); - - _evaluate_volume_sensitivity(&volume, &perimeter, level_set_assembly, obj_grad); - - /*_evaluate_compliance_sensitivity(compliance, - nonlinear_elem_ops, - nonlinear_assembly, - grad1); - - for (unsigned int i=0; i + grad1(obj_grad.size(), 0.); + + _evaluate_volume_sensitivity(nullptr, &perimeter, level_set_assembly, obj_grad); + + _evaluate_compliance_sensitivity(compliance, + nonlinear_elem_ops, + nonlinear_assembly, + grad1); + + for (unsigned int i=0; iclose(); _filter->compute_filtered_values(*dphi_base, *dphi_filtered); - _level_set_vel->init(*_level_set_sys_init, *_level_set_sys->solution, *dphi_filtered); + _level_set_vel->init(*_level_set_sys_init, + *_level_set_function, + *_level_set_sys->solution, + dphi_filtered.get()); // if the volume output was specified then compute the sensitivity // and add to the grad vector @@ -1984,8 +1042,7 @@ public MAST::FunctionEvaluation { *_dv_params[i].second, *volume); - grad[i] = _obj_scaling * volume->output_sensitivity_total(*_dv_params[i].second); - //grad[i] = volume->output_sensitivity_total(*_dv_params[i].second)/_length/_height; + grad[i] = volume->output_sensitivity_total(*_dv_params[i].second); } // if the perimeter output was specified then compute the sensitivity @@ -1998,7 +1055,7 @@ public MAST::FunctionEvaluation { *perimeter); assembly.set_evaluate_output_on_negative_phi(false); - grad[i] += _obj_scaling * _perimeter_penalty * + grad[i] += _perimeter_penalty * perimeter->output_sensitivity_total(*_dv_params[i].second); } } @@ -2015,7 +1072,7 @@ public MAST::FunctionEvaluation { _evaluate_stress_sensitivity (MAST::StressStrainOutputBase& stress, MAST::AssemblyElemOperations& nonlinear_elem_ops, - MAST::LevelSetNonlinearImplicitAssembly& nonlinear_assembly, + MAST::NonlinearImplicitAssembly& nonlinear_assembly, MAST::StructuralModalEigenproblemAssemblyElemOperations& eigen_elem_ops, MAST::LevelSetEigenproblemAssembly& eigen_assembly, std::vector& grads) { @@ -2051,7 +1108,10 @@ public MAST::FunctionEvaluation { // // initialize the level set perturbation function to create a velocity // field - _level_set_vel->init(*_level_set_sys_init, *_level_set_sys->solution, *dphi_filtered); + _level_set_vel->init(*_level_set_sys_init, + *_level_set_function, + *_level_set_sys->solution, + dphi_filtered.get()); ////////////////////////////////////////////////////////////////////// // stress sensitivity @@ -2087,11 +1147,14 @@ public MAST::FunctionEvaluation { _evaluate_compliance_sensitivity (MAST::ComplianceOutput& compliance, MAST::AssemblyElemOperations& nonlinear_elem_ops, - MAST::LevelSetNonlinearImplicitAssembly& nonlinear_assembly, + MAST::NonlinearImplicitAssembly& nonlinear_assembly, std::vector& grads) { // Adjoint solution for compliance = - X - + // if the shifted boundary is implementing a traction-free condition + // compliance does not need contribution from shifted boundary load + _sys->adjoint_solve(nonlinear_elem_ops, compliance, nonlinear_assembly, false); + std::unique_ptr> dphi_base(_level_set_sys->solution->zero_clone().release()), dphi_filtered(_level_set_sys->solution->zero_clone().release()); @@ -2119,14 +1182,17 @@ public MAST::FunctionEvaluation { // // initialize the level set perturbation function to create a velocity // field - _level_set_vel->init(*_level_set_sys_init, *_level_set_sys->solution, *dphi_filtered); + _level_set_vel->init(*_level_set_sys_init, + *_level_set_function, + *_level_set_sys->solution, + dphi_filtered.get()); ////////////////////////////////////////////////////////////////////// // compliance sensitivity ////////////////////////////////////////////////////////////////////// - grads[i] = -1. * + grads[i] = 1. * nonlinear_assembly.calculate_output_adjoint_sensitivity(*_sys->solution, - *_sys->solution, + _sys->get_adjoint_solution(), *_dv_params[i].second, nonlinear_elem_ops, compliance); @@ -2134,6 +1200,9 @@ public MAST::FunctionEvaluation { nonlinear_assembly.clear_elem_parameter_dependence_object(); } + + + void set_n_vars(const unsigned int n_vars) {_n_vars = n_vars;} // // \subsection ex_5_design_output Output of Design Iterate @@ -2253,13 +1322,13 @@ public MAST::FunctionEvaluation { // \subsection ex_5_constructor Constructor // - TopologyOptimizationLevelSet2D(const libMesh::Parallel::Communicator& comm_in, + TopologyOptimizationLevelSet(const libMesh::Parallel::Communicator& comm_in, MAST::Examples::GetPotWrapper& input): MAST::FunctionEvaluation (comm_in), _initialized (false), _input (input), - _length (0.), - _height (0.), + _problem (), + _volume (0.), _obj_scaling (0.), _stress_penalty (0.), _perimeter_penalty (0.), @@ -2270,6 +1339,7 @@ public MAST::FunctionEvaluation { _n_eig_vals (0), _mesh (nullptr), _level_set_mesh (nullptr), + _mesh_refinement (nullptr), _eq_sys (nullptr), _level_set_eq_sys (nullptr), _sys (nullptr), @@ -2280,36 +1350,56 @@ public MAST::FunctionEvaluation { _level_set_sys_init_on_str_mesh (nullptr), _level_set_sys_init (nullptr), _indicator_sys_init (nullptr), + _nsp (nullptr), _discipline (nullptr), _indicator_discipline (nullptr), _level_set_discipline (nullptr), _filter (nullptr), - _m_card (nullptr), - _p_card (nullptr), + _m_card1 (nullptr), + _m_card2 (nullptr), + _p_card1 (nullptr), + _p_card2 (nullptr), _level_set_function (nullptr), _level_set_vel (nullptr), - _output (nullptr) { + _output (nullptr), + _shifted_boundary_load (nullptr) { libmesh_assert(!_initialized); // // call the initialization routines for each component // + + std::string + s = _input("mesh", "type of mesh to be analyzed {inplane, bracket, truss, eyebar}", + "inplane"); + + _mesh = new libMesh::SerialMesh(this->comm()); + _level_set_mesh = new libMesh::SerialMesh(this->comm()); + + _init_fetype(); - _init_mesh(); + T::init_analysis_mesh(*this, *_mesh); + T::init_level_set_mesh(*this, *_level_set_mesh); _init_system_and_discipline(); - _init_dirichlet_conditions(); + T::init_analysis_dirichlet_conditions(*this); + T::init_indicator_dirichlet_conditions(*this); _init_eq_sys(); _init_material(); - _init_loads(); + T::init_structural_loads(*this); + T::init_indicator_loads(*this); _init_section_property(); _initialized = true; + _nsp = new MAST::StructuralNearNullVectorSpace; + _sys->nonlinear_solver->nearnullspace_object = _nsp; + // // ask structure to use Mindlin bending operator // - dynamic_cast(*_p_card).set_bending_model(MAST::MINDLIN); - + dynamic_cast(*_p_card1).set_bending_model(MAST::MINDLIN); + dynamic_cast(*_p_card2).set_bending_model(MAST::MINDLIN); + ///////////////////////////////////////////////// // now initialize the design data. ///////////////////////////////////////////////// @@ -2317,15 +1407,25 @@ public MAST::FunctionEvaluation { // // first, initialize the level set functions over the domain // - this->initialize_solution(); + T::initialize_level_set_solution(*this); // // next, define a new parameter to define design variable for nodal level-set // function value // - this->_init_phi_dvs(); + T::init_level_set_dvs(*this); + + Real + filter_radius = _input("filter_radius", "radius of geometric filter for level set field", 0.015); + _filter = new MAST::FilterBase(*_level_set_sys, filter_radius, _dv_dof_ids); + libMesh::NumericVector& vec = _level_set_sys->add_vector("base_values"); + vec = *_level_set_sys->solution; + vec.close(); + - _obj_scaling = 1./_length/_height; + _problem = _input("problem_type", "{compliance_volume, volume_stress}", "compliance_volume"); + _volume = T::reference_volume(*this); + _obj_scaling = 1./_volume; _stress_penalty = _input("stress_penalty", "penalty value for stress_constraint", 0.); _perimeter_penalty = _input("perimeter_penalty", "penalty value for perimeter in the objective function", 0.); _stress_lim = _input("vm_stress_limit", "limit von-mises stress value", 2.e8); @@ -2335,6 +1435,12 @@ public MAST::FunctionEvaluation { _level_set_function = new PhiMeshFunction; _output = new libMesh::ExodusII_IO(*_mesh); + MAST::BoundaryConditionBase + *bc = new MAST::BoundaryConditionBase(MAST::BOUNDARY_VELOCITY); + bc->add(*_level_set_vel); + _discipline->add_side_load(8, *bc); + _boundary_conditions.insert(bc); + _n_eig_vals = _input("n_eig", "number of eigenvalues to constrain", 0); if (_n_eig_vals) { // @@ -2359,7 +1465,7 @@ public MAST::FunctionEvaluation { // // \subsection ex_5_destructor Destructor // - ~TopologyOptimizationLevelSet2D() { + ~TopologyOptimizationLevelSet() { { std::set::iterator @@ -2388,10 +1494,15 @@ public MAST::FunctionEvaluation { if (!_initialized) return; - delete _m_card; - delete _p_card; - + delete _nsp; + + delete _m_card1; + delete _m_card2; + delete _p_card1; + delete _p_card2; + delete _eq_sys; + delete _mesh_refinement; delete _mesh; delete _discipline; @@ -2421,7 +1532,7 @@ public MAST::FunctionEvaluation { // \subsection ex_5_wrappers_snopt Wrappers for SNOPT // -TopologyOptimizationLevelSet2D* _my_func_eval = nullptr; +MAST::FunctionEvaluation* _my_func_eval = nullptr; #if MAST_ENABLE_SNOPT == 1 @@ -2585,12 +1696,40 @@ int main(int argc, char* argv[]) { MAST::Examples::GetPotWrapper input(argc, argv, "input"); - TopologyOptimizationLevelSet2D top_opt(init.comm(), input); - _my_func_eval = &top_opt; + + std::unique_ptr + top_opt; + + std::string + mesh = input("mesh", "inplane2d, bracket2d, truss2d, eyebar2d", "inplane2d"); + + if (mesh == "inplane2d") { + top_opt.reset + (new TopologyOptimizationLevelSet + (init.comm(), input)); + } + else if (mesh == "bracket2d") { + top_opt.reset + (new TopologyOptimizationLevelSet + (init.comm(), input)); + } + else if (mesh == "eyebar2d") { + top_opt.reset + (new TopologyOptimizationLevelSet + (init.comm(), input)); + } + else if (mesh == "truss2d") { + top_opt.reset + (new TopologyOptimizationLevelSet + (init.comm(), input)); + } + else + libmesh_error(); + + _my_func_eval = top_opt.get(); + - //MAST::NLOptOptimizationInterface optimizer(NLOPT_LD_SLSQP); - std::unique_ptr - optimizer; + std::unique_ptr optimizer; std::string s = input("optimizer", "optimizer to use in the example", "gcmma"); @@ -2627,14 +1766,18 @@ int main(int argc, char* argv[]) { if (optimizer.get()) { - optimizer->attach_function_evaluation_object(top_opt); + optimizer->attach_function_evaluation_object(*top_opt); - //std::vector xx1(top_opt.n_vars()), xx2(top_opt.n_vars()); - //top_opt.init_dvar(xx1, xx2, xx2); - //top_opt.initialize_dv_from_output_file("output1.txt", 24, xx1); - //top_opt.verify_gradients(xx1); - optimizer->optimize(); - //top_opt.parametric_line_study("output1.txt", 0, 450, 500); + bool + verify_grads = input("verify_gradients", "If true, the gradients of objective and constraints will be verified without optimization", false); + if (verify_grads) { + + std::vector xx1(top_opt->n_vars()), xx2(top_opt->n_vars()); + top_opt->init_dvar(xx1, xx2, xx2); + top_opt->verify_gradients(xx1); + } + else + optimizer->optimize(); } // END_TRANSLATE diff --git a/examples/structural/example_6/example_6.cpp b/examples/structural/example_6/example_6.cpp index 656f9f38..1cee8092 100644 --- a/examples/structural/example_6/example_6.cpp +++ b/examples/structural/example_6/example_6.cpp @@ -32,6 +32,7 @@ #include "elasticity/level_set_stress_assembly.h" #include "elasticity/compliance_output.h" #include "elasticity/structural_system_initialization.h" +#include "elasticity/structural_near_null_vector_space.h" #include "base/parameter.h" #include "base/constant_field_function.h" #include "base/mesh_field_function.h" @@ -46,10 +47,13 @@ #include "optimization/gcmma_optimization_interface.h" #include "optimization/npsol_optimization_interface.h" #include "optimization/function_evaluation.h" +#include "examples/structural/base/bracket_2d_model.h" +#include "examples/structural/base/inplane_2d_model.h" +#include "examples/structural/base/truss_2d_model.h" +#include "examples/structural/base/eyebar_2d_model.h" // libMesh includes -#include "libmesh/parallel.h" #include "libmesh/fe_type.h" #include "libmesh/serial_mesh.h" #include "libmesh/equation_systems.h" @@ -60,6 +64,7 @@ #include "libmesh/petsc_nonlinear_solver.h" #include "libmesh/mesh_refinement.h" #include "libmesh/error_vector.h" +#include "libmesh/parallel.h" void @@ -81,7 +86,7 @@ _optim_con(int* mode, int* nstate); // -// BEGIN_TRANSLATE 2D SIMP topology optimization +// BEGIN_TRANSLATE SIMP topology optimization // // \tableofcontents // @@ -153,17 +158,17 @@ public MAST::AssemblyBase::ElemParameterDependence { }; - -class TopologyOptimizationSIMP2D: +template +class TopologyOptimizationSIMP: public MAST::FunctionEvaluation { -protected: +public: bool _initialized; MAST::Examples::GetPotWrapper& _input; - Real _length; - Real _height; + std::string _problem; + Real _volume; Real _obj_scaling; Real _stress_penalty; Real _perimeter_penalty; @@ -183,7 +188,9 @@ public MAST::FunctionEvaluation { MAST::StructuralSystemInitialization* _sys_init; MAST::PhysicsDisciplineBase* _discipline; - + + MAST::StructuralNearNullVectorSpace* _nsp; + MAST::FilterBase* _filter; MAST::MaterialPropertyCardBase* _m_card; @@ -201,266 +208,13 @@ public MAST::FunctionEvaluation { std::set _field_functions; std::set _boundary_conditions; std::set _dv_dof_ids; - - std::vector> _dv_params; + std::set _dirichlet_bc_ids; -public: - - // \section ex_6_init_mesh Mesh Generation - // This creates the mesh for the specified problem type. - // - void _init_mesh() { - - // The mesh is created using classes written in MAST. The particular - // mesh to be used can be selected using the input parameter - // ` mesh=val `, where `val` can be one of the following: - // - `inplane` inplane structure with load on top and left and right boundaries constrained - // - `bracket` L-bracket - // - std::string - s = _input("mesh", "type of mesh to be analyzed {inplane, bracket}", "inplane"); - - if (s == "inplane" || s == "truss") - _init_mesh_inplane(); - else if (s == "bracket") - _init_mesh_bracket(); - else if (s == "eye_bar") - _init_mesh_eye_bar(); - else - libmesh_error(); - } - - // - // \subsection ex_6_inplane_mesh Inplane problem - // - void _init_mesh_inplane() { - - _mesh = new libMesh::SerialMesh(this->comm()); - - // - // identify the element type from the input file or from the order - // of the element - // - unsigned int - nx_divs = _input("nx_divs", "number of elements along x-axis", 20), - ny_divs = _input("ny_divs", "number of elements along y-axis", 20); - - _length = _input("length", "length of domain along x-axis", 0.3), - _height = _input("height", "length of domain along y-axis", 0.3); - - std::string - t = _input("elem_type", "type of geometric element in the mesh", "quad4"); - - libMesh::ElemType - e_type = libMesh::Utility::string_to_enum(t); - - // - // if high order FE is used, libMesh requires atleast a second order - // geometric element. - // - if (_fetype.order > 1 && e_type == libMesh::QUAD4) - e_type = libMesh::QUAD9; - else if (_fetype.order > 1 && e_type == libMesh::TRI3) - e_type = libMesh::TRI6; - - // - // initialize the mesh with one element - // - libMesh::MeshTools::Generation::build_square(*_mesh, - nx_divs, ny_divs, - 0, _length, - 0, _height, - e_type); - } - - // - // \subsection ex_6_bracket_mesh Bracket - // - void _init_mesh_bracket() { - - { - unsigned int - nx_divs = _input("nx_divs", "number of elements along x-axis", 20), - ny_divs = _input("ny_divs", "number of elements along y-axis", 20); - - if (nx_divs%10 != 0 || ny_divs%10 != 0) libmesh_error(); - } - - _init_mesh_inplane(); - _delete_elems_from_bracket_mesh(*_mesh); - } - - - void _delete_elems_from_bracket_mesh(libMesh::MeshBase &mesh) { - - Real - tol = 1.e-12, - x = -1., - y = -1., - length = _input("length", "length of domain along x-axis", 0.3), - width = _input( "height", "length of domain along y-axis", 0.3), - l_frac = 0.4, - w_frac = 0.4, - x_lim = length * l_frac, - y_lim = width * (1.-w_frac); - - // - // now, remove elements that are outside of the L-bracket domain - // - libMesh::MeshBase::element_iterator - e_it = mesh.elements_begin(), - e_end = mesh.elements_end(); - - for ( ; e_it!=e_end; e_it++) { - - libMesh::Elem* elem = *e_it; - x = length; - y = 0.; - for (unsigned int i=0; in_nodes(); i++) { - const libMesh::Node& n = elem->node_ref(i); - if (x > n(0)) x = n(0); - if (y < n(1)) y = n(1); - } - - // - // delete element if the lowest x,y locations are outside of the bracket - // domain - // - if (x >= x_lim && y<= y_lim) - mesh.delete_elem(elem); - } - - mesh.prepare_for_use(); - - // - // add the two additional boundaries to the boundary info so that - // we can apply loads on them - // - bool - facing_right = false, - facing_down = false; - - e_it = mesh.elements_begin(); - e_end = mesh.elements_end(); - - for ( ; e_it != e_end; e_it++) { - - libMesh::Elem* elem = *e_it; - - if (!elem->on_boundary()) continue; - - for (unsigned int i=0; in_sides(); i++) { - - if (elem->neighbor_ptr(i)) continue; - - std::unique_ptr s(elem->side_ptr(i).release()); - - const libMesh::Point p = s->centroid(); - - facing_right = true; - facing_down = true; - for (unsigned int j=0; jn_nodes(); j++) { - const libMesh::Node& n = s->node_ref(j); - - if (n(0) < x_lim || n(1) > y_lim) { - facing_right = false; - facing_down = false; - } - else if (std::fabs(n(0) - p(0)) > tol) - facing_right = false; - else if (std::fabs(n(1) - p(1)) > tol) - facing_down = false; - } - - if (facing_right) mesh.boundary_info->add_side(elem, i, 4); - if (facing_down) mesh.boundary_info->add_side(elem, i, 5); - } - } - - mesh.boundary_info->sideset_name(4) = "facing_right"; - mesh.boundary_info->sideset_name(5) = "facing_down"; - } + std::vector> _dv_params; // - // \subsection ex_6_eyebar_mesh Eyebar - // - void _init_mesh_eye_bar() { - - _mesh = new libMesh::SerialMesh(this->comm()); - - // - // identify the element type from the input file or from the order - // of the element - // - unsigned int - n_radial_divs = _input("n_radial_divs", "number of elements along radial direction", 20), - n_quarter_divs = _input("n_quarter_divs", "number of elements along height", 20); - - Real - radius = 1.5, - h_ratio = _input("h_ratio", "ratio of radial element size at cylinder and at edge", 2); - _height = 8.; - _length = _height*2; - - std::string - t = _input("elem_type", "type of geometric element in the mesh", "quad4"); - - libMesh::ElemType - e_type = libMesh::Utility::string_to_enum(t); - - // - // if high order FE is used, libMesh requires atleast a second order - // geometric element. - // - if (_fetype.order > 1 && e_type == libMesh::QUAD4) - e_type = libMesh::QUAD9; - else if (_fetype.order > 1 && e_type == libMesh::TRI3) - e_type = libMesh::TRI6; - - MAST::Examples::CylinderMesh2D cylinder; - cylinder.mesh(radius, _height/2., - n_radial_divs, n_quarter_divs, h_ratio, - *_mesh, e_type, - true, _height, n_quarter_divs*2); - - // - // add the boundary ids for Dirichlet conditions - // - libMesh::MeshBase::const_element_iterator - e_it = _mesh->elements_begin(), - e_end = _mesh->elements_end(); - - Real - tol = radius * 1.e-8; - - for (; e_it != e_end; e_it++) { - - libMesh::Elem* elem = *e_it; - - std::unique_ptr edge(elem->side_ptr(1)); - libMesh::Point p = edge->centroid(); - - if (std::fabs(p(0)-_height*1.5) < tol && - std::fabs(p(1)) <= 1.) // on the right edge - _mesh->boundary_info->add_side(elem, 1, 0); - - // check for the circumference of the circle where load will be - // applied - edge.reset(elem->side_ptr(3).release()); - p = edge->centroid(); - - if ((std::fabs(p.norm()-radius) < 1.e-2) && - p(0) < 0.) // left semi-circle - _mesh->boundary_info->add_side(elem, 3, 5); - } - - _mesh->boundary_info->sideset_name(0) = "dirichlet"; - _mesh->boundary_info->sideset_name(5) = "load"; - } - - // - // \section ex_6_system_discipline System and Discipline + // \section ex_6_system_discipline System and Discipline // void _init_system_and_discipline() { @@ -525,286 +279,14 @@ public MAST::FunctionEvaluation { fe = libMesh::Utility::string_to_enum(family_str); _fetype = libMesh::FEType(o, fe); } - - - - // - // \section ex_6_dirichlet Dirichlet Constraints - // - void _init_dirichlet_conditions() { - std::string - s = _input("mesh", "type of mesh to be analyzed {inplane, truss, bracket, eye_bar}", "inplane"); - - if (s == "inplane") - _init_dirichlet_conditions_inplane(); - else if (s == "truss") - _init_dirichlet_conditions_truss(); - else if (s == "bracket") - _init_dirichlet_conditions_bracket(); - else if (s == "eye_bar") - _init_dirichlet_conditions_eye_bar(); - else - libmesh_error(); - } // - // \subsection ex_6_inplane_dirichlet Inplane + // \section ex_6_properties Properties // - void _init_dirichlet_conditions_inplane() { - - /////////////////////////////////////////////////////////////////////// - // initialize Dirichlet conditions for structural system - /////////////////////////////////////////////////////////////////////// - MAST::DirichletBoundaryCondition - *dirichlet = new MAST::DirichletBoundaryCondition; // right boundary - dirichlet->init(1, _sys_init->vars()); - _discipline->add_dirichlet_bc(1, *dirichlet); - - dirichlet = new MAST::DirichletBoundaryCondition; // right boundary - dirichlet->init(3, _sys_init->vars()); - _discipline->add_dirichlet_bc(3, *dirichlet); - - _discipline->init_system_dirichlet_bc(*_sys); - } - // - // \subsection ex_6_truss_dirichlet Truss // - void _init_dirichlet_conditions_truss() { - - Real - dirichlet_length_fraction = _input("truss_dirichlet_length_fraction", "length fraction of the truss boundary where dirichlet condition is applied", 0.05); - - // identify the boundaries for dirichlet condition - libMesh::MeshBase::const_element_iterator - e_it = _mesh->elements_begin(), - e_end = _mesh->elements_end(); - - for ( ; e_it != e_end; e_it++) { - - const libMesh::Elem* e = *e_it; - - if ((*e->node_ptr(0))(1) < 1.e-8 && - e->centroid()(0) <= _length*dirichlet_length_fraction) - _mesh->boundary_info->add_side(e, 0, 6); - else if ((*e->node_ptr(1))(1) < 1.e-8 && - e->centroid()(0) >= _length*(1.-dirichlet_length_fraction)) - _mesh->boundary_info->add_side(e, 0, 7); - - if ((*e->node_ptr(0))(0) < 1.e-8 && - (*e->node_ptr(0))(1) < 1.e-8 && - e->centroid()(0) <= _length*dirichlet_length_fraction) - _mesh->boundary_info->add_side(e, 0, 8); - } - - _mesh->boundary_info->sideset_name(6) = "left_dirichlet"; - _mesh->boundary_info->sideset_name(7) = "right_dirichlet"; - - /////////////////////////////////////////////////////////////////////// - // initialize Dirichlet conditions for structural system - /////////////////////////////////////////////////////////////////////// - std::vector vars = {1, 2, 3, 4, 5}; - MAST::DirichletBoundaryCondition - *dirichlet = new MAST::DirichletBoundaryCondition; // left support - dirichlet->init(6, vars); - _discipline->add_dirichlet_bc(6, *dirichlet); - - dirichlet = new MAST::DirichletBoundaryCondition; // right support - dirichlet->init(7, vars); - _discipline->add_dirichlet_bc(7, *dirichlet); - - vars = {0}; - dirichlet = new MAST::DirichletBoundaryCondition; // left support - dirichlet->init(8, vars); - _discipline->add_dirichlet_bc(8, *dirichlet); - - _discipline->init_system_dirichlet_bc(*_sys); - } - - - // - // \subsection ex_6_bracket_dirichlet Bracket - // - void _init_dirichlet_conditions_bracket() { - - /////////////////////////////////////////////////////////////////////// - // initialize Dirichlet conditions for structural system - /////////////////////////////////////////////////////////////////////// - MAST::DirichletBoundaryCondition - *dirichlet = new MAST::DirichletBoundaryCondition; // bottom boundary - dirichlet->init(0, _sys_init->vars()); - _discipline->add_dirichlet_bc(0, *dirichlet); - - _discipline->init_system_dirichlet_bc(*_sys); - } - - - // - // \subsection ex_6_eyebar_dirichlet Eyebar - // - void _init_dirichlet_conditions_eye_bar() { - - /////////////////////////////////////////////////////////////////////// - // initialize Dirichlet conditions for structural system - /////////////////////////////////////////////////////////////////////// - MAST::DirichletBoundaryCondition - *dirichlet = new MAST::DirichletBoundaryCondition; // right boundary - dirichlet->init(0, _sys_init->vars()); - _discipline->add_dirichlet_bc(0, *dirichlet); - - _discipline->init_system_dirichlet_bc(*_sys); - } - - - - // - // \section ex_6_loading Loading - // - // - void _init_loads() { - - std::string - s = _input("mesh", "type of mesh to be analyzed {inplane, truss, bracket, eye_bar}", "inplane"); - - if (s == "inplane" || s == "truss") - _init_loads_inplane(); - else if (s == "bracket") - _init_loads_bracket(); - else if (s == "eye_bar") - _init_loads_eye_bar(); - else - libmesh_error(); - } - - - // \subsection ex_6_inplane_loading Inplane - // - class FluxLoad: - public MAST::FieldFunction { - public: - FluxLoad(const std::string& nm, Real p, Real l1, Real fraction): - MAST::FieldFunction(nm), _p(p), _l1(l1), _frac(fraction) { } - virtual ~FluxLoad() {} - virtual void operator() (const libMesh::Point& p, const Real t, Real& v) const { - if (fabs(p(0)-_l1*0.5) <= 0.5*_frac*_l1) v = _p; - else v = 0.; - } - virtual void derivative(const MAST::FunctionBase& f, const libMesh::Point& p, const Real t, Real& v) const { - v = 0.; - } - protected: - Real _p, _l1, _frac; - }; - - - void _init_loads_inplane() { - - Real - frac = _input("load_length_fraction", "fraction of boundary length on which pressure will act", 0.2), - p_val = _input("pressure", "pressure on side of domain", 2.e4); - - FluxLoad - *press_f = new FluxLoad( "pressure", p_val, _length, frac); - - // initialize the load - MAST::BoundaryConditionBase - *p_load = new MAST::BoundaryConditionBase(MAST::SURFACE_PRESSURE); - - p_load->add(*press_f); - _discipline->add_side_load(2, *p_load); - - _field_functions.insert(press_f); - } - - - // - // \subsection ex_6_bracket_loading Bracket - // - class BracketLoad: - public MAST::FieldFunction { - public: - BracketLoad(const std::string& nm, Real p, Real l1, Real fraction): - MAST::FieldFunction(nm), _p(p), _l1(l1), _frac(fraction) { } - virtual ~BracketLoad() {} - virtual void operator() (const libMesh::Point& p, const Real t, Real& v) const { - if (fabs(p(0) >= _l1*(1.-_frac))) v = _p; - else v = 0.; - } - virtual void derivative(const MAST::FunctionBase& f, const libMesh::Point& p, const Real t, Real& v) const { - v = 0.; - } - protected: - Real _p, _l1, _frac; - }; - - - - void _init_loads_bracket() { - - Real - length = _input("length", "length of domain along x-axis", 0.3), - frac = _input("load_length_fraction", "fraction of boundary length on which pressure will act", 0.125), - p_val = _input("pressure", "pressure on side of domain", 5.e7); - - BracketLoad - *press_f = new BracketLoad( "pressure", p_val, length, frac); - - // - // initialize the load - // - MAST::BoundaryConditionBase - *p_load = new MAST::BoundaryConditionBase(MAST::SURFACE_PRESSURE); - - p_load->add(*press_f); - _discipline->add_side_load(5, *p_load); - - _field_functions.insert(press_f); - } - - - // - // \subsection ex_6_eyebar_loading Eyebar - // - class EyebarLoad: - public MAST::FieldFunction { - public: - EyebarLoad(): - MAST::FieldFunction("pressure") { } - virtual ~EyebarLoad() {} - virtual void operator() (const libMesh::Point& p, const Real t, Real& v) const { - if (p(0) <= 0.) v = (-std::pow(p(1), 2) + std::pow(1.5, 2))*1.e6; - else v = 0.; - } - virtual void derivative(const MAST::FunctionBase& f, const libMesh::Point& p, const Real t, Real& v) const { - v = 0.; - } - }; - - - - void _init_loads_eye_bar() { - - EyebarLoad - *press_f = new EyebarLoad(); - - // initialize the load - MAST::BoundaryConditionBase - *p_load = new MAST::BoundaryConditionBase(MAST::SURFACE_PRESSURE); - - p_load->add(*press_f); - _discipline->add_side_load(5, *p_load); - - _field_functions.insert(press_f); - } - - - // - // \section ex_6_properties Properties - // - // - // - // \subsection ex_6_material_properties Material Properties + // \subsection ex_6_material_properties Material Properties // void _init_material() { @@ -922,384 +404,7 @@ public MAST::FunctionEvaluation { _density_sys->solution->close(); } - - void _init_phi_dvs() { - std::string - s = _input("mesh", "type of mesh to be analyzed {inplane, truss, bracket, eye_bar}", "inplane"); - - if (s == "inplane" || s == "truss") - _init_phi_dvs_inplane(); - else if (s == "bracket") - _init_phi_dvs_bracket(); - else if (s == "eye_bar") - _init_phi_dvs_eye_bar(); - else - libmesh_error(); - - Real - filter_radius = _input("filter_radius", "radius of geometric filter for level set field", 0.015); - _filter = new MAST::FilterBase(*_density_sys, filter_radius, _dv_dof_ids); - libMesh::NumericVector& vec = _density_sys->add_vector("base_values"); - vec = *_density_sys->solution; - vec.close(); - } - - // - // \subsection ex_6_inplane_initial_level_set Inplane - // - void _init_phi_dvs_inplane() { - - // - // this assumes that density variable has a constant value per element - // - libmesh_assert_equal_to(_density_fetype.family, libMesh::LAGRANGE); - - Real - frac = _input("load_length_fraction", "fraction of boundary length on which pressure will act", 0.2), - filter_radius = _input("filter_radius", "radius of geometric filter for level set field", 0.015); - - unsigned int - sys_num = _density_sys->number(), - dof_id = 0; - - Real - val = 0.; - - // - // all ranks will have DVs defined for all variables. So, we should be - // operating on a replicated mesh - // - libmesh_assert(_mesh->is_replicated()); - - std::vector local_phi(_density_sys->solution->size()); - _density_sys->solution->localize(local_phi); - - // iterate over all the element values - libMesh::MeshBase::const_node_iterator - it = _mesh->nodes_begin(), - end = _mesh->nodes_end(); - - // - // maximum number of dvs is the number of nodes on the level set function - // mesh. We will evaluate the actual number of dvs - // - _dv_params.reserve(_mesh->n_elem()); - _n_vars = 0; - - for ( ; it!=end; it++) { - - const libMesh::Node& n = **it; - - dof_id = n.dof_number(sys_num, 0, 0); - - // only if node is not on the upper edge - if ((n(1)+filter_radius >= _height) && - (n(0)-filter_radius <= _length*.5*(1.+frac)) && - (n(0)+filter_radius >= _length*.5*(1.-frac))) { - - // set value at the material points to a small positive number - if (dof_id >= _density_sys->solution->first_local_index() && - dof_id < _density_sys->solution->last_local_index()) - _density_sys->solution->set(dof_id, 1.e0); - } - else { - - std::ostringstream oss; - oss << "dv_" << _n_vars; - val = local_phi[dof_id]; - - _dv_params.push_back(std::pair()); - _dv_params[_n_vars].first = dof_id; - _dv_params[_n_vars].second = new MAST::LevelSetParameter(oss.str(), val, &n); - _dv_params[_n_vars].second->set_as_topology_parameter(true); - _dv_dof_ids.insert(dof_id); - - _n_vars++; - } - } - - _density_sys->solution->close(); - } - - // - // \subsection ex_6_truss_initial_level_set Truss - // - void _init_phi_dvs_truss() { - - // - // this assumes that density variable has a constant value per element - // - libmesh_assert_equal_to(_density_fetype.family, libMesh::LAGRANGE); - - Real - frac = _input("load_length_fraction", "fraction of boundary length on which pressure will act", 0.2), - filter_radius = _input("filter_radius", "radius of geometric filter for level set field", 0.015); - - unsigned int - sys_num = _density_sys->number(), - dof_id = 0; - - Real - val = 0.; - - // - // all ranks will have DVs defined for all variables. So, we should be - // operating on a replicated mesh - // - libmesh_assert(_mesh->is_replicated()); - - std::vector local_phi(_density_sys->solution->size()); - _density_sys->solution->localize(local_phi); - - // iterate over all the element values - libMesh::MeshBase::const_node_iterator - it = _mesh->nodes_begin(), - end = _mesh->nodes_end(); - - // - // maximum number of dvs is the number of nodes on the level set function - // mesh. We will evaluate the actual number of dvs - // - _dv_params.reserve(_mesh->n_elem()); - _n_vars = 0; - - for ( ; it!=end; it++) { - - const libMesh::Node& n = **it; - - dof_id = n.dof_number(sys_num, 0, 0); - - // only if node is not on the upper edge - if ((n(1)-filter_radius <= 0.) && - (n(0)-filter_radius <= _length*.5*(1.+frac)) && - (n(0)+filter_radius >= _length*.5*(1.-frac))) { - - // set value at the material points to a small positive number - if (dof_id >= _density_sys->solution->first_local_index() && - dof_id < _density_sys->solution->last_local_index()) - _density_sys->solution->set(dof_id, 1.e0); - } - else { - - std::ostringstream oss; - oss << "dv_" << _n_vars; - val = local_phi[dof_id]; - - _dv_params.push_back(std::pair()); - _dv_params[_n_vars].first = dof_id; - _dv_params[_n_vars].second = new MAST::LevelSetParameter(oss.str(), val, &n); - _dv_params[_n_vars].second->set_as_topology_parameter(true); - _dv_dof_ids.insert(dof_id); - - _n_vars++; - } - } - - _density_sys->solution->close(); - } - - // - // \subsection ex_6_bracket_initial_level_set Bracket - // - void _init_phi_dvs_bracket() { - - libmesh_assert(_initialized); - - // - // this assumes that density variable has a constant value per element - // - libmesh_assert_equal_to(_density_fetype.family, libMesh::LAGRANGE); - - Real - tol = 1.e-12, - length = _input("length", "length of domain along x-axis", 0.3), - height = _input("height", "length of domain along y-axis", 0.3), - l_frac = 0.4,//_input("length_fraction", "fraction of length along x-axis that is in the bracket", 0.4), - h_frac = 0.4,//_input( "height_fraction", "fraction of length along y-axis that is in the bracket", 0.4), - x_lim = length * l_frac, - y_lim = height * (1.-h_frac), - frac = _input("load_length_fraction", "fraction of boundary length on which pressure will act", 0.125), - filter_radius = _input("filter_radius", "radius of geometric filter for level set field", 0.015); - - unsigned int - sys_num = _density_sys->number(), - dof_id = 0; - - Real - val = 0.; - - // - // all ranks will have DVs defined for all variables. So, we should be - // operating on a replicated mesh - // - libmesh_assert(_mesh->is_replicated()); - - std::vector local_phi(_density_sys->solution->size()); - _density_sys->solution->localize(local_phi); - - // iterate over all the element values - libMesh::MeshBase::const_node_iterator - it = _mesh->nodes_begin(), - end = _mesh->nodes_end(); - - // - // maximum number of dvs is the number of nodes on the level set function - // mesh. We will evaluate the actual number of dvs - // - _dv_params.reserve(_mesh->n_elem()); - _n_vars = 0; - - for ( ; it!=end; it++) { - - const libMesh::Node& n = **it; - - dof_id = n.dof_number(sys_num, 0, 0); - - if ((n(1)-filter_radius) <= y_lim && (n(0)+filter_radius) >= length*(1.-frac)) { - - // - // set value at the constrained points to a small positive number - // material here - // - if (dof_id >= _density_sys->solution->first_local_index() && - dof_id < _density_sys->solution->last_local_index()) - _density_sys->solution->set(dof_id, 1.e0); - } - else { - - std::ostringstream oss; - oss << "dv_" << _n_vars; - val = local_phi[dof_id]; - - // - // on the boundary, set everything to be zero, so that there - // is always a boundary there that the optimizer can move - // - if (n(0) < tol || // left boundary - std::fabs(n(0) - length) < tol || // right boundary - std::fabs(n(1) - height) < tol || // top boundary - (n(0) >= x_lim && n(1) <= y_lim)) { - - if (dof_id >= _density_sys->solution->first_local_index() && - dof_id < _density_sys->solution->last_local_index()) - _density_sys->solution->set(dof_id, _rho_min); - val = _rho_min; - } - - _dv_params.push_back(std::pair()); - _dv_params[_n_vars].first = dof_id; - _dv_params[_n_vars].second = new MAST::LevelSetParameter(oss.str(), val, &n); - _dv_params[_n_vars].second->set_as_topology_parameter(true); - _dv_dof_ids.insert(dof_id); - - _n_vars++; - } - } - - _density_sys->solution->close(); - } - - - // - // \subsection ex_6_eyebar_initial_level_set Eyebar - // - void _init_phi_dvs_eye_bar() { - - libmesh_assert(_initialized); - - // - // this assumes that density variable has a constant value per element - // - libmesh_assert_equal_to(_density_fetype.family, libMesh::LAGRANGE); - - Real - tol = 1.e-6, - filter_radius = _input("filter_radius", "radius of geometric filter for level set field", 0.015); - - unsigned int - sys_num = _density_sys->number(), - dof_id = 0; - - Real - val = 0.; - - // - // all ranks will have DVs defined for all variables. So, we should be - // operating on a replicated mesh - // - libmesh_assert(_mesh->is_replicated()); - - std::vector local_phi(_density_sys->solution->size()); - _density_sys->solution->localize(local_phi); - - // iterate over all the element values - // iterate over all the element values - libMesh::MeshBase::const_node_iterator - it = _mesh->nodes_begin(), - end = _mesh->nodes_end(); - - // - // maximum number of dvs is the number of nodes on the level set function - // mesh. We will evaluate the actual number of dvs - // - _dv_params.reserve(_mesh->n_elem()); - _n_vars = 0; - - for ( ; it!=end; it++) { - - const libMesh::Node& n = **it; - - dof_id = n.dof_number(sys_num, 0, 0); - - - - if (((n.norm() <= 1.5+filter_radius) && n(0) <= 0.) || // circle - (std::fabs(n(0)-_height*1.5) < filter_radius && // right edge - std::fabs(n(1)) <= 1.+filter_radius)) { // dirichlet constraint - - // - // set value at the constrained points to material - // - if (dof_id >= _density_sys->solution->first_local_index() && - dof_id < _density_sys->solution->last_local_index()) - _density_sys->solution->set(dof_id, 1.e0); - } - else { - - std::ostringstream oss; - oss << "dv_" << _n_vars; - val = local_phi[dof_id]; - - // - // on the boundary, set everything to be zero, so that there - // is always a boundary there that the optimizer can move - // - if (std::fabs(n(0)+_height*0.5) < tol || // left boundary - std::fabs(n(1)-_height*0.5) < tol || // top boundary - std::fabs(n(1)+_height*0.5) < tol || // bottom boundary - std::fabs(n(0)-_height*1.5) < tol) { // right boundary - - if (dof_id >= _density_sys->solution->first_local_index() && - dof_id < _density_sys->solution->last_local_index()) - _density_sys->solution->set(dof_id, _rho_min); - val = _rho_min; - } - - _dv_params.push_back(std::pair()); - _dv_params[_n_vars].first = dof_id; - _dv_params[_n_vars].second = new MAST::LevelSetParameter(oss.str(), val, &n); - _dv_params[_n_vars].second->set_as_topology_parameter(true); - _dv_dof_ids.insert(dof_id); - - _n_vars++; - } - } - - _density_sys->solution->close(); - } - - // // \subsection ex_6_design_variable_init Design Variables // @@ -1416,54 +521,66 @@ public MAST::FunctionEvaluation { return; } - // evaluate compliance - //nonlinear_assembly.calculate_output(*_sys->solution, compliance); - - // set the elasticity penalty for stress evaluation - _Ef->set_penalty_val(stress_penalty); - nonlinear_assembly.calculate_output(*_sys->solution, stress); - - ////////////////////////////////////////////////////////////////////// - // evaluate the objective - ////////////////////////////////////////////////////////////////////// Real - max_vm = stress.get_maximum_von_mises_stress(), - vm_agg = stress.output_total(), + max_vm = 0., + vm_agg = 0., vol = 0., - comp = compliance.output_total(); + comp = 0.; + // evaluate the volume for used in the problem setup _evaluate_volume(&vol, nullptr); - - //obj = _obj_scaling * comp; - obj = _obj_scaling * vol; - //_obj_scaling * (vol+ _perimeter_penalty * per) + - //_stress_penalty * (vm_agg);///_stress_lim - 1.); - - fvals[0] = stress.output_total()/_stress_lim - 1.; // g = sigma/sigma0-1 <= 0 - //fvals[0] = stress.output_total(); // g = sigma/sigma0-1 <= 0 - //fvals[0] = vol/_length/_height - _vf; // vol/vol0 - a <= libMesh::out << "volume: " << vol << std::endl; - libMesh::out << "max: " << max_vm << " constr: " << vm_agg///_stress_lim - 1. - << std::endl; - libMesh::out << "compliance: " << comp << std::endl; + + // evaluate the output based on specified problem type + if (_problem == "compliance_volume") { + + nonlinear_assembly.calculate_output(*_sys->solution, compliance); + comp = compliance.output_total(); + obj = _obj_scaling * comp; + fvals[0] = vol/_volume - _vf; // vol/vol0 - a <= + libMesh::out << "compliance: " << comp << std::endl; + } + else if (_problem == "volume_stress") { + + // set the elasticity penalty for stress evaluation + _Ef->set_penalty_val(stress_penalty); + nonlinear_assembly.calculate_output(*_sys->solution, stress); + max_vm = stress.get_maximum_von_mises_stress(); + vm_agg = stress.output_total(); + obj = _obj_scaling * vol; + fvals[0] = stress.output_total()/_stress_lim - 1.; // g = sigma/sigma0-1 <= 0 + libMesh::out + << " max: " << max_vm + << " constr: " << vm_agg + << std::endl; + } + else + libmesh_error(); + ////////////////////////////////////////////////////////////////////// // evaluate the objective sensitivities, if requested ////////////////////////////////////////////////////////////////////// if (eval_obj_grad) { - _evaluate_volume(nullptr, &obj_grad); - for (unsigned int i=0; i -// grad1(obj_grad.size(), 0.); -// -// _evaluate_compliance_sensitivity(compliance, -// nonlinear_elem_ops, -// nonlinear_assembly, -// grad1); -// -// for (unsigned int i=0; iset_penalty_val(stress_penalty); stress_assembly.update_stress_strain_data(stress, *_sys->solution); _density_function->clear(); @@ -1750,6 +876,8 @@ public MAST::FunctionEvaluation { nonlinear_assembly.clear_elem_parameter_dependence_object(); } + void set_n_vars(const unsigned int n_vars) {_n_vars = n_vars;} + // // \subsection ex_6_design_output Output of Design Iterate // @@ -1831,7 +959,7 @@ public MAST::FunctionEvaluation { _optimization_interface->set_real_parameter ("initial_rel_step", initial_step); } - MAST::FunctionEvaluation::output(iter, x, obj/_obj_scaling, fval, if_write_to_optim_file); + MAST::FunctionEvaluation::output(iter, x, obj/_obj_scaling, f, if_write_to_optim_file); } #if MAST_ENABLE_SNOPT == 1 @@ -1855,13 +983,13 @@ public MAST::FunctionEvaluation { // \subsection ex_6_constructor Constructor // - TopologyOptimizationSIMP2D(const libMesh::Parallel::Communicator& comm_in, + TopologyOptimizationSIMP(const libMesh::Parallel::Communicator& comm_in, MAST::Examples::GetPotWrapper& input): MAST::FunctionEvaluation (comm_in), _initialized (false), _input (input), - _length (0.), - _height (0.), + _problem (""), + _volume (0.), _obj_scaling (0.), _stress_penalty (0.), _perimeter_penalty (0.), @@ -1875,6 +1003,7 @@ public MAST::FunctionEvaluation { _sys (nullptr), _sys_init (nullptr), _discipline (nullptr), + _nsp (nullptr), _filter (nullptr), _m_card (nullptr), _p_card (nullptr), @@ -1885,19 +1014,24 @@ public MAST::FunctionEvaluation { // // call the initialization routines for each component // + _mesh = new libMesh::SerialMesh(this->comm()); + _init_fetype(); - _init_mesh(); + T::init_analysis_mesh(*this, *_mesh); _init_system_and_discipline(); - _init_dirichlet_conditions(); + T::init_analysis_dirichlet_conditions(*this); _init_eq_sys(); - + + _nsp = new MAST::StructuralNearNullVectorSpace; + _sys->nonlinear_solver->nearnullspace_object = _nsp; + // density function is used by elasticity modulus function. So, we // initialize this here _density_function = new MAST::MeshFieldFunction(*_density_sys, "rho"); _density_sens_function = new MAST::MeshFieldFunction(*_density_sys, "rho"); _init_material(); - _init_loads(); + T::init_structural_loads(*this); _init_section_property(); _initialized = true; @@ -1911,17 +1045,32 @@ public MAST::FunctionEvaluation { ///////////////////////////////////////////////// // - // first, initialize the level set functions over the domain + // initialize density field to a constant value of the specified + // volume fraction // - this->initialize_solution(); - + _vf = _input("volume_fraction", "upper limit for the voluem fraction", 0.5); + + _density_sys->solution->zero(); + _density_sys->solution->add(_vf); + _density_sys->solution->close(); + // // next, define a new parameter to define design variable for nodal level-set // function value // - this->_init_phi_dvs(); + T::init_simp_dvs(*this); - _obj_scaling = 1./_length/_height; + Real + filter_radius = _input("filter_radius", "radius of geometric filter for level set field", 0.015); + _filter = new MAST::FilterBase(*_density_sys, filter_radius, _dv_dof_ids); + libMesh::NumericVector& vec = _density_sys->add_vector("base_values"); + vec = *_density_sys->solution; + vec.close(); + + + _problem = _input("problem_type", "{compliance_volume, volume_stress}", "compliance_volume"); + _volume = T::reference_volume(*this); + _obj_scaling = 1./_volume; _stress_penalty = _input("stress_penalty", "penalty value for stress_constraint", 0.); _perimeter_penalty = _input("perimeter_penalty", "penalty value for perimeter in the objective function", 0.); _stress_lim = _input("vm_stress_limit", "limit von-mises stress value", 2.e8); @@ -1944,7 +1093,7 @@ public MAST::FunctionEvaluation { // // \subsection ex_6_destructor Destructor // - ~TopologyOptimizationSIMP2D() { + ~TopologyOptimizationSIMP() { { std::set::iterator @@ -1972,6 +1121,8 @@ public MAST::FunctionEvaluation { if (!_initialized) return; + + delete _nsp; delete _m_card; delete _p_card; @@ -1999,7 +1150,7 @@ public MAST::FunctionEvaluation { // \subsection ex_6_wrappers_snopt Wrappers for SNOPT // -TopologyOptimizationSIMP2D* _my_func_eval = nullptr; +MAST::FunctionEvaluation* _my_func_eval = nullptr; #if MAST_ENABLE_SNOPT == 1 @@ -2163,8 +1314,36 @@ int main(int argc, char* argv[]) { MAST::Examples::GetPotWrapper input(argc, argv, "input"); - TopologyOptimizationSIMP2D top_opt(init.comm(), input); - _my_func_eval = &top_opt; + std::unique_ptr + top_opt; + + std::string + mesh = input("mesh", "inplane2d, bracket2d, truss2d, eyebar2d", "inplane2d"); + + if (mesh == "inplane2d") { + top_opt.reset + (new TopologyOptimizationSIMP + (init.comm(), input)); + } + else if (mesh == "bracket2d") { + top_opt.reset + (new TopologyOptimizationSIMP + (init.comm(), input)); + } + else if (mesh == "eyebar2d") { + top_opt.reset + (new TopologyOptimizationSIMP + (init.comm(), input)); + } + else if (mesh == "truss2d") { + top_opt.reset + (new TopologyOptimizationSIMP + (init.comm(), input)); + } + else + libmesh_error(); + + _my_func_eval = top_opt.get(); //MAST::NLOptOptimizationInterface optimizer(NLOPT_LD_SLSQP); std::unique_ptr @@ -2205,12 +1384,18 @@ int main(int argc, char* argv[]) { if (optimizer.get()) { - optimizer->attach_function_evaluation_object(top_opt); + optimizer->attach_function_evaluation_object(*top_opt); - //std::vector xx1(top_opt.n_vars()), xx2(top_opt.n_vars()); - //top_opt.init_dvar(xx1, xx2, xx2); - //top_opt.verify_gradients(xx1); - optimizer->optimize(); + bool + verify_grads = input("verify_gradients", "If true, the gradients of objective and constraints will be verified without optimization", false); + if (verify_grads) { + + std::vector xx1(top_opt->n_vars()), xx2(top_opt->n_vars()); + top_opt->init_dvar(xx1, xx2, xx2); + top_opt->verify_gradients(xx1); + } + else + optimizer->optimize(); } // END_TRANSLATE diff --git a/examples/structural/example_7/CMakeLists.txt b/examples/structural/example_7/CMakeLists.txt index 1f761cd5..a3fc24fc 100644 --- a/examples/structural/example_7/CMakeLists.txt +++ b/examples/structural/example_7/CMakeLists.txt @@ -1,12 +1,16 @@ -add_executable(structural_example_7 - example_7.cpp) +if(ENABLE_NASTRANIO) -target_link_libraries(structural_example_7 mast) + add_executable(structural_example_7 + example_7.cpp) -install(TARGETS structural_example_7 - RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/examples) + target_link_libraries(structural_example_7 mast) -configure_file(${CMAKE_CURRENT_LIST_DIR}/example_7_acoss_mesh.bdf ${CMAKE_CURRENT_BINARY_DIR} COPYONLY) + install(TARGETS structural_example_7 + RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/examples) -add_test(NAME structural_example_7_mpi - COMMAND ${MPIEXEC_EXECUTABLE} -np 2 $ -ksp_type "preonly" -pc_type "lu") \ No newline at end of file + configure_file(${CMAKE_CURRENT_LIST_DIR}/example_7_acoss_mesh.bdf ${CMAKE_CURRENT_BINARY_DIR} COPYONLY) + + add_test(NAME structural_example_7_mpi + COMMAND ${MPIEXEC_EXECUTABLE} -np 2 $ -ksp_type "preonly" -pc_type "lu") + +endif() diff --git a/examples/structural/example_8/CMakeLists.txt b/examples/structural/example_8/CMakeLists.txt new file mode 100644 index 00000000..06f86fec --- /dev/null +++ b/examples/structural/example_8/CMakeLists.txt @@ -0,0 +1,16 @@ +# since an optimizer is required for optimization we turn this on only if +# NLOPT was enabled for MAST +if(ENABLE_NLOPT OR ENABLE_SNOPT OR ENABLE_GCMMA) + add_executable(structural_example_8 + ${MAST_ROOT_DIR}/examples/fluid/meshing/cylinder.cpp + example_8.cpp) + + target_include_directories(structural_example_8 PRIVATE + ${CMAKE_CURRENT_LIST_DIR} + ${PROJECT_SOURCE_DIR} + ${PROJECT_SOURCE_DIR}/src) + target_link_libraries(structural_example_8 mast) + + install(TARGETS structural_example_8 + RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/examples) +endif() diff --git a/examples/structural/example_8/example_8.cpp b/examples/structural/example_8/example_8.cpp new file mode 100644 index 00000000..86d0a0c4 --- /dev/null +++ b/examples/structural/example_8/example_8.cpp @@ -0,0 +1,1651 @@ +/* + * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit + * Copyright (C) 2013-2019 Manav Bhatia + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +// C++ includes +#include + +// MAST includes +#include "examples/base/input_wrapper.h" +#include "level_set/level_set_discipline.h" +#include "level_set/level_set_system_initialization.h" +#include "level_set/level_set_nonlinear_implicit_assembly.h" +#include "level_set/level_set_volume_output.h" +#include "level_set/level_set_perimeter_output.h" +#include "level_set/level_set_constrain_dofs.h" +#include "level_set/heaviside_elem_homogenization_function.h" +#include "level_set/filter_base.h" +#include "level_set/level_set_parameter.h" +#include "level_set/sub_elem_mesh_refinement.h" +#include "elasticity/structural_nonlinear_assembly.h" +#include "elasticity/structural_modal_eigenproblem_assembly.h" +#include "elasticity/ks_stress_output.h" +#include "elasticity/smooth_ramp_stress_output.h" +#include "elasticity/level_set_stress_assembly.h" +#include "elasticity/compliance_output.h" +#include "elasticity/structural_system_initialization.h" +#include "elasticity/structural_near_null_vector_space.h" +#include "base/constant_field_function.h" +#include "base/nonlinear_system.h" +#include "base/transient_assembly.h" +#include "base/boundary_condition_base.h" +#include "base/mesh_field_function.h" +#include "boundary_condition/dirichlet_boundary_condition.h" +#include "solver/slepc_eigen_solver.h" +#include "property_cards/isotropic_material_property_card.h" +#include "property_cards/solid_2d_section_element_property_card.h" +#include "optimization/gcmma_optimization_interface.h" +#include "optimization/npsol_optimization_interface.h" +#include "optimization/function_evaluation.h" +#include "examples/structural/base/bracket_2d_model.h" +#include "examples/structural/base/inplane_2d_model.h" +#include "examples/structural/base/truss_2d_model.h" +#include "examples/structural/base/eyebar_2d_model.h" + + +// libMesh includes +#include "libmesh/fe_type.h" +#include "libmesh/serial_mesh.h" +#include "libmesh/equation_systems.h" +#include "libmesh/string_to_enum.h" +#include "libmesh/dof_map.h" +#include "libmesh/exodusII_io.h" +#include "libmesh/petsc_nonlinear_solver.h" +#include "libmesh/mesh_refinement.h" +#include "libmesh/error_vector.h" +#include "libmesh/parallel.h" + + +void +_optim_obj(int* mode, + int* n, + double* x, + double* f, + double* g, + int* nstate); +void +_optim_con(int* mode, + int* ncnln, + int* n, + int* ldJ, + int* needc, + double* x, + double* c, + double* cJac, + int* nstate); + +// +// BEGIN_TRANSLATE Topology optimization using homogenized level-set approach +// +// \tableofcontents +// +// This example computes the optimal topology of a structure subject to +// specified boundary conditions (Dirichlet and Neumann). A level-set function +// is used to implicitly define the geometry inside a mesh using the +// immersed boundary approach. +// +// Level Set Mesh Function +class PhiMeshFunction: +public MAST::FieldFunction { +public: + PhiMeshFunction(): + MAST::FieldFunction("phi"), _phi(nullptr), _dphi(nullptr) { } + virtual ~PhiMeshFunction(){ + if ( _phi) delete _phi; + if (_dphi) delete _dphi; } + + void init(MAST::SystemInitialization& sys, + const libMesh::NumericVector* sol, + const libMesh::NumericVector* dsol = nullptr) { + + if ( sol) { + if (! _phi) _phi = new MAST::MeshFieldFunction(sys, "phi"); + else _phi->clear(); + _phi->init(*sol); + } + + if (dsol) { + if (!_dphi) _dphi = new MAST::MeshFieldFunction(sys, "dphi"); + else _dphi->clear(); + _dphi->init(*dsol); + } + } + + MAST::MeshFieldFunction& get_mesh_function() {return *_phi;} + + virtual void operator() (const libMesh::Point& p, const Real t, Real& v) const { + libmesh_assert(_phi); + RealVectorX v1; + (*_phi)(p, t, v1); + v = v1(0); + } + + virtual void derivative(const MAST::FunctionBase& f, + const libMesh::Point& p, const Real t, Real& v) const { + libmesh_assert(_dphi); + RealVectorX v1; + (*_dphi)(p, t, v1); + v = v1(0); + } + +protected: + MAST::MeshFieldFunction *_phi, *_dphi; +}; + + +// Elasticity function with the penalty term +class ElasticityFunction: +public MAST::FieldFunction { +public: + ElasticityFunction(Real E0, Real rho_min, Real penalty, + MAST::HomogenizedDensityFunctionBase& vf): + MAST::FieldFunction("E"), + _E0(E0), + _rho_min(rho_min), + _penalty(penalty), + _vf(vf) { } + virtual ~ElasticityFunction(){} + void set_penalty_val(Real penalty) {_penalty = penalty;} + + virtual bool depends_on(const MAST::FunctionBase& f) const { return true;} + virtual void operator() (const libMesh::Point& p, const Real t, Real& v) const { + + Real vf; + _vf(p, t, vf); + + v = _E0 * (_rho_min + (1.-_rho_min) * pow(vf, _penalty)); + } + + virtual void derivative(const MAST::FunctionBase& f, + const libMesh::Point& p, const Real t, Real& v) const { + + Real vf, dvf; + _vf(p, t, vf); + _vf.derivative(f, p, t, dvf); + + v = _E0 * (1.-_rho_min) * _penalty * pow(vf, _penalty-1.) * dvf; + } + +protected: + Real _E0; // value of the material Young's modulus + Real _rho_min; // lower limit on density + Real _penalty; // penalty for density penalization + MAST::HomogenizedDensityFunctionBase & _vf; +}; + + + +class ElementParameterDependence: +public MAST::AssemblyBase::ElemParameterDependence { +public: + ElementParameterDependence(const MAST::FilterBase& filter): + MAST::AssemblyBase::ElemParameterDependence(true), _filter(filter) {} + virtual ~ElementParameterDependence() {} + virtual bool if_elem_depends_on_parameter(const libMesh::Elem& e, + const MAST::FunctionBase& p) const { + const MAST::LevelSetParameter + &p_ls = dynamic_cast(p); + + return _filter.if_elem_in_domain_of_influence(e, *p_ls.level_set_node()); + } + +private: + const MAST::FilterBase& _filter; +}; + + +template +class TopologyOptimizationLevelSet: +public MAST::FunctionEvaluation { + +public: + + bool _initialized; + MAST::Examples::GetPotWrapper& _input; + + std::string _problem; + Real _volume; + Real _obj_scaling; + Real _stress_penalty; + Real _perimeter_penalty; + Real _stress_lim; + Real _p_val, _vm_rho; + + MAST::HeavisideElemHomogenizedDensityFunction* _vf; + ElasticityFunction* _Ef; + libMesh::UnstructuredMesh* _mesh; + libMesh::UnstructuredMesh* _level_set_mesh; + + MAST::SubElemMeshRefinement* _mesh_refinement; + + libMesh::EquationSystems* _eq_sys; + libMesh::EquationSystems* _level_set_eq_sys; + + MAST::NonlinearSystem* _sys; + MAST::NonlinearSystem* _level_set_sys; + MAST::NonlinearSystem* _level_set_sys_on_str_mesh; + + MAST::StructuralSystemInitialization* _sys_init; + MAST::LevelSetSystemInitialization* _level_set_sys_init_on_str_mesh; + MAST::LevelSetSystemInitialization* _level_set_sys_init; + + MAST::StructuralNearNullVectorSpace* _nsp; + + MAST::PhysicsDisciplineBase* _discipline; + MAST::LevelSetDiscipline* _level_set_discipline; + + MAST::FilterBase* _filter; + + MAST::MaterialPropertyCardBase *_m_card1, *_m_card2; + MAST::ElementPropertyCardBase *_p_card1, *_p_card2; + + PhiMeshFunction* _level_set_function; + libMesh::ExodusII_IO* _output; + + libMesh::FEType _fetype; + libMesh::FEType _level_set_fetype; + + std::vector _params_for_sensitivity; + std::map _parameters; + std::set _field_functions; + std::set _boundary_conditions; + std::set _dv_dof_ids; + std::set _dirichlet_bc_ids; + + std::vector> _dv_params; + + + // + // \section ex_8_system_discipline System and Discipline + // + void _init_system_and_discipline() { + + // + // make sure that the mesh has been initialized + // + libmesh_assert(_mesh); + + // + // create the equation system + // + _eq_sys = new libMesh::EquationSystems(*_mesh); + + // + // create the libmesh system and set the preferences for structural + // eigenvalue problems + // + _sys = &(_eq_sys->add_system("structural")); + _sys->set_eigenproblem_type(libMesh::GHEP); + + _mesh_refinement = new MAST::SubElemMeshRefinement(*_mesh, *_sys); + _sys->attach_constraint_object(*_mesh_refinement); + + // + // initialize the system to the right set of variables + // + _sys_init = new MAST::StructuralSystemInitialization(*_sys, + _sys->name(), + _fetype); + _discipline = new MAST::PhysicsDisciplineBase(*_eq_sys); + + // + // Initialize the system for level set function. + // A level set function is defined on a coarser mesh than the structural + // mesh. + // A level set function is assumed to be a first-order Lagrange finite element + // + _level_set_fetype = libMesh::FEType(libMesh::FIRST, libMesh::LAGRANGE); + _level_set_eq_sys = new libMesh::EquationSystems(*_level_set_mesh); + _level_set_sys = &(_level_set_eq_sys->add_system("level_set")); + _level_set_sys->extra_quadrature_order = 4; + _level_set_sys_init = new MAST::LevelSetSystemInitialization(*_level_set_sys, + _level_set_sys->name(), + _level_set_fetype); + _level_set_discipline = new MAST::LevelSetDiscipline(*_eq_sys); + + // + // A system with level set function is defined on the strucutral mesh + // for the purpose of plotting. + // + _level_set_sys_on_str_mesh = &(_eq_sys->add_system("level_set")); + _level_set_sys_init_on_str_mesh = new MAST::LevelSetSystemInitialization(*_level_set_sys_on_str_mesh, + _level_set_sys->name(), + _level_set_fetype); + } + + + void _init_eq_sys() { + + _eq_sys->init(); + _sys->eigen_solver->set_position_of_spectrum(libMesh::LARGEST_MAGNITUDE); + _sys->set_exchange_A_and_B(true); + + _level_set_eq_sys->init(); + } + + + // + // variables added to the mesh + // + void _init_fetype() { + + // FEType to initialize the system. Get the order and type of element. + std::string + order_str = _input("fe_order", "order of finite element shape basis functions", "first"), + family_str = _input("fe_family", "family of finite element shape functions", "lagrange"); + + libMesh::Order + o = libMesh::Utility::string_to_enum(order_str); + libMesh::FEFamily + fe = libMesh::Utility::string_to_enum(family_str); + _fetype = libMesh::FEType(o, fe); + } + + + // + // \section ex_8_properties Properties + // + // + // + // \subsection ex_8_material_properties Material Properties + // + + void _init_material() { + + Real + Eval = _input("E", "modulus of elasticity", 72.e9), + rho_min = _input("rho_min", "minimum value of volume fraction", 1.e-8), + penalty = _input("rho_penalty", "penalty parameter of volume fraction", 4.), + rhoval = _input("rho", "material density", 2700.), + nu_val = _input("nu", "Poisson's ratio", 0.33), + kappa_val = _input("kappa", "shear correction factor", 5./6.), + kval = _input("k", "thermal conductivity", 1.e-2), + cpval = _input("cp", "thermal capacitance", 864.); + + + MAST::Parameter + *rho = new MAST::Parameter("rho", rhoval), + *nu = new MAST::Parameter("nu", nu_val), + *kappa = new MAST::Parameter("kappa", kappa_val), + *k = new MAST::Parameter("k", kval), + *cp = new MAST::Parameter("cp", cpval); + + MAST::ConstantFieldFunction + *rho_f = new MAST::ConstantFieldFunction( "rho", *rho), + *nu_f = new MAST::ConstantFieldFunction( "nu", *nu), + *kappa_f = new MAST::ConstantFieldFunction("kappa", *kappa), + *k_f = new MAST::ConstantFieldFunction( "k_th", *k), + *cp_f = new MAST::ConstantFieldFunction( "cp", *cp); + + _Ef = new ElasticityFunction(Eval, rho_min, penalty, *_vf); + + _parameters[ rho->name()] = rho; + _parameters[ nu->name()] = nu; + _parameters[kappa->name()] = kappa; + _parameters[ k->name()] = k; + _parameters[ cp->name()] = cp; + _field_functions.insert(_Ef); + _field_functions.insert(rho_f); + _field_functions.insert(nu_f); + _field_functions.insert(kappa_f); + _field_functions.insert(k_f); + _field_functions.insert(cp_f); + + _m_card1 = new MAST::IsotropicMaterialPropertyCard; + _m_card2 = new MAST::IsotropicMaterialPropertyCard; + _m_card1->add(*_Ef); + _m_card1->add(*rho_f); + _m_card1->add(*nu_f); + _m_card1->add(*kappa_f); + _m_card1->add(*k_f); + _m_card1->add(*cp_f); + + // material for void + _m_card2->add(*_Ef); + _m_card2->add(*rho_f); + _m_card2->add(*nu_f); + _m_card2->add(*kappa_f); + _m_card2->add(*k_f); + _m_card2->add(*cp_f); + } + + + // + // \subsection ex_8_section_properties Section Properties + // + + void _init_section_property(){ + + + + Real + th_v = _input("th", "thickness of 2D element", 0.001); + + MAST::Parameter + *th = new MAST::Parameter("th", th_v), + *zero = new MAST::Parameter("zero", 0.); + + MAST::ConstantFieldFunction + *th_f = new MAST::ConstantFieldFunction("h", *th), + *hoff_f = new MAST::ConstantFieldFunction("off", *zero); + + + _parameters[th->name()] = th; + _parameters[zero->name()] = zero; + _field_functions.insert(th_f); + _field_functions.insert(hoff_f); + + MAST::Solid2DSectionElementPropertyCard + *p_card1 = new MAST::Solid2DSectionElementPropertyCard, + *p_card2 = new MAST::Solid2DSectionElementPropertyCard; + + _p_card1 = p_card1; + _p_card2 = p_card2; + + // set nonlinear strain if requested + bool + nonlinear = _input("if_nonlinear", "flag to turn on/off nonlinear strain", false); + if (nonlinear) _p_card1->set_strain(MAST::NONLINEAR_STRAIN); + _p_card2->set_strain(MAST::LINEAR_STRAIN); + + p_card1->add(*th_f); + p_card1->add(*hoff_f); + p_card1->set_material(*_m_card1); + + // property card for void + p_card2->add(*th_f); + p_card2->add(*hoff_f); + p_card2->set_material(*_m_card2); + + _discipline->set_property_for_subdomain(0, *p_card1); + _discipline->set_property_for_subdomain(1, *p_card1); + + // inactive + _discipline->set_property_for_subdomain(3, *p_card2); + + // negative level set + _discipline->set_property_for_subdomain(6, *p_card2); + _discipline->set_property_for_subdomain(7, *p_card2); + } + + // + // \subsection ex_8_design_variable_init Design Variables + // + // initializes the design variable vector, called by the + // optimization interface. + // + void init_dvar(std::vector& x, + std::vector& xmin, + std::vector& xmax) { + + x.resize(_n_vars); + xmin.resize(_n_vars); + xmax.resize(_n_vars); + + std::fill(xmin.begin(), xmin.end(), -1.e1); + std::fill(xmax.begin(), xmax.end(), 1.e1); + + // + // now, check if the user asked to initialize dvs from a previous file + // + std::string + nm = _input("restart_optimization_file", "filename with optimization history for restart", ""); + + if (nm.length()) { + + unsigned int + iter = _input("restart_optimization_iter", "restart iteration number from file", 0); + this->initialize_dv_from_output_file(nm, iter, x); + } + else { + + for (unsigned int i=0; i<_n_vars; i++) + x[i] = (*_dv_params[i].second)(); + } + } + + // + // \section ex_8_analysis Function Evaluation and Sensitivity + // + // + // \subsection ex_8_element_error_metric Element Error Metric + // + void + _compute_element_errors(libMesh::ErrorVector& error) { + + Real + vf = 0.; + + libMesh::MeshBase::const_element_iterator + it = _mesh->active_elements_begin(), + end = _mesh->active_elements_end(); + + for ( ; it != end; it++) { + + const libMesh::Elem* elem = *it; + vf = _vf->get_elem_volume_fraction(*elem); + error[elem->id()] = vf; + } + } + + + + class ElemFlag: public libMesh::MeshRefinement::ElementFlagging { + public: + ElemFlag(libMesh::MeshBase& mesh, + MAST::HomogenizedDensityFunctionBase& vf, + unsigned int max_h): + _mesh(mesh), _vf(vf), _max_h(max_h) {} + virtual ~ElemFlag() {} + virtual void flag_elements () { + + Real + vf = 0.; + + libMesh::MeshBase::element_iterator + it = _mesh.active_elements_begin(), + end = _mesh.active_elements_end(); + + for ( ; it != end; it++) { + + libMesh::Elem* elem = *it; + vf = _vf.get_elem_volume_fraction(*elem); + + if (vf < 0.5 && elem->level() < _max_h) + elem->set_refinement_flag(libMesh::Elem::REFINE); + else if (vf > 0.90) + elem->set_refinement_flag(libMesh::Elem::COARSEN); + } + } + + protected: + libMesh::MeshBase& _mesh; + MAST::HomogenizedDensityFunctionBase& _vf; + unsigned int _max_h; + }; + + + + // + // \subsection ex_8_function_evaluation Function Evaluation + // + void evaluate(const std::vector& dvars, + Real& obj, + bool eval_obj_grad, + std::vector& obj_grad, + std::vector& fvals, + std::vector& eval_grads, + std::vector& grads) { + + libMesh::out << "New Evaluation" << std::endl; + + // copy DVs to level set function + libMesh::NumericVector + &base_phi = _level_set_sys->get_vector("base_values"); + + for (unsigned int i=0; i<_n_vars; i++) + if (_dv_params[i].first >= base_phi.first_local_index() && + _dv_params[i].first < base_phi.last_local_index()) + base_phi.set(_dv_params[i].first, dvars[i]); + base_phi.close(); + _filter->compute_filtered_values(base_phi, *_level_set_sys->solution); + _level_set_function->init(*_level_set_sys_init, _level_set_sys->solution.get()); + _vf->initialize_element_volume_fractions(); + _sys->solution->zero(); + + //********************************************************************* + // DO NOT zero out the gradient vector, since GCMMA needs it for the * + // subproblem solution * + //********************************************************************* + MAST::NonlinearImplicitAssembly nonlinear_assembly; + MAST::NonlinearImplicitAssembly perimeter_assembly; + MAST::StressAssembly stress_assembly; + MAST::StructuralNonlinearAssemblyElemOperations nonlinear_elem_ops; + + // + // reinitialize the dof constraints before solution of the linear system + // FIXME: we should be able to clear the constraint object from the + // system before it goes out of scope, but libMesh::System does not + // have a clear method. So, we are going to leave it as is, hoping + // that libMesh::System will not attempt to use it (most likely, we + // shoudl be ok). + // + + ///////////////////////////////////////////////////////////////////// + // solve + ///////////////////////////////////////////////////////////////////// + nonlinear_assembly.set_discipline_and_system(*_discipline, *_sys_init); + perimeter_assembly.set_discipline_and_system(*_level_set_discipline, *_level_set_sys_init); + stress_assembly.set_discipline_and_system(*_discipline, *_sys_init); + nonlinear_elem_ops.set_discipline_and_system(*_discipline, *_sys_init); + + + libMesh::MeshRefinement refine(*_mesh); + + libMesh::out << "before refinement" << std::endl; + _mesh->print_info(); + + bool + continue_refining = true; + Real + threshold = _input("refinement_threshold","threshold for element to be refined", 0.1); + unsigned int + n_refinements = 0, + max_refinements = _input("max_refinements","maximum refinements", 3); + + while (n_refinements < max_refinements && continue_refining) { + + // The ErrorVector is a particular StatisticsVector + // for computing error information on a finite element mesh. + libMesh::ErrorVector error(_mesh->max_elem_id(), _mesh); + _compute_element_errors(error); + libMesh::out + << "After refinement: " << n_refinements << std::endl + << "max error: " << error.maximum() + << ", mean error: " << error.mean() << std::endl; + + if (error.maximum() > threshold) { + + ElemFlag flag(*_mesh, *_vf, max_refinements); + refine.max_h_level() = max_refinements; + refine.refine_fraction() = 1.; + refine.coarsen_fraction() = 0.5; + refine.flag_elements_by (flag); + if (refine.refine_and_coarsen_elements()) + _eq_sys->reinit (); + + _mesh->print_info(); + + n_refinements++; + } + else + continue_refining = false; + } + + MAST::LevelSetPerimeter perimeter; + MAST::StressStrainOutputBase stress; + MAST::ComplianceOutput compliance; + perimeter.set_discipline_and_system(*_level_set_discipline, *_level_set_sys_init); + stress.set_discipline_and_system(*_discipline, *_sys_init); + perimeter.set_participating_elements_to_all(); + stress.set_participating_elements_to_all(); + stress.set_aggregation_coefficients(_p_val, 1., _vm_rho, _stress_lim) ; + compliance.set_participating_elements_to_all(); + compliance.set_discipline_and_system(*_discipline, *_sys_init); + + ////////////////////////////////////////////////////////////////////// + // evaluate the stress constraint + ////////////////////////////////////////////////////////////////////// + // tell the thermal jacobian scaling object about the assembly object + + SNESConvergedReason r; + + libMesh::out << "Static Solve" << std::endl; + + Real + penalty = _input("rho_penalty", "SIMP modulus of elasticity penalty", 4.), + stress_penalty = _input("stress_rho_penalty", "SIMP modulus of elasticity penalty for stress evaluation", 0.5); + perimeter.set_heaviside_smoothing_delta(_input("heaviside_smoothing_width", + "width over which approximate Heaviside function is smoothed", + 0.1)); + + // set the elasticity penalty for solution + _Ef->set_penalty_val(penalty); + + _sys->solve(nonlinear_elem_ops, nonlinear_assembly); + r = dynamic_cast&> + (*_sys->nonlinear_solver).get_converged_reason(); + + // if the solver diverged due to linear solve, then there is a problem with + // this geometry and we need to return with a high value set for the + // constraints + if (r == SNES_DIVERGED_LINEAR_SOLVE || + _sys->final_nonlinear_residual() > 1.e-1) { + + obj = 1.e10; + for (unsigned int i=0; i<_n_ineq; i++) + fvals[i] = 1.e10; + return; + } + + ////////////////////////////////////////////////////////////////////// + // evaluate the functions + ////////////////////////////////////////////////////////////////////// + + perimeter_assembly.calculate_output(*_level_set_sys->solution, perimeter); + + Real + max_vm = 0., + vm_agg = 0., + vol = 0., + per = perimeter.output_total(), + comp = 0.; + + _evaluate_volume(&vol, nullptr); + + libMesh::out << "volume: " << vol << " perim: " << per << std::endl; + + // evaluate the output based on specified problem type + if (_problem == "compliance_volume") { + + Real + vf = _input("volume_fraction", "volume fraction", 0.3); + + // if the shifted boundary is implementing a traction-free condition + // compliance does not need contribution from shifted boundary load + nonlinear_assembly.calculate_output(*_sys->solution, compliance); + comp = compliance.output_total(); + obj = _obj_scaling * (comp + _perimeter_penalty * per); + fvals[0] = vol/_volume - vf; // vol/vol0 - a <= + libMesh::out << "compliance: " << comp << std::endl; + } + else if (_problem == "volume_stress") { + + // set the elasticity penalty for stress evaluation + _Ef->set_penalty_val(stress_penalty); + nonlinear_assembly.calculate_output(*_sys->solution, stress); + max_vm = stress.get_maximum_von_mises_stress(); + vm_agg = stress.output_total(); + obj = _obj_scaling * (vol + _perimeter_penalty * per); + fvals[0] = stress.output_total()/_stress_lim - 1.; // g = sigma/sigma0-1 <= 0 + //fvals[0] = stress.output_total()/_length/_height; // g <= 0 for the smooth ramp function + libMesh::out + << " max: " << max_vm + << " constr: " << vm_agg + << std::endl; + } + else + libmesh_error(); + + ////////////////////////////////////////////////////////////////////// + // evaluate the objective sensitivities, if requested + ////////////////////////////////////////////////////////////////////// + if (eval_obj_grad) { + + std::vector + grad1(obj_grad.size(), 0.); + + if (_problem == "compliance_volume") { + + + _evaluate_compliance_sensitivity(compliance, + nonlinear_elem_ops, + nonlinear_assembly, + obj_grad); + + _evaluate_perimeter_sensitivity(perimeter, perimeter_assembly, grad1); + + for (unsigned int i=0; iset_penalty_val(stress_penalty); + stress_assembly.update_stress_strain_data(stress, *_sys->solution); + _vf->clear_element_volume_fractions(); + } + + // + // \subsection ex_8_volume_sensitivity Sensitivity of Material Volume + // + void _evaluate_volume(Real* volume, + std::vector* grad) { + + if (volume) { + + // iterate over all elements, and use the volume fraction to + // compute the total volume + libMesh::MeshBase::const_element_iterator + e_it = _mesh->active_local_elements_begin(), + e_end = _mesh->active_local_elements_end(); + + *volume = 0.; + + for ( ; e_it != e_end; e_it++) { + + const libMesh::Elem* e = *e_it; + + *volume += _vf->get_elem_volume_fraction(*e) * e->volume(); + } + + this->comm().sum(*volume); + } + + if (grad) { + + std::fill(grad->begin(), grad->end(), 0.); + + // + // iterate over each DV, create a sensitivity vector and calculate the + // volume sensitivity explicitly + // + std::unique_ptr> + dphi_base(_level_set_sys->solution->zero_clone().release()), + dphi_filtered(_level_set_sys->solution->zero_clone().release()); + + ElementParameterDependence dep(*_filter); + + for (unsigned int i=0; i<_n_vars; i++) { + + dphi_base->zero(); + dphi_filtered->zero(); + + // + // set the value only if the dof corresponds to a local node + // + if (_dv_params[i].first >= dphi_base->first_local_index() && + _dv_params[i].first < dphi_base->last_local_index()) + dphi_base->set(_dv_params[i].first, 1.); + + dphi_base->close(); + _filter->compute_filtered_values(*dphi_base, *dphi_filtered); + _level_set_function->init(*_level_set_sys_init, nullptr, dphi_filtered.get()); + _vf->clear_element_volume_fraction_sensitivity(); + _vf->initialize_element_volume_fraction_sensitivity(*_dv_params[i].second); + + libMesh::MeshBase::element_iterator + e_it = _mesh->active_local_elements_begin(), + e_end = _mesh->active_local_elements_end(); + + for ( ; e_it != e_end; e_it++) { + + const libMesh::Elem* e = *e_it; + + // do not compute if the element is not in the domain + // of influence of the parameter + if (!dep.if_elem_depends_on_parameter(*e, *_dv_params[i].second)) + continue; + + (*grad)[i] += e->volume() * + _vf->get_elem_volume_fraction_sensitivity(*_dv_params[i].second, *e); + } + } + + this->comm().sum(*grad); + _vf->clear_element_volume_fraction_sensitivity(); + } + } + + + // + // \subsection ex_8_perimeter_sensitivity Sensitivity of approximate + // Perimeter + // + void _evaluate_perimeter_sensitivity(MAST::LevelSetPerimeter& perimeter, + MAST::NonlinearImplicitAssembly& assembly, + std::vector& grad) { + + std::fill(grad.begin(), grad.end(), 0.); + + // + // iterate over each DV, create a sensitivity vector and calculate the + // volume sensitivity explicitly + // + std::unique_ptr> + dphi_base(_level_set_sys->solution->zero_clone().release()), + dphi_filtered(_level_set_sys->solution->zero_clone().release()); + + ElementParameterDependence dep(*_filter); + assembly.attach_elem_parameter_dependence_object(dep); + + for (unsigned int i=0; i<_n_vars; i++) { + + dphi_base->zero(); + dphi_filtered->zero(); + // + // set the value only if the dof corresponds to a local node + // + if (_dv_params[i].first >= dphi_base->first_local_index() && + _dv_params[i].first < dphi_base->last_local_index()) + dphi_base->set(_dv_params[i].first, 1.); + dphi_base->close(); + _filter->compute_filtered_values(*dphi_base, *dphi_filtered); + + // if the perimeter output was specified then compute the sensitivity + // and add to the grad vector + assembly.calculate_output_direct_sensitivity(*_level_set_sys->solution, + dphi_filtered.get(), + *_dv_params[i].second, + perimeter); + + grad[i] += perimeter.output_sensitivity_total(*_dv_params[i].second); + } + + assembly.clear_elem_parameter_dependence_object(); + } + + + // + // \subsection ex_8_stress_sensitivity Sensitivity of Stress and Eigenvalues + // + void + _evaluate_stress_sensitivity + (const Real penalty, + const Real stress_penalty, + MAST::StressStrainOutputBase& stress, + MAST::AssemblyElemOperations& nonlinear_elem_ops, + MAST::NonlinearImplicitAssembly& nonlinear_assembly, + std::vector& grads) { + + _sys->adjoint_solve(nonlinear_elem_ops, stress, nonlinear_assembly, false); + + std::unique_ptr> + dphi_base(_level_set_sys->solution->zero_clone().release()), + dphi_filtered(_level_set_sys->solution->zero_clone().release()); + + ElementParameterDependence dep(*_filter); + nonlinear_assembly.attach_elem_parameter_dependence_object(dep); + + ////////////////////////////////////////////////////////////////// + // indices used by GCMMA follow this rule: + // grad_k = dfi/dxj , where k = j*NFunc + i + ////////////////////////////////////////////////////////////////// + for (unsigned int i=0; i<_n_vars; i++) { + + dphi_base->zero(); + dphi_filtered->zero(); + // + // set the value only if the dof corresponds to a local node + // + if (_dv_params[i].first >= dphi_base->first_local_index() && + _dv_params[i].first < dphi_base->last_local_index()) + dphi_base->set(_dv_params[i].first, 1.); + dphi_base->close(); + _filter->compute_filtered_values(*dphi_base, *dphi_filtered); + _level_set_function->init(*_level_set_sys_init, nullptr, dphi_filtered.get()); + _vf->clear_element_volume_fraction_sensitivity(); + _vf->initialize_element_volume_fraction_sensitivity(*_dv_params[i].second); + + ////////////////////////////////////////////////////////////////////// + // stress sensitivity + ////////////////////////////////////////////////////////////////////// + // set the elasticity penalty for solution, which is needed for + // computation of the residual sensitivity + _Ef->set_penalty_val(penalty); + + grads[1*i+0] = 1./_stress_lim* + nonlinear_assembly.calculate_output_adjoint_sensitivity(*_sys->solution, + _sys->get_adjoint_solution(), + *_dv_params[i].second, + nonlinear_elem_ops, + stress, + false); + + _Ef->set_penalty_val(stress_penalty); + nonlinear_assembly.calculate_output_direct_sensitivity(*_sys->solution, + nullptr, + *_dv_params[i].second, + stress); + grads[1*i+0] += 1./_stress_lim* stress.output_sensitivity_total(*_dv_params[i].second); + + + stress.clear_sensitivity_data(); + _vf->clear_element_volume_fraction_sensitivity(); + } + + nonlinear_assembly.clear_elem_parameter_dependence_object(); + } + + + void + _evaluate_compliance_sensitivity + (MAST::ComplianceOutput& compliance, + MAST::AssemblyElemOperations& nonlinear_elem_ops, + MAST::NonlinearImplicitAssembly& nonlinear_assembly, + std::vector& grads) { + + // Adjoint solution for compliance = - X + // if the shifted boundary is implementing a traction-free condition + // compliance does not need contribution from shifted boundary load + _sys->adjoint_solve(nonlinear_elem_ops, compliance, nonlinear_assembly, false); + + std::unique_ptr> + dphi_base(_level_set_sys->solution->zero_clone().release()), + dphi_filtered(_level_set_sys->solution->zero_clone().release()); + + ElementParameterDependence dep(*_filter); + nonlinear_assembly.attach_elem_parameter_dependence_object(dep); + + ////////////////////////////////////////////////////////////////// + // indices used by GCMMA follow this rule: + // grad_k = dfi/dxj , where k = j*NFunc + i + ////////////////////////////////////////////////////////////////// + for (unsigned int i=0; i<_n_vars; i++) { + + dphi_base->zero(); + dphi_filtered->zero(); + // + // set the value only if the dof corresponds to a local node + // + if (_dv_params[i].first >= dphi_base->first_local_index() && + _dv_params[i].first < dphi_base->last_local_index()) + dphi_base->set(_dv_params[i].first, 1.); + dphi_base->close(); + _filter->compute_filtered_values(*dphi_base, *dphi_filtered); + _level_set_function->init(*_level_set_sys_init, nullptr, dphi_filtered.get()); + _vf->clear_element_volume_fraction_sensitivity(); + _vf->initialize_element_volume_fraction_sensitivity(*_dv_params[i].second); + + ////////////////////////////////////////////////////////////////////// + // compliance sensitivity + ////////////////////////////////////////////////////////////////////// + grads[i] = 1. * + nonlinear_assembly.calculate_output_adjoint_sensitivity(*_sys->solution, + _sys->get_adjoint_solution(), + *_dv_params[i].second, + nonlinear_elem_ops, + compliance); + _vf->clear_element_volume_fraction_sensitivity(); + } + + nonlinear_assembly.clear_elem_parameter_dependence_object(); + } + + + void set_n_vars(const unsigned int n_vars) {_n_vars = n_vars;} + + // + // \subsection ex_8_design_output Output of Design Iterate + // + void output(unsigned int iter, + const std::vector& x, + Real obj, + const std::vector& fval, + bool if_write_to_optim_file) { + + libmesh_assert_equal_to(x.size(), _n_vars); + + Real + sys_time = _sys->time; + + std::string + output_name = _input("output_file_root", "prefix of output file names", "output"), + modes_name = output_name + "modes.exo"; + + std::ostringstream oss; + oss << "output_optim.e-s." << std::setfill('0') << std::setw(5) << iter ; + + // + // copy DVs to level set function + // + libMesh::NumericVector + &base_phi = _level_set_sys->get_vector("base_values"); + + for (unsigned int i=0; i<_n_vars; i++) + if (_dv_params[i].first >= base_phi.first_local_index() && + _dv_params[i].first < base_phi.last_local_index()) + base_phi.set(_dv_params[i].first, x[i]); + base_phi.close(); + _filter->compute_filtered_values(base_phi, *_level_set_sys->solution); + _level_set_function->init(*_level_set_sys_init, _level_set_sys->solution.get()); + _level_set_sys_init_on_str_mesh->initialize_solution(_level_set_function->get_mesh_function()); + + std::vector eval_grads(this->n_ineq(), false); + std::vector f(this->n_ineq(), 0.), grads; + this->evaluate(x, obj, false, grads, f, eval_grads, grads); + + _sys->time = iter; + _sys_init->get_stress_sys().time = iter; + // "1" is the number of time-steps in the file, as opposed to the time-step number. + libMesh::ExodusII_IO(*_mesh).write_timestep(oss.str(), *_eq_sys, 1, (1.*iter)); + + // + // set the value of time back to its original value + // + _sys->time = sys_time; + + // + // increment the parameter values + // + unsigned int + update_freq = _input("update_freq_optim_params", "number of iterations after which the optimization parameters are updated", 50), + factor = iter/update_freq ; + if (factor > 0 && iter%update_freq == 0) { + + Real + p_val = _input("constraint_aggregation_p_val", "value of p in p-norm stress aggregation", 2.0), + vm_rho = _input("constraint_aggregation_rho_val", "value of rho in p-norm stress aggregation", 2.0), + constr_penalty = _input("constraint_penalty", "constraint penalty in GCMMA", 50.), + max_penalty = _input("max_constraint_penalty", "maximum constraint penalty in GCMMA", 1.e7), + initial_step = _input("initial_rel_step", "initial relative step length in GCMMA", 0.5), + min_step = _input("minimum_rel_step", "minimum relative step length in GCMMA", 0.001); + + constr_penalty = std::min(constr_penalty*pow(10, factor), max_penalty); + initial_step = std::max(initial_step-0.01*factor, min_step); + _p_val = std::min(p_val+2*factor, 10.); + _vm_rho = std::min(vm_rho+factor*0.5, 2.); + libMesh::out + << "Updated values: c = " << constr_penalty + << " step = " << initial_step + << " p = " << _p_val + << " rho = " << _vm_rho << std::endl; + + _optimization_interface->set_real_parameter ( "constraint_penalty", constr_penalty); + _optimization_interface->set_real_parameter ("initial_rel_step", initial_step); + } + + MAST::FunctionEvaluation::output(iter, x, obj/_obj_scaling, f, if_write_to_optim_file); + } + +#if MAST_ENABLE_SNOPT == 1 + MAST::FunctionEvaluation::funobj + get_objective_evaluation_function() { + + return _optim_obj; + } + + MAST::FunctionEvaluation::funcon + get_constraint_evaluation_function() { + + return _optim_con; + } +#endif + + + // + // \section ex_8_initialization Initialization + // + // \subsection ex_8_constructor Constructor + // + + TopologyOptimizationLevelSet(const libMesh::Parallel::Communicator& comm_in, + MAST::Examples::GetPotWrapper& input): + MAST::FunctionEvaluation (comm_in), + _initialized (false), + _input (input), + _problem (), + _volume (0.), + _obj_scaling (0.), + _stress_penalty (0.), + _perimeter_penalty (0.), + _stress_lim (0.), + _p_val (0.), + _vm_rho (0.), + _vf (nullptr), + _Ef (nullptr), + _mesh (nullptr), + _level_set_mesh (nullptr), + _mesh_refinement (nullptr), + _eq_sys (nullptr), + _level_set_eq_sys (nullptr), + _sys (nullptr), + _level_set_sys (nullptr), + _level_set_sys_on_str_mesh (nullptr), + _sys_init (nullptr), + _level_set_sys_init_on_str_mesh (nullptr), + _level_set_sys_init (nullptr), + _nsp (nullptr), + _discipline (nullptr), + _level_set_discipline (nullptr), + _filter (nullptr), + _m_card1 (nullptr), + _m_card2 (nullptr), + _p_card1 (nullptr), + _p_card2 (nullptr), + _level_set_function (nullptr), + _output (nullptr) { + + libmesh_assert(!_initialized); + + // + // call the initialization routines for each component + // + + std::string + s = _input("mesh", "type of mesh to be analyzed {inplane, bracket, truss, eyebar}", + "inplane"); + + _mesh = new libMesh::SerialMesh(this->comm()); + _level_set_mesh = new libMesh::SerialMesh(this->comm()); + _level_set_function = new PhiMeshFunction; + _vf = new MAST::HeavisideElemHomogenizedDensityFunction("volume_fraction"); + _vf->set_smoothing_width(_input("heaviside_smoothing_width", "width over which approximate Heaviside function is smoothed", 0.1)); + + _init_fetype(); + T::init_analysis_mesh(*this, *_mesh); + T::init_level_set_mesh(*this, *_level_set_mesh); + _init_system_and_discipline(); + T::init_analysis_dirichlet_conditions(*this); + _init_eq_sys(); + _init_material(); + T::init_structural_loads(*this); + _init_section_property(); + _initialized = true; + + _nsp = new MAST::StructuralNearNullVectorSpace; + _sys->nonlinear_solver->nearnullspace_object = _nsp; + + // + // ask structure to use Mindlin bending operator + // + dynamic_cast(*_p_card1).set_bending_model(MAST::MINDLIN); + dynamic_cast(*_p_card2).set_bending_model(MAST::MINDLIN); + + ///////////////////////////////////////////////// + // now initialize the design data. + ///////////////////////////////////////////////// + + // + // first, initialize the level set functions over the domain + // + T::initialize_level_set_solution(*this); + + // + // next, define a new parameter to define design variable for nodal level-set + // function value + // + T::init_level_set_dvs(*this); + + Real + filter_radius = _input("filter_radius", "radius of geometric filter for level set field", 0.015); + _filter = new MAST::FilterBase(*_level_set_sys, filter_radius, _dv_dof_ids); + libMesh::NumericVector& vec = _level_set_sys->add_vector("base_values"); + vec = *_level_set_sys->solution; + vec.close(); + _vf->init(*_level_set_sys_init, *_mesh, *_level_set_function, *_filter); + + + _problem = _input("problem_type", "{compliance_volume, volume_stress}", "compliance_volume"); + _volume = T::reference_volume(*this); + _obj_scaling = 1./_volume; + _stress_penalty = _input("stress_penalty", "penalty value for stress_constraint", 0.); + _perimeter_penalty = _input("perimeter_penalty", "penalty value for perimeter in the objective function", 0.); + _stress_lim = _input("vm_stress_limit", "limit von-mises stress value", 2.e8); + _p_val = _input("constraint_aggregation_p_val", "value of p in p-norm stress aggregation", 2.0); + _vm_rho = _input("constraint_aggregation_rho_val", "value of rho in p-norm stress aggregation", 2.0); + _output = new libMesh::ExodusII_IO(*_mesh); + + // + // two inequality constraints: stress and eigenvalue. + // + _n_ineq = 1; + + std::string + output_name = _input("output_file_root", "prefix of output file names", "output"); + output_name += "_optim_history.txt"; + this->set_output_file(output_name); + + } + + // + // \subsection ex_8_destructor Destructor + // + ~TopologyOptimizationLevelSet() { + + { + std::set::iterator + it = _boundary_conditions.begin(), + end = _boundary_conditions.end(); + for ( ; it!=end; it++) + delete *it; + } + + { + std::set::iterator + it = _field_functions.begin(), + end = _field_functions.end(); + for ( ; it!=end; it++) + delete *it; + } + + { + std::map::iterator + it = _parameters.begin(), + end = _parameters.end(); + for ( ; it!=end; it++) + delete it->second; + } + + if (!_initialized) + return; + + delete _nsp; + + delete _m_card1; + delete _m_card2; + delete _p_card1; + delete _p_card2; + + delete _eq_sys; + delete _mesh_refinement; + delete _mesh; + delete _vf; + + delete _discipline; + delete _sys_init; + + delete _level_set_function; + delete _level_set_sys_init; + delete _level_set_discipline; + delete _filter; + delete _level_set_eq_sys; + delete _level_set_mesh; + delete _output; + delete _level_set_sys_init_on_str_mesh; + + for (unsigned int i=0; i<_dv_params.size(); i++) + delete _dv_params[i].second; + } + + +}; + + +// +// \subsection ex_8_wrappers_snopt Wrappers for SNOPT +// + +MAST::FunctionEvaluation* _my_func_eval = nullptr; + +#if MAST_ENABLE_SNOPT == 1 + +unsigned int +it_num = 0; + +void +_optim_obj(int* mode, + int* n, + double* x, + double* f, + double* g, + int* nstate) { + + // + // make sure that the global variable has been setup + // + libmesh_assert(_my_func_eval); + + // + // initialize the local variables + // + Real + obj = 0.; + + unsigned int + n_vars = _my_func_eval->n_vars(), + n_con = _my_func_eval->n_eq()+_my_func_eval->n_ineq(); + + libmesh_assert_equal_to(*n, n_vars); + + std::vector + dvars (*n, 0.), + obj_grad(*n, 0.), + fvals (n_con, 0.), + grads (0); + + std::vector + eval_grads(n_con); + std::fill(eval_grads.begin(), eval_grads.end(), false); + + // + // copy the dvars + // + for (unsigned int i=0; i_evaluate_wrapper(dvars, + obj, + *mode>0, // request the derivatives of obj + obj_grad, + fvals, + eval_grads, + grads); + + // + // now copy them back as necessary + // + *f = obj; + if (*mode > 0) { + + // output data to the file + _my_func_eval->_output_wrapper(it_num, dvars, obj, fvals, true); + it_num++; + + for (unsigned int i=0; i 1.e5) *mode = -1; +} + + + + + + +void +_optim_con(int* mode, + int* ncnln, + int* n, + int* ldJ, + int* needc, + double* x, + double* c, + double* cJac, + int* nstate) { + + // + // make sure that the global variable has been setup + // + libmesh_assert(_my_func_eval); + + // + // initialize the local variables + // + Real + obj = 0.; + + unsigned int + n_vars = _my_func_eval->n_vars(), + n_con = _my_func_eval->n_eq()+_my_func_eval->n_ineq(); + + libmesh_assert_equal_to( *n, n_vars); + libmesh_assert_equal_to(*ncnln, n_con); + + std::vector + dvars (*n, 0.), + obj_grad(*n, 0.), + fvals (n_con, 0.), + grads (n_vars*n_con, 0.); + + std::vector + eval_grads(n_con); + std::fill(eval_grads.begin(), eval_grads.end(), *mode>0); + + // + // copy the dvars + // + for (unsigned int i=0; i_evaluate_wrapper(dvars, + obj, + false, // request the derivatives of obj + obj_grad, + fvals, + eval_grads, + grads); + + // + // now copy them back as necessary + // + // first the constraint functions + // + for (unsigned int i=0; i 0) { + // + // next, the constraint gradients + // + for (unsigned int i=0; i 1.e5) *mode = -1; +} +#endif + +// +// \subsection ex_8_main Main function +// + +int main(int argc, char* argv[]) { + + libMesh::LibMeshInit init(argc, argv); + + MAST::Examples::GetPotWrapper + input(argc, argv, "input"); + + + std::unique_ptr + top_opt; + + std::string + mesh = input("mesh", "inplane2d, bracket2d, truss2d, eyebar2d", "inplane2d"); + + if (mesh == "inplane2d") { + top_opt.reset + (new TopologyOptimizationLevelSet + (init.comm(), input)); + } + else if (mesh == "bracket2d") { + top_opt.reset + (new TopologyOptimizationLevelSet + (init.comm(), input)); + } + else if (mesh == "eyebar2d") { + top_opt.reset + (new TopologyOptimizationLevelSet + (init.comm(), input)); + } + else if (mesh == "truss2d") { + top_opt.reset + (new TopologyOptimizationLevelSet + (init.comm(), input)); + } + else + libmesh_error(); + + _my_func_eval = top_opt.get(); + + + std::unique_ptr optimizer; + + std::string + s = input("optimizer", "optimizer to use in the example", "gcmma"); + + if (s == "gcmma") { + + optimizer.reset(new MAST::GCMMAOptimizationInterface); + + unsigned int + max_inner_iters = input("max_inner_iters", "maximum inner iterations in GCMMA", 15); + + Real + constr_penalty = input("constraint_penalty", "constraint penalty in GCMMA", 50.), + initial_rel_step = input("initial_rel_step", "initial step size in GCMMA", 1.e-2), + asymptote_reduction = input("asymptote_reduction", "reduction of aymptote in GCMMA", 0.7), + asymptote_expansion = input("asymptote_expansion", "expansion of asymptote in GCMMA", 1.2); + + optimizer->set_real_parameter ("constraint_penalty", constr_penalty); + optimizer->set_real_parameter ("initial_rel_step", initial_rel_step); + optimizer->set_real_parameter ("asymptote_reduction", asymptote_reduction); + optimizer->set_real_parameter ("asymptote_expansion", asymptote_expansion); + optimizer->set_integer_parameter( "max_inner_iters", max_inner_iters); + } + else if (s == "snopt") { + + optimizer.reset(new MAST::NPSOLOptimizationInterface); + } + else { + + libMesh::out + << "Unrecognized optimizer specified: " << s << std::endl; + libmesh_error(); + } + + if (optimizer.get()) { + + optimizer->attach_function_evaluation_object(*top_opt); + + bool + verify_grads = input("verify_gradients", "If true, the gradients of objective and constraints will be verified without optimization", false); + if (verify_grads) { + + std::vector xx1(top_opt->n_vars()), xx2(top_opt->n_vars()); + top_opt->init_dvar(xx1, xx2, xx2); + top_opt->verify_gradients(xx1); + } + else + optimizer->optimize(); + } + + // END_TRANSLATE + return 0; +} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3833d1d9..0346ddba 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -37,7 +37,9 @@ target_link_libraries(mast ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} debug ${libMesh_dbg_LIBRARIES} + debug ${timpi_dbg_LIBRARIES} optimized ${libMesh_opt_LIBRARIES} + optimized ${timpi_opt_LIBRARIES} ${LIBGFORTRAN_LIBRARIES}) # NOTE: Use of PUBLIC keyword above means other CMake target (like an example) diff --git a/src/base/assembly_base.cpp b/src/base/assembly_base.cpp index dea08ed5..b0dbd802 100644 --- a/src/base/assembly_base.cpp +++ b/src/base/assembly_base.cpp @@ -288,6 +288,9 @@ MAST::AssemblyBase::calculate_output(const libMesh::NumericVector& X, const libMesh::Elem* elem = *el; + if (diagonal_elem_subdomain_id.count(elem->subdomain_id())) + continue; + dof_map.dof_indices (elem, dof_indices); // get the solution @@ -366,7 +369,10 @@ calculate_output_derivative(const libMesh::NumericVector& X, for ( ; el != end_el; ++el) { const libMesh::Elem* elem = *el; - + + if (diagonal_elem_subdomain_id.count(elem->subdomain_id())) + continue; + dof_map.dof_indices (elem, dof_indices); // get the solution @@ -457,6 +463,9 @@ calculate_output_direct_sensitivity(const libMesh::NumericVector& X, const libMesh::Elem* elem = *el; + if (diagonal_elem_subdomain_id.count(elem->subdomain_id())) + continue; + // no sensitivity computation assembly is neeed in these cases if (_param_dependence && // if object is specified and elem does not depend on it diff --git a/src/base/assembly_base.h b/src/base/assembly_base.h index 8ebb042f..565cdcec 100644 --- a/src/base/assembly_base.h +++ b/src/base/assembly_base.h @@ -63,7 +63,14 @@ namespace MAST { */ virtual ~AssemblyBase(); + /*! + * subdomain ids for which residuakl and Jacobian contributions will not be computed. Instead, + * a small diagonal value will be added to the Jacobian for the dofs corresponding to this + * element. + */ + std::set diagonal_elem_subdomain_id; + class SolverMonitor { public: SolverMonitor(){} diff --git a/src/base/assembly_elem_operation.cpp b/src/base/assembly_elem_operation.cpp index 4986bd8a..a465de1c 100644 --- a/src/base/assembly_elem_operation.cpp +++ b/src/base/assembly_elem_operation.cpp @@ -21,6 +21,10 @@ #include "base/assembly_elem_operation.h" #include "base/elem_base.h" #include "base/assembly_base.h" +#include "base/physics_discipline_base.h" +#include "base/boundary_condition_base.h" +#include "base/field_function_base.h" +#include "mesh/geom_elem.h" #include "mesh/fe_base.h" @@ -195,3 +199,51 @@ MAST::AssemblyElemOperations::clear_elem() { _physics_elem = nullptr; } + + +std::pair*, unsigned int> +MAST::AssemblyElemOperations:: +get_elem_boundary_velocity_data() { + + libmesh_assert(_physics_elem); + + std::pair*, unsigned int> + val = std::make_pair(nullptr, 0); + + std::map> loads; + _physics_elem->elem().external_side_loads_for_quadrature_elem(_discipline->side_loads(), + loads); + + std::map>::const_iterator + it = loads.begin(), + end = loads.end(); + + for ( ; it != end; it++) { + + std::vector::const_iterator + bc_it = it->second.begin(), + bc_end = it->second.end(); + + for ( ; bc_it != bc_end; bc_it++) { + + // apply all the types of loading + switch ((*bc_it)->type()) { + + case MAST::BOUNDARY_VELOCITY: { + + val.first = &((*bc_it)->get>("phi_vel")); + val.second = it->first; + } + break; + + + default: + // nothing to be done here + break; + } + } + } + + return val; +} + diff --git a/src/base/assembly_elem_operation.h b/src/base/assembly_elem_operation.h index 5e11ca5e..2c24d99e 100644 --- a/src/base/assembly_elem_operation.h +++ b/src/base/assembly_elem_operation.h @@ -37,6 +37,7 @@ namespace MAST { class SystemInitialization; class PhysicsDisciplineBase; class GeomElem; + template class FieldFunction; class AssemblyElemOperations { @@ -167,6 +168,16 @@ namespace MAST { virtual void set_elem_perturbed_acceleration(const RealVectorX& accel); + /*! + * searches through the side load data and populates the data + * with the boundary id and velocity function on the + * boundary. Returns a null pointer for velocity if no boundary is + * specified for this elem. + */ + virtual std::pair*, unsigned int> + get_elem_boundary_velocity_data(); + + protected: MAST::SystemInitialization *_system; diff --git a/src/base/boundary_condition_base.h b/src/base/boundary_condition_base.h index 540423c1..eb4cdb31 100644 --- a/src/base/boundary_condition_base.h +++ b/src/base/boundary_condition_base.h @@ -29,6 +29,8 @@ namespace MAST { enum BoundaryConditionType { SURFACE_PRESSURE, + SURFACE_TRACTION, + SURFACE_TRACTION_SHIFTED_BOUNDARY, POINT_LOAD, POINT_MOMENT, PISTON_THEORY, @@ -44,7 +46,8 @@ namespace MAST { FAR_FIELD, EXHAUST, ISOTHERMAL, - ADIABATIC + ADIABATIC, + BOUNDARY_VELOCITY }; diff --git a/src/base/eigenproblem_assembly_elem_operations.h b/src/base/eigenproblem_assembly_elem_operations.h index 138d50f7..77b5b8f5 100644 --- a/src/base/eigenproblem_assembly_elem_operations.h +++ b/src/base/eigenproblem_assembly_elem_operations.h @@ -59,6 +59,15 @@ namespace MAST { RealMatrixX& mat_A, RealMatrixX& mat_B) = 0; + /*! + * performs the element topology sensitivity calculations over \p elem. + */ + virtual void + elem_topology_sensitivity_calculations(const MAST::FunctionBase& f, + bool base_sol, + RealMatrixX& mat_A, + RealMatrixX& mat_B) = 0; + /*! * performs the element topology sensitivity calculations over \p elem. */ diff --git a/src/base/elem_base.cpp b/src/base/elem_base.cpp index cec649f6..3eea64ad 100644 --- a/src/base/elem_base.cpp +++ b/src/base/elem_base.cpp @@ -25,10 +25,8 @@ MAST::ElementBase::ElementBase(MAST::SystemInitialization& sys, - MAST::AssemblyBase& assembly, const MAST::GeomElem& elem): _system (sys), -_assembly (assembly), _elem (elem), _active_sol_function (nullptr), _time (_system.system().time) { diff --git a/src/base/elem_base.h b/src/base/elem_base.h index 8021915a..9a858db5 100644 --- a/src/base/elem_base.h +++ b/src/base/elem_base.h @@ -80,7 +80,6 @@ namespace MAST { * performed. */ ElementBase(MAST::SystemInitialization& sys, - MAST::AssemblyBase& assembly, const MAST::GeomElem& elem); @@ -97,13 +96,6 @@ namespace MAST { return _system; } - /*! - * @returns a reference to the libMesh::System object - */ - MAST::AssemblyBase& assembly() { - return _assembly; - } - /*! * @returns a reference to the libMesh::System object @@ -207,11 +199,6 @@ namespace MAST { */ MAST::SystemInitialization& _system; - /*! - * Assembly object - */ - MAST::AssemblyBase& _assembly; - /*! * geometric element for which the computations are performed */ diff --git a/src/base/mast_config.h.in b/src/base/mast_config.h.in index a65a9ab7..3882b118 100644 --- a/src/base/mast_config.h.in +++ b/src/base/mast_config.h.in @@ -26,6 +26,8 @@ #define MAST_ENABLE_SNOPT @MAST_ENABLE_SNOPT@ +#define MAST_ENABLE_NASTRANIO @MAST_ENABLE_NASTRANIO@ + #define MAST_ENABLE_CYTHON @MAST_ENABLE_CYTHON@ #define MAST_ENABLE_MATPLOTLIB @MAST_ENABLE_MATPLOTLIB@ diff --git a/src/base/mesh_field_function.cpp b/src/base/mesh_field_function.cpp index 2e33d0e7..48ae8d19 100644 --- a/src/base/mesh_field_function.cpp +++ b/src/base/mesh_field_function.cpp @@ -167,6 +167,38 @@ MAST::MeshFieldFunction::perturbation(const libMesh::Point& p, } +void +MAST::MeshFieldFunction::perturbation_gradient (const libMesh::Point& p, + const Real t, + RealMatrixX& v) const { + + // if the element has provided a quadrature point solution, + // then use it + if (_use_qp_sol) { + v = _qp_sol; + return; + } + + // make sure that the object was initialized + libmesh_assert(_function); + + unsigned int + n_vars = _sys->n_vars(); + + std::vector v1; + _perturbed_function->gradient(p, t, v1); + + // make sure that the mesh function was able to find the element + // and a solution + libmesh_assert_equal_to(v1.size(), n_vars); + + // now copy this to the output vector + v = RealMatrixX::Zero(n_vars, 3); // assume 3-dimensional by default + for (unsigned int i=0; i& X, dof_map.dof_indices (elem, dof_indices); - MAST::GeomElem geom_elem; - ops.set_elem_data(elem->dim(), *elem, geom_elem); - geom_elem.init(*elem, *_system); - - ops.init(geom_elem); + if (diagonal_elem_subdomain_id.count(elem->subdomain_id())) { - // get the solution - unsigned int ndofs = (unsigned int)dof_indices.size(); - sol.setZero(ndofs); - vec.setZero(ndofs); - mat.setZero(ndofs, ndofs); - - for (unsigned int i=0; iattach_active_solution_function(*_sol_function); - - //_check_element_numerical_jacobian(*physics_elem, sol); - - // perform the element level calculations - ops.elem_calculations(J!=nullptr?true:false, - vec, mat); - -// physics_elem->detach_active_solution_function(); - - ops.clear_elem(); - - // copy to the libMesh matrix for further processing - DenseRealVector v; - DenseRealMatrix m; - if (R) - MAST::copy(v, vec); - if (J) - MAST::copy(m, mat); - - // constrain the quantities to account for hanging dofs, - // Dirichlet constraints, etc. - if (R && J) - dof_map.constrain_element_matrix_and_vector(m, v, dof_indices); - else if (R) - dof_map.constrain_element_vector(v, dof_indices); - else - dof_map.constrain_element_matrix(m, dof_indices); - - // add to the global matrices - if (R) R->add_vector(v, dof_indices); - if (J) J->add_matrix(m, dof_indices); - dof_indices.clear(); + if (J) { + + unsigned int ndofs = (unsigned int)dof_indices.size(); + mat.setIdentity(ndofs, ndofs); + mat *= 1.e-24; + DenseRealMatrix m; + MAST::copy(m, mat); + dof_map.constrain_element_matrix(m, dof_indices); + J->add_matrix(m, dof_indices); + dof_indices.clear(); + } + } + else { + + MAST::GeomElem geom_elem; + ops.set_elem_data(elem->dim(), *elem, geom_elem); + geom_elem.init(*elem, *_system); + + ops.init(geom_elem); + + // get the solution + unsigned int ndofs = (unsigned int)dof_indices.size(); + sol.setZero(ndofs); + vec.setZero(ndofs); + mat.setZero(ndofs, ndofs); + + for (unsigned int i=0; iattach_active_solution_function(*_sol_function); + + //_check_element_numerical_jacobian(*physics_elem, sol); + + // perform the element level calculations + ops.elem_calculations(J!=nullptr?true:false, + vec, mat); + + // physics_elem->detach_active_solution_function(); + + ops.clear_elem(); + + // copy to the libMesh matrix for further processing + DenseRealVector v; + DenseRealMatrix m; + if (R) + MAST::copy(v, vec); + if (J) + MAST::copy(m, mat); + + // constrain the quantities to account for hanging dofs, + // Dirichlet constraints, etc. + if (R && J) + dof_map.constrain_element_matrix_and_vector(m, v, dof_indices); + else if (R) + dof_map.constrain_element_vector(v, dof_indices); + else + dof_map.constrain_element_matrix(m, dof_indices); + + // add to the global matrices + if (R) R->add_vector(v, dof_indices); + if (J) J->add_matrix(m, dof_indices); + dof_indices.clear(); + } } @@ -307,6 +324,9 @@ linearized_jacobian_solution_product (const libMesh::NumericVector& X, const libMesh::Elem* elem = *el; + if (diagonal_elem_subdomain_id.count(elem->subdomain_id())) + continue; + dof_map.dof_indices (elem, dof_indices); MAST::GeomElem geom_elem; @@ -420,6 +440,9 @@ second_derivative_dot_solution_assembly (const libMesh::NumericVector& X, const libMesh::Elem* elem = *el; + if (diagonal_elem_subdomain_id.count(elem->subdomain_id())) + continue; + dof_map.dof_indices (elem, dof_indices); MAST::GeomElem geom_elem; @@ -490,7 +513,7 @@ sensitivity_assemble (const MAST::FunctionBase& f, // iterate over each element, initialize it and get the relevant // analysis quantities - RealVectorX vec, sol; + RealVectorX vec, vec1, sol; std::vector dof_indices; const libMesh::DofMap& dof_map = nonlin_sys.get_dof_map(); @@ -515,7 +538,10 @@ sensitivity_assemble (const MAST::FunctionBase& f, for ( ; el != end_el; ++el) { const libMesh::Elem* elem = *el; - + + if (diagonal_elem_subdomain_id.count(elem->subdomain_id())) + continue; + // no sensitivity computation assembly is neeed in these cases if (_param_dependence && // if object is specified and elem does not depend on it @@ -534,7 +560,8 @@ sensitivity_assemble (const MAST::FunctionBase& f, unsigned int ndofs = (unsigned int)dof_indices.size(); sol.setZero(ndofs); vec.setZero(ndofs); - + vec1.setZero(ndofs); + for (unsigned int i=0; iattach_active_solution_function(*_sol_function); ops.elem_sensitivity_calculations(f, vec); + if (f.is_topology_parameter()) { + ops.elem_topology_sensitivity_calculations(f, vec1); + vec += vec1; + } + // physics_elem->detach_active_solution_function(); ops.clear_elem(); diff --git a/src/base/nonlinear_implicit_assembly_elem_operations.h b/src/base/nonlinear_implicit_assembly_elem_operations.h index 664df7d9..ee8df6d5 100644 --- a/src/base/nonlinear_implicit_assembly_elem_operations.h +++ b/src/base/nonlinear_implicit_assembly_elem_operations.h @@ -79,6 +79,15 @@ namespace MAST { elem_shape_sensitivity_calculations(const MAST::FunctionBase& f, RealVectorX& vec) = 0; + /*! + * performs the element topology sensitivity calculations over \p elem, + * and returns the element residual sensitivity in \p vec . + */ + virtual void + elem_topology_sensitivity_calculations(const MAST::FunctionBase& f, + RealVectorX& vec) = 0; + + /*! * performs the element topology sensitivity calculations over \p elem, * and returns the element residual sensitivity in \p vec . diff --git a/src/base/output_assembly_elem_operations.h b/src/base/output_assembly_elem_operations.h index 86073e89..f6e04a70 100644 --- a/src/base/output_assembly_elem_operations.h +++ b/src/base/output_assembly_elem_operations.h @@ -154,6 +154,15 @@ namespace MAST { */ virtual void evaluate_shape_sensitivity(const MAST::FunctionBase& f) = 0; + /*! + * this evaluates all relevant topological sensitivity components on + * the element. + * This is only done on the current element for which this + * object has been initialized. + */ + virtual void + evaluate_topology_sensitivity(const MAST::FunctionBase& f) = 0; + /*! * this evaluates all relevant topological sensitivity components on * the element. diff --git a/src/base/physics_discipline_base.cpp b/src/base/physics_discipline_base.cpp index 0b4a5cfb..b2e20de9 100644 --- a/src/base/physics_discipline_base.cpp +++ b/src/base/physics_discipline_base.cpp @@ -57,6 +57,24 @@ MAST::PhysicsDisciplineBase::add_side_load(libMesh::boundary_id_type bid, +void +MAST::PhysicsDisciplineBase::remove_side_load(libMesh::boundary_id_type bid, + MAST::BoundaryConditionBase& load) { + // make sure that this boundary and load have been applied + std::pair it = + _side_bc_map.equal_range(bid); + + for ( ; it.first != it.second; it.first++) + if (it.first->second == &load) { + + _side_bc_map.erase(it.first); + break; + } +} + + + + void MAST::PhysicsDisciplineBase::add_dirichlet_bc(libMesh::boundary_id_type bid, @@ -102,6 +120,22 @@ MAST::PhysicsDisciplineBase::add_volume_load(libMesh::subdomain_id_type sid, } +void +MAST::PhysicsDisciplineBase::remove_volume_load(libMesh::subdomain_id_type sid, + MAST::BoundaryConditionBase& load) { + std::pair it = + _vol_bc_map.equal_range(sid); + + for ( ; it.first != it.second; it.first++) { + if (it.first->second == &load) { + + _vol_bc_map.erase(it.first); + break; + } + } +} + + void diff --git a/src/base/physics_discipline_base.h b/src/base/physics_discipline_base.h index f799f87b..ce708ba1 100644 --- a/src/base/physics_discipline_base.h +++ b/src/base/physics_discipline_base.h @@ -93,7 +93,13 @@ namespace MAST { */ void add_side_load(libMesh::boundary_id_type bid, MAST::BoundaryConditionBase& load); - + + /*! + * remove the specified side loads for the boudnary with tag \p b_id + */ + void remove_side_load(libMesh::boundary_id_type bid, + MAST::BoundaryConditionBase& load); + /*! * adds the specified Dirichlet boundary condition for the boundary * with tag \p b_id @@ -123,6 +129,13 @@ namespace MAST { void add_volume_load(libMesh::subdomain_id_type bid, MAST::BoundaryConditionBase& load); + /*! + * remove the specified volume loads for the elements with + * subdomain tag \p s_id + */ + void remove_volume_load(libMesh::subdomain_id_type bid, + MAST::BoundaryConditionBase& load); + /*! * adds the specified point load diff --git a/src/elasticity/bending_structural_element.cpp b/src/elasticity/bending_structural_element.cpp index 69ef11d0..4f410c14 100644 --- a/src/elasticity/bending_structural_element.cpp +++ b/src/elasticity/bending_structural_element.cpp @@ -25,10 +25,9 @@ MAST::BendingStructuralElem:: BendingStructuralElem(MAST::SystemInitialization& sys, - MAST::AssemblyBase& assembly, const MAST::GeomElem& elem, const MAST::ElementPropertyCardBase& p): -MAST::StructuralElementBase(sys, assembly, elem, p) { +MAST::StructuralElementBase(sys, elem, p) { } diff --git a/src/elasticity/bending_structural_element.h b/src/elasticity/bending_structural_element.h index aab961a0..12d02035 100644 --- a/src/elasticity/bending_structural_element.h +++ b/src/elasticity/bending_structural_element.h @@ -38,7 +38,6 @@ namespace MAST { public: BendingStructuralElem(MAST::SystemInitialization& sys, - MAST::AssemblyBase& assembly, const MAST::GeomElem& elem, const MAST::ElementPropertyCardBase& p); diff --git a/src/elasticity/compliance_output.cpp b/src/elasticity/compliance_output.cpp index 46b9698a..169819ef 100644 --- a/src/elasticity/compliance_output.cpp +++ b/src/elasticity/compliance_output.cpp @@ -153,6 +153,46 @@ MAST::ComplianceOutput::evaluate_sensitivity(const MAST::FunctionBase &f) { +void +MAST::ComplianceOutput:: +evaluate_topology_sensitivity(const MAST::FunctionBase &f) { + + // the primal data should have been calculated + libmesh_assert(_physics_elem); + libmesh_assert(f.is_topology_parameter()); + + if (this->if_evaluate_for_element(_physics_elem->elem())) { + + std::pair*, unsigned int> + val = this->get_elem_boundary_velocity_data(); + + if (val.first) { + + MAST::StructuralElementBase& e = + dynamic_cast(*_physics_elem); + + RealVectorX + vec = RealVectorX::Zero(e.sol().size()); + + RealMatrixX + dummy = RealMatrixX::Zero(vec.size(), vec.size()); + + e.volume_external_residual_boundary_velocity(f, + val.second, + *val.first, + _discipline->volume_loads(), + false, + vec, + dummy); + + // compute the contribution of this element to compliance + _dcompliance_dp -= vec.dot(e.sol()); + } + } +} + + + void MAST::ComplianceOutput:: evaluate_topology_sensitivity(const MAST::FunctionBase &f, @@ -280,7 +320,7 @@ MAST::ComplianceOutput::init(const MAST::GeomElem& elem) { dynamic_cast(_discipline->get_property_card(elem)); _physics_elem = - MAST::build_structural_element(*_system, *_assembly, elem, p).release(); + MAST::build_structural_element(*_system, elem, p).release(); } diff --git a/src/elasticity/compliance_output.h b/src/elasticity/compliance_output.h index c5b3a0de..543fa534 100644 --- a/src/elasticity/compliance_output.h +++ b/src/elasticity/compliance_output.h @@ -114,6 +114,15 @@ namespace MAST { libmesh_assert(false); // to be implemented } + /*! + * this evaluates all relevant topological sensitivity components on + * the element. + * This is only done on the current element for which this + * object has been initialized. + */ + virtual void + evaluate_topology_sensitivity(const MAST::FunctionBase& f); + /*! * This evaluates the contribution to the topology sensitivity on the * boundary. Given that the integral is nonlinear due to the \f$p-\f$norm, diff --git a/src/elasticity/fluid_structure_assembly_elem_operations.cpp b/src/elasticity/fluid_structure_assembly_elem_operations.cpp index 941df910..c2670e9d 100644 --- a/src/elasticity/fluid_structure_assembly_elem_operations.cpp +++ b/src/elasticity/fluid_structure_assembly_elem_operations.cpp @@ -69,7 +69,7 @@ MAST::FluidStructureAssemblyElemOperations::init(const MAST::GeomElem& elem) { dynamic_cast(_discipline->get_property_card(elem)); _physics_elem = - MAST::build_structural_element(*_system, *_assembly, elem, p).release(); + MAST::build_structural_element(*_system, elem, p).release(); } diff --git a/src/elasticity/smooth_ramp_stress_output.cpp b/src/elasticity/smooth_ramp_stress_output.cpp index 92577f85..12dd5137 100644 --- a/src/elasticity/smooth_ramp_stress_output.cpp +++ b/src/elasticity/smooth_ramp_stress_output.cpp @@ -35,6 +35,7 @@ #include "libmesh/parallel.h" + MAST::SmoothRampStressStrainOutput::SmoothRampStressStrainOutput(): MAST::StressStrainOutputBase() { diff --git a/src/elasticity/solid_element_3d.cpp b/src/elasticity/solid_element_3d.cpp index eccca5a1..e2d955e7 100644 --- a/src/elasticity/solid_element_3d.cpp +++ b/src/elasticity/solid_element_3d.cpp @@ -33,10 +33,9 @@ MAST::StructuralElement3D:: StructuralElement3D(MAST::SystemInitialization& sys, - MAST::AssemblyBase& assembly, const MAST::GeomElem& elem, const MAST::ElementPropertyCardBase& p): -MAST::StructuralElementBase(sys, assembly, elem, p) { +MAST::StructuralElementBase(sys, elem, p) { } @@ -610,7 +609,7 @@ surface_pressure_residual(bool request_jacobian, // prepare the side finite element std::unique_ptr - fe(_elem.init_side_fe(side, false)); + fe(_elem.init_side_fe(side, false, false)); const std::vector &JxW = fe->get_JxW(); const std::vector& qpoint = fe->get_xyz(); @@ -678,7 +677,7 @@ surface_pressure_residual_sensitivity(const MAST::FunctionBase& p, // prepare the side finite element std::unique_ptr - fe(_elem.init_side_fe(side, false)); + fe(_elem.init_side_fe(side, false, false)); const std::vector &JxW = fe->get_JxW(); const std::vector& qpoint = fe->get_xyz(); diff --git a/src/elasticity/solid_element_3d.h b/src/elasticity/solid_element_3d.h index 864b5faa..c8a4bea6 100644 --- a/src/elasticity/solid_element_3d.h +++ b/src/elasticity/solid_element_3d.h @@ -37,7 +37,6 @@ namespace MAST { public: StructuralElement3D(MAST::SystemInitialization& sys, - MAST::AssemblyBase& assembly, const MAST::GeomElem& elem, const MAST::ElementPropertyCardBase& p); @@ -149,6 +148,55 @@ namespace MAST { protected: + /*! + * Calculates the force vector and Jacobian due to surface traction. + */ + virtual bool + surface_traction_residual(bool request_jacobian, + RealVectorX& f, + RealMatrixX& jac, + const unsigned int side, + MAST::BoundaryConditionBase& bc) {} + + + /*! + * Calculates the sensitivity of element vector and matrix quantities for surface traction + * boundary condition. + */ + virtual bool + surface_traction_residual_sensitivity(const MAST::FunctionBase& p, + bool request_jacobian, + RealVectorX& f, + RealMatrixX& jac, + const unsigned int side, + MAST::BoundaryConditionBase& bc) {} + + + /*! + * Calculates the sensitivity of force vector and Jacobian due to surface traction and + * sensitiity due to boundary movement. + */ + virtual bool + surface_traction_residual_shifted_boundary(bool request_jacobian, + RealVectorX& f, + RealMatrixX& jac, + const unsigned int side, + MAST::BoundaryConditionBase& bc) {} + + /*! + * Calculates the sensitivity of force vector and Jacobian due to surface traction and + * sensitiity due to boundary movement. + */ + virtual bool + surface_traction_residual_shifted_boundary_sensitivity(const MAST::FunctionBase& p, + bool request_jacobian, + RealVectorX& f, + RealMatrixX& jac, + const unsigned int side, + MAST::BoundaryConditionBase& bc) {} + + + /*! * Calculates the force vector and Jacobian due to surface pressure. */ diff --git a/src/elasticity/stress_assembly.cpp b/src/elasticity/stress_assembly.cpp index 1eb7a779..12854411 100644 --- a/src/elasticity/stress_assembly.cpp +++ b/src/elasticity/stress_assembly.cpp @@ -165,6 +165,8 @@ update_stress_strain_data(MAST::StressStrainOutputBase& ops, ops.set_elem_data(elem->dim(), *elem, geom_elem); geom_elem.init(*elem, *_system); + if (!ops.if_evaluate_for_element(geom_elem)) continue; + ops.init(geom_elem); ops.set_elem_solution(sol); ops.evaluate(); @@ -301,6 +303,8 @@ update_stress_strain_sensitivity_data(MAST::StressStrainOutputBase& ops, ops.set_elem_data(elem->dim(), *elem, geom_elem); geom_elem.init(*elem, *_system); + if (!ops.if_evaluate_for_element(geom_elem)) continue; + ops.init(geom_elem); ops.set_stress_plot_mode(true); ops.set_elem_solution(sol); diff --git a/src/elasticity/stress_output_base.cpp b/src/elasticity/stress_output_base.cpp index 16af69ce..ad987e03 100644 --- a/src/elasticity/stress_output_base.cpp +++ b/src/elasticity/stress_output_base.cpp @@ -352,6 +352,34 @@ MAST::StressStrainOutputBase::evaluate_sensitivity(const MAST::FunctionBase &f) +void +MAST::StressStrainOutputBase:: +evaluate_topology_sensitivity(const MAST::FunctionBase &f) { + + // the primal data should have been calculated + libmesh_assert(_physics_elem); + libmesh_assert(f.is_topology_parameter()); + if (!_if_stress_plot_mode) + libmesh_assert(_primal_data_initialized); + + // sensitivity only exists at the boundary. So, we proceed with calculation + // only if this element has an intersection in the interior, or with a side. + + if (this->if_evaluate_for_element(_physics_elem->elem())) { + + std::pair*, unsigned int> + val = this->get_elem_boundary_velocity_data(); + + if (val.first) + dynamic_cast + (_physics_elem)->calculate_stress_boundary_velocity(f, *this, + val.second, + *val.first); + } +} + + + void MAST::StressStrainOutputBase:: evaluate_topology_sensitivity(const MAST::FunctionBase &f, @@ -482,7 +510,7 @@ MAST::StressStrainOutputBase::init(const MAST::GeomElem& elem) { dynamic_cast(_discipline->get_property_card(elem)); _physics_elem = - MAST::build_structural_element(*_system, *_assembly, elem, p).release(); + MAST::build_structural_element(*_system, elem, p).release(); } diff --git a/src/elasticity/stress_output_base.h b/src/elasticity/stress_output_base.h index f7267c91..9cb91739 100644 --- a/src/elasticity/stress_output_base.h +++ b/src/elasticity/stress_output_base.h @@ -328,6 +328,16 @@ namespace MAST { libmesh_assert(false); // to be implemented } + /*! + * this evaluates all relevant topological sensitivity components on + * the element. + * This is only done on the current element for which this + * object has been initialized. + */ + virtual void + evaluate_topology_sensitivity(const MAST::FunctionBase& f); + + /*! * This evaluates the contribution to the topology sensitivity on the * boundary. Given that the integral is nonlinear due to the \f$p-\f$norm, diff --git a/src/elasticity/structural_buckling_eigenproblem_elem_operations.cpp b/src/elasticity/structural_buckling_eigenproblem_elem_operations.cpp index 449dcb4f..4c98b3e4 100644 --- a/src/elasticity/structural_buckling_eigenproblem_elem_operations.cpp +++ b/src/elasticity/structural_buckling_eigenproblem_elem_operations.cpp @@ -71,7 +71,7 @@ MAST::StructuralBucklingEigenproblemElemOperations::init(const MAST::GeomElem& e (_discipline->get_property_card(elem)); _physics_elem = - MAST::build_structural_element(*_system, *_assembly, elem, p).release(); + MAST::build_structural_element(*_system, elem, p).release(); } diff --git a/src/elasticity/structural_element_1d.cpp b/src/elasticity/structural_element_1d.cpp index a790b537..745b1170 100644 --- a/src/elasticity/structural_element_1d.cpp +++ b/src/elasticity/structural_element_1d.cpp @@ -35,10 +35,9 @@ MAST::StructuralElement1D::StructuralElement1D(MAST::SystemInitialization& sys, - MAST::AssemblyBase& assembly, const MAST::GeomElem& elem, const MAST::ElementPropertyCardBase& p): -MAST::BendingStructuralElem(sys, assembly, elem, p) { +MAST::BendingStructuralElem(sys, elem, p) { } @@ -1709,7 +1708,7 @@ surface_pressure_residual(bool request_jacobian, libmesh_assert(!follower_forces); // not implemented yet for follower forces // prepare the side finite element - std::unique_ptr fe(_elem.init_side_fe(side, false)); + std::unique_ptr fe(_elem.init_side_fe(side, false, false)); const std::vector &JxW = fe->get_JxW(); const std::vector& qpoint = fe->get_xyz(); @@ -1788,7 +1787,7 @@ surface_pressure_residual_sensitivity(const MAST::FunctionBase& p, libmesh_assert(!follower_forces); // not implemented yet for follower forces // prepare the side finite element - std::unique_ptr fe(_elem.init_side_fe(side, false)); + std::unique_ptr fe(_elem.init_side_fe(side, false, false)); const std::vector &JxW = fe->get_JxW(); const std::vector& qpoint = fe->get_xyz(); diff --git a/src/elasticity/structural_element_1d.h b/src/elasticity/structural_element_1d.h index 0bd890ef..497c9255 100644 --- a/src/elasticity/structural_element_1d.h +++ b/src/elasticity/structural_element_1d.h @@ -39,7 +39,6 @@ namespace MAST { public: StructuralElement1D(MAST::SystemInitialization& sys, - MAST::AssemblyBase& assembly, const MAST::GeomElem& elem, const MAST::ElementPropertyCardBase& p); @@ -160,7 +159,55 @@ namespace MAST { protected: - + /*! + * Calculates the force vector and Jacobian due to surface traction. + */ + virtual bool + surface_traction_residual(bool request_jacobian, + RealVectorX& f, + RealMatrixX& jac, + const unsigned int side, + MAST::BoundaryConditionBase& bc){ return false;} + + + /*! + * Calculates the sensitivity of element vector and matrix quantities for surface traction + * boundary condition. + */ + virtual bool + surface_traction_residual_sensitivity(const MAST::FunctionBase& p, + bool request_jacobian, + RealVectorX& f, + RealMatrixX& jac, + const unsigned int side, + MAST::BoundaryConditionBase& bc) {} + + + /*! + * Calculates the sensitivity of force vector and Jacobian due to surface traction and + * sensitiity due to boundary movement. + */ + virtual bool + surface_traction_residual_shifted_boundary(bool request_jacobian, + RealVectorX& f, + RealMatrixX& jac, + const unsigned int side, + MAST::BoundaryConditionBase& bc) {} + + /*! + * Calculates the sensitivity of force vector and Jacobian due to surface traction and + * sensitiity due to boundary movement. + */ + virtual bool + surface_traction_residual_shifted_boundary_sensitivity(const MAST::FunctionBase& p, + bool request_jacobian, + RealVectorX& f, + RealMatrixX& jac, + const unsigned int side, + MAST::BoundaryConditionBase& bc) {} + + + /*! * Calculates the force vector and Jacobian due to surface pressure. */ diff --git a/src/elasticity/structural_element_2d.cpp b/src/elasticity/structural_element_2d.cpp index 6b45c81b..33e1b981 100644 --- a/src/elasticity/structural_element_2d.cpp +++ b/src/elasticity/structural_element_2d.cpp @@ -32,14 +32,14 @@ #include "base/parameter.h" #include "base/constant_field_function.h" #include "base/assembly_base.h" +#include "level_set/level_set_boundary_velocity.h" MAST::StructuralElement2D:: StructuralElement2D(MAST::SystemInitialization& sys, - MAST::AssemblyBase& assembly, const MAST::GeomElem& elem, const MAST::ElementPropertyCardBase& p): -MAST::BendingStructuralElem(sys, assembly, elem, p) { +MAST::BendingStructuralElem(sys, elem, p) { } @@ -249,6 +249,60 @@ initialize_green_lagrange_strain_operator(const unsigned int qp, } + +void +MAST::StructuralElement2D:: +initialize_strain_operator_gradient(const unsigned int qp, + const MAST::FEBase& fe, + const RealVectorX& local_disp, + RealMatrixX& epsilon_grad, + std::vector& dBmat_lin) { + + epsilon_grad.setZero(); + + const std::vector >& + d2phi = fe.get_d2phi(); + + unsigned int n_phi = (unsigned int)d2phi.size(); + RealVectorX + phi = RealVectorX::Zero(n_phi), + depsilon = RealVectorX::Zero(3); + + // make sure all matrices are the right size + libmesh_assert_equal_to(epsilon_grad.rows(), 3); + libmesh_assert_equal_to(epsilon_grad.cols(), 2); + libmesh_assert_equal_to(dBmat_lin.size(), 2); + + + for (unsigned int i=0; i<2; i++) { + + libmesh_assert_equal_to(dBmat_lin[i].m(), 3); + libmesh_assert_equal_to(dBmat_lin[i].n(), 6*n_phi); + + // now set the shape function values + // d2N/dxdxi + for ( unsigned int i_nd=0; i_nd& vel_f) { - std::unique_ptr fe(_elem.init_side_fe(s, true)); + std::unique_ptr fe(_elem.init_side_fe(s, true, false)); const unsigned int qp_loc_fe_size = (unsigned int)fe->get_qpoints().size(), @@ -2301,7 +2355,7 @@ MAST::StructuralElement2D::prestress_residual_sensitivity (const MAST::FunctionB bool MAST::StructuralElement2D:: -surface_pressure_residual(bool request_jacobian, +surface_traction_residual(bool request_jacobian, RealVectorX &f, RealMatrixX &jac, const unsigned int side, @@ -2310,12 +2364,11 @@ surface_pressure_residual(bool request_jacobian, libmesh_assert(!follower_forces); // not implemented yet for follower forces // prepare the side finite element - std::unique_ptr fe(_elem.init_side_fe(side, false)); + std::unique_ptr fe(_elem.init_side_fe(side, false, false)); const std::vector &JxW = fe->get_JxW(); const std::vector& qpoint = fe->get_xyz(); const std::vector >& phi = fe->get_phi(); - const std::vector& face_normals = fe->get_normals_for_local_coordinate(); const unsigned int n_phi = (unsigned int)phi.size(), n1 = 3, @@ -2323,16 +2376,17 @@ surface_pressure_residual(bool request_jacobian, // get the function from this boundary condition - const MAST::FieldFunction& p_func = - bc.get >("pressure"); + const MAST::FieldFunction& trac_func = + bc.get >("traction"); // get the thickness function to calculate the force const MAST::FieldFunction& t_func = _property.get >("h"); FEMOperatorMatrix Bmat; + RealVectorX + trac = RealVectorX::Zero(3); Real - press = 0., t_val = 0.; RealVectorX @@ -2350,12 +2404,12 @@ surface_pressure_residual(bool request_jacobian, Bmat.reinit(2*n1, phi_vec); // get pressure and thickness values - p_func(qpoint[qp], _time, press); - t_func(qpoint[qp], _time, t_val); + trac_func(qpoint[qp], _time, trac); + t_func (qpoint[qp], _time, t_val); // calculate force for (unsigned int i_dim=0; i_dim fe(_elem.init_side_fe(side, false)); + std::unique_ptr fe(_elem.init_side_fe(side, false, false)); const std::vector &JxW = fe->get_JxW(); const std::vector& qpoint = fe->get_xyz(); const std::vector >& phi = fe->get_phi(); - const std::vector& face_normals = fe->get_normals_for_local_coordinate(); const unsigned int n_phi = (unsigned int)phi.size(), n1 = 3, @@ -2399,20 +2450,20 @@ surface_pressure_residual_sensitivity(const MAST::FunctionBase& p, // get the function from this boundary condition - const MAST::FieldFunction& p_func = - bc.get >("pressure"); - + const MAST::FieldFunction& trac_func = + bc.get >("traction"); + // get the thickness function to calculate the force const MAST::FieldFunction& t_func = _property.get >("h"); - FEMOperatorMatrix Bmat; + RealVectorX + trac = RealVectorX::Zero(3), + dtrac = RealVectorX::Zero(3); Real - press = 0., - dpress = 0., - t_val = 0., - dt_val = 0.; + t_val = 0., + dt_val = 0.; RealVectorX phi_vec = RealVectorX::Zero(n_phi), @@ -2428,15 +2479,15 @@ surface_pressure_residual_sensitivity(const MAST::FunctionBase& p, Bmat.reinit(2*n1, phi_vec); - // get pressure and thickness values and their sensitivities - p_func(qpoint[qp], _time, press); - p_func.derivative(p, qpoint[qp], _time, dpress); - t_func(qpoint[qp], _time, t_val); + // get pressure and thickness values + trac_func(qpoint[qp], _time, trac); + trac_func.derivative(p, qpoint[qp], _time, dtrac); + t_func (qpoint[qp], _time, t_val); t_func.derivative(p, qpoint[qp], _time, dt_val); - + // calculate force for (unsigned int i_dim=0; i_dim fe(_elem.init_fe(true, - false, - _property.extra_quadrature_order(_elem))); - - const std::vector& JxW = fe->get_JxW(); - const std::vector& xyz = fe->get_xyz(); + libmesh_assert(!follower_forces); // not implemented yet for follower forces + // prepare the side finite element + std::unique_ptr fe(_elem.init_side_fe(side, true, true)); + + const std::vector &JxW = fe->get_JxW(); + const std::vector& qpoint = fe->get_xyz(); + const std::vector >& phi = fe->get_phi(); + const std::vector& face_normals = fe->get_normals_for_local_coordinate(); const unsigned int - n_phi = (unsigned int)fe->get_phi().size(), - n1 = this->n_direct_strain_components(), - n2 = 6*n_phi, - n3 = this->n_von_karman_strain_components(); + n_phi = (unsigned int)phi.size(), + n1 = 3, + n2 = 6*n_phi; + + + // get the function from this boundary condition at the projected point + const MAST::FieldFunction& trac_func = + bc.get >("traction"); + const MAST::LevelSetBoundaryVelocity& interface = + bc.get("phi_vel"); - RealMatrixX - material_exp_A_mat, - material_exp_B_mat, - mat1_n1n2 = RealMatrixX::Zero(n1,n2), - mat2_n2n2 = RealMatrixX::Zero(n2,n2), - mat3 = RealMatrixX::Zero(2, n2), - mat4_n3n2 = RealMatrixX::Zero(n3,n2), - vk_dwdxi_mat = RealMatrixX::Zero(n1,n3), - stress = RealMatrixX::Zero(2,2), - mat_x = RealMatrixX::Zero(3,2), - mat_y = RealMatrixX::Zero(3,2), - local_jac = RealMatrixX::Zero(n2,n2); + // get the thickness function to calculate the force + const MAST::FieldFunction& t_func = + _property.get >("h"); + + FEMOperatorMatrix Bmat; RealVectorX - vec1_n1 = RealVectorX::Zero(n1), - vec2_n1 = RealVectorX::Zero(n1), - vec3_n2 = RealVectorX::Zero(n2), - vec4_2 = RealVectorX::Zero(2), - vec5_n3 = RealVectorX::Zero(n3), + trac = RealVectorX::Zero(3), + stress = RealVectorX::Zero(3), + dnormal = RealVectorX::Zero(3), + normal = RealVectorX::Zero(3), + bnd_pt = RealVectorX::Zero(3), + phi_vec = RealVectorX::Zero(n_phi), + force = RealVectorX::Zero(2*n1), local_f = RealVectorX::Zero(n2), - strain = RealVectorX::Zero(3), - delta_t = RealVectorX::Zero(1); - - FEMOperatorMatrix - Bmat_lin, - Bmat_nl_x, - Bmat_nl_y, - Bmat_nl_u, - Bmat_nl_v, - Bmat_bend, - Bmat_vk; - - Bmat_lin.reinit(n1, _system.n_vars(), n_phi); // three stress-strain components - Bmat_nl_x.reinit(2, _system.n_vars(), n_phi); - Bmat_nl_y.reinit(2, _system.n_vars(), n_phi); - Bmat_nl_u.reinit(2, _system.n_vars(), n_phi); - Bmat_nl_v.reinit(2, _system.n_vars(), n_phi); - Bmat_bend.reinit(n1, _system.n_vars(), n_phi); - Bmat_vk.reinit(n3, _system.n_vars(), n_phi); // only dw/dx and dw/dy + vec_n2 = RealVectorX::Zero(n2); - bool if_vk = (_property.strain_type() == MAST::NONLINEAR_STRAIN); + RealMatrixX + normal_mat = RealMatrixX::Zero(2,n1), + stress_grad = RealMatrixX::Zero(n1,2), + mat1_n1n2 = RealMatrixX::Zero(2*n1, n2), + mat2_n2n2 = RealMatrixX::Zero(n2, n2), + local_jac = RealMatrixX::Zero(n2, n2), + dstress_dX = RealMatrixX::Zero(n1,n2), + *dstress_mat= request_jacobian?&dstress_dX:nullptr; - MAST::BendingOperatorType - bending_model = _property.bending_model(_elem); + Real + t_val = 0., + elem_h = _elem.get_reference_elem().hmax(); - std::unique_ptr bend; + libMesh::Point + pt; - if (bending_model != MAST::NO_BENDING) - bend.reset(MAST::build_bending_operator_2D(bending_model, - *this, - fe->get_qpoints()).release()); - - std::unique_ptr > - expansion_A = _property.thermal_expansion_A_matrix(*this), - expansion_B = _property.thermal_expansion_B_matrix(*this); + std::vector + stress_grad_dX(2, RealMatrixX::Zero(n1,n2)), + *stress_grad_mat = request_jacobian?&stress_grad_dX:nullptr; - const MAST::FieldFunction - &temp_func = bc.get >("temperature"), - &ref_temp_func = bc.get >("ref_temperature"); - Real - t = 0., - t0 = 0., - scaling = 1.; - - if (bc.contains("thermal_jacobian_scaling")) - bc.get>("thermal_jacobian_scaling")(scaling); - - for (unsigned int qp=0; qpinitialize_green_lagrange_strain_operator(qp, - *fe, - _local_sol, - strain, - mat_x, - mat_y, - Bmat_lin, - Bmat_nl_x, - Bmat_nl_y, - Bmat_nl_u, - Bmat_nl_v); + // compute difference in normal vector + for (unsigned int i_dim=0; i_diminitialize_bending_strain_operator(*fe, qp, Bmat_bend); - Bmat_bend.vector_mult_transpose(vec3_n2, vec2_n1); - local_f += JxW[qp] * vec3_n2; - - // von Karman strain - if (if_vk) { - // get the vonKarman strain operator if needed - this->initialize_von_karman_strain_operator(qp, - *fe, - vec2_n1, // epsilon_vk - vk_dwdxi_mat, - Bmat_vk); - // von Karman strain - vec4_2 = vk_dwdxi_mat.transpose() * vec1_n1; - Bmat_vk.vector_mult_transpose(vec3_n2, vec4_2); - local_f += JxW[qp] * vec3_n2; - } - } + // contribution from gradient of stress, which uses the + // surface normal at the mapped point + _surface_normal_voigt_notation(normal, normal_mat); + _compute_stress_gradient(*fe, qp, stress_grad, stress_grad_mat); - if (request_jacobian && - _property.strain_type() == MAST::NONLINEAR_STRAIN) { - - // u-disp - Bmat_nl_u.left_multiply(mat3, stress); - Bmat_nl_u.right_multiply_transpose(mat2_n2n2, mat3); - local_jac.topLeftCorner(n2, n2) += JxW[qp] * mat2_n2n2; + for (unsigned int i_dim=0; i_dim<2; i_dim++) + force.topRows(2) -= normal_mat * stress_grad.col(i_dim) * (bnd_pt(i_dim) - qpoint[qp](i_dim)); + + Bmat.vector_mult_transpose(vec_n2, force); + + /*libMesh::out + << "id: " << _elem.get_reference_elem().id() << std::endl + << "qp: " << qpoint[qp](0) << " " << qpoint[qp](1) << std::endl + << "x-mapped: " << bnd_pt(0) << " " << bnd_pt(1) << std::endl + << "trac " << trac(0) << " " << trac(1) << std::endl + << "normal: " << normal(0) << " " << normal(1) << std::endl + << "force: " << force.transpose() << std::endl << std::endl;*/ + + local_f += t_val * JxW[qp] * vec_n2; + + if (request_jacobian) { - // v-disp - Bmat_nl_v.left_multiply(mat3, stress); - Bmat_nl_v.right_multiply_transpose(mat2_n2n2, mat3); - local_jac.topLeftCorner(n2, n2) += JxW[qp] * mat2_n2n2; - } + // contribution from the stress + _surface_normal_voigt_notation(dnormal, normal_mat); + mat1_n1n2.topLeftCorner(2, n2) = normal_mat * dstress_dX; - if (request_jacobian && if_vk) { - // vk - vk - mat3 = RealMatrixX::Zero(2, n2); - Bmat_vk.left_multiply(mat3, stress); - Bmat_vk.right_multiply_transpose(mat2_n2n2, mat3); - local_jac += JxW[qp] * mat2_n2n2; + // contribution from the stress gradient + _surface_normal_voigt_notation(normal, normal_mat); + for (unsigned int i_dim=0; i_dim<2; i_dim++) { + + mat1_n1n2.topLeftCorner(2, n2) -= + (bnd_pt(i_dim) - qpoint[qp](i_dim)) * normal_mat * stress_grad_dX[i_dim]; + } + + Bmat.right_multiply_transpose(mat2_n2n2, mat1_n1n2); + local_jac += t_val * JxW[qp] * mat2_n2n2; } } - // now transform to the global coorodinate system - transform_vector_to_global_system(local_f, vec3_n2); - f -= vec3_n2; - if (request_jacobian && if_vk) { - transform_matrix_to_global_system(local_jac, mat2_n2n2); - jac -= scaling * mat2_n2n2; - } - - // Jacobian contribution from von Karman strain + // now transform to the global system and add + transform_vector_to_global_system(local_f, vec_n2); + f -= vec_n2; + + if (request_jacobian) { + transform_matrix_to_global_system(local_jac, mat2_n2n2); + jac -= mat2_n2n2; + } + + return request_jacobian; } - bool MAST::StructuralElement2D:: -thermal_residual_sensitivity (const MAST::FunctionBase& p, - bool request_jacobian, - RealVectorX& f, - RealMatrixX& jac, - MAST::BoundaryConditionBase& bc) -{ - std::unique_ptr fe(_elem.init_fe(true, - false, - _property.extra_quadrature_order(_elem))); - - const std::vector& JxW = fe->get_JxW(); - const std::vector& xyz = fe->get_xyz(); +surface_traction_residual_shifted_boundary_sensitivity(const MAST::FunctionBase& p, + bool request_jacobian, + RealVectorX &f, + RealMatrixX &jac, + const unsigned int side, + MAST::BoundaryConditionBase& bc) { + + libmesh_assert(!follower_forces); // not implemented yet for follower forces + + // prepare the side finite element + std::unique_ptr fe(_elem.init_side_fe(side, true, true)); + const std::vector &JxW = fe->get_JxW(); + const std::vector& qpoint = fe->get_xyz(); + const std::vector >& phi = fe->get_phi(); + const std::vector& face_normals = fe->get_normals_for_local_coordinate(); const unsigned int - n_phi = (unsigned int)fe->get_phi().size(), - n1 = this->n_direct_strain_components(), - n2 = 6*n_phi, - n3 = this->n_von_karman_strain_components(); + n_phi = (unsigned int)phi.size(), + n1 = 3, + n2 = 6*n_phi; - RealMatrixX - material_exp_A_mat, - material_exp_B_mat, - material_exp_A_mat_sens, - material_exp_B_mat_sens, - mat1_n1n2 = RealMatrixX::Zero(n1,n2), - mat2_n2n2 = RealMatrixX::Zero(n2,n2), - mat3 = RealMatrixX::Zero(2, n2), - mat4_n3n2 = RealMatrixX::Zero(n3,n2), - vk_dwdxi_mat = RealMatrixX::Zero(n1,n3), - stress = RealMatrixX::Zero(2,2), - mat_x = RealMatrixX::Zero(3,2), - mat_y = RealMatrixX::Zero(3,2), - local_jac = RealMatrixX::Zero(n2,n2); - RealVectorX - vec1_n1 = RealVectorX::Zero(n1), - vec2_n1 = RealVectorX::Zero(n1), - vec3_n2 = RealVectorX::Zero(n2), - vec4_2 = RealVectorX::Zero(2), - vec5_n1 = RealVectorX::Zero(n1), - local_f = RealVectorX::Zero(n2), - strain = RealVectorX::Zero(3), - delta_t = RealVectorX::Zero(1), - delta_t_sens = RealVectorX::Zero(1); + // get the function from this boundary condition at the projected point + const MAST::FieldFunction& trac_func = + bc.get >("traction"); + const MAST::LevelSetBoundaryVelocity& interface = + bc.get("phi_vel"); + + // get the thickness function to calculate the force + const MAST::FieldFunction& t_func = + _property.get >("h"); - FEMOperatorMatrix - Bmat_lin, - Bmat_nl_x, - Bmat_nl_y, - Bmat_nl_u, - Bmat_nl_v, - Bmat_bend, - Bmat_vk; + FEMOperatorMatrix Bmat; - Bmat_lin.reinit(n1, _system.n_vars(), n_phi); // three stress-strain components - Bmat_nl_x.reinit(2, _system.n_vars(), n_phi); - Bmat_nl_y.reinit(2, _system.n_vars(), n_phi); - Bmat_nl_u.reinit(2, _system.n_vars(), n_phi); - Bmat_nl_v.reinit(2, _system.n_vars(), n_phi); - Bmat_bend.reinit(n1, _system.n_vars(), n_phi); - Bmat_vk.reinit(n3, _system.n_vars(), n_phi); // only dw/dx and dw/dy + RealVectorX + trac = RealVectorX::Zero(3), + dtrac = RealVectorX::Zero(3), + stress = RealVectorX::Zero(3), + dnormal = RealVectorX::Zero(3), + normal = RealVectorX::Zero(3), + normal_sens = RealVectorX::Zero(3), + bnd_pt = RealVectorX::Zero(3), + bnd_pt_sens = RealVectorX::Zero(3), + phi_vec = RealVectorX::Zero(n_phi), + force = RealVectorX::Zero(2*n1), + local_f = RealVectorX::Zero(n2), + vec_n2 = RealVectorX::Zero(n2); - bool if_vk = (_property.strain_type() == MAST::NONLINEAR_STRAIN); - - MAST::BendingOperatorType - bending_model = _property.bending_model(_elem); + RealMatrixX + normal_mat = RealMatrixX::Zero(2,n1), + stress_grad = RealMatrixX::Zero(n1,2), + mat1_n1n2 = RealMatrixX::Zero(2*n1, n2), + mat2_n2n2 = RealMatrixX::Zero(n2, n2), + local_jac = RealMatrixX::Zero(n2, n2), + dstress_dX = RealMatrixX::Zero(n1,n2), + *dstress_mat= request_jacobian?&dstress_dX:nullptr; - std::unique_ptr bend; + Real + t_val = 0., + dt_val = 0., + elem_h = _elem.get_reference_elem().hmax(); - if (bending_model != MAST::NO_BENDING) - bend.reset(MAST::build_bending_operator_2D(bending_model, - *this, - fe->get_qpoints()).release()); - - std::unique_ptr > - expansion_A = _property.thermal_expansion_A_matrix(*this), - expansion_B = _property.thermal_expansion_B_matrix(*this); + libMesh::Point + pt; - // temperature function - const MAST::FieldFunction - &temp_func = bc.get >("temperature"), - &ref_temp_func = bc.get >("ref_temperature"); + std::vector + stress_grad_dX(2, RealMatrixX::Zero(n1,n2)), + *stress_grad_mat = request_jacobian?&stress_grad_dX:nullptr; - Real t, t0, t_sens, t0_sens; - for (unsigned int qp=0; qpderivative(p, xyz[qp], _time, material_exp_A_mat_sens); - expansion_B->derivative(p, xyz[qp], _time, material_exp_B_mat_sens); + // now set the shape function values + for ( unsigned int i_nd=0; i_ndinitialize_green_lagrange_strain_operator(qp, - *fe, - _local_sol, - strain, - mat_x, - mat_y, - Bmat_lin, - Bmat_nl_x, - Bmat_nl_y, - Bmat_nl_u, - Bmat_nl_v); + local_f += t_val * JxW[qp] * vec_n2; - // membrane strain - Bmat_lin.vector_mult_transpose(vec3_n2, vec1_n1); - local_f += JxW[qp] * vec3_n2; - if (_property.strain_type() == MAST::NONLINEAR_STRAIN) { - - // nonlinear strain operotor - // x - vec4_2 = mat_x.transpose() * vec1_n1; - Bmat_nl_x.vector_mult_transpose(vec3_n2, vec4_2); - local_f.topRows(n2) += JxW[qp] * vec3_n2; - - // y - vec4_2 = mat_y.transpose() * vec1_n1; - Bmat_nl_y.vector_mult_transpose(vec3_n2, vec4_2); - local_f.topRows(n2) += JxW[qp] * vec3_n2; - } + /*libMesh::out + << "id: " << _elem.get_reference_elem().id() << std::endl + << "qp: " << qpoint[qp](0) << " " << qpoint[qp](1) << std::endl + << "x-mapped: " << bnd_pt(0) << " " << bnd_pt(1) << std::endl + << "x-mapped_sens: " << bnd_pt_sens(0) << " " << bnd_pt_sens(1) << std::endl + << "trac " << trac(0) << " " << trac(1) << std::endl + << "trac_sens: " << dtrac(0) << " " << dtrac(1) << std::endl + << "normal: " << normal(0) << " " << normal(1) << std::endl + << "normal_sens: " << normal_sens(0) << " " << normal_sens(1) << std::endl + << "force: " << force.transpose() << std::endl << std::endl;*/ + + + // also include contribution from sensitivity of thickness + for (unsigned int i_dim=0; i_diminitialize_bending_strain_operator(*fe, qp, Bmat_bend); - Bmat_bend.vector_mult_transpose(vec3_n2, vec2_n1); - local_f += JxW[qp] * vec3_n2; - - // von Karman strain - if (if_vk) { - // get the vonKarman strain operator if needed - this->initialize_von_karman_strain_operator(qp, - *fe, - vec2_n1, // epsilon_vk - vk_dwdxi_mat, - Bmat_vk); - // von Karman strain - vec4_2 = vk_dwdxi_mat.transpose() * vec1_n1; - Bmat_vk.vector_mult_transpose(vec3_n2, vec4_2); - local_f += JxW[qp] * vec3_n2; - } - } + // compute stress + _compute_stress(*fe, qp, stress, dstress_mat); + + // contribution from dnormal + force.topRows(2) = trac.topRows(2) + normal_mat * stress; + + // contribution from gradient of stress, which uses the + // surface normal at the mapped point + _surface_normal_voigt_notation(normal, normal_mat); + _compute_stress_gradient(*fe, qp, stress_grad, nullptr); + + for (unsigned int i_dim=0; i_dim<2; i_dim++) + force.topRows(2) -= normal_mat * stress_grad.col(i_dim) * (bnd_pt(i_dim) - qpoint[qp](i_dim)); + + Bmat.vector_mult_transpose(vec_n2, force); + + local_f += dt_val * JxW[qp] * vec_n2; - if (request_jacobian && - _property.strain_type() == MAST::NONLINEAR_STRAIN) { - - // u-disp - Bmat_nl_u.left_multiply(mat3, stress); - Bmat_nl_u.right_multiply_transpose(mat2_n2n2, mat3); - local_jac.topLeftCorner(n2, n2) += JxW[qp] * mat2_n2n2; - - // v-disp - Bmat_nl_v.left_multiply(mat3, stress); - Bmat_nl_v.right_multiply_transpose(mat2_n2n2, mat3); - local_jac.topLeftCorner(n2, n2) += JxW[qp] * mat2_n2n2; - } - if (request_jacobian && if_vk) { // Jacobian only for vk strain + if (request_jacobian) { - // vk - vk - mat3 = RealMatrixX::Zero(2, n2); - Bmat_vk.left_multiply(mat3, stress); - Bmat_vk.right_multiply_transpose(mat2_n2n2, mat3); - local_jac += JxW[qp] * mat2_n2n2; + libmesh_assert(false); // to be implemented } } - - // now transform to the global coorodinate system - transform_vector_to_global_system(local_f, vec3_n2); - f -= vec3_n2; - if (request_jacobian && if_vk) { + // now transform to the global system and add + transform_vector_to_global_system(local_f, vec_n2); + f -= vec_n2; + + if (request_jacobian) { transform_matrix_to_global_system(local_jac, mat2_n2n2); jac -= mat2_n2n2; } + - // Jacobian contribution from von Karman strain return request_jacobian; } - -void +bool MAST::StructuralElement2D:: -thermal_residual_boundary_velocity(const MAST::FunctionBase& p, - const unsigned int s, - const MAST::FieldFunction& vel_f, - MAST::BoundaryConditionBase& bc, - bool request_jacobian, - RealVectorX& f, - RealMatrixX& jac) { +surface_pressure_residual(bool request_jacobian, + RealVectorX &f, + RealMatrixX &jac, + const unsigned int side, + MAST::BoundaryConditionBase& bc) { + + libmesh_assert(!follower_forces); // not implemented yet for follower forces // prepare the side finite element - std::unique_ptr fe(_elem.init_side_fe(s, - true, - _property.extra_quadrature_order(_elem))); + std::unique_ptr fe(_elem.init_side_fe(side, false, false)); - std::vector JxW_Vn = fe->get_JxW(); - const std::vector& xyz = fe->get_xyz(); + const std::vector &JxW = fe->get_JxW(); + const std::vector& qpoint = fe->get_xyz(); + const std::vector >& phi = fe->get_phi(); const std::vector& face_normals = fe->get_normals_for_local_coordinate(); + const unsigned int + n_phi = (unsigned int)phi.size(), + n1 = 3, + n2 = 6*n_phi; + + + // get the function from this boundary condition + const MAST::FieldFunction& p_func = + bc.get >("pressure"); + + // get the thickness function to calculate the force + const MAST::FieldFunction& t_func = + _property.get >("h"); + + FEMOperatorMatrix Bmat; + Real + press = 0., + t_val = 0.; + + RealVectorX + phi_vec = RealVectorX::Zero(n_phi), + force = RealVectorX::Zero(2*n1), + local_f = RealVectorX::Zero(n2), + vec_n2 = RealVectorX::Zero(n2); + + for (unsigned int qp=0; qp fe(_elem.init_side_fe(side, false, false)); + const std::vector &JxW = fe->get_JxW(); + const std::vector& qpoint = fe->get_xyz(); + const std::vector >& phi = fe->get_phi(); + const std::vector& face_normals = fe->get_normals_for_local_coordinate(); const unsigned int - n_phi = (unsigned int)fe->get_phi().size(), - n1 = this->n_direct_strain_components(), n2=6*n_phi, - n3 = this->n_von_karman_strain_components(), - dim = 2; + n_phi = (unsigned int)phi.size(), + n1 = 3, + n2 = 6*n_phi; + + + // get the function from this boundary condition + const MAST::FieldFunction& p_func = + bc.get >("pressure"); + + // get the thickness function to calculate the force + const MAST::FieldFunction& t_func = + _property.get >("h"); + + + FEMOperatorMatrix Bmat; + Real + press = 0., + dpress = 0., + t_val = 0., + dt_val = 0.; + + RealVectorX + phi_vec = RealVectorX::Zero(n_phi), + force = RealVectorX::Zero(2*n1), + local_f = RealVectorX::Zero(n2), + vec_n2 = RealVectorX::Zero(n2); + + for (unsigned int qp=0; qp fe(_elem.init_fe(true, + false, + _property.extra_quadrature_order(_elem))); + + const std::vector& JxW = fe->get_JxW(); + const std::vector& xyz = fe->get_xyz(); + + const unsigned int + n_phi = (unsigned int)fe->get_phi().size(), + n1 = this->n_direct_strain_components(), + n2 = 6*n_phi, + n3 = this->n_von_karman_strain_components(); RealMatrixX material_exp_A_mat, @@ -2908,9 +3048,8 @@ thermal_residual_boundary_velocity(const MAST::FunctionBase& p, vec4_2 = RealVectorX::Zero(2), vec5_n3 = RealVectorX::Zero(n3), local_f = RealVectorX::Zero(n2), - delta_t = RealVectorX::Zero(1), strain = RealVectorX::Zero(3), - vel = RealVectorX::Zero(dim); + delta_t = RealVectorX::Zero(1); FEMOperatorMatrix Bmat_lin, @@ -2921,13 +3060,13 @@ thermal_residual_boundary_velocity(const MAST::FunctionBase& p, Bmat_bend, Bmat_vk; - Bmat_lin.reinit (n1, _system.n_vars(), n_phi); // three stress-strain components + Bmat_lin.reinit(n1, _system.n_vars(), n_phi); // three stress-strain components Bmat_nl_x.reinit(2, _system.n_vars(), n_phi); Bmat_nl_y.reinit(2, _system.n_vars(), n_phi); Bmat_nl_u.reinit(2, _system.n_vars(), n_phi); Bmat_nl_v.reinit(2, _system.n_vars(), n_phi); Bmat_bend.reinit(n1, _system.n_vars(), n_phi); - Bmat_vk.reinit (n3, _system.n_vars(), n_phi); // only dw/dx and dw/dy + Bmat_vk.reinit(n3, _system.n_vars(), n_phi); // only dw/dx and dw/dy bool if_vk = (_property.strain_type() == MAST::NONLINEAR_STRAIN); @@ -2950,21 +3089,14 @@ thermal_residual_boundary_velocity(const MAST::FunctionBase& p, &ref_temp_func = bc.get >("ref_temperature"); Real - vn = 0., - t = 0., - t0 = 0.; - - // modify the JxW_Vn by multiplying the normal velocity to it - for (unsigned int qp=0; qp>("thermal_jacobian_scaling")(scaling); + + for (unsigned int qp=0; qpinitialize_green_lagrange_strain_operator(qp, *fe, _local_sol, @@ -2996,27 +3128,27 @@ thermal_residual_boundary_velocity(const MAST::FunctionBase& p, // membrane strain Bmat_lin.vector_mult_transpose(vec3_n2, vec1_n1); - local_f += JxW_Vn[qp] * vec3_n2; + local_f += JxW[qp] * vec3_n2; if (_property.strain_type() == MAST::NONLINEAR_STRAIN) { - + // nonlinear strain operotor // x vec4_2 = mat_x.transpose() * vec1_n1; Bmat_nl_x.vector_mult_transpose(vec3_n2, vec4_2); - local_f.topRows(n2) += JxW_Vn[qp] * vec3_n2; + local_f.topRows(n2) += JxW[qp] * vec3_n2; // y vec4_2 = mat_y.transpose() * vec1_n1; Bmat_nl_y.vector_mult_transpose(vec3_n2, vec4_2); - local_f.topRows(n2) += JxW_Vn[qp] * vec3_n2; + local_f.topRows(n2) += JxW[qp] * vec3_n2; } - + if (bend.get()) { // bending strain bend->initialize_bending_strain_operator(*fe, qp, Bmat_bend); Bmat_bend.vector_mult_transpose(vec3_n2, vec2_n1); - local_f += JxW_Vn[qp] * vec3_n2; + local_f += JxW[qp] * vec3_n2; // von Karman strain if (if_vk) { @@ -3029,7 +3161,7 @@ thermal_residual_boundary_velocity(const MAST::FunctionBase& p, // von Karman strain vec4_2 = vk_dwdxi_mat.transpose() * vec1_n1; Bmat_vk.vector_mult_transpose(vec3_n2, vec4_2); - local_f += JxW_Vn[qp] * vec3_n2; + local_f += JxW[qp] * vec3_n2; } } @@ -3039,20 +3171,20 @@ thermal_residual_boundary_velocity(const MAST::FunctionBase& p, // u-disp Bmat_nl_u.left_multiply(mat3, stress); Bmat_nl_u.right_multiply_transpose(mat2_n2n2, mat3); - local_jac.topLeftCorner(n2, n2) += JxW_Vn[qp] * mat2_n2n2; + local_jac.topLeftCorner(n2, n2) += JxW[qp] * mat2_n2n2; // v-disp Bmat_nl_v.left_multiply(mat3, stress); Bmat_nl_v.right_multiply_transpose(mat2_n2n2, mat3); - local_jac.topLeftCorner(n2, n2) += JxW_Vn[qp] * mat2_n2n2; + local_jac.topLeftCorner(n2, n2) += JxW[qp] * mat2_n2n2; } - - if (request_jacobian && if_vk) { // Jacobian only for vk strain - // vk - vk - mat3 = RealMatrixX::Zero(2, n2); - Bmat_vk.left_multiply(mat3, stress); - Bmat_vk.right_multiply_transpose(mat2_n2n2, mat3); - local_jac += JxW_Vn[qp] * mat2_n2n2; + + if (request_jacobian && if_vk) { + // vk - vk + mat3 = RealMatrixX::Zero(2, n2); + Bmat_vk.left_multiply(mat3, stress); + Bmat_vk.right_multiply_transpose(mat2_n2n2, mat3); + local_jac += JxW[qp] * mat2_n2n2; } } @@ -3061,57 +3193,62 @@ thermal_residual_boundary_velocity(const MAST::FunctionBase& p, f -= vec3_n2; if (request_jacobian && if_vk) { transform_matrix_to_global_system(local_jac, mat2_n2n2); - jac -= mat2_n2n2; + jac -= scaling * mat2_n2n2; } + + // Jacobian contribution from von Karman strain + return request_jacobian; } -void + +bool MAST::StructuralElement2D:: -thermal_residual_temperature_derivative(const MAST::FEBase& fe_thermal, - RealMatrixX& m) { - - - const std::vector>& phi_temp = fe_thermal.get_phi(); - const std::vector& JxW = fe_thermal.get_JxW(); - const std::vector& xyz = fe_thermal.get_xyz(); - - std::unique_ptr fe_str(_elem.init_fe(true, false, - _property.extra_quadrature_order(_elem))); - libmesh_assert(fe_str->get_fe_type() == fe_thermal.get_fe_type()); - // this is a weak assertion. We really want that the same qpoints be used, - // but we are assuming that if the elem type is the same, and if the - // number fo qpoints is the same, then the location of qpoints will also - // be the same. - libmesh_assert_equal_to(fe_str->get_qpoints().size(), fe_thermal.get_qpoints().size()); - - - const unsigned int - n_phi_str = (unsigned int)fe_str->get_phi().size(), - nt = (unsigned int)fe_thermal.get_phi().size(), - n1 = this->n_direct_strain_components(), - n2 = 6*n_phi_str, - n3 = this->n_von_karman_strain_components(); +thermal_residual_sensitivity (const MAST::FunctionBase& p, + bool request_jacobian, + RealVectorX& f, + RealMatrixX& jac, + MAST::BoundaryConditionBase& bc) +{ + std::unique_ptr fe(_elem.init_fe(true, + false, + _property.extra_quadrature_order(_elem))); + + const std::vector& JxW = fe->get_JxW(); + const std::vector& xyz = fe->get_xyz(); + + const unsigned int + n_phi = (unsigned int)fe->get_phi().size(), + n1 = this->n_direct_strain_components(), + n2 = 6*n_phi, + n3 = this->n_von_karman_strain_components(); RealMatrixX material_exp_A_mat, material_exp_B_mat, - mat1_n1nt = RealMatrixX::Zero(n1,nt), - mat2_n1nt = RealMatrixX::Zero(n1,nt), - mat3_n2nt = RealMatrixX::Zero(n2,nt), - mat5, - vk_dwdxi_mat = RealMatrixX::Zero(n1,n3), - stress = RealMatrixX::Zero(2,2), - mat_x = RealMatrixX::Zero(3,2), - mat_y = RealMatrixX::Zero(3,2), - Bmat_temp = RealMatrixX::Zero(1,nt), - local_m = RealMatrixX::Zero(n2,nt); + material_exp_A_mat_sens, + material_exp_B_mat_sens, + mat1_n1n2 = RealMatrixX::Zero(n1,n2), + mat2_n2n2 = RealMatrixX::Zero(n2,n2), + mat3 = RealMatrixX::Zero(2, n2), + mat4_n3n2 = RealMatrixX::Zero(n3,n2), + vk_dwdxi_mat = RealMatrixX::Zero(n1,n3), + stress = RealMatrixX::Zero(2,2), + mat_x = RealMatrixX::Zero(3,2), + mat_y = RealMatrixX::Zero(3,2), + local_jac = RealMatrixX::Zero(n2,n2); RealVectorX - phi = RealVectorX::Zero(nt), - vec_n1 = RealVectorX::Zero(n1), - strain = RealVectorX::Zero(3); + vec1_n1 = RealVectorX::Zero(n1), + vec2_n1 = RealVectorX::Zero(n1), + vec3_n2 = RealVectorX::Zero(n2), + vec4_2 = RealVectorX::Zero(2), + vec5_n1 = RealVectorX::Zero(n1), + local_f = RealVectorX::Zero(n2), + strain = RealVectorX::Zero(3), + delta_t = RealVectorX::Zero(1), + delta_t_sens = RealVectorX::Zero(1); FEMOperatorMatrix Bmat_lin, @@ -3122,14 +3259,14 @@ thermal_residual_temperature_derivative(const MAST::FEBase& fe_thermal, Bmat_bend, Bmat_vk; - Bmat_lin.reinit(n1, _system.n_vars(), n_phi_str); // three stress-strain components - Bmat_nl_x.reinit(2, _system.n_vars(), n_phi_str); - Bmat_nl_y.reinit(2, _system.n_vars(), n_phi_str); - Bmat_nl_u.reinit(2, _system.n_vars(), n_phi_str); - Bmat_nl_v.reinit(2, _system.n_vars(), n_phi_str); - Bmat_bend.reinit(n1, _system.n_vars(), n_phi_str); - Bmat_vk.reinit(n3, _system.n_vars(), n_phi_str); // only dw/dx and dw/dy - + Bmat_lin.reinit(n1, _system.n_vars(), n_phi); // three stress-strain components + Bmat_nl_x.reinit(2, _system.n_vars(), n_phi); + Bmat_nl_y.reinit(2, _system.n_vars(), n_phi); + Bmat_nl_u.reinit(2, _system.n_vars(), n_phi); + Bmat_nl_v.reinit(2, _system.n_vars(), n_phi); + Bmat_bend.reinit(n1, _system.n_vars(), n_phi); + Bmat_vk.reinit(n3, _system.n_vars(), n_phi); // only dw/dx and dw/dy + bool if_vk = (_property.strain_type() == MAST::NONLINEAR_STRAIN); MAST::BendingOperatorType @@ -3140,24 +3277,56 @@ thermal_residual_temperature_derivative(const MAST::FEBase& fe_thermal, if (bending_model != MAST::NO_BENDING) bend.reset(MAST::build_bending_operator_2D(bending_model, *this, - fe_str->get_qpoints()).release()); + fe->get_qpoints()).release()); std::unique_ptr > expansion_A = _property.thermal_expansion_A_matrix(*this), expansion_B = _property.thermal_expansion_B_matrix(*this); + // temperature function + const MAST::FieldFunction + &temp_func = bc.get >("temperature"), + &ref_temp_func = bc.get >("ref_temperature"); + + Real t, t0, t_sens, t0_sens; + for (unsigned int qp=0; qpderivative(p, xyz[qp], _time, material_exp_A_mat_sens); + expansion_B->derivative(p, xyz[qp], _time, material_exp_B_mat_sens); + + // get the temperature function + temp_func(xyz[qp], _time, t); + ref_temp_func(xyz[qp], _time, t0); + delta_t(0) = t-t0; + + // get the temperature function + temp_func(xyz[qp], _time, t); + temp_func.derivative(p, xyz[qp], _time, t_sens); + ref_temp_func(xyz[qp], _time, t0); + ref_temp_func.derivative(p, xyz[qp], _time, t0_sens); + delta_t(0) = t-t0; + delta_t_sens(0) = t_sens-t0_sens; + + // now prepare the membrane force sensitivity + vec1_n1 = material_exp_A_mat * delta_t_sens; // [C]{alpha dT/dp} (with membrane strain) + vec2_n1 = material_exp_A_mat_sens * delta_t; // d([C]alpha)/dp (T - T0)} (with membrane strain) + vec1_n1 += vec2_n1; + stress(0,0) = vec1_n1(0); // sigma_xx + stress(0,1) = vec1_n1(2); // sigma_xy + stress(1,0) = vec1_n1(2); // sigma_yx + stress(1,1) = vec1_n1(1); // sigma_yy + + vec2_n1 = material_exp_B_mat * delta_t_sens; // [C]{alpha dT/dp} (with bending strain) + vec5_n1 = material_exp_B_mat_sens * delta_t; // d([C] alpha)/dp (T - T0) (with bending strain) + vec2_n1 += vec5_n1; + this->initialize_green_lagrange_strain_operator(qp, - *fe_str, + *fe, _local_sol, strain, mat_x, @@ -3167,451 +3336,1747 @@ thermal_residual_temperature_derivative(const MAST::FEBase& fe_thermal, Bmat_nl_y, Bmat_nl_u, Bmat_nl_v); - - mat1_n1nt = material_exp_A_mat * Bmat_temp; - mat2_n1nt = material_exp_B_mat * Bmat_temp; - Bmat_lin.right_multiply_transpose(mat3_n2nt, mat1_n1nt); - local_m += JxW[qp] * mat3_n2nt; - + // membrane strain + Bmat_lin.vector_mult_transpose(vec3_n2, vec1_n1); + local_f += JxW[qp] * vec3_n2; + if (_property.strain_type() == MAST::NONLINEAR_STRAIN) { // nonlinear strain operotor // x - mat5 = mat_x.transpose() * mat1_n1nt; - Bmat_nl_x.right_multiply_transpose(mat3_n2nt, mat5); - local_m.topRows(n2) += JxW[qp] * mat3_n2nt; + vec4_2 = mat_x.transpose() * vec1_n1; + Bmat_nl_x.vector_mult_transpose(vec3_n2, vec4_2); + local_f.topRows(n2) += JxW[qp] * vec3_n2; // y - mat5 = mat_y.transpose() * mat1_n1nt; - Bmat_nl_y.right_multiply_transpose(mat3_n2nt, mat5); - local_m.topRows(n2) += JxW[qp] * mat3_n2nt; + vec4_2 = mat_y.transpose() * vec1_n1; + Bmat_nl_y.vector_mult_transpose(vec3_n2, vec4_2); + local_f.topRows(n2) += JxW[qp] * vec3_n2; } - + if (bend.get()) { // bending strain - bend->initialize_bending_strain_operator(*fe_str, qp, Bmat_bend); - Bmat_bend.right_multiply_transpose(mat3_n2nt, mat2_n1nt); - local_m += JxW[qp] * mat3_n2nt; + bend->initialize_bending_strain_operator(*fe, qp, Bmat_bend); + Bmat_bend.vector_mult_transpose(vec3_n2, vec2_n1); + local_f += JxW[qp] * vec3_n2; // von Karman strain if (if_vk) { // get the vonKarman strain operator if needed this->initialize_von_karman_strain_operator(qp, - *fe_str, - vec_n1, // epsilon_vk + *fe, + vec2_n1, // epsilon_vk vk_dwdxi_mat, Bmat_vk); // von Karman strain - mat5 = vk_dwdxi_mat.transpose() * mat1_n1nt; - Bmat_vk.right_multiply_transpose(mat3_n2nt, mat5); - local_m += JxW[qp] * mat3_n2nt; + vec4_2 = vk_dwdxi_mat.transpose() * vec1_n1; + Bmat_vk.vector_mult_transpose(vec3_n2, vec4_2); + local_f += JxW[qp] * vec3_n2; } } - } - mat3_n2nt.setZero(); - phi = RealVectorX::Zero(n2); - vec_n1 = RealVectorX::Zero(n2); - for (unsigned int i=0; i& vel_f, + MAST::BoundaryConditionBase& bc, bool request_jacobian, - RealVectorX &f, - RealMatrixX& jac_xdot, - RealMatrixX& jac, - const unsigned int side, - MAST::BoundaryConditionBase& bc) { - - libmesh_assert(false); // to be implemented + RealVectorX& f, + RealMatrixX& jac) { - return (request_jacobian); -} - - - - + // prepare the side finite element + std::unique_ptr fe(_elem.init_side_fe(s, + true, + _property.extra_quadrature_order(_elem))); -bool -MAST::StructuralElement2D:: -piston_theory_residual(bool request_jacobian, - RealVectorX &f, - RealMatrixX& jac_xdot, - RealMatrixX& jac, - MAST::BoundaryConditionBase& bc) { - - libmesh_assert(_elem.dim() < 3); // only applicable for lower dimensional elements - libmesh_assert(!follower_forces); // not implemented yet for follower forces - - std::unique_ptr fe(_elem.init_fe(true, false)); + std::vector JxW_Vn = fe->get_JxW(); + const std::vector& xyz = fe->get_xyz(); + const std::vector& face_normals = fe->get_normals_for_local_coordinate(); - const std::vector &JxW = fe->get_JxW(); - const std::vector& qpoint = fe->get_xyz(); - const std::vector >& phi = fe->get_phi(); const unsigned int - n_phi = (unsigned int)phi.size(), - n1 = 2, - n2 = _system.n_vars()*n_phi; - - - // normal for face integration - libMesh::Point normal; - // direction of pressure assumed to be normal (along local z-axis) - // to the element face for 2D and along local y-axis for 1D element. - normal(_elem.dim()) = -1.; - - - // convert to piston theory boundary condition so that the necessary - // flow properties can be obtained - const MAST::PistonTheoryBoundaryCondition& piston_bc = - dynamic_cast(bc); + n_phi = (unsigned int)fe->get_phi().size(), + n1 = this->n_direct_strain_components(), n2=6*n_phi, + n3 = this->n_von_karman_strain_components(), + dim = 2; + RealMatrixX + material_exp_A_mat, + material_exp_B_mat, + mat1_n1n2 = RealMatrixX::Zero(n1,n2), + mat2_n2n2 = RealMatrixX::Zero(n2,n2), + mat3 = RealMatrixX::Zero(2, n2), + mat4_n3n2 = RealMatrixX::Zero(n3,n2), + vk_dwdxi_mat = RealMatrixX::Zero(n1,n3), + stress = RealMatrixX::Zero(2,2), + mat_x = RealMatrixX::Zero(3,2), + mat_y = RealMatrixX::Zero(3,2), + local_jac = RealMatrixX::Zero(n2,n2); - // create the constant field functions to pass the dwdx and dwdt values - // to the piston theory pressure functions - MAST::Parameter - dwdx_p ("dwdx", 0.), - dwdt_p ("dwdt", 0.); - - MAST::ConstantFieldFunction - dwdx_f ("dwdx", dwdx_p), - dwdt_f ("dwdx", dwdt_p); + RealVectorX + vec1_n1 = RealVectorX::Zero(n1), + vec2_n1 = RealVectorX::Zero(n1), + vec3_n2 = RealVectorX::Zero(n2), + vec4_2 = RealVectorX::Zero(2), + vec5_n3 = RealVectorX::Zero(n3), + local_f = RealVectorX::Zero(n2), + delta_t = RealVectorX::Zero(1), + strain = RealVectorX::Zero(3), + vel = RealVectorX::Zero(dim); + FEMOperatorMatrix + Bmat_lin, + Bmat_nl_x, + Bmat_nl_y, + Bmat_nl_u, + Bmat_nl_v, + Bmat_bend, + Bmat_vk; - std::unique_ptr > - pressure (piston_bc.get_pressure_function(dwdx_f, dwdt_f).release()), - dpressure_dx (piston_bc.get_dpdx_function (dwdx_f, dwdt_f).release()), - dpressure_dxdot (piston_bc.get_dpdxdot_function (dwdx_f, dwdt_f).release()); + Bmat_lin.reinit (n1, _system.n_vars(), n_phi); // three stress-strain components + Bmat_nl_x.reinit(2, _system.n_vars(), n_phi); + Bmat_nl_y.reinit(2, _system.n_vars(), n_phi); + Bmat_nl_u.reinit(2, _system.n_vars(), n_phi); + Bmat_nl_v.reinit(2, _system.n_vars(), n_phi); + Bmat_bend.reinit(n1, _system.n_vars(), n_phi); + Bmat_vk.reinit (n3, _system.n_vars(), n_phi); // only dw/dx and dw/dy + + bool if_vk = (_property.strain_type() == MAST::NONLINEAR_STRAIN); - FEMOperatorMatrix - Bmat_w, // operator matrix for the w-displacement - dBmat; // operator matrix to calculate the derivativ of w wrt x and y + MAST::BendingOperatorType + bending_model = _property.bending_model(_elem); - dBmat.reinit(n1, _system.n_vars(), n_phi); + std::unique_ptr bend; - RealVectorX - phi_vec = RealVectorX::Zero(n_phi), - force = RealVectorX::Zero(n1), - local_f = RealVectorX::Zero(n2), - vec_n1 = RealVectorX::Zero(n1), - vec_n2 = RealVectorX::Zero(n2), - vel_vec = RealVectorX::Zero(3), - dummy = RealVectorX::Zero(3); + if (bending_model != MAST::NO_BENDING) + bend.reset(MAST::build_bending_operator_2D(bending_model, + *this, + fe->get_qpoints()).release()); - RealMatrixX - dwdx = RealMatrixX::Zero(3,2), - local_jac_xdot = RealMatrixX::Zero(n2,n2), - local_jac = RealMatrixX::Zero(n2,n2), - mat_n2n2 = RealMatrixX::Zero(n2,n2), - mat_n1n2 = RealMatrixX::Zero(n1,n2), - mat_22 = RealMatrixX::Zero(2,2); + std::unique_ptr > + expansion_A = _property.thermal_expansion_A_matrix(*this), + expansion_B = _property.thermal_expansion_B_matrix(*this); - // we need the velocity vector in the local coordinate system so that - // the appropriate component of the w-derivative can be used - vel_vec = _elem.T_matrix().transpose() * piston_bc.vel_vec(); + const MAST::FieldFunction + &temp_func = bc.get >("temperature"), + &ref_temp_func = bc.get >("ref_temperature"); Real - dwdt_val = 0., - dwdx_val = 0., - p_val = 0.; + vn = 0., + t = 0., + t0 = 0.; + // modify the JxW_Vn by multiplying the normal velocity to it + for (unsigned int qp=0; qpinitialize_von_karman_strain_operator(qp, - *fe, - dummy, - dwdx, - dBmat); + vec1_n1 = material_exp_A_mat * delta_t; // [C]{alpha (T - T0)} (with membrane strain) + vec2_n1 = material_exp_B_mat * delta_t; // [C]{alpha (T - T0)} (with bending strain) + stress(0,0) = vec1_n1(0); // sigma_xx + stress(0,1) = vec1_n1(2); // sigma_xy + stress(1,0) = vec1_n1(2); // sigma_yx + stress(1,1) = vec1_n1(1); // sigma_yy - // the diagonal of dwdx matrix stores the - dwdx_val = 0.; - for (unsigned int i=0; i<2; i++) - dwdx_val += dwdx(i,i) * vel_vec(i); // (dw/dx_i)*U_inf . n_i - - // calculate the pressure value - dwdx_p = dwdx_val; - dwdt_p = dwdt_val; - (*pressure)(qpoint[qp], _time, p_val); - - // calculate force - force(0) = p_val * normal(2); - - - Bmat_w.vector_mult_transpose(vec_n2, force); - local_f += JxW[qp] * vec_n2; - + this->initialize_green_lagrange_strain_operator(qp, + *fe, + _local_sol, + strain, + mat_x, + mat_y, + Bmat_lin, + Bmat_nl_x, + Bmat_nl_y, + Bmat_nl_u, + Bmat_nl_v); - // calculate the Jacobian if requested - if (request_jacobian) { + // membrane strain + Bmat_lin.vector_mult_transpose(vec3_n2, vec1_n1); + local_f += JxW_Vn[qp] * vec3_n2; + + if (_property.strain_type() == MAST::NONLINEAR_STRAIN) { - // we need the derivative of cp wrt normal velocity - (*dpressure_dxdot)(qpoint[qp], _time, p_val); + // nonlinear strain operotor + // x + vec4_2 = mat_x.transpose() * vec1_n1; + Bmat_nl_x.vector_mult_transpose(vec3_n2, vec4_2); + local_f.topRows(n2) += JxW_Vn[qp] * vec3_n2; - // calculate the component of Jacobian due to w-velocity - Bmat_w.right_multiply_transpose(mat_n2n2, Bmat_w); - local_jac_xdot += (JxW[qp] * p_val * normal(2)) * mat_n2n2; + // y + vec4_2 = mat_y.transpose() * vec1_n1; + Bmat_nl_y.vector_mult_transpose(vec3_n2, vec4_2); + local_f.topRows(n2) += JxW_Vn[qp] * vec3_n2; + } - // now calculate the component of Jacobian - (*dpressure_dx)(qpoint[qp], _time, p_val); + if (bend.get()) { + // bending strain + bend->initialize_bending_strain_operator(*fe, qp, Bmat_bend); + Bmat_bend.vector_mult_transpose(vec3_n2, vec2_n1); + local_f += JxW_Vn[qp] * vec3_n2; - // derivative wrt x - mat_22.setZero(2,2); - mat_22(0,0) = vel_vec(0); - dBmat.left_multiply(mat_n1n2, mat_22); - Bmat_w.right_multiply_transpose(mat_n2n2, mat_n1n2); // v: B^T dB/dx - local_jac += (JxW[qp] * p_val * normal(2)) * mat_n2n2; + // von Karman strain + if (if_vk) { + // get the vonKarman strain operator if needed + this->initialize_von_karman_strain_operator(qp, + *fe, + vec2_n1, // epsilon_vk + vk_dwdxi_mat, + Bmat_vk); + // von Karman strain + vec4_2 = vk_dwdxi_mat.transpose() * vec1_n1; + Bmat_vk.vector_mult_transpose(vec3_n2, vec4_2); + local_f += JxW_Vn[qp] * vec3_n2; + } + } + + if (request_jacobian && + _property.strain_type() == MAST::NONLINEAR_STRAIN) { - // derivative wrt y - mat_22.setZero(2,2); - mat_22(1,1) = vel_vec(1); - dBmat.left_multiply(mat_n1n2, mat_22); - Bmat_w.right_multiply_transpose(mat_n2n2, mat_n1n2); // v: B^T dB/dy - local_jac += (JxW[qp] * p_val * normal(2)) * mat_n2n2; + // u-disp + Bmat_nl_u.left_multiply(mat3, stress); + Bmat_nl_u.right_multiply_transpose(mat2_n2n2, mat3); + local_jac.topLeftCorner(n2, n2) += JxW_Vn[qp] * mat2_n2n2; + + // v-disp + Bmat_nl_v.left_multiply(mat3, stress); + Bmat_nl_v.right_multiply_transpose(mat2_n2n2, mat3); + local_jac.topLeftCorner(n2, n2) += JxW_Vn[qp] * mat2_n2n2; } - } - - - // now transform to the global system and add - transform_vector_to_global_system(local_f, vec_n2); - f -= vec_n2; + + if (request_jacobian && if_vk) { // Jacobian only for vk strain + // vk - vk + mat3 = RealMatrixX::Zero(2, n2); + Bmat_vk.left_multiply(mat3, stress); + Bmat_vk.right_multiply_transpose(mat2_n2n2, mat3); + local_jac += JxW_Vn[qp] * mat2_n2n2; + } + } + + // now transform to the global coorodinate system + transform_vector_to_global_system(local_f, vec3_n2); + f -= vec3_n2; + if (request_jacobian && if_vk) { + transform_matrix_to_global_system(local_jac, mat2_n2n2); + jac -= mat2_n2n2; + } +} + + + +void +MAST::StructuralElement2D:: +thermal_residual_temperature_derivative(const MAST::FEBase& fe_thermal, + RealMatrixX& m) { + + + const std::vector>& phi_temp = fe_thermal.get_phi(); + const std::vector& JxW = fe_thermal.get_JxW(); + const std::vector& xyz = fe_thermal.get_xyz(); + + std::unique_ptr fe_str(_elem.init_fe(true, false, + _property.extra_quadrature_order(_elem))); + libmesh_assert(fe_str->get_fe_type() == fe_thermal.get_fe_type()); + // this is a weak assertion. We really want that the same qpoints be used, + // but we are assuming that if the elem type is the same, and if the + // number fo qpoints is the same, then the location of qpoints will also + // be the same. + libmesh_assert_equal_to(fe_str->get_qpoints().size(), fe_thermal.get_qpoints().size()); + + + const unsigned int + n_phi_str = (unsigned int)fe_str->get_phi().size(), + nt = (unsigned int)fe_thermal.get_phi().size(), + n1 = this->n_direct_strain_components(), + n2 = 6*n_phi_str, + n3 = this->n_von_karman_strain_components(); + + RealMatrixX + material_exp_A_mat, + material_exp_B_mat, + mat1_n1nt = RealMatrixX::Zero(n1,nt), + mat2_n1nt = RealMatrixX::Zero(n1,nt), + mat3_n2nt = RealMatrixX::Zero(n2,nt), + mat5, + vk_dwdxi_mat = RealMatrixX::Zero(n1,n3), + stress = RealMatrixX::Zero(2,2), + mat_x = RealMatrixX::Zero(3,2), + mat_y = RealMatrixX::Zero(3,2), + Bmat_temp = RealMatrixX::Zero(1,nt), + local_m = RealMatrixX::Zero(n2,nt); + + RealVectorX + phi = RealVectorX::Zero(nt), + vec_n1 = RealVectorX::Zero(n1), + strain = RealVectorX::Zero(3); + + FEMOperatorMatrix + Bmat_lin, + Bmat_nl_x, + Bmat_nl_y, + Bmat_nl_u, + Bmat_nl_v, + Bmat_bend, + Bmat_vk; + + Bmat_lin.reinit(n1, _system.n_vars(), n_phi_str); // three stress-strain components + Bmat_nl_x.reinit(2, _system.n_vars(), n_phi_str); + Bmat_nl_y.reinit(2, _system.n_vars(), n_phi_str); + Bmat_nl_u.reinit(2, _system.n_vars(), n_phi_str); + Bmat_nl_v.reinit(2, _system.n_vars(), n_phi_str); + Bmat_bend.reinit(n1, _system.n_vars(), n_phi_str); + Bmat_vk.reinit(n3, _system.n_vars(), n_phi_str); // only dw/dx and dw/dy + + bool if_vk = (_property.strain_type() == MAST::NONLINEAR_STRAIN); + + MAST::BendingOperatorType + bending_model = _property.bending_model(_elem); + + std::unique_ptr bend; + + if (bending_model != MAST::NO_BENDING) + bend.reset(MAST::build_bending_operator_2D(bending_model, + *this, + fe_str->get_qpoints()).release()); + + std::unique_ptr > + expansion_A = _property.thermal_expansion_A_matrix(*this), + expansion_B = _property.thermal_expansion_B_matrix(*this); + + for (unsigned int qp=0; qpinitialize_green_lagrange_strain_operator(qp, + *fe_str, + _local_sol, + strain, + mat_x, + mat_y, + Bmat_lin, + Bmat_nl_x, + Bmat_nl_y, + Bmat_nl_u, + Bmat_nl_v); + + mat1_n1nt = material_exp_A_mat * Bmat_temp; + mat2_n1nt = material_exp_B_mat * Bmat_temp; + Bmat_lin.right_multiply_transpose(mat3_n2nt, mat1_n1nt); + local_m += JxW[qp] * mat3_n2nt; + + + if (_property.strain_type() == MAST::NONLINEAR_STRAIN) { + + // nonlinear strain operotor + // x + mat5 = mat_x.transpose() * mat1_n1nt; + Bmat_nl_x.right_multiply_transpose(mat3_n2nt, mat5); + local_m.topRows(n2) += JxW[qp] * mat3_n2nt; + + // y + mat5 = mat_y.transpose() * mat1_n1nt; + Bmat_nl_y.right_multiply_transpose(mat3_n2nt, mat5); + local_m.topRows(n2) += JxW[qp] * mat3_n2nt; + } + + if (bend.get()) { + // bending strain + bend->initialize_bending_strain_operator(*fe_str, qp, Bmat_bend); + Bmat_bend.right_multiply_transpose(mat3_n2nt, mat2_n1nt); + local_m += JxW[qp] * mat3_n2nt; + + // von Karman strain + if (if_vk) { + // get the vonKarman strain operator if needed + this->initialize_von_karman_strain_operator(qp, + *fe_str, + vec_n1, // epsilon_vk + vk_dwdxi_mat, + Bmat_vk); + // von Karman strain + mat5 = vk_dwdxi_mat.transpose() * mat1_n1nt; + Bmat_vk.right_multiply_transpose(mat3_n2nt, mat5); + local_m += JxW[qp] * mat3_n2nt; + } + } + } + + mat3_n2nt.setZero(); + phi = RealVectorX::Zero(n2); + vec_n1 = RealVectorX::Zero(n2); + for (unsigned int i=0; i fe(_elem.init_fe(true, false)); + + const std::vector &JxW = fe->get_JxW(); + const std::vector& qpoint = fe->get_xyz(); + const std::vector >& phi = fe->get_phi(); + const unsigned int + n_phi = (unsigned int)phi.size(), + n1 = 2, + n2 = _system.n_vars()*n_phi; + + + // normal for face integration + libMesh::Point normal; + // direction of pressure assumed to be normal (along local z-axis) + // to the element face for 2D and along local y-axis for 1D element. + normal(_elem.dim()) = -1.; + + + // convert to piston theory boundary condition so that the necessary + // flow properties can be obtained + const MAST::PistonTheoryBoundaryCondition& piston_bc = + dynamic_cast(bc); + + + // create the constant field functions to pass the dwdx and dwdt values + // to the piston theory pressure functions + MAST::Parameter + dwdx_p ("dwdx", 0.), + dwdt_p ("dwdt", 0.); + + MAST::ConstantFieldFunction + dwdx_f ("dwdx", dwdx_p), + dwdt_f ("dwdx", dwdt_p); + + + std::unique_ptr > + pressure (piston_bc.get_pressure_function(dwdx_f, dwdt_f).release()), + dpressure_dx (piston_bc.get_dpdx_function (dwdx_f, dwdt_f).release()), + dpressure_dxdot (piston_bc.get_dpdxdot_function (dwdx_f, dwdt_f).release()); + + FEMOperatorMatrix + Bmat_w, // operator matrix for the w-displacement + dBmat; // operator matrix to calculate the derivativ of w wrt x and y + + dBmat.reinit(n1, _system.n_vars(), n_phi); + + RealVectorX + phi_vec = RealVectorX::Zero(n_phi), + force = RealVectorX::Zero(n1), + local_f = RealVectorX::Zero(n2), + vec_n1 = RealVectorX::Zero(n1), + vec_n2 = RealVectorX::Zero(n2), + vel_vec = RealVectorX::Zero(3), + dummy = RealVectorX::Zero(3); + + RealMatrixX + dwdx = RealMatrixX::Zero(3,2), + local_jac_xdot = RealMatrixX::Zero(n2,n2), + local_jac = RealMatrixX::Zero(n2,n2), + mat_n2n2 = RealMatrixX::Zero(n2,n2), + mat_n1n2 = RealMatrixX::Zero(n1,n2), + mat_22 = RealMatrixX::Zero(2,2); + + // we need the velocity vector in the local coordinate system so that + // the appropriate component of the w-derivative can be used + vel_vec = _elem.T_matrix().transpose() * piston_bc.vel_vec(); + + Real + dwdt_val = 0., + dwdx_val = 0., + p_val = 0.; + + + for (unsigned int qp=0; qpinitialize_von_karman_strain_operator(qp, + *fe, + dummy, + dwdx, + dBmat); + + // the diagonal of dwdx matrix stores the + dwdx_val = 0.; + for (unsigned int i=0; i<2; i++) + dwdx_val += dwdx(i,i) * vel_vec(i); // (dw/dx_i)*U_inf . n_i + + // calculate the pressure value + dwdx_p = dwdx_val; + dwdt_p = dwdt_val; + (*pressure)(qpoint[qp], _time, p_val); + + // calculate force + force(0) = p_val * normal(2); + + + Bmat_w.vector_mult_transpose(vec_n2, force); + local_f += JxW[qp] * vec_n2; + + + // calculate the Jacobian if requested + if (request_jacobian) { + + // we need the derivative of cp wrt normal velocity + (*dpressure_dxdot)(qpoint[qp], _time, p_val); + + // calculate the component of Jacobian due to w-velocity + Bmat_w.right_multiply_transpose(mat_n2n2, Bmat_w); + local_jac_xdot += (JxW[qp] * p_val * normal(2)) * mat_n2n2; + + // now calculate the component of Jacobian + (*dpressure_dx)(qpoint[qp], _time, p_val); + + // derivative wrt x + mat_22.setZero(2,2); + mat_22(0,0) = vel_vec(0); + dBmat.left_multiply(mat_n1n2, mat_22); + Bmat_w.right_multiply_transpose(mat_n2n2, mat_n1n2); // v: B^T dB/dx + local_jac += (JxW[qp] * p_val * normal(2)) * mat_n2n2; + + // derivative wrt y + mat_22.setZero(2,2); + mat_22(1,1) = vel_vec(1); + dBmat.left_multiply(mat_n1n2, mat_22); + Bmat_w.right_multiply_transpose(mat_n2n2, mat_n1n2); // v: B^T dB/dy + local_jac += (JxW[qp] * p_val * normal(2)) * mat_n2n2; + } + } + + + // now transform to the global system and add + transform_vector_to_global_system(local_f, vec_n2); + f -= vec_n2; + + // if the Jacobian was requested, then transform it and add to the + // global Jacobian + if (request_jacobian) { + transform_matrix_to_global_system(local_jac_xdot, mat_n2n2); + jac_xdot -= mat_n2n2; + + transform_matrix_to_global_system(local_jac, mat_n2n2); + jac -= mat_n2n2; + } + + return request_jacobian; +} + + + + +bool +MAST::StructuralElement2D:: +piston_theory_residual_sensitivity(const MAST::FunctionBase& p, + bool request_jacobian, + RealVectorX &f, + RealMatrixX& jac_xdot, + RealMatrixX& jac, + MAST::BoundaryConditionBase& bc) { + + + libmesh_assert(_elem.dim() < 3); // only applicable for lower dimensional elements + libmesh_assert(!follower_forces); // not implemented yet for follower forces + + std::unique_ptr fe(_elem.init_fe(true, false)); + + const std::vector &JxW = fe->get_JxW(); + const std::vector& qpoint = fe->get_xyz(); + const std::vector >& phi = fe->get_phi(); + const unsigned int + n_phi = (unsigned int)phi.size(), + n1 = 2, + n2 = _system.n_vars()*n_phi; + + + // normal for face integration + libMesh::Point normal; + // direction of pressure assumed to be normal (along local z-axis) + // to the element face for 2D and along local y-axis for 1D element. + normal(_elem.dim()) = -1.; + + + // convert to piston theory boundary condition so that the necessary + // flow properties can be obtained + const MAST::PistonTheoryBoundaryCondition& piston_bc = + dynamic_cast(bc); + + + // create the constant field functions to pass the dwdx and dwdt values + // to the piston theory pressure functions + MAST::Parameter + dwdx_p ("dwdx", 0.), + dwdt_p ("dwdt", 0.); + + MAST::ConstantFieldFunction + dwdx_f ("dwdx", dwdx_p), + dwdt_f ("dwdx", dwdt_p); + + + std::unique_ptr > + pressure (piston_bc.get_pressure_function(dwdx_f, dwdt_f).release()), + dpressure_dx (piston_bc.get_dpdx_function (dwdx_f, dwdt_f).release()), + dpressure_dxdot (piston_bc.get_dpdxdot_function (dwdx_f, dwdt_f).release()); + + FEMOperatorMatrix + Bmat_w, // operator matrix for the w-displacement + dBmat; // operator matrix to calculate the derivativ of w wrt x and y + + dBmat.reinit(n1, _system.n_vars(), n_phi); + + RealVectorX + phi_vec = RealVectorX::Zero(n_phi), + force = RealVectorX::Zero(n1), + local_f = RealVectorX::Zero(n2), + vec_n1 = RealVectorX::Zero(n1), + vec_n2 = RealVectorX::Zero(n2), + vel_vec = RealVectorX::Zero(3), + dummy = RealVectorX::Zero(3); + + RealMatrixX + dwdx = RealMatrixX::Zero(3,2), + local_jac_xdot = RealMatrixX::Zero(n2,n2), + local_jac = RealMatrixX::Zero(n2,n2), + mat_n2n2 = RealMatrixX::Zero(n2,n2), + mat_n1n2 = RealMatrixX::Zero(n1,n2), + mat_22 = RealMatrixX::Zero(2,2); + + // we need the velocity vector in the local coordinate system so that + // the appropriate component of the w-derivative can be used + vel_vec = _elem.T_matrix().transpose() * piston_bc.vel_vec(); + + Real + dwdt_val = 0., + dwdx_val = 0., + p_val = 0.; + + + for (unsigned int qp=0; qpinitialize_von_karman_strain_operator(qp, + *fe, + dummy, + dwdx, + dBmat); + + // the diagonal of dwdx matrix stores the + dwdx_val = 0.; + for (unsigned int i=0; i<2; i++) + dwdx_val += dwdx(i,i) * vel_vec(i); // (dw/dx_i)*U_inf . n_i + + // calculate the pressure value + dwdx_p = dwdx_val; + dwdt_p = dwdt_val; + pressure->derivative(p, qpoint[qp], _time, p_val); + + // calculate force + force(0) = p_val * normal(2); + + + Bmat_w.vector_mult_transpose(vec_n2, force); + local_f += JxW[qp] * vec_n2; + + + // calculate the Jacobian if requested + if (request_jacobian) { + + // we need the derivative of cp wrt normal velocity + dpressure_dxdot->derivative(p, qpoint[qp], _time, p_val); + + // calculate the component of Jacobian due to w-velocity + Bmat_w.right_multiply_transpose(mat_n2n2, Bmat_w); + local_jac_xdot += (JxW[qp] * p_val * normal(2)) * mat_n2n2; + + // now calculate the component of Jacobian + dpressure_dx->derivative(p, qpoint[qp], _time, p_val); + + // derivative wrt x + mat_22.setZero(2,2); + mat_22(0,0) = vel_vec(0); + dBmat.left_multiply(mat_n1n2, mat_22); + Bmat_w.right_multiply_transpose(mat_n2n2, mat_n1n2); // v: B^T dB/dx + local_jac += (JxW[qp] * p_val * normal(2)) * mat_n2n2; + + // derivative wrt y + mat_22.setZero(2,2); + mat_22(1,1) = vel_vec(1); + dBmat.left_multiply(mat_n1n2, mat_22); + Bmat_w.right_multiply_transpose(mat_n2n2, mat_n1n2); // v: B^T dB/dy + local_jac += (JxW[qp] * p_val * normal(2)) * mat_n2n2; + } + } + + + // now transform to the global system and add + transform_vector_to_global_system(local_f, vec_n2); + f -= vec_n2; + + // if the Jacobian was requested, then transform it and add to the + // global Jacobian + if (request_jacobian) { + transform_matrix_to_global_system(local_jac_xdot, mat_n2n2); + jac_xdot -= mat_n2n2; + + transform_matrix_to_global_system(local_jac, mat_n2n2); + jac -= mat_n2n2; + } + + + return request_jacobian; +} + + + + + + +void +MAST::StructuralElement2D::_compute_stress(MAST::FEBase& fe, + unsigned int qp, + RealVectorX& stress, + RealMatrixX* dstress_dX) { + + /* + MAST::BendingOperatorType bending_model = + _property.bending_model(_elem); + + std::unique_ptr + bend(MAST::build_bending_operator_2D(bending_model, + *this, + qp_loc_fe).release()); + */ + + std::vector JxW = fe.get_JxW(); + const std::vector& xyz = fe.get_xyz(); + + const unsigned int + n_phi = (unsigned int)fe.n_shape_functions(), + n1 = this->n_direct_strain_components(), + n2 = 6*n_phi, + n3 = this->n_von_karman_strain_components(); + + /* + Real + z = 0., + z_off = 0., + temp = 0., + ref_t = 0., + alpha = 0., + dtemp = 0., + dref_t= 0., + dalpha= 0.; + */ + + RealMatrixX + material_mat, + vk_dwdxi_mat = RealMatrixX::Zero(n1,n3), + dstrain_dX = RealMatrixX::Zero(n1,n2), + mat_n1n2 = RealMatrixX::Zero(n1,n2), + eye = RealMatrixX::Identity(n1, n1), + mat_x = RealMatrixX::Zero(3,2), + mat_y = RealMatrixX::Zero(3,2), + dstrain_dX_3D= RealMatrixX::Zero(6,n2), + dstress_dX_3D= RealMatrixX::Zero(6,n2); + + RealVectorX + strain = RealVectorX::Zero(n1), + strain_vk = RealVectorX::Zero(n1), + strain_bend = RealVectorX::Zero(n1), + strain_3D = RealVectorX::Zero(6), + stress_3D = RealVectorX::Zero(6), + dstrain_dp = RealVectorX::Zero(n1), + dstress_dp = RealVectorX::Zero(n1), + vec1 = RealVectorX::Zero(n2), + vec2 = RealVectorX::Zero(n2); + + + FEMOperatorMatrix + Bmat_lin, + Bmat_nl_x, + Bmat_nl_y, + Bmat_nl_u, + Bmat_nl_v, + Bmat_bend, + Bmat_vk; + + Bmat_lin.reinit (n1, _system.n_vars(), n_phi); // three stress-strain components + Bmat_nl_x.reinit(2, _system.n_vars(), n_phi); + Bmat_nl_y.reinit(2, _system.n_vars(), n_phi); + Bmat_nl_u.reinit(2, _system.n_vars(), n_phi); + Bmat_nl_v.reinit(2, _system.n_vars(), n_phi); + Bmat_bend.reinit(n1, _system.n_vars(), n_phi); + Bmat_vk.reinit (n3, _system.n_vars(), n_phi); // only dw/dx and dw/dy + + // TODO: remove this const-cast, which may need change in API of + // material card + const MAST::FieldFunction& + mat_stiff = + const_cast(_property.get_material()). + stiffness_matrix(2); + + /* + // get the thickness values for the bending strain calculation + const MAST::FieldFunction + &h = _property.get >("h"), + &h_off = _property.get >("off"); + + + bool if_vk = (_property.strain_type() == MAST::NONLINEAR_STRAIN), + if_bending = (_property.bending_model(_elem) != MAST::NO_BENDING); + + + // check to see if the element has any thermal loads specified + // The object returns null + MAST::BoundaryConditionBase *thermal_load = + stress_output.get_thermal_load_for_elem(_elem); + + const MAST::FieldFunction + *temp_func = nullptr, + *ref_temp_func = nullptr, + *alpha_func = nullptr; + + // get pointers to the temperature, if thermal load is specified + if (thermal_load) { + temp_func = + &(thermal_load->get >("temperature")); + ref_temp_func = + &(thermal_load->get >("ref_temperature")); + alpha_func = + &(_property.get_material().get >("alpha_expansion")); + } + */ + + /////////////////////////////////////////////////////////////////////// + // get the material matrix + mat_stiff(xyz[qp], _time, material_mat); + + this->initialize_green_lagrange_strain_operator(qp, + fe, + _local_sol, + strain, + mat_x, + mat_y, + Bmat_lin, + Bmat_nl_x, + Bmat_nl_y, + Bmat_nl_u, + Bmat_nl_v); + + /* + // if thermal load was specified, then set the thermal strain + // component of the total strain + if (thermal_load) { + (*temp_func) (xyz[qp_loc_index], _time, temp); + (*ref_temp_func)(xyz[qp_loc_index], _time, ref_t); + (*alpha_func) (xyz[qp_loc_index], _time, alpha); + strain(0) -= alpha*(temp-ref_t); // epsilon-xx + strain(1) -= alpha*(temp-ref_t); // epsilon-yy + } + + if (if_bending) { + + // von Karman strain + if (if_vk) { // get the vonKarman strain operator if needed + + this->initialize_von_karman_strain_operator(qp, + fe, + strain_vk, + vk_dwdxi_mat, + Bmat_vk); + strain += strain_vk; + } + + // add to this the bending strain + // TODO: add coupling due to h_offset + h (xyz[qp], _time, z); + h_off(xyz[qp], _time, z_off); + // TODO: this assumes isotropic section. Multilayered sections need + // special considerations + bend->initialize_bending_strain_operator_for_z(fe, + qp, + qp_loc[qp](2) * z/2.+z_off, + Bmat_bend); + Bmat_bend.vector_mult(strain_bend, _local_sol); + + + // add stress due to bending. + strain += strain_bend; + }*/ + + // note that this assumes linear material laws + stress = material_mat * strain; + + // calculate the derivative if requested + if (dstress_dX) { + + Bmat_lin.left_multiply(dstrain_dX, eye); + + /*if (_property.strain_type() == MAST::NONLINEAR_STRAIN) { + + Bmat_nl_x.left_multiply(mat_n1n2, mat_x); + dstrain_dX += mat_n1n2; + Bmat_nl_y.left_multiply(mat_n1n2, mat_y); + dstrain_dX += mat_n1n2; + } + + if (if_bending) { + + // von Karman strain + if (if_vk) { + + Bmat_vk.left_multiply(mat_n1n2, vk_dwdxi_mat); + dstrain_dX += mat_n1n2; + } + + // bending strain + Bmat_bend.left_multiply(mat_n1n2, eye); + dstrain_dX += mat_n1n2; + } + */ + + // note: this assumes linear material laws + *dstress_dX = material_mat * dstrain_dX; + + /* + if (p) { + // sensitivity of the response, s, is + // ds/dp = partial s/partial p + + // partial s/partial X dX/dp + // the first part of the sensitivity is obtained from + // + // the first term includes direct sensitivity of the stress + // with respect to the parameter, while holding the solution + // constant. This should include influence of shape changes, + // if the parameter is shape-dependent. + // TODO: include shape sensitivity. + // presently, only material parameter is included + + + dstrain_dp = RealVectorX::Zero(n1); + + // if thermal load was specified, then set the thermal strain + // component of the total strain + if (thermal_load) { + temp_func->derivative(*p, xyz[qp_loc_index], _time, dtemp); + ref_temp_func->derivative(*p, xyz[qp_loc_index], _time, dref_t); + alpha_func->derivative(*p, xyz[qp_loc_index], _time, dalpha); + dstrain_dp(0) -= alpha*(dtemp-dref_t) + dalpha*(temp-ref_t); // epsilon-xx + dstrain_dp(1) -= alpha*(dtemp-dref_t) + dalpha*(temp-ref_t); // epsilon-yy + } + + + + if (if_bending) { + + // add to this the bending strain + h.derivative (*p, + xyz[qp_loc_index], _time, z); + h_off.derivative(*p, + xyz[qp_loc_index], _time, z_off); + // TODO: this assumes isotropic section. Multilayered sections need + // special considerations + bend->initialize_bending_strain_operator_for_z(*fe, + qp_loc_index, + qp_loc[qp](2) * z/2.+z_off, + Bmat_bend); + Bmat_bend.vector_mult(strain_bend, _local_sol); + + + // add stress due to bending. + dstrain_dp += strain_bend; + } + + + // now use this to calculate the stress sensitivity. + dstress_dp = material_mat * dstrain_dp; + + // get the material matrix sensitivity + mat_stiff.derivative(*p, + xyz[qp_loc_index], + _time, + material_mat); + + // partial sensitivity of strain is zero unless it is a + // shape parameter. + // TODO: shape sensitivity of strain operator + + // now use this to calculate the stress sensitivity. + dstress_dp += material_mat * strain; + + // + // use the derivative data to evaluate the second term in the + // sensitivity + // + dstress_dp += dstress_dX * _local_sol_sens; + dstrain_dp += dstrain_dX * _local_sol_sens; + + // copy the 3D object + stress_3D(0) = dstress_dp(0); // sigma-xx + stress_3D(1) = dstress_dp(1); // sigma-yy + stress_3D(3) = dstress_dp(2); // tau-xy + strain_3D(0) = dstrain_dp(0); // epsilon-xx + strain_3D(1) = dstrain_dp(1); // epsilon-yy + strain_3D(3) = dstrain_dp(2); // gamma-xy + + // tell the data object about the sensitivity values + data->set_sensitivity(*p, + stress_3D, + strain_3D); + } + */ + } +} + + + +void +MAST::StructuralElement2D::_compute_stress_sensitivity(const MAST::FunctionBase& p, + MAST::FEBase& fe, + unsigned int qp, + RealVectorX& stress) { - // if the Jacobian was requested, then transform it and add to the - // global Jacobian - if (request_jacobian) { - transform_matrix_to_global_system(local_jac_xdot, mat_n2n2); - jac_xdot -= mat_n2n2; + /* + MAST::BendingOperatorType bending_model = + _property.bending_model(_elem); + + std::unique_ptr + bend(MAST::build_bending_operator_2D(bending_model, + *this, + qp_loc_fe).release()); + */ + + std::vector JxW = fe.get_JxW(); + const std::vector& xyz = fe.get_xyz(); + + const unsigned int + n_phi = (unsigned int)fe.n_shape_functions(), + n1 = this->n_direct_strain_components(), + n2 = 6*n_phi, + n3 = this->n_von_karman_strain_components(); + + /* + Real + z = 0., + z_off = 0., + temp = 0., + ref_t = 0., + alpha = 0., + dtemp = 0., + dref_t= 0., + dalpha= 0.; + */ + + RealMatrixX + material_mat, + vk_dwdxi_mat = RealMatrixX::Zero(n1,n3), + dstrain_dX = RealMatrixX::Zero(n1,n2), + mat_n1n2 = RealMatrixX::Zero(n1,n2), + eye = RealMatrixX::Identity(n1, n1), + mat_x = RealMatrixX::Zero(3,2), + mat_y = RealMatrixX::Zero(3,2), + dstrain_dX_3D= RealMatrixX::Zero(6,n2), + dstress_dX_3D= RealMatrixX::Zero(6,n2); + + RealVectorX + strain = RealVectorX::Zero(n1), + strain_vk = RealVectorX::Zero(n1), + strain_bend = RealVectorX::Zero(n1), + strain_3D = RealVectorX::Zero(6), + stress_3D = RealVectorX::Zero(6), + dstrain_dp = RealVectorX::Zero(n1), + dstress_dp = RealVectorX::Zero(n1), + vec1 = RealVectorX::Zero(n2), + vec2 = RealVectorX::Zero(n2); + + + FEMOperatorMatrix + Bmat_lin, + Bmat_nl_x, + Bmat_nl_y, + Bmat_nl_u, + Bmat_nl_v, + Bmat_bend, + Bmat_vk; + + Bmat_lin.reinit (n1, _system.n_vars(), n_phi); // three stress-strain components + Bmat_nl_x.reinit(2, _system.n_vars(), n_phi); + Bmat_nl_y.reinit(2, _system.n_vars(), n_phi); + Bmat_nl_u.reinit(2, _system.n_vars(), n_phi); + Bmat_nl_v.reinit(2, _system.n_vars(), n_phi); + Bmat_bend.reinit(n1, _system.n_vars(), n_phi); + Bmat_vk.reinit (n3, _system.n_vars(), n_phi); // only dw/dx and dw/dy + + // TODO: remove this const-cast, which may need change in API of + // material card + const MAST::FieldFunction& + mat_stiff = + const_cast(_property.get_material()). + stiffness_matrix(2); + + /* + // get the thickness values for the bending strain calculation + const MAST::FieldFunction + &h = _property.get >("h"), + &h_off = _property.get >("off"); + + + bool if_vk = (_property.strain_type() == MAST::NONLINEAR_STRAIN), + if_bending = (_property.bending_model(_elem) != MAST::NO_BENDING); + + + // check to see if the element has any thermal loads specified + // The object returns null + MAST::BoundaryConditionBase *thermal_load = + stress_output.get_thermal_load_for_elem(_elem); + + const MAST::FieldFunction + *temp_func = nullptr, + *ref_temp_func = nullptr, + *alpha_func = nullptr; + + // get pointers to the temperature, if thermal load is specified + if (thermal_load) { + temp_func = + &(thermal_load->get >("temperature")); + ref_temp_func = + &(thermal_load->get >("ref_temperature")); + alpha_func = + &(_property.get_material().get >("alpha_expansion")); + } + */ + + /////////////////////////////////////////////////////////////////////// + // get the material matrix + mat_stiff.derivative(p, xyz[qp], _time, material_mat); + + this->initialize_green_lagrange_strain_operator(qp, + fe, + _local_sol, + strain, + mat_x, + mat_y, + Bmat_lin, + Bmat_nl_x, + Bmat_nl_y, + Bmat_nl_u, + Bmat_nl_v); + + /* + // if thermal load was specified, then set the thermal strain + // component of the total strain + if (thermal_load) { + (*temp_func) (xyz[qp_loc_index], _time, temp); + (*ref_temp_func)(xyz[qp_loc_index], _time, ref_t); + (*alpha_func) (xyz[qp_loc_index], _time, alpha); + strain(0) -= alpha*(temp-ref_t); // epsilon-xx + strain(1) -= alpha*(temp-ref_t); // epsilon-yy + } + + if (if_bending) { + + // von Karman strain + if (if_vk) { // get the vonKarman strain operator if needed + + this->initialize_von_karman_strain_operator(qp, + fe, + strain_vk, + vk_dwdxi_mat, + Bmat_vk); + strain += strain_vk; + } + + // add to this the bending strain + // TODO: add coupling due to h_offset + h (xyz[qp], _time, z); + h_off(xyz[qp], _time, z_off); + // TODO: this assumes isotropic section. Multilayered sections need + // special considerations + bend->initialize_bending_strain_operator_for_z(fe, + qp, + qp_loc[qp](2) * z/2.+z_off, + Bmat_bend); + Bmat_bend.vector_mult(strain_bend, _local_sol); + + + // add stress due to bending. + strain += strain_bend; + }*/ + + // note that this assumes linear material laws + stress = material_mat * strain; +} + + + +void +MAST::StructuralElement2D:: +_compute_stress_gradient(MAST::FEBase& fe, + unsigned int qp, + RealMatrixX& stress_grad, + std::vector* dstress_grad_dX) { + + /* + MAST::BendingOperatorType bending_model = + _property.bending_model(_elem); + + std::unique_ptr + bend(MAST::build_bending_operator_2D(bending_model, + *this, + qp_loc_fe).release()); + */ + + std::vector JxW = fe.get_JxW(); + const std::vector& xyz = fe.get_xyz(); + + const unsigned int + n_phi = (unsigned int)fe.n_shape_functions(), + n1 = this->n_direct_strain_components(), + n2 = 6*n_phi, + n3 = this->n_von_karman_strain_components(); + + /* + Real + z = 0., + z_off = 0., + temp = 0., + ref_t = 0., + alpha = 0., + dtemp = 0., + dref_t= 0., + dalpha= 0.; + */ + + RealMatrixX + material_mat, + vk_dwdxi_mat = RealMatrixX::Zero(n1,n3), + dstrain = RealMatrixX::Zero(n1,2), + dstrain_dX = RealMatrixX::Zero(n1,n2), + mat_n1n2 = RealMatrixX::Zero(n1,n2), + eye = RealMatrixX::Identity(n1, n1), + mat_x = RealMatrixX::Zero(3,2), + mat_y = RealMatrixX::Zero(3,2), + dstrain_dX_3D= RealMatrixX::Zero(6,n2), + dstress_dX_3D= RealMatrixX::Zero(6,n2); + + RealVectorX + strain_vk = RealVectorX::Zero(n1), + strain_bend = RealVectorX::Zero(n1), + strain_3D = RealVectorX::Zero(6), + stress_3D = RealVectorX::Zero(6), + dstrain_dp = RealVectorX::Zero(n1), + dstress_dp = RealVectorX::Zero(n1), + vec1 = RealVectorX::Zero(n2), + vec2 = RealVectorX::Zero(n2); + + + FEMOperatorMatrix + Bmat_nl_x, + Bmat_nl_y, + Bmat_nl_u, + Bmat_nl_v, + Bmat_bend, + Bmat_vk; + + std::vector + dBmat_lin(2); + + for (unsigned int i=0; i<2; i++) + dBmat_lin[i].reinit (n1, _system.n_vars(), n_phi); // three stress-strain components + + /* + Bmat_nl_x.reinit(2, _system.n_vars(), n_phi); + Bmat_nl_y.reinit(2, _system.n_vars(), n_phi); + Bmat_nl_u.reinit(2, _system.n_vars(), n_phi); + Bmat_nl_v.reinit(2, _system.n_vars(), n_phi); + Bmat_bend.reinit(n1, _system.n_vars(), n_phi); + Bmat_vk.reinit (n3, _system.n_vars(), n_phi); // only dw/dx and dw/dy + */ + + // TODO: remove this const-cast, which may need change in API of + // material card + const MAST::FieldFunction& + mat_stiff = + const_cast(_property.get_material()). + stiffness_matrix(2); + + /* + // get the thickness values for the bending strain calculation + const MAST::FieldFunction + &h = _property.get >("h"), + &h_off = _property.get >("off"); + + + bool if_vk = (_property.strain_type() == MAST::NONLINEAR_STRAIN), + if_bending = (_property.bending_model(_elem) != MAST::NO_BENDING); + + + // check to see if the element has any thermal loads specified + // The object returns null + MAST::BoundaryConditionBase *thermal_load = + stress_output.get_thermal_load_for_elem(_elem); + + const MAST::FieldFunction + *temp_func = nullptr, + *ref_temp_func = nullptr, + *alpha_func = nullptr; + + // get pointers to the temperature, if thermal load is specified + if (thermal_load) { + temp_func = + &(thermal_load->get >("temperature")); + ref_temp_func = + &(thermal_load->get >("ref_temperature")); + alpha_func = + &(_property.get_material().get >("alpha_expansion")); + } + */ + + /////////////////////////////////////////////////////////////////////// + // get the material matrix + mat_stiff(xyz[qp], _time, material_mat); + + this->initialize_strain_operator_gradient(qp, + fe, + _local_sol, + dstrain, + dBmat_lin); + + /* + // if thermal load was specified, then set the thermal strain + // component of the total strain + if (thermal_load) { + (*temp_func) (xyz[qp_loc_index], _time, temp); + (*ref_temp_func)(xyz[qp_loc_index], _time, ref_t); + (*alpha_func) (xyz[qp_loc_index], _time, alpha); + strain(0) -= alpha*(temp-ref_t); // epsilon-xx + strain(1) -= alpha*(temp-ref_t); // epsilon-yy + } + + if (if_bending) { + + // von Karman strain + if (if_vk) { // get the vonKarman strain operator if needed + + this->initialize_von_karman_strain_operator(qp, + fe, + strain_vk, + vk_dwdxi_mat, + Bmat_vk); + strain += strain_vk; + } + + // add to this the bending strain + // TODO: add coupling due to h_offset + h (xyz[qp], _time, z); + h_off(xyz[qp], _time, z_off); + // TODO: this assumes isotropic section. Multilayered sections need + // special considerations + bend->initialize_bending_strain_operator_for_z(fe, + qp, + qp_loc[qp](2) * z/2.+z_off, + Bmat_bend); + Bmat_bend.vector_mult(strain_bend, _local_sol); + + + // add stress due to bending. + strain += strain_bend; + }*/ + + // note that this assumes linear material laws + stress_grad = material_mat * dstrain; + + // calculate the derivative if requested + if (dstress_grad_dX) { - transform_matrix_to_global_system(local_jac, mat_n2n2); - jac -= mat_n2n2; + for (unsigned int i=0; i<2; i++) { + + dBmat_lin[i].left_multiply(dstrain_dX, eye); + + /*if (_property.strain_type() == MAST::NONLINEAR_STRAIN) { + + Bmat_nl_x.left_multiply(mat_n1n2, mat_x); + dstrain_dX += mat_n1n2; + Bmat_nl_y.left_multiply(mat_n1n2, mat_y); + dstrain_dX += mat_n1n2; + } + + if (if_bending) { + + // von Karman strain + if (if_vk) { + + Bmat_vk.left_multiply(mat_n1n2, vk_dwdxi_mat); + dstrain_dX += mat_n1n2; + } + + // bending strain + Bmat_bend.left_multiply(mat_n1n2, eye); + dstrain_dX += mat_n1n2; + } + */ + + // note: this assumes linear material laws + (*dstress_grad_dX)[i] = material_mat * dstrain_dX; + } } - - return request_jacobian; } -bool +void MAST::StructuralElement2D:: -piston_theory_residual_sensitivity(const MAST::FunctionBase& p, - bool request_jacobian, - RealVectorX &f, - RealMatrixX& jac_xdot, - RealMatrixX& jac, - MAST::BoundaryConditionBase& bc) { +_compute_stress_gradient_sensitivity(const MAST::FunctionBase& p, + MAST::FEBase& fe, + unsigned int qp, + RealMatrixX& stress_grad) { - - libmesh_assert(_elem.dim() < 3); // only applicable for lower dimensional elements - libmesh_assert(!follower_forces); // not implemented yet for follower forces + /* + MAST::BendingOperatorType bending_model = + _property.bending_model(_elem); - std::unique_ptr fe(_elem.init_fe(true, false)); + std::unique_ptr + bend(MAST::build_bending_operator_2D(bending_model, + *this, + qp_loc_fe).release()); + */ + + stress_grad.setZero(); + + std::vector JxW = fe.get_JxW(); + const std::vector& xyz = fe.get_xyz(); - const std::vector &JxW = fe->get_JxW(); - const std::vector& qpoint = fe->get_xyz(); - const std::vector >& phi = fe->get_phi(); const unsigned int - n_phi = (unsigned int)phi.size(), - n1 = 2, - n2 = _system.n_vars()*n_phi; - - - // normal for face integration - libMesh::Point normal; - // direction of pressure assumed to be normal (along local z-axis) - // to the element face for 2D and along local y-axis for 1D element. - normal(_elem.dim()) = -1.; - + n_phi = (unsigned int)fe.n_shape_functions(), + n1 = this->n_direct_strain_components(), + n2 = 6*n_phi, + n3 = this->n_von_karman_strain_components(); - // convert to piston theory boundary condition so that the necessary - // flow properties can be obtained - const MAST::PistonTheoryBoundaryCondition& piston_bc = - dynamic_cast(bc); + /* + Real + z = 0., + z_off = 0., + temp = 0., + ref_t = 0., + alpha = 0., + dtemp = 0., + dref_t= 0., + dalpha= 0.; + */ + RealMatrixX + material_mat, + vk_dwdxi_mat = RealMatrixX::Zero(n1,n3), + dstrain = RealMatrixX::Zero(n1,2), + dstrain_dX = RealMatrixX::Zero(n1,n2), + mat_n1n2 = RealMatrixX::Zero(n1,n2), + eye = RealMatrixX::Identity(n1, n1), + mat_x = RealMatrixX::Zero(3,2), + mat_y = RealMatrixX::Zero(3,2), + dstrain_dX_3D= RealMatrixX::Zero(6,n2), + dstress_dX_3D= RealMatrixX::Zero(6,n2); - // create the constant field functions to pass the dwdx and dwdt values - // to the piston theory pressure functions - MAST::Parameter - dwdx_p ("dwdx", 0.), - dwdt_p ("dwdt", 0.); + RealVectorX + strain_vk = RealVectorX::Zero(n1), + strain_bend = RealVectorX::Zero(n1), + strain_3D = RealVectorX::Zero(6), + stress_3D = RealVectorX::Zero(6), + dstrain_dp = RealVectorX::Zero(n1), + dstress_dp = RealVectorX::Zero(n1), + vec1 = RealVectorX::Zero(n2), + vec2 = RealVectorX::Zero(n2); - MAST::ConstantFieldFunction - dwdx_f ("dwdx", dwdx_p), - dwdt_f ("dwdx", dwdt_p); + FEMOperatorMatrix + Bmat_nl_x, + Bmat_nl_y, + Bmat_nl_u, + Bmat_nl_v, + Bmat_bend, + Bmat_vk; + + std::vector + dBmat_lin(2); + + for (unsigned int i=0; i<2; i++) + dBmat_lin[i].reinit (n1, _system.n_vars(), n_phi); // three stress-strain components + + /* + Bmat_nl_x.reinit(2, _system.n_vars(), n_phi); + Bmat_nl_y.reinit(2, _system.n_vars(), n_phi); + Bmat_nl_u.reinit(2, _system.n_vars(), n_phi); + Bmat_nl_v.reinit(2, _system.n_vars(), n_phi); + Bmat_bend.reinit(n1, _system.n_vars(), n_phi); + Bmat_vk.reinit (n3, _system.n_vars(), n_phi); // only dw/dx and dw/dy + */ - std::unique_ptr > - pressure (piston_bc.get_pressure_function(dwdx_f, dwdt_f).release()), - dpressure_dx (piston_bc.get_dpdx_function (dwdx_f, dwdt_f).release()), - dpressure_dxdot (piston_bc.get_dpdxdot_function (dwdx_f, dwdt_f).release()); + // TODO: remove this const-cast, which may need change in API of + // material card + const MAST::FieldFunction& + mat_stiff = + const_cast(_property.get_material()). + stiffness_matrix(2); - FEMOperatorMatrix - Bmat_w, // operator matrix for the w-displacement - dBmat; // operator matrix to calculate the derivativ of w wrt x and y + /* + // get the thickness values for the bending strain calculation + const MAST::FieldFunction + &h = _property.get >("h"), + &h_off = _property.get >("off"); - dBmat.reinit(n1, _system.n_vars(), n_phi); - RealVectorX - phi_vec = RealVectorX::Zero(n_phi), - force = RealVectorX::Zero(n1), - local_f = RealVectorX::Zero(n2), - vec_n1 = RealVectorX::Zero(n1), - vec_n2 = RealVectorX::Zero(n2), - vel_vec = RealVectorX::Zero(3), - dummy = RealVectorX::Zero(3); + bool if_vk = (_property.strain_type() == MAST::NONLINEAR_STRAIN), + if_bending = (_property.bending_model(_elem) != MAST::NO_BENDING); - RealMatrixX - dwdx = RealMatrixX::Zero(3,2), - local_jac_xdot = RealMatrixX::Zero(n2,n2), - local_jac = RealMatrixX::Zero(n2,n2), - mat_n2n2 = RealMatrixX::Zero(n2,n2), - mat_n1n2 = RealMatrixX::Zero(n1,n2), - mat_22 = RealMatrixX::Zero(2,2); - // we need the velocity vector in the local coordinate system so that - // the appropriate component of the w-derivative can be used - vel_vec = _elem.T_matrix().transpose() * piston_bc.vel_vec(); + // check to see if the element has any thermal loads specified + // The object returns null + MAST::BoundaryConditionBase *thermal_load = + stress_output.get_thermal_load_for_elem(_elem); - Real - dwdt_val = 0., - dwdx_val = 0., - p_val = 0.; + const MAST::FieldFunction + *temp_func = nullptr, + *ref_temp_func = nullptr, + *alpha_func = nullptr; + // get pointers to the temperature, if thermal load is specified + if (thermal_load) { + temp_func = + &(thermal_load->get >("temperature")); + ref_temp_func = + &(thermal_load->get >("ref_temperature")); + alpha_func = + &(_property.get_material().get >("alpha_expansion")); + } + */ - for (unsigned int qp=0; qpinitialize_von_karman_strain_operator(qp, - *fe, - dummy, - dwdx, - dBmat); - - // the diagonal of dwdx matrix stores the - dwdx_val = 0.; - for (unsigned int i=0; i<2; i++) - dwdx_val += dwdx(i,i) * vel_vec(i); // (dw/dx_i)*U_inf . n_i - - // calculate the pressure value - dwdx_p = dwdx_val; - dwdt_p = dwdt_val; - pressure->derivative(p, qpoint[qp], _time, p_val); - - // calculate force - force(0) = p_val * normal(2); - - - Bmat_w.vector_mult_transpose(vec_n2, force); - local_f += JxW[qp] * vec_n2; - + /////////////////////////////////////////////////////////////////////// + // get the material matrix + mat_stiff.derivative(p, xyz[qp], _time, material_mat); + + this->initialize_strain_operator_gradient(qp, + fe, + _local_sol, + dstrain, + dBmat_lin); + + /* + // if thermal load was specified, then set the thermal strain + // component of the total strain + if (thermal_load) { + (*temp_func) (xyz[qp_loc_index], _time, temp); + (*ref_temp_func)(xyz[qp_loc_index], _time, ref_t); + (*alpha_func) (xyz[qp_loc_index], _time, alpha); + strain(0) -= alpha*(temp-ref_t); // epsilon-xx + strain(1) -= alpha*(temp-ref_t); // epsilon-yy + } + + if (if_bending) { - // calculate the Jacobian if requested - if (request_jacobian) { - - // we need the derivative of cp wrt normal velocity - dpressure_dxdot->derivative(p, qpoint[qp], _time, p_val); - - // calculate the component of Jacobian due to w-velocity - Bmat_w.right_multiply_transpose(mat_n2n2, Bmat_w); - local_jac_xdot += (JxW[qp] * p_val * normal(2)) * mat_n2n2; - - // now calculate the component of Jacobian - dpressure_dx->derivative(p, qpoint[qp], _time, p_val); - - // derivative wrt x - mat_22.setZero(2,2); - mat_22(0,0) = vel_vec(0); - dBmat.left_multiply(mat_n1n2, mat_22); - Bmat_w.right_multiply_transpose(mat_n2n2, mat_n1n2); // v: B^T dB/dx - local_jac += (JxW[qp] * p_val * normal(2)) * mat_n2n2; + // von Karman strain + if (if_vk) { // get the vonKarman strain operator if needed - // derivative wrt y - mat_22.setZero(2,2); - mat_22(1,1) = vel_vec(1); - dBmat.left_multiply(mat_n1n2, mat_22); - Bmat_w.right_multiply_transpose(mat_n2n2, mat_n1n2); // v: B^T dB/dy - local_jac += (JxW[qp] * p_val * normal(2)) * mat_n2n2; + this->initialize_von_karman_strain_operator(qp, + fe, + strain_vk, + vk_dwdxi_mat, + Bmat_vk); + strain += strain_vk; } - } - - - // now transform to the global system and add - transform_vector_to_global_system(local_f, vec_n2); - f -= vec_n2; - - // if the Jacobian was requested, then transform it and add to the - // global Jacobian - if (request_jacobian) { - transform_matrix_to_global_system(local_jac_xdot, mat_n2n2); - jac_xdot -= mat_n2n2; - transform_matrix_to_global_system(local_jac, mat_n2n2); - jac -= mat_n2n2; - } - + // add to this the bending strain + // TODO: add coupling due to h_offset + h (xyz[qp], _time, z); + h_off(xyz[qp], _time, z_off); + // TODO: this assumes isotropic section. Multilayered sections need + // special considerations + bend->initialize_bending_strain_operator_for_z(fe, + qp, + qp_loc[qp](2) * z/2.+z_off, + Bmat_bend); + Bmat_bend.vector_mult(strain_bend, _local_sol); + + + // add stress due to bending. + strain += strain_bend; + }*/ - return request_jacobian; + // note that this assumes linear material laws + stress_grad = material_mat * dstrain; +} + + +void +MAST::StructuralElement2D::_surface_normal_voigt_notation(const RealVectorX& normal, + RealMatrixX& normal_mat) { + + libmesh_assert_equal_to(normal.size(), 3); + libmesh_assert_equal_to(normal_mat.rows(), 2); + libmesh_assert_equal_to(normal_mat.cols(), 3); + normal_mat.setZero(); + + /* + // for a 3D stress-tensor the relation will be + normal_mat = RealMatrixX::Zero(3, 6); + // nx + normal_mat(0,0) = normal_mat(1,3) = normal_mat(2,5) = normal(0); + // ny + normal_mat(0,3) = normal_mat(1,1) = normal_mat(2,4) = normal(1); + // nz + normal_mat(0,5) = normal_mat(1,4) = normal_mat(2,2) = normal(2); + */ + + // for a 2D stress tensor the relation will be + normal_mat = RealMatrixX::Zero(2, 3); + + // nx + normal_mat(0,0) = normal_mat(1,2) = normal(0); + + // ny + normal_mat(0,2) = normal_mat(1,1) = normal(1); } + + diff --git a/src/elasticity/structural_element_2d.h b/src/elasticity/structural_element_2d.h index 7cbeaf3b..038a80b9 100644 --- a/src/elasticity/structural_element_2d.h +++ b/src/elasticity/structural_element_2d.h @@ -44,7 +44,6 @@ namespace MAST { public: StructuralElement2D(MAST::SystemInitialization& sys, - MAST::AssemblyBase& assembly, const MAST::GeomElem& elem, const MAST::ElementPropertyCardBase& p); @@ -153,7 +152,55 @@ namespace MAST { protected: - + + /*! + * Calculates the force vector and Jacobian due to surface traction. + */ + virtual bool + surface_traction_residual(bool request_jacobian, + RealVectorX& f, + RealMatrixX& jac, + const unsigned int side, + MAST::BoundaryConditionBase& bc); + + + /*! + * Calculates the sensitivity of element vector and matrix quantities for surface traction + * boundary condition. + */ + virtual bool + surface_traction_residual_sensitivity(const MAST::FunctionBase& p, + bool request_jacobian, + RealVectorX& f, + RealMatrixX& jac, + const unsigned int side, + MAST::BoundaryConditionBase& bc); + + + /*! + * Calculates the sensitivity of force vector and Jacobian due to surface traction and + * sensitiity due to boundary movement. + */ + virtual bool + surface_traction_residual_shifted_boundary(bool request_jacobian, + RealVectorX& f, + RealMatrixX& jac, + const unsigned int side, + MAST::BoundaryConditionBase& bc); + + /*! + * Calculates the sensitivity of force vector and Jacobian due to surface traction and + * sensitiity due to boundary movement. + */ + virtual bool + surface_traction_residual_shifted_boundary_sensitivity(const MAST::FunctionBase& p, + bool request_jacobian, + RealVectorX& f, + RealMatrixX& jac, + const unsigned int side, + MAST::BoundaryConditionBase& bc); + + /*! * Calculates the force vector and Jacobian due to surface pressure. */ @@ -336,6 +383,52 @@ namespace MAST { MAST::FEMOperatorMatrix& Bmat_nl_u, MAST::FEMOperatorMatrix& Bmat_nl_v); + + virtual void + initialize_strain_operator_gradient(const unsigned int qp, + const MAST::FEBase& fe, + const RealVectorX& local_disp, + RealMatrixX& epsilon_grad, + std::vector& dBmat_lin); + + /*! + * Computes the stress at the specified quadrature point of the FE data structure. The + * FE object must already be initialized. The derivative of the stress with respect + * to the state variables is computed if a pointer to the matrix is provided. + */ + void _compute_stress(MAST::FEBase& fe, unsigned int qp, + RealVectorX& stress, + RealMatrixX* dstress_dX); + + + void _compute_stress_sensitivity(const MAST::FunctionBase& f, + MAST::FEBase& fe, unsigned int qp, + RealVectorX& stress); + + /*! + * computes the gradient of stress in Voigt notation in \p stress_grad where the three + * columns are the derivative of stress in x, y, z, respectively. If a pointer is provided in + * \p dstress_grad_dX then each element of this vector contains the derive of the gradient + * matrix column wrt the state variables. + */ + void _compute_stress_gradient(MAST::FEBase& fe, + unsigned int qp, + RealMatrixX& stress_grad, + std::vector* dstress_grad_dX); + + void _compute_stress_gradient_sensitivity(const MAST::FunctionBase& f, + MAST::FEBase& fe, + unsigned int qp, + RealMatrixX& stress_grad); + + /*! + * creates a matrix that can be multiplied with the Voigt notation of stress to compute the + * surface normal traction + */ + void _surface_normal_voigt_notation(const RealVectorX& normal, + RealMatrixX& normal_mat); + + /*! * performs integration at the quadrature point for the provided * matrices. The temperature vector and matrix entities are provided for diff --git a/src/elasticity/structural_element_base.cpp b/src/elasticity/structural_element_base.cpp index 07ee820e..411976c4 100644 --- a/src/elasticity/structural_element_base.cpp +++ b/src/elasticity/structural_element_base.cpp @@ -36,10 +36,9 @@ MAST::StructuralElementBase::StructuralElementBase(MAST::SystemInitialization& sys, - MAST::AssemblyBase& assembly, const MAST::GeomElem& elem, const MAST::ElementPropertyCardBase& p): -MAST::ElementBase(sys, assembly, elem), +MAST::ElementBase(sys, elem), follower_forces (false), _property (p), _incompatible_sol (nullptr) { @@ -516,7 +515,7 @@ inertial_residual_boundary_velocity (const MAST::FunctionBase& p, RealMatrixX& jac) { // prepare the side finite element - std::unique_ptr fe(_elem.init_side_fe(s, false)); + std::unique_ptr fe(_elem.init_side_fe(s, false, false)); std::vector JxW_Vn = fe->get_JxW(); const std::vector& xyz = fe->get_xyz(); @@ -658,6 +657,22 @@ side_external_residual(bool request_jacobian, it->first, **bc_it); break; + + + case MAST::SURFACE_TRACTION: + surface_traction_residual(request_jacobian, + f, jac, + it->first, + **bc_it); + break; + + + case MAST::SURFACE_TRACTION_SHIFTED_BOUNDARY: + surface_traction_residual_shifted_boundary(request_jacobian, + f, jac, + it->first, + **bc_it); + break; case MAST::PISTON_THEORY: @@ -670,6 +685,7 @@ side_external_residual(bool request_jacobian, break; + case MAST::BOUNDARY_VELOCITY: case MAST::DIRICHLET: // nothing to be done here break; @@ -711,6 +727,7 @@ linearized_side_external_residual // apply all the types of loading switch ((*bc_it)->type()) { + case MAST::BOUNDARY_VELOCITY: case MAST::DIRICHLET: // nothing to be done here break; @@ -765,6 +782,7 @@ linearized_frequency_domain_side_external_residual break; + case MAST::BOUNDARY_VELOCITY: case MAST::DIRICHLET: // nothing to be done here break; @@ -985,6 +1003,24 @@ side_external_residual_sensitivity(const MAST::FunctionBase& p, break; + case MAST::SURFACE_TRACTION: + surface_traction_residual_sensitivity(p, + request_jacobian, + f, jac, + it->first, + **bc_it); + break; + + + case MAST::SURFACE_TRACTION_SHIFTED_BOUNDARY: + surface_traction_residual_shifted_boundary_sensitivity(p, + request_jacobian, + f, jac, + it->first, + **bc_it); + break; + + case MAST::PISTON_THEORY: piston_theory_residual_sensitivity(p, request_jacobian, @@ -996,6 +1032,7 @@ side_external_residual_sensitivity(const MAST::FunctionBase& p, break; + case MAST::BOUNDARY_VELOCITY: case MAST::DIRICHLET: // nothing to be done here break; @@ -1290,7 +1327,7 @@ surface_pressure_boundary_velocity(const MAST::FunctionBase& p, libmesh_assert(!follower_forces); // not implemented yet for follower forces // prepare the side finite element - std::unique_ptr fe(_elem.init_side_fe(s, false)); + std::unique_ptr fe(_elem.init_side_fe(s, false, false)); std::vector JxW_Vn = fe->get_JxW(); const std::vector& xyz = fe->get_xyz(); @@ -1642,7 +1679,6 @@ transform_vector_to_global_system(const ValType& local_vec, std::unique_ptr MAST::build_structural_element(MAST::SystemInitialization& sys, - MAST::AssemblyBase& assembly, const MAST::GeomElem& elem, const MAST::ElementPropertyCardBase& p) { @@ -1650,15 +1686,15 @@ MAST::build_structural_element(MAST::SystemInitialization& sys, switch (elem.dim()) { case 1: - e.reset(new MAST::StructuralElement1D(sys, assembly, elem, p)); + e.reset(new MAST::StructuralElement1D(sys, elem, p)); break; case 2: - e.reset(new MAST::StructuralElement2D(sys, assembly, elem, p)); + e.reset(new MAST::StructuralElement2D(sys, elem, p)); break; case 3: - e.reset(new MAST::StructuralElement3D(sys, assembly, elem, p)); + e.reset(new MAST::StructuralElement3D(sys, elem, p)); break; default: diff --git a/src/elasticity/structural_element_base.h b/src/elasticity/structural_element_base.h index a45d2ab7..57897db3 100644 --- a/src/elasticity/structural_element_base.h +++ b/src/elasticity/structural_element_base.h @@ -47,7 +47,6 @@ namespace MAST { * Constructor. */ StructuralElementBase(MAST::SystemInitialization& sys, - MAST::AssemblyBase& assembly, const MAST::GeomElem& elem, const MAST::ElementPropertyCardBase& p); @@ -454,6 +453,52 @@ namespace MAST { protected: + /*! + * Calculates the force vector and Jacobian due to surface traction. + */ + virtual bool + surface_traction_residual(bool request_jacobian, + RealVectorX& f, + RealMatrixX& jac, + const unsigned int side, + MAST::BoundaryConditionBase& bc) = 0; + + /*! + * Calculates the sensitivity of element vector and matrix quantities for surface traction + * boundary condition. + */ + virtual bool + surface_traction_residual_sensitivity(const MAST::FunctionBase& p, + bool request_jacobian, + RealVectorX& f, + RealMatrixX& jac, + const unsigned int side, + MAST::BoundaryConditionBase& bc) = 0; + + + /*! + * Calculates the sensitivity of force vector and Jacobian due to surface traction and + * sensitiity due to boundary movement. + */ + virtual bool + surface_traction_residual_shifted_boundary(bool request_jacobian, + RealVectorX& f, + RealMatrixX& jac, + const unsigned int side, + MAST::BoundaryConditionBase& bc) = 0; + + /*! + * Calculates the sensitivity of force vector and Jacobian due to surface traction and + * sensitiity due to boundary movement. + */ + virtual bool + surface_traction_residual_shifted_boundary_sensitivity(const MAST::FunctionBase& p, + bool request_jacobian, + RealVectorX& f, + RealMatrixX& jac, + const unsigned int side, + MAST::BoundaryConditionBase& bc) = 0; + /*! * Calculates the force vector and Jacobian due to surface pressure. */ @@ -786,7 +831,6 @@ namespace MAST { */ std::unique_ptr build_structural_element(MAST::SystemInitialization& sys, - MAST::AssemblyBase& assembly, const MAST::GeomElem& elem, const MAST::ElementPropertyCardBase& p); diff --git a/src/elasticity/structural_modal_eigenproblem_assembly.cpp b/src/elasticity/structural_modal_eigenproblem_assembly.cpp index 426f1f10..088a8dc7 100644 --- a/src/elasticity/structural_modal_eigenproblem_assembly.cpp +++ b/src/elasticity/structural_modal_eigenproblem_assembly.cpp @@ -32,7 +32,8 @@ MAST::StructuralModalEigenproblemAssemblyElemOperations:: StructuralModalEigenproblemAssemblyElemOperations(): -MAST::EigenproblemAssemblyElemOperations() { } +MAST::EigenproblemAssemblyElemOperations(), +_incompatible_sol_assembly(nullptr) { } @@ -151,6 +152,62 @@ elem_sensitivity_calculations(const MAST::FunctionBase& f, +void +MAST::StructuralModalEigenproblemAssemblyElemOperations:: +elem_topology_sensitivity_calculations(const MAST::FunctionBase& f, + bool base_sol, + RealMatrixX& mat_A, + RealMatrixX& mat_B) { + + libmesh_assert(_physics_elem); + libmesh_assert(f.is_topology_parameter()); + + RealVectorX vec = RealVectorX::Zero(mat_A.rows()); // dummy vector + RealMatrixX mat = RealMatrixX::Zero(mat_A.rows(), mat_A.cols()); // dummy matrix + mat_A.setZero(); + mat_B.setZero(); + + std::pair*, unsigned int> + val = this->get_elem_boundary_velocity_data(); + + if (val.first) { + + MAST::StructuralElementBase& e = + dynamic_cast(*_physics_elem); + + e.internal_residual_boundary_velocity(f, + val.second, + *val.first, + true, + vec, + mat_A); + e.volume_external_residual_boundary_velocity(f, + val.second, + *val.first, + _discipline->volume_loads(), + true, + vec, + mat_A); + + e.inertial_residual_boundary_velocity(f, + val.second, + *val.first, + true, + vec, + mat_B, + mat, + mat_A); + + // if the linearization is about a base state, then the sensitivity of + // the base state will influence the sensitivity of the Jacobian + if (base_sol) + libmesh_assert(false); // to be implemented + //e.internal_residual_jac_dot_state_sensitivity(mat_A); + } +} + + + void MAST::StructuralModalEigenproblemAssemblyElemOperations:: elem_topology_sensitivity_calculations(const MAST::FunctionBase& f, @@ -242,6 +299,6 @@ init(const MAST::GeomElem& elem) { (_discipline->get_property_card(elem)); _physics_elem = - MAST::build_structural_element(*_system, *_assembly, elem, p).release(); + MAST::build_structural_element(*_system, elem, p).release(); } diff --git a/src/elasticity/structural_modal_eigenproblem_assembly.h b/src/elasticity/structural_modal_eigenproblem_assembly.h index 503fada4..5dd5286e 100644 --- a/src/elasticity/structural_modal_eigenproblem_assembly.h +++ b/src/elasticity/structural_modal_eigenproblem_assembly.h @@ -88,6 +88,16 @@ namespace MAST { RealMatrixX& mat_A, RealMatrixX& mat_B); + /*! + * performs the element topology sensitivity calculations over \p elem. + */ + virtual void + elem_topology_sensitivity_calculations(const MAST::FunctionBase& f, + bool base_sol, + RealMatrixX& mat_A, + RealMatrixX& mat_B); + + /*! * performs the element topology sensitivity calculations over \p elem. */ diff --git a/src/elasticity/structural_nonlinear_assembly.cpp b/src/elasticity/structural_nonlinear_assembly.cpp index 71482a53..1366f446 100644 --- a/src/elasticity/structural_nonlinear_assembly.cpp +++ b/src/elasticity/structural_nonlinear_assembly.cpp @@ -103,7 +103,7 @@ init(const MAST::GeomElem& elem) { (_discipline->get_property_card(elem)); _physics_elem = - MAST::build_structural_element(*_system, *_assembly, elem, p).release(); + MAST::build_structural_element(*_system, elem, p).release(); } @@ -198,6 +198,49 @@ elem_sensitivity_calculations(const MAST::FunctionBase& f, +void +MAST::StructuralNonlinearAssemblyElemOperations:: +elem_topology_sensitivity_calculations(const MAST::FunctionBase& f, + RealVectorX& vec) { + + libmesh_assert(_physics_elem); + libmesh_assert(f.is_topology_parameter()); + + std::pair*, unsigned int> + val = this->get_elem_boundary_velocity_data(); + + if (val.first) { + + MAST::StructuralElementBase& e = + dynamic_cast(*_physics_elem); + + vec.setZero(); + RealMatrixX + dummy = RealMatrixX::Zero(vec.size(), vec.size()); + + e.internal_residual_boundary_velocity(f, + val.second, + *val.first, + false, + vec, + dummy); + e.volume_external_residual_boundary_velocity(f, + val.second, + *val.first, + _discipline->volume_loads(), + false, + vec, + dummy); + /*e.side_external_residual_sensitivity(f, false, + vec, + dummy, + dummy, + _discipline->side_loads());*/ + } +} + + + void MAST::StructuralNonlinearAssemblyElemOperations:: elem_topology_sensitivity_calculations(const MAST::FunctionBase& f, diff --git a/src/elasticity/structural_nonlinear_assembly.h b/src/elasticity/structural_nonlinear_assembly.h index 3c9d37b8..cb83b79f 100644 --- a/src/elasticity/structural_nonlinear_assembly.h +++ b/src/elasticity/structural_nonlinear_assembly.h @@ -104,6 +104,15 @@ namespace MAST { libmesh_assert(false); // to be implemented } + /*! + * performs the element topology sensitivity calculations over \p elem, + * and returns the element residual sensitivity in \p vec . + */ + virtual void + elem_topology_sensitivity_calculations(const MAST::FunctionBase& f, + RealVectorX& vec); + + /*! * performs the element topology sensitivity calculations over \p elem, * and returns the element residual sensitivity in \p vec . diff --git a/src/elasticity/structural_transient_assembly.cpp b/src/elasticity/structural_transient_assembly.cpp index 91e90352..0e1f4728 100644 --- a/src/elasticity/structural_transient_assembly.cpp +++ b/src/elasticity/structural_transient_assembly.cpp @@ -242,6 +242,6 @@ MAST::StructuralTransientAssemblyElemOperations::init(const MAST::GeomElem& elem dynamic_cast(_discipline->get_property_card(elem)); _physics_elem = - MAST::build_structural_element(*_system, *_assembly, elem, p).release(); + MAST::build_structural_element(*_system, elem, p).release(); } diff --git a/src/fluid/conservative_fluid_element_base.cpp b/src/fluid/conservative_fluid_element_base.cpp index a9dd16a6..97b23573 100644 --- a/src/fluid/conservative_fluid_element_base.cpp +++ b/src/fluid/conservative_fluid_element_base.cpp @@ -35,11 +35,10 @@ MAST::ConservativeFluidElementBase:: ConservativeFluidElementBase(MAST::SystemInitialization& sys, - MAST::AssemblyBase& assembly, const MAST::GeomElem& elem, const MAST::FlightCondition& f): MAST::FluidElemBase(elem.dim(), f), -MAST::ElementBase(sys, assembly, elem) { +MAST::ElementBase(sys, elem) { } @@ -775,7 +774,7 @@ MAST::ConservativeFluidElementBase::side_integrated_force(const unsigned int s, RealMatrixX* dfdX) { // prepare the side finite element - std::unique_ptr fe(_elem.init_side_fe(s, if_viscous())); + std::unique_ptr fe(_elem.init_side_fe(s, if_viscous(), false)); const std::vector &JxW = fe->get_JxW(); const std::vector& normals = fe->get_normals_for_reference_coordinate(); @@ -884,7 +883,7 @@ side_integrated_force_sensitivity(const MAST::FunctionBase& p, RealVectorX& f) { // prepare the side finite element - std::unique_ptr fe(_elem.init_side_fe(s, if_viscous())); + std::unique_ptr fe(_elem.init_side_fe(s, if_viscous(), false)); const std::vector &JxW = fe->get_JxW(); const std::vector& normals = fe->get_normals_for_reference_coordinate(); @@ -980,7 +979,7 @@ symmetry_surface_residual(bool request_jacobian, MAST::BoundaryConditionBase& bc) { // prepare the side finite element - std::unique_ptr fe(_elem.init_side_fe(s, false)); + std::unique_ptr fe(_elem.init_side_fe(s, false, false)); const std::vector &JxW = fe->get_JxW(); const std::vector& normals = fe->get_normals_for_reference_coordinate(); @@ -1087,7 +1086,7 @@ slip_wall_surface_residual(bool request_jacobian, // qi ni = 0 (since heat flux occurs only on no-slip wall and far-field bc) // prepare the side finite element - std::unique_ptr fe(_elem.init_side_fe(s, false)); + std::unique_ptr fe(_elem.init_side_fe(s, false, false)); const std::vector &JxW = fe->get_JxW(); const std::vector& normals = fe->get_normals_for_reference_coordinate(); @@ -1231,7 +1230,7 @@ linearized_slip_wall_surface_residual(bool request_jacobian, // qi ni = 0 (since heat flux occurs only on no-slip wall and far-field bc) // prepare the side finite element - std::unique_ptr fe(_elem.init_side_fe(s, false)); + std::unique_ptr fe(_elem.init_side_fe(s, false, false)); const std::vector &JxW = fe->get_JxW(); const std::vector& normals = fe->get_normals_for_reference_coordinate(); @@ -1434,7 +1433,7 @@ noslip_wall_surface_residual(bool request_jacobian, // qi ni = 0 (since heat flux occurs only on no-slip wall and far-field bc) // prepare the side finite element - std::unique_ptr fe(_elem.init_side_fe(s, true)); + std::unique_ptr fe(_elem.init_side_fe(s, true, false)); const std::vector &JxW = fe->get_JxW(); const std::vector& normals = fe->get_normals_for_reference_coordinate(); @@ -1637,7 +1636,7 @@ far_field_surface_residual(bool request_jacobian, // -- f_diff_i ni = f_diff (evaluation of diffusion flux based on domain solution) // prepare the side finite element - std::unique_ptr fe(_elem.init_side_fe(s, false)); + std::unique_ptr fe(_elem.init_side_fe(s, false, false)); const std::vector &JxW = fe->get_JxW(); const std::vector& normals = fe->get_normals_for_reference_coordinate(); @@ -1772,7 +1771,7 @@ far_field_surface_residual_sensitivity(const MAST::FunctionBase& p, // -- f_diff_i ni = f_diff (evaluation of diffusion flux based on domain solution) // prepare the side finite element - std::unique_ptr fe(_elem.init_side_fe(s, false)); + std::unique_ptr fe(_elem.init_side_fe(s, false, false)); const std::vector &JxW = fe->get_JxW(); const std::vector& normals = fe->get_normals_for_reference_coordinate(); @@ -1870,7 +1869,7 @@ _calculate_surface_integrated_load(bool request_derivative, MAST::OutputAssemblyElemOperations& output) { // prepare the side finite element - std::unique_ptr fe(_elem.init_side_fe(s, false)); + std::unique_ptr fe(_elem.init_side_fe(s, false, false)); const std::vector &JxW = fe->get_JxW(); const std::vector& normals = fe->get_normals_for_reference_coordinate(); diff --git a/src/fluid/conservative_fluid_element_base.h b/src/fluid/conservative_fluid_element_base.h index d11d163f..c568553f 100644 --- a/src/fluid/conservative_fluid_element_base.h +++ b/src/fluid/conservative_fluid_element_base.h @@ -46,7 +46,6 @@ namespace MAST { public: ConservativeFluidElementBase(MAST::SystemInitialization& sys, - MAST::AssemblyBase& assembly, const MAST::GeomElem& elem, const MAST::FlightCondition& f); diff --git a/src/fluid/conservative_fluid_transient_assembly.cpp b/src/fluid/conservative_fluid_transient_assembly.cpp index f20831ef..22a070c6 100644 --- a/src/fluid/conservative_fluid_transient_assembly.cpp +++ b/src/fluid/conservative_fluid_transient_assembly.cpp @@ -152,6 +152,6 @@ init(const MAST::GeomElem& elem) { (_assembly->discipline()).flight_condition(); _physics_elem = - new MAST::ConservativeFluidElementBase(*_system, *_assembly, elem, p); + new MAST::ConservativeFluidElementBase(*_system, elem, p); } diff --git a/src/fluid/frequency_domain_linearized_complex_assembly.cpp b/src/fluid/frequency_domain_linearized_complex_assembly.cpp index 2df79b30..f15f8457 100644 --- a/src/fluid/frequency_domain_linearized_complex_assembly.cpp +++ b/src/fluid/frequency_domain_linearized_complex_assembly.cpp @@ -122,7 +122,7 @@ init(const MAST::GeomElem& elem) { FrequencyDomainLinearizedConservativeFluidElem *freq_elem = - new MAST::FrequencyDomainLinearizedConservativeFluidElem(*_system, *_assembly, elem, p); + new MAST::FrequencyDomainLinearizedConservativeFluidElem(*_system, elem, p); freq_elem->freq = _frequency; _physics_elem = freq_elem; diff --git a/src/fluid/frequency_domain_linearized_conservative_fluid_elem.cpp b/src/fluid/frequency_domain_linearized_conservative_fluid_elem.cpp index 44082a8a..f18f7556 100644 --- a/src/fluid/frequency_domain_linearized_conservative_fluid_elem.cpp +++ b/src/fluid/frequency_domain_linearized_conservative_fluid_elem.cpp @@ -36,10 +36,9 @@ MAST::FrequencyDomainLinearizedConservativeFluidElem:: FrequencyDomainLinearizedConservativeFluidElem(MAST::SystemInitialization& sys, - MAST::AssemblyBase& assembly, const MAST::GeomElem& elem, const MAST::FlightCondition& f): -MAST::ConservativeFluidElementBase(sys, assembly, elem, f), +MAST::ConservativeFluidElementBase(sys, elem, f), freq(nullptr) { @@ -487,7 +486,7 @@ slip_wall_surface_residual(bool request_jacobian, // qi ni = 0 (since heat flux occurs only on no-slip wall and far-field bc) // prepare the side finite element - std::unique_ptr fe(_elem.init_side_fe(s, false)); + std::unique_ptr fe(_elem.init_side_fe(s, false, false)); const std::vector &JxW = fe->get_JxW(); const std::vector& normals = fe->get_normals_for_reference_coordinate(); @@ -717,7 +716,7 @@ slip_wall_surface_residual_sensitivity(const MAST::FunctionBase& p, // qi ni = 0 (since heat flux occurs only on no-slip wall and far-field bc) // prepare the side finite element - std::unique_ptr fe(_elem.init_side_fe(s, false)); + std::unique_ptr fe(_elem.init_side_fe(s, false, false)); const std::vector &JxW = fe->get_JxW(); const std::vector& normals = fe->get_normals_for_reference_coordinate(); diff --git a/src/fluid/frequency_domain_linearized_conservative_fluid_elem.h b/src/fluid/frequency_domain_linearized_conservative_fluid_elem.h index c59bd49e..90cb2bb4 100644 --- a/src/fluid/frequency_domain_linearized_conservative_fluid_elem.h +++ b/src/fluid/frequency_domain_linearized_conservative_fluid_elem.h @@ -38,7 +38,6 @@ namespace MAST { FrequencyDomainLinearizedConservativeFluidElem (MAST::SystemInitialization& sys, - MAST::AssemblyBase& assembly, const MAST::GeomElem& elem, const MAST::FlightCondition& f); diff --git a/src/fluid/integrated_force_output.cpp b/src/fluid/integrated_force_output.cpp index 82f5830d..e531d0e3 100644 --- a/src/fluid/integrated_force_output.cpp +++ b/src/fluid/integrated_force_output.cpp @@ -62,7 +62,7 @@ MAST::IntegratedForceOutput::init(const MAST::GeomElem& elem) { (_assembly->discipline()).flight_condition(); _physics_elem = - new MAST::ConservativeFluidElementBase(*_system, *_assembly, elem, p); + new MAST::ConservativeFluidElementBase(*_system, elem, p); } diff --git a/src/fluid/integrated_force_output.h b/src/fluid/integrated_force_output.h index 3c67d88e..9e5e8969 100644 --- a/src/fluid/integrated_force_output.h +++ b/src/fluid/integrated_force_output.h @@ -144,6 +144,17 @@ namespace MAST { libmesh_error(); // not yet implemented } + /*! + * this evaluates all relevant topological sensitivity components on + * the element. + * This is only done on the current element for which this + * object has been initialized. + */ + virtual void + evaluate_topology_sensitivity(const MAST::FunctionBase& f) { + libmesh_error(); // not yet implemented + } + /*! * this evaluates all relevant topological sensitivity components on * the element. diff --git a/src/heat_conduction/heat_conduction_elem_base.cpp b/src/heat_conduction/heat_conduction_elem_base.cpp index 474182da..3ee0a2fa 100644 --- a/src/heat_conduction/heat_conduction_elem_base.cpp +++ b/src/heat_conduction/heat_conduction_elem_base.cpp @@ -34,10 +34,9 @@ MAST::HeatConductionElementBase:: HeatConductionElementBase(MAST::SystemInitialization& sys, - MAST::AssemblyBase& assembly, const MAST::GeomElem& elem, const MAST::ElementPropertyCardBase& p): -MAST::ElementBase (sys, assembly, elem), +MAST::ElementBase (sys, elem), _property (p) { } @@ -605,7 +604,7 @@ internal_residual_boundary_velocity (const MAST::FunctionBase& p, const MAST::FieldFunction& vel_f) { // prepare the side finite element - std::unique_ptr fe(_elem.init_side_fe(s, true)); + std::unique_ptr fe(_elem.init_side_fe(s, true, false)); std::vector JxW_Vn = fe->get_JxW(); const std::vector& xyz = fe->get_xyz(); @@ -744,7 +743,7 @@ velocity_residual_boundary_velocity (const MAST::FunctionBase& p, const MAST::FieldFunction& vel_f) { // prepare the side finite element - std::unique_ptr fe(_elem.init_side_fe(s, false)); + std::unique_ptr fe(_elem.init_side_fe(s, false, false)); std::vector JxW_Vn = fe->get_JxW(); const std::vector& xyz = fe->get_xyz(); @@ -816,7 +815,7 @@ surface_flux_residual(bool request_jacobian, MAST::BoundaryConditionBase& bc) { // prepare the side finite element - std::unique_ptr fe(_elem.init_side_fe(s, false)); + std::unique_ptr fe(_elem.init_side_fe(s, false, false)); // get the function from this boundary condition @@ -895,7 +894,7 @@ surface_flux_residual_sensitivity(const MAST::FunctionBase& p, MAST::BoundaryConditionBase& bc) { // prepare the side finite element - std::unique_ptr fe(_elem.init_side_fe(s, false)); + std::unique_ptr fe(_elem.init_side_fe(s, false, false)); // get the function from this boundary condition @@ -976,7 +975,7 @@ surface_flux_boundary_velocity(const MAST::FunctionBase& p, // prepare the side finite element - std::unique_ptr fe(_elem.init_side_fe(s, false)); + std::unique_ptr fe(_elem.init_side_fe(s, false, false)); std::vector JxW_Vn = fe->get_JxW(); const std::vector& xyz = fe->get_xyz(); @@ -1032,7 +1031,7 @@ surface_convection_residual(bool request_jacobian, MAST::BoundaryConditionBase& bc) { // prepare the side finite element - std::unique_ptr fe(_elem.init_side_fe(s, false)); + std::unique_ptr fe(_elem.init_side_fe(s, false, false)); // get the function from this boundary condition const MAST::FieldFunction @@ -1147,7 +1146,7 @@ surface_convection_residual_sensitivity(const MAST::FunctionBase& p, MAST::BoundaryConditionBase& bc) { // prepare the side finite element - std::unique_ptr fe(_elem.init_side_fe(s, false)); + std::unique_ptr fe(_elem.init_side_fe(s, false, false)); // get the function from this boundary condition const MAST::FieldFunction @@ -1256,7 +1255,7 @@ surface_convection_boundary_velocity(const MAST::FunctionBase& p, MAST::BoundaryConditionBase& bc) { // prepare the side finite element - std::unique_ptr fe(_elem.init_side_fe(s, false)); + std::unique_ptr fe(_elem.init_side_fe(s, false, false)); std::vector JxW_Vn = fe->get_JxW(); const std::vector& xyz = fe->get_xyz(); @@ -1327,7 +1326,7 @@ surface_radiation_residual(bool request_jacobian, MAST::BoundaryConditionBase& bc) { // prepare the side finite element - std::unique_ptr fe(_elem.init_side_fe(s, false)); + std::unique_ptr fe(_elem.init_side_fe(s, false, false)); // get the function from this boundary condition const MAST::FieldFunction @@ -1447,7 +1446,7 @@ surface_radiation_residual_sensitivity(const MAST::FunctionBase& p, // prepare the side finite element - std::unique_ptr fe(_elem.init_side_fe(s, false)); + std::unique_ptr fe(_elem.init_side_fe(s, false, false)); // get the function from this boundary condition const MAST::FieldFunction @@ -1551,7 +1550,7 @@ surface_radiation_boundary_velocity(const MAST::FunctionBase& p, MAST::BoundaryConditionBase& bc) { // prepare the side finite element - std::unique_ptr fe(_elem.init_side_fe(s, false)); + std::unique_ptr fe(_elem.init_side_fe(s, false, false)); std::vector JxW_Vn = fe->get_JxW(); const std::vector& xyz = fe->get_xyz(); @@ -1703,7 +1702,7 @@ volume_heat_source_boundary_velocity(const MAST::FunctionBase& p, MAST::BoundaryConditionBase& bc) { // prepare the side finite element - std::unique_ptr fe(_elem.init_side_fe(s, false)); + std::unique_ptr fe(_elem.init_side_fe(s, false, false)); std::vector JxW_Vn = fe->get_JxW(); const std::vector& xyz = fe->get_xyz(); diff --git a/src/heat_conduction/heat_conduction_elem_base.h b/src/heat_conduction/heat_conduction_elem_base.h index 1bafc055..dd16f1f3 100644 --- a/src/heat_conduction/heat_conduction_elem_base.h +++ b/src/heat_conduction/heat_conduction_elem_base.h @@ -58,7 +58,6 @@ namespace MAST { * Constructor */ HeatConductionElementBase(MAST::SystemInitialization& sys, - MAST::AssemblyBase& assembly, const MAST::GeomElem& elem, const MAST::ElementPropertyCardBase& p); diff --git a/src/heat_conduction/heat_conduction_nonlinear_assembly.cpp b/src/heat_conduction/heat_conduction_nonlinear_assembly.cpp index 8f7cc60a..7fbcd6cd 100644 --- a/src/heat_conduction/heat_conduction_nonlinear_assembly.cpp +++ b/src/heat_conduction/heat_conduction_nonlinear_assembly.cpp @@ -72,7 +72,7 @@ init(const MAST::GeomElem& elem) { (_discipline->get_property_card(elem)); _physics_elem = - new MAST::HeatConductionElementBase(*_system, *_assembly, elem, p); + new MAST::HeatConductionElementBase(*_system, elem, p); } @@ -118,6 +118,42 @@ elem_sensitivity_calculations(const MAST::FunctionBase& f, } +void +MAST::HeatConductionNonlinearAssemblyElemOperations:: +elem_topology_sensitivity_calculations(const MAST::FunctionBase& f, + RealVectorX& vec) { + + libmesh_assert(_physics_elem); + libmesh_assert(f.is_topology_parameter()); + + std::pair*, unsigned int> + val = this->get_elem_boundary_velocity_data(); + + if (val.first) { + + MAST::HeatConductionElementBase& e = + dynamic_cast(*_physics_elem); + + vec.setZero(); + RealMatrixX + dummy = RealMatrixX::Zero(vec.size(), vec.size()); + + e.internal_residual_boundary_velocity(f, vec, + val.second, + *val.first); + e.volume_external_residual_boundary_velocity(f, vec, + val.second, + *val.first, + _discipline->volume_loads()); + /*e.side_external_residual_sensitivity(f, false, + vec, + dummy, + dummy, + _discipline->side_loads());*/ + } +} + + void MAST::HeatConductionNonlinearAssemblyElemOperations:: elem_topology_sensitivity_calculations(const MAST::FunctionBase& f, diff --git a/src/heat_conduction/heat_conduction_nonlinear_assembly.h b/src/heat_conduction/heat_conduction_nonlinear_assembly.h index 18cd5fd4..0696e145 100644 --- a/src/heat_conduction/heat_conduction_nonlinear_assembly.h +++ b/src/heat_conduction/heat_conduction_nonlinear_assembly.h @@ -74,6 +74,15 @@ namespace MAST { libmesh_assert(false); // to be implemented } + /*! + * performs the element topology sensitivity calculations over \p elem, + * and returns the element residual sensitivity in \p vec . + */ + virtual void + elem_topology_sensitivity_calculations(const MAST::FunctionBase& f, + RealVectorX& vec); + + /*! * performs the element topology sensitivity calculations over \p elem, * and returns the element residual sensitivity in \p vec . diff --git a/src/heat_conduction/heat_conduction_transient_assembly.cpp b/src/heat_conduction/heat_conduction_transient_assembly.cpp index 463285e9..0705fdfb 100644 --- a/src/heat_conduction/heat_conduction_transient_assembly.cpp +++ b/src/heat_conduction/heat_conduction_transient_assembly.cpp @@ -132,6 +132,6 @@ init(const MAST::GeomElem& elem) { dynamic_cast(_discipline->get_property_card(elem)); _physics_elem = - new MAST::HeatConductionElementBase(*_system, *_assembly, elem, p); + new MAST::HeatConductionElementBase(*_system, elem, p); } diff --git a/src/level_set/CMakeLists.txt b/src/level_set/CMakeLists.txt index ae643d71..69ab7b76 100644 --- a/src/level_set/CMakeLists.txt +++ b/src/level_set/CMakeLists.txt @@ -2,10 +2,16 @@ target_sources(mast PRIVATE ${CMAKE_CURRENT_LIST_DIR}/filter_base.cpp ${CMAKE_CURRENT_LIST_DIR}/filter_base.h + ${CMAKE_CURRENT_LIST_DIR}/heaviside_elem_homogenization_function.cpp + ${CMAKE_CURRENT_LIST_DIR}/heaviside_elem_homogenization_function.h + ${CMAKE_CURRENT_LIST_DIR}/homogenized_density_function_base.cpp + ${CMAKE_CURRENT_LIST_DIR}/homogenized_density_function_base.h ${CMAKE_CURRENT_LIST_DIR}/indicator_function_constrain_dofs.cpp ${CMAKE_CURRENT_LIST_DIR}/indicator_function_constrain_dofs.h ${CMAKE_CURRENT_LIST_DIR}/interface_dof_handler.cpp ${CMAKE_CURRENT_LIST_DIR}/interface_dof_handler.h + ${CMAKE_CURRENT_LIST_DIR}/intersected_elem_homogenization_function.cpp + ${CMAKE_CURRENT_LIST_DIR}/intersected_elem_homogenization_function.h ${CMAKE_CURRENT_LIST_DIR}/level_set_boundary_velocity.cpp ${CMAKE_CURRENT_LIST_DIR}/level_set_boundary_velocity.h ${CMAKE_CURRENT_LIST_DIR}/level_set_constrain_dofs.cpp @@ -37,7 +43,11 @@ target_sources(mast ${CMAKE_CURRENT_LIST_DIR}/material_patch.cpp ${CMAKE_CURRENT_LIST_DIR}/material_patch.h ${CMAKE_CURRENT_LIST_DIR}/sub_cell_fe.cpp - ${CMAKE_CURRENT_LIST_DIR}/sub_cell_fe.h) + ${CMAKE_CURRENT_LIST_DIR}/sub_cell_fe.h + ${CMAKE_CURRENT_LIST_DIR}/sub_elem_mesh_refinement.cpp + ${CMAKE_CURRENT_LIST_DIR}/sub_elem_mesh_refinement.h + ${CMAKE_CURRENT_LIST_DIR}/sub_elem_node_map.h + ${CMAKE_CURRENT_LIST_DIR}/sub_elem_node_map.cpp) # Install MAST headers for this directory. install(DIRECTORY ./ DESTINATION include/level_set diff --git a/src/level_set/filter_base.cpp b/src/level_set/filter_base.cpp index ff122359..678b8272 100644 --- a/src/level_set/filter_base.cpp +++ b/src/level_set/filter_base.cpp @@ -1,21 +1,21 @@ /* -* MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit -* Copyright (C) 2013-2019 Manav Bhatia -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 2.1 of the License, or (at your option) any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ + * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit + * Copyright (C) 2013-2019 Manav Bhatia + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ // C++ includes #include @@ -27,7 +27,9 @@ #include "libmesh/mesh_base.h" #include "libmesh/node.h" #include "libmesh/numeric_vector.h" - +#ifdef LIBMESH_HAVE_NANOFLANN +#include "libmesh/nanoflann.hpp" +#endif MAST::FilterBase::FilterBase(libMesh::System& sys, @@ -40,7 +42,11 @@ _dv_dof_ids (dv_dof_ids) { libmesh_assert_greater(radius, 0.); - _init(); +#ifdef LIBMESH_HAVE_NANOFLANN + _init2(); // KD-tree search using NanoFlann +#else + _init(); // linear filter search +#endif } @@ -95,7 +101,7 @@ MAST::FilterBase::compute_filtered_values(const std::vector& input, libmesh_assert_equal_to(input.size(), _filter_map.size()); libmesh_assert_equal_to(output.size(), _filter_map.size()); - + std::fill(output.begin(), output.end(), 0.); std::map>>::const_iterator @@ -147,6 +153,183 @@ if_elem_in_domain_of_influence(const libMesh::Elem& elem, } +#ifdef LIBMESH_HAVE_NANOFLANN +// Nanoflann uses "duck typing" to allow users to define their own adaptors... +template +class NanoflannMeshAdaptor +{ +private: + // Constant reference to the Mesh we are adapting for use in Nanoflann + const libMesh::MeshBase & _mesh; + +public: + NanoflannMeshAdaptor (const libMesh::MeshBase & mesh) : + _mesh(mesh) + {} + + /** + * libMesh \p Point coordinate type + */ + typedef Real coord_t; + + /** + * Must return the number of data points + */ + inline size_t + kdtree_get_point_count() const { return _mesh.n_nodes(); } + + /** + * Returns the distance between the vector "p1[0:size-1]" + * and the data point with index "idx_p2" stored in _mesh + */ + inline coord_t + kdtree_distance(const coord_t * p1, + const size_t idx_p2, + size_t size) const { + + libmesh_assert_equal_to (size, Dim); + + // Construct a libmesh Point object from the input coord_t. This + // assumes LIBMESH_DIM==3. + libMesh::Point point1(p1[0], + size > 1 ? p1[1] : 0., + size > 2 ? p1[2] : 0.); + + // Get the referred-to point from the Mesh + const libMesh::Point & point2 = _mesh.point(idx_p2); + + // Compute Euclidean distance + return (point1 - point2).norm_sq(); + } + + /** + * Returns the dim'th component of the idx'th point in the class: + * Since this is inlined and the "dim" argument is typically an immediate value, the + * "if's" are actually solved at compile time. + */ + inline coord_t + kdtree_get_pt(const size_t idx, int dim) const + { + libmesh_assert_less (dim, (int) Dim); + libmesh_assert_less (idx, _mesh.n_nodes()); + libmesh_assert_less (dim, 3); + + return _mesh.point(idx)(dim); + } + + /** + * Optional bounding-box computation: return false to default to a standard bbox computation loop. + * Return true if the BBOX was already computed by the class and returned in "bb" so it can be + * avoided to redo it again. Look at bb.size() to find out the expected dimensionality + * (e.g. 2 or 3 for point clouds) + */ + template + bool kdtree_get_bbox(BBOX & /* bb */) const { return false; } +}; + + +void +MAST::FilterBase::_init2() { + + //libmesh_assert(!_filter_map.size()); + + libMesh::MeshBase& mesh = _level_set_system.get_mesh(); + + // currently implemented for replicated mesh + libmesh_assert(mesh.is_replicated()); + + // Loop over nodes to try and detect duplicates. We use nanoflann + // for this, inspired by + // https://gist.github.com/jwpeterson/7a36f9f794df67d51126#file-detect_slit-cc-L65 + // which was inspired by nanoflann example in libMesh source: + // contrib/nanoflann/examples/pointcloud_adaptor_example.cpp + + // Declare a type templated on NanoflannMeshAdaptor + typedef nanoflann::L2_Simple_Adaptor > adatper_t; + + // Declare a KDTree type based on NanoflannMeshAdaptor + typedef nanoflann::KDTreeSingleIndexAdaptor, 3> kd_tree_t; + + // Build adaptor and tree objects + NanoflannMeshAdaptor<3> mesh_adaptor(mesh); + kd_tree_t kd_tree(3, mesh_adaptor, nanoflann::KDTreeSingleIndexAdaptorParams(/*max leaf=*/10)); + + // Construct the tree + kd_tree.buildIndex(); + + Real + d_12 = 0., + sum = 0.; + + unsigned int + dof_1, + dof_2; + + libMesh::MeshBase::const_node_iterator + node_it = mesh.nodes_begin(), + node_end = mesh.nodes_end(); + + // For every node in the mesh, search the KDtree and find any + // nodes at _radius distance from the current + // node being searched... this will be added to the . + for (; node_it != node_end; node_it++) { + + const libMesh::Node* node = *node_it; + + dof_1 = node->dof_number(_level_set_system.number(), 0, 0); + + Real query_pt[3] = {(*node)(0), (*node)(1), (*node)(2)}; + + std::vector> + indices_dists; + nanoflann::RadiusResultSet + resultSet(_radius*_radius, indices_dists); + + kd_tree.findNeighbors(resultSet, query_pt, nanoflann::SearchParams()); + + sum = 0.; + + for (unsigned r=0; rdof_number(_level_set_system.number(), 0, 0); + + _filter_map[dof_1].push_back(std::pair(dof_2, _radius - d_12)); + } + + libmesh_assert_greater(sum, 0.); + + // with the coefficients computed for dof_1, divide each coefficient + // with the sum + std::vector>& vec = _filter_map[dof_1]; + for (unsigned int i=0; ihmax(); + + if (_level_set_fe_size < d_12) + _level_set_fe_size = d_12; + } +} +#endif + void MAST::FilterBase::_init() { @@ -193,7 +376,7 @@ MAST::FilterBase::_init() { sum += _radius - d_12; dof_2 = (*node_it_2)->dof_number(_level_set_system.number(), 0, 0); - + _filter_map[dof_1].push_back(std::pair(dof_2, _radius - d_12)); } } @@ -229,7 +412,7 @@ void MAST::FilterBase::print(std::ostream& o) const { o << "Filter radius: " << _radius << std::endl; - + o << std::setw(20) << "Filtered ID" << std::setw(20) << "Dependent Vars" << std::endl; diff --git a/src/level_set/filter_base.h b/src/level_set/filter_base.h index 01c0dccc..f762dd7d 100644 --- a/src/level_set/filter_base.h +++ b/src/level_set/filter_base.h @@ -81,6 +81,7 @@ namespace MAST { * initializes the algebraic data structures */ void _init(); + void _init2(); /*! * system on which the level set discrete function is defined diff --git a/src/level_set/heaviside_elem_homogenization_function.cpp b/src/level_set/heaviside_elem_homogenization_function.cpp new file mode 100644 index 00000000..a1d5d53f --- /dev/null +++ b/src/level_set/heaviside_elem_homogenization_function.cpp @@ -0,0 +1,175 @@ +/* + * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit + * Copyright (C) 2013-2019 Manav Bhatia + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +// MAST includes +#include "level_set/heaviside_elem_homogenization_function.h" +#include "level_set/level_set_elem_base.h" +#include "level_set/filter_base.h" +#include "level_set/level_set_parameter.h" +#include "base/system_initialization.h" +#include "base/nonlinear_system.h" +#include "mesh/geom_elem.h" + +// libMesh includes +#include "libmesh/elem.h" + + +MAST::HeavisideElemHomogenizedDensityFunction:: +HeavisideElemHomogenizedDensityFunction(const std::string& nm): +MAST::HomogenizedDensityFunctionBase(nm), +_width (0.1) { + +} + + + +MAST::HeavisideElemHomogenizedDensityFunction:: +~HeavisideElemHomogenizedDensityFunction() { + +} + + +void +MAST::HeavisideElemHomogenizedDensityFunction:: +initialize_element_volume_fractions() { + + libmesh_assert(_analysis_mesh); + libmesh_assert(_elem_volume_fraction.empty()); + + // make sure that the system uses Lagrange shape functions for + // the level set. + libmesh_assert(_level_set_sys->system().variable_type(0).family == libMesh::LAGRANGE); + + // Next, compute the value of level-set at the nodes of the analysis mesh + // and obtain the value of level-set from the mesh function. + // These values will be provided to the elmeent for computation of + // the homogenized volume fraction. + + RealVectorX + phi; + + unsigned int + n_nodes = 0; + + Real + v = 0.; + + libMesh::MeshBase::const_element_iterator + e_it = _analysis_mesh->active_local_elements_begin(), + e_end = _analysis_mesh->active_local_elements_end(); + + for ( ; e_it != e_end; e_it++) { + + const libMesh::Elem* e = *e_it; + + n_nodes = e->n_nodes(); + phi.setZero(n_nodes); + + // get the nodal values for this element + for (unsigned int i=0; inode_ptr(i), 0., v); + phi(i) = v; + } + + // compute the integral of Heaviside function to approximate the + // volume fraction + MAST::GeomElem geom_elem; + geom_elem.init(*e, *_level_set_sys); + MAST::LevelSetElementBase level_set_elem(*_level_set_sys, geom_elem); + level_set_elem.set_solution(phi); + v = level_set_elem.homogenized_volume_fraction(_width); + + // store the value for this elmeent + _elem_volume_fraction[e] = v; + } +} + + + +void +MAST::HeavisideElemHomogenizedDensityFunction:: +initialize_element_volume_fraction_sensitivity(const MAST::FunctionBase& f) { + + libmesh_assert(_analysis_mesh); + libmesh_assert(_elem_volume_fraction_sensitivity.empty()); + libmesh_assert(f.is_topology_parameter()); + + // make sure that the system uses Lagrange shape functions for + // the level set. + libmesh_assert(_level_set_sys->system().variable_type(0).family == libMesh::LAGRANGE); + + // Next, compute the value of level-set at the nodes of the analysis mesh + // and obtain the value of level-set from the mesh function. + // These values will be provided to the elmeent for computation of + // the homogenized volume fraction. + + RealVectorX + phi, + phi_sens; + + unsigned int + n_nodes = 0; + + Real + v = 0.; + + const MAST::LevelSetParameter + &p_ls = dynamic_cast(f); + + libMesh::MeshBase::const_element_iterator + e_it = _analysis_mesh->active_local_elements_begin(), + e_end = _analysis_mesh->active_local_elements_end(); + + for ( ; e_it != e_end; e_it++) { + + const libMesh::Elem* e = *e_it; + + if (_filter->if_elem_in_domain_of_influence(*e, *p_ls.level_set_node())) { + + n_nodes = e->n_nodes(); + phi.setZero(n_nodes); + phi_sens.setZero(n_nodes); + + // get the nodal values for this element + for (unsigned int i=0; inode_ptr(i), 0., v); + phi(i) = v; + _level_set->derivative(f, *e->node_ptr(i), 0., v); + phi_sens(i) = v; + } + + // compute the integral of Heaviside function to approximate the + // volume fraction + MAST::GeomElem geom_elem; + geom_elem.init(*e, *_level_set_sys); + MAST::LevelSetElementBase level_set_elem(*_level_set_sys, geom_elem); + level_set_elem.set_solution(phi); + level_set_elem.set_solution(phi_sens, true); + v = level_set_elem.homogenized_volume_fraction_sensitivity(_width); + + // store the value for this elmeent + _elem_volume_fraction_sensitivity[e] = v; + } + else + _elem_volume_fraction_sensitivity[e] = 0.; + } +} + + diff --git a/src/level_set/heaviside_elem_homogenization_function.h b/src/level_set/heaviside_elem_homogenization_function.h new file mode 100644 index 00000000..f1147cb4 --- /dev/null +++ b/src/level_set/heaviside_elem_homogenization_function.h @@ -0,0 +1,58 @@ +/* + * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit + * Copyright (C) 2013-2019 Manav Bhatia + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __mast__heaviside_elem_homogenized_density_function_h__ +#define __mast__heaviside_elem_homogenized_density_function_h__ + +// MAST includes +#include "level_set/homogenized_density_function_base.h" + + +namespace MAST { + + class HeavisideElemHomogenizedDensityFunction: + public MAST::HomogenizedDensityFunctionBase { + + public: + + HeavisideElemHomogenizedDensityFunction(const std::string& nm); + + virtual ~HeavisideElemHomogenizedDensityFunction(); + + /*! + * width over which the approximate Heaviside function is smoothed. Note that this is the + * width fo the level-set function value, and not necessarily the width of the geometric element. + * For level-set functions that are initialized to have a unit gradient norm, these two would + * coincide. The default value is 0.1. + */ + void set_smoothing_width(Real w) { _width = w;} + + virtual void initialize_element_volume_fractions(); + + virtual void initialize_element_volume_fraction_sensitivity(const MAST::FunctionBase& f); + + protected: + + + Real _width; + }; +} + +#endif // __mast__heaviside_elem_homogenized_density_function_h__ + diff --git a/src/level_set/homogenized_density_function_base.cpp b/src/level_set/homogenized_density_function_base.cpp new file mode 100644 index 00000000..903ceeb1 --- /dev/null +++ b/src/level_set/homogenized_density_function_base.cpp @@ -0,0 +1,131 @@ +/* + * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit + * Copyright (C) 2013-2019 Manav Bhatia + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +// MAST includes +#include "level_set/homogenized_density_function_base.h" +#include "level_set/level_set_parameter.h" +#include "level_set/filter_base.h" + + +MAST::HomogenizedDensityFunctionBase:: +HomogenizedDensityFunctionBase(const std::string& nm): +MAST::FieldFunction (nm), +_level_set_sys (nullptr), +_analysis_mesh (nullptr), +_level_set (nullptr), +_filter (nullptr) { + +} + + +MAST::HomogenizedDensityFunctionBase:: +~HomogenizedDensityFunctionBase() { + +} + + +void +MAST::HomogenizedDensityFunctionBase::init(MAST::SystemInitialization& level_set_sys, + libMesh::MeshBase& analysis_mesh, + MAST::FieldFunction& level_set, + MAST::FilterBase& filter) { + + libmesh_assert(!_level_set_sys); + + _level_set_sys = &level_set_sys; + _analysis_mesh = &analysis_mesh; + _level_set = &level_set; + _filter = &filter; + _sub_point_locator.reset(_analysis_mesh->sub_point_locator().release()); +} + + +void +MAST::HomogenizedDensityFunctionBase:: +operator() (const libMesh::Point& p, const Real t, Real& v) const { + + libmesh_assert(_analysis_mesh); + libmesh_assert(!_elem_volume_fraction.empty()); + + // identify the element in the analysis mesh that this point belongs to + // and return the value of the homogenized function + const libMesh::Elem* e = (*_sub_point_locator)(p); + + libmesh_assert(e); + + std::map::const_iterator + it = _elem_volume_fraction.find(e); + + libmesh_assert(it != _elem_volume_fraction.end()); + + v = it->second; +} + + + +void +MAST::HomogenizedDensityFunctionBase:: +derivative(const MAST::FunctionBase& f, + const libMesh::Point& p, const Real t, Real& v) const { + + libmesh_assert(_analysis_mesh); + libmesh_assert(!_elem_volume_fraction_sensitivity.empty()); + + // identify the element in the analysis mesh that this point belongs to + // and return the value of the homogenized function + const libMesh::Elem* e = (*_sub_point_locator)(p); + + libmesh_assert(e); + + std::map::const_iterator + it = _elem_volume_fraction_sensitivity.find(e); + + libmesh_assert(it != _elem_volume_fraction.end()); + + v = it->second; +} + + +Real +MAST::HomogenizedDensityFunctionBase:: +get_elem_volume_fraction(const libMesh::Elem& e) const { + + std::map::const_iterator + it = _elem_volume_fraction.find(&e); + + libmesh_assert(it != _elem_volume_fraction.end()); + + return it->second; +} + + + +Real +MAST::HomogenizedDensityFunctionBase:: +get_elem_volume_fraction_sensitivity(const MAST::FunctionBase& f, + const libMesh::Elem& e) const { + + std::map::const_iterator + it = _elem_volume_fraction_sensitivity.find(&e); + + libmesh_assert (it != _elem_volume_fraction_sensitivity.end()); + + return it->second; +} + diff --git a/src/level_set/homogenized_density_function_base.h b/src/level_set/homogenized_density_function_base.h new file mode 100644 index 00000000..dd7bf9e1 --- /dev/null +++ b/src/level_set/homogenized_density_function_base.h @@ -0,0 +1,102 @@ +/* + * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit + * Copyright (C) 2013-2019 Manav Bhatia + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __mast__homogenized_density_function_base_h__ +#define __mast__homogenized_density_function_base_h__ + +// MAST includes +#include "base/field_function_base.h" + +// libMesh includes +#include "libmesh/mesh_base.h" + + +namespace MAST { + + // Forward declerations + class FilterBase; + class SystemInitialization; + + + class HomogenizedDensityFunctionBase: + public MAST::FieldFunction { + + public: + + HomogenizedDensityFunctionBase(const std::string& nm); + + virtual ~HomogenizedDensityFunctionBase(); + + virtual void init(MAST::SystemInitialization& level_set_sys, + libMesh::MeshBase& analysis_mesh, + MAST::FieldFunction& level_set, + MAST::FilterBase& filter); + + virtual bool depends_on(const MAST::FunctionBase& f) const { return true;} + + virtual void operator() (const libMesh::Point& p, const Real t, Real& v) const; + + virtual void derivative(const MAST::FunctionBase& f, + const libMesh::Point& p, const Real t, Real& v) const; + + const std::map& + get_elem_volume_fraction_map() const { return _elem_volume_fraction;} + + const std::map& + get_elem_volume_fraction_sensitivity_map() const + { return _elem_volume_fraction_sensitivity;} + + Real + get_elem_volume_fraction(const libMesh::Elem& e) const; + + Real + get_elem_volume_fraction_sensitivity(const MAST::FunctionBase& f, + const libMesh::Elem& e) const; + + virtual void initialize_element_volume_fractions() = 0; + + virtual void + initialize_element_volume_fraction_sensitivity(const MAST::FunctionBase& f) = 0; + + virtual void + clear_element_volume_fractions() { _elem_volume_fraction.clear(); } + + virtual void + clear_element_volume_fraction_sensitivity() { _elem_volume_fraction_sensitivity.clear();} + + protected: + + MAST::SystemInitialization *_level_set_sys; + + libMesh::MeshBase *_analysis_mesh; + + MAST::FieldFunction *_level_set; + + MAST::FilterBase *_filter; + + std::map _elem_volume_fraction; + + std::map _elem_volume_fraction_sensitivity; + + std::unique_ptr _sub_point_locator; + }; +} + +#endif // __mast__homogenized_density_function_base_h__ + diff --git a/src/level_set/intersected_elem_homogenization_function.cpp b/src/level_set/intersected_elem_homogenization_function.cpp new file mode 100644 index 00000000..60be3e31 --- /dev/null +++ b/src/level_set/intersected_elem_homogenization_function.cpp @@ -0,0 +1,118 @@ +/* + * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit + * Copyright (C) 2013-2019 Manav Bhatia + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +// MAST includes +#include "level_set/intersected_elem_homogenization_function.h" +#include "level_set/level_set_intersection.h" +#include "level_set/level_set_intersected_elem.h" + + +// libMesh includes +#include "libmesh/elem.h" + +MAST::IntersectedElemHomogenizedDensityFunction:: +IntersectedElemHomogenizedDensityFunction(const std::string& nm): +MAST::HomogenizedDensityFunctionBase(nm), +_intersection (nullptr) { + +} + + + +MAST::IntersectedElemHomogenizedDensityFunction:: +~IntersectedElemHomogenizedDensityFunction() { + +} + + +void +MAST::IntersectedElemHomogenizedDensityFunction:: +initialize_element_volume_fractions() { + + libmesh_assert(_analysis_mesh); + libmesh_assert(_intersection); + libmesh_assert(_elem_volume_fraction.empty()); + + libMesh::MeshBase::const_element_iterator + e_it = _analysis_mesh->local_elements_begin(), + e_end = _analysis_mesh->local_elements_begin(); + + for ( ; e_it != e_end; e_it++) { + + _intersection->init(*_level_set, **e_it, 0., + _analysis_mesh->max_elem_id(), + _analysis_mesh->max_node_id()); + + _elem_volume_fraction[*e_it] = _intersection->get_positive_phi_volume_fraction(); + _intersection->clear(); + } +} + + +void +MAST::IntersectedElemHomogenizedDensityFunction:: +initialize_element_volume_fraction_sensitivity(const MAST::FunctionBase& f) { + + libmesh_assert(_analysis_mesh); + libmesh_assert(_intersection); + libmesh_assert(_elem_volume_fraction_sensitivity.empty()); + + libMesh::MeshBase::const_element_iterator + e_it = _analysis_mesh->local_elements_begin(), + e_end = _analysis_mesh->local_elements_begin(); + + for ( ; e_it != e_end; e_it++) { + + const libMesh::Elem* elem = *e_it; + + _intersection->init(*_level_set, *elem, 0., + _analysis_mesh->max_elem_id(), + _analysis_mesh->max_node_id()); + + // iterate over all elements on the positive side and + // add compute the sensitivity of the volume + const std::vector & + elems_hi = _intersection->get_sub_elems_positive_phi(); + + std::vector::const_iterator + hi_sub_elem_it = elems_hi.begin(), + hi_sub_elem_end = elems_hi.end(); + +// for (; hi_sub_elem_it != hi_sub_elem_end; hi_sub_elem_it++ ) { +// +// const libMesh::Elem* sub_elem = *hi_sub_elem_it; +// +// MAST::LevelSetIntersectedElem geom_elem; +// ops.set_elem_data(elem->dim(), *elem, geom_elem); +// geom_elem.init(*sub_elem, *_system, *_intersection); +// +// ops.init(geom_elem); +// +// ops.elem_calculations(J!=nullptr?true:false, sub_elem_vec, sub_elem_mat); +// +// ops.clear_elem(); +// } + + _elem_volume_fraction_sensitivity[elem] = + _intersection->get_positive_phi_volume_fraction(); + + _intersection->clear(); + } +} + diff --git a/src/level_set/intersected_elem_homogenization_function.h b/src/level_set/intersected_elem_homogenization_function.h new file mode 100644 index 00000000..d56e7191 --- /dev/null +++ b/src/level_set/intersected_elem_homogenization_function.h @@ -0,0 +1,58 @@ +/* + * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit + * Copyright (C) 2013-2019 Manav Bhatia + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __mast__intersected_elem_homogenized_density_function_h__ +#define __mast__intersected_elem_homogenized_density_function_h__ + +// MAST includes +#include "level_set/homogenized_density_function_base.h" + + +namespace MAST { + + // Forward declerations + + class LevelSetIntersection; + + class IntersectedElemHomogenizedDensityFunction: + public MAST::HomogenizedDensityFunctionBase { + + public: + + IntersectedElemHomogenizedDensityFunction(const std::string& nm); + + virtual ~IntersectedElemHomogenizedDensityFunction(); + + /*! + * computes and stores the volume fraction of each local element + */ + virtual void initialize_element_volume_fractions(); + + virtual void + initialize_element_volume_fraction_sensitivity(const MAST::FunctionBase& f); + + protected: + + MAST::LevelSetIntersection *_intersection; + + }; +} + +#endif // __mast__intersected_elem_homogenized_density_function_h__ + diff --git a/src/level_set/level_set_boundary_velocity.cpp b/src/level_set/level_set_boundary_velocity.cpp index cc6a63d1..1fdf806a 100644 --- a/src/level_set/level_set_boundary_velocity.cpp +++ b/src/level_set/level_set_boundary_velocity.cpp @@ -19,12 +19,17 @@ // MAST includes #include "level_set/level_set_boundary_velocity.h" +#include "level_set/level_set_intersection.h" +#include "base/system_initialization.h" +#include "base/nonlinear_system.h" MAST::LevelSetBoundaryVelocity::LevelSetBoundaryVelocity(const unsigned int dim): -MAST::FieldFunction("phi"), -_dim(dim), -_phi(nullptr) { +MAST::FieldFunction("phi_vel"), +_dim (dim), +_phi (nullptr), +_mesh (nullptr), +_level_set_func (nullptr) { } @@ -34,16 +39,20 @@ MAST::LevelSetBoundaryVelocity::~LevelSetBoundaryVelocity() { delete _phi; } + void MAST::LevelSetBoundaryVelocity::init(MAST::SystemInitialization& sys, + const MAST::FieldFunction& phi_func, const libMesh::NumericVector& sol, - const libMesh::NumericVector& dsol) { + const libMesh::NumericVector* dsol) { if (!_phi) - _phi = new MAST::MeshFieldFunction(sys, "phi"); + _phi = new MAST::MeshFieldFunction(sys, "phi_vel"); else _phi->clear(); - _phi->init(sol, &dsol); + _phi->init(sol, dsol); + _mesh = &sys.system().get_mesh(); + _level_set_func = &phi_func; } @@ -51,12 +60,17 @@ void MAST::LevelSetBoundaryVelocity::operator() (const libMesh::Point& p, const Real t, RealVectorX& v) const { + this->velocity(p, t, v); +} + + +void +MAST::LevelSetBoundaryVelocity::velocity(const libMesh::Point& p, + const Real t, + RealVectorX& v) const { libmesh_assert(_phi); - Real - tol = 1.e-6; - RealVectorX val = RealVectorX::Zero(1), grad = RealVectorX::Zero(_dim), @@ -96,3 +110,326 @@ MAST::LevelSetBoundaryVelocity::operator() (const libMesh::Point& p, v = -dval(0)/grad.squaredNorm()*grad; } + + +#include +void +MAST::LevelSetBoundaryVelocity:: +search_nearest_interface_point(const libMesh::Elem& e, + const unsigned int side, + const libMesh::Point& p, + const Real t, + RealVectorX& pt) const { + + MAST::LevelSetIntersection intersection; + + const libMesh::Elem* + elem = e.neighbor_ptr(side); + + libmesh_assert(elem); + + intersection.init(*_level_set_func, + *elem, 0., + _mesh->max_elem_id(), + _mesh->max_node_id()); + + libMesh::Point p2; + intersection.get_nearest_intersection_point(p, p2); + pt(0) = p2(0); pt(1) = p2(1); pt(2) = p2(2); +// std::fstream o; +// o.open("pts.csv", std::fstream::app); +// o << p(0) << " , " << p(1) << " , 0 \n"; +// o << pt(0) << " , " << pt(1) << " , 0 \n"; +} + + +void +MAST::LevelSetBoundaryVelocity:: +search_nearest_interface_point_derivative(const MAST::FunctionBase& f, + const libMesh::Elem& e, + const unsigned int side, + const libMesh::Point& p, + const Real t, + RealVectorX& v) const { + + libmesh_assert(_phi); + + // velocity at this interface point is given by the normal velocity + // So, we first find the point and then compute its velocity + + this->search_nearest_interface_point(e, side, p, t, v); + + libMesh::Point + pt(v(0), v(1), v(2)); + + // now compute the velocity at this point. + v.setZero(); + this->velocity(pt, t, v); +} + + + + +void +MAST::LevelSetBoundaryVelocity:: +search_nearest_interface_point_old(const libMesh::Point& p, + const Real t, + const Real length, + RealVectorX& v, + bool allow_sub_search) const { + + libmesh_assert(_phi); + + RealVectorX + phi = RealVectorX::Zero(1), + grad_phi = RealVectorX::Zero(_dim), + grad0 = RealVectorX::Zero(3), + grad1 = RealVectorX::Zero(3), + z = RealVectorX::Zero(3), + dval = RealVectorX::Zero(1), + p_ref = RealVectorX::Zero(3), + dv0 = RealVectorX::Zero(4), + dv1 = RealVectorX::Zero(4), + dx = RealVectorX::Zero(4), + gradL = RealVectorX::Zero(4); + + RealMatrixX + hess = RealMatrixX::Zero(3, 3), + gradmat = RealMatrixX::Zero(1, _dim), + coeffs = RealMatrixX::Zero(3, 3); + + libMesh::Point + p_opt = p; + + p_ref(0) = p(0); + p_ref(1) = p(1); + p_ref(2) = p(2); + + // The point is identified from a constrained optimization problem. + // p* = argmin { .5 * || p* - p ||^2: phi(p*) = 0 } + // This is formulated as a constrained minimization problem: + // (p*, l) = argmin { .5 * || p* - p ||^2 + l * phi(p*) }, + // where the Lagrangian is defined as + // L (p*, l) = .5 * || p* - p ||^2 + l * phi(p*) + // = .5 * ((px* - px)^2 + (py* - py)^2 + (pz* - pz)^2) + l * phi(p*) + // The first order optimality for this provides + // grad ( L (p*, l)) = { (p*-p) + l * grad(phi(p*)); phi(p*) } = 0 + // We solve this using Newton-Raphson with an approximate Hessian + // + + bool + if_cont = true; + + unsigned int + n_iters = 0, + max_iters = 80; + + Real + tol = 1.e-8, + L0 = 1.e12, + damp = 0.5, + L1 = 0.; + + // initialize the design point + dv0.topRows(3) = p_ref; + dv0(3) = 1.; // arbitrary value of Lagrange multiplier + dv1 = dv0; + + while (if_cont) { + + // compute the gradient of Lagrangian + (*_phi) (p_opt, t, phi); + _phi->gradient (p_opt, t, gradmat); + + // this defines the gradient of Lagrangian + gradL.topRows(3) = (dv0.topRows(3)-p_ref) + dv0(3) * gradmat.row(0).transpose(); + gradL(3) = phi(0); + + // approximate hessian + coeffs.setZero(4,4); + for (unsigned int i=0; i<3; i++) { + coeffs(i,i) = 1.; + coeffs(3,i) = coeffs(i,3) = gradmat(0,i); + } + coeffs.topLeftCorner(3, 3) += hess; + + Eigen::FullPivLU solver(coeffs); + + bool + continue_search = true; + dx = - solver.solve(gradL); + Real + factor = 1.; + unsigned int + n_it = 0, + max_it = 10; + + + // some searches may end up outside the mesh, and libMesh will through + // an exception. So, we catch the exception and take a smaller step. + while (continue_search) { + try { + + // update the design points and check for convergence + dv1 = dv0 + damp*factor * dx; + L1 = _evaluate_point_search_obj(p, t, dv1); + continue_search = false; + } + catch (...) { + + factor *= 0.5; + n_it ++; + if (n_it == max_it) { + // could not find a point inside the mesh. returning + // the reference point. + v.topRows(_dim) = dv0.topRows(_dim); + return; + } + else + continue_search = true; + } + } + + p_opt(0) = dv1(0); p_opt(1) = dv1(1); p_opt(2) = dv1(2); + L1 = _evaluate_point_search_obj(p, t, dv1); + + // update Jacobian + grad1 = gradmat.row(0); + z = (dv1.topRows(3)-dv0.topRows(3)) - hess * (grad1-grad0); + //hess += (z*z.transpose())/z.dot(grad1-grad0); + grad0 = grad1; + dv0 = dv1; + // reduce the step if the gradient is upated + /*if (z.norm()) + damp = 0.3; + else + damp = 0.5; + */ + if (n_iters == max_iters) { + + // instead, find the point closest to the latest point returned + // by the failed search. Do not allow another sub-search here + if (allow_sub_search) { + this->search_nearest_interface_point_old(p_opt, t, length, v, false); + + p_opt(0) = v(0); p_opt(1) = v(1); p_opt(2) = v(2); + dv0.topRows(3) = v; + (*_phi) (p_opt, t, phi); + } + + if_cont = false; + libMesh::Point dp = p_opt - p; + libMesh::out + << "Warning: nearest interface point search did not converge. Point found from sub-search. " + << std::endl; + libMesh::out + << " given pt: (" + << p(0) << " , " << p(1) << " , " << p(2) + << ") -> mapped pt: (" + << p_opt(0) << " , " << p_opt(1) << " , " << p_opt(2) + << "). phi = " << phi(0) + << " d/h = " << dp.norm()/length << std::endl; + } + if (std::fabs(gradL.norm()) <= tol) if_cont = false; + if (std::fabs((L1-L0)/L0) <= tol) if_cont = false; + + L0 = L1; + n_iters++; + } + + v.setZero(); + v.topRows(_dim) = dv0.topRows(_dim); +} + + + +void +MAST::LevelSetBoundaryVelocity:: +search_nearest_interface_point_derivative_old(const MAST::FunctionBase& f, + const libMesh::Point& p, + const Real t, + const Real length, + RealVectorX& v) const { + + libmesh_assert(_phi); + + // velocity at this interface point is given by the normal velocity + // So, we first find the point and then compute its velocity + + this->search_nearest_interface_point_old(p, t, length, v); + + libMesh::Point + pt(v(0), v(1), v(2)); + + // now compute the velocity at this point. + v.setZero(); + this->velocity(pt, t, v); +} + + + + +void +MAST::LevelSetBoundaryVelocity::normal_at_point(const libMesh::Point& p, + const Real t, + RealVectorX& n) const { + + libmesh_assert(_phi); + + RealMatrixX + gradmat = RealMatrixX::Zero(1, _dim); + + n.setZero(); + + // the velocity is identified using the level set function gradient + // and its sensitivity + _phi->gradient(p, t, gradmat); + n.topRows(3) = -gradmat.row(0); + + n /= n.norm(); +} + + + +void +MAST::LevelSetBoundaryVelocity::normal_derivative_at_point(const MAST::FunctionBase& f, + const libMesh::Point& p, + const Real t, + RealVectorX& n) const { + + libmesh_assert(_phi); + + RealMatrixX + gradmat = RealMatrixX::Zero(1, _dim), + dgrad = RealMatrixX::Zero(1, _dim); + + n.setZero(); + + // the velocity is identified using the level set function gradient + // and its sensitivity + _phi->gradient(p, t, gradmat); + _phi->perturbation_gradient(p, t, dgrad); + + RealVectorX + v = gradmat.row(0), + dv = dgrad.row(0); + + n.topRows(3) = (-dv/v.norm() + v.dot(dv)/std::pow(v.dot(v),1.5) * v); +} + + + +Real +MAST::LevelSetBoundaryVelocity:: +_evaluate_point_search_obj(const libMesh::Point& p, + const Real t, + const RealVectorX& dv) const { + + libMesh::Point p1(dv(0), dv(1), dv(2)); + RealVectorX phi; + (*_phi)(p1, t, phi); + p1 -= p; + return .5 * p1.norm_sq() + dv(3)*phi(0); +} + + diff --git a/src/level_set/level_set_boundary_velocity.h b/src/level_set/level_set_boundary_velocity.h index d1ba8dd5..46fafd93 100644 --- a/src/level_set/level_set_boundary_velocity.h +++ b/src/level_set/level_set_boundary_velocity.h @@ -35,17 +35,77 @@ namespace MAST { virtual ~LevelSetBoundaryVelocity(); void init(MAST::SystemInitialization& sys, + const MAST::FieldFunction& phi, const libMesh::NumericVector& sol, - const libMesh::NumericVector& dsol); + const libMesh::NumericVector* dsol); virtual void operator() (const libMesh::Point& p, const Real t, RealVectorX& v) const; + + void velocity(const libMesh::Point& p, + const Real t, + RealVectorX& v) const; + + void search_nearest_interface_point(const libMesh::Elem& e, + const unsigned int side, + const libMesh::Point& p, + const Real t, + RealVectorX& pt) const; + + void search_nearest_interface_point_derivative(const MAST::FunctionBase& f, + const libMesh::Elem& e, + const unsigned int side, + const libMesh::Point& p, + const Real t, + RealVectorX& v) const; + + + /*! + * serches for a point \p pt in the vicinity of \p p on the level set interface, where + * level set function is zero. \p length is a reference length that is used to identify + * the step-size for the search. If the interface point is expected to be within a few elements, + * then this length coudl be the element edge length. + */ + void search_nearest_interface_point_old(const libMesh::Point& p, + const Real t, + const Real length, + RealVectorX& pt, + bool allow_sub_search = true) const; + + /*! + * serches for a point \p pt in the vicinity of \p p on the level set interface, where + * level set function is zero. \p length is a reference length that is used to identify + * the step-size for the search. If the interface point is expected to be within a few elements, + * then this length coudl be the element edge length. + */ + void search_nearest_interface_point_derivative_old(const MAST::FunctionBase& f, + const libMesh::Point& p, + const Real t, + const Real length, + RealVectorX& v) const; + + void normal_at_point(const libMesh::Point& p, + const Real t, + RealVectorX& n) const; + + + void normal_derivative_at_point(const MAST::FunctionBase& f, + const libMesh::Point& p, + const Real t, + RealVectorX& n) const; + protected: - unsigned int _dim; - MAST::MeshFieldFunction *_phi; + Real _evaluate_point_search_obj(const libMesh::Point& p, + const Real t, + const RealVectorX& dv) const; + + unsigned int _dim; + MAST::MeshFieldFunction* _phi; + libMesh::MeshBase* _mesh; + const MAST::FieldFunction* _level_set_func; }; } diff --git a/src/level_set/level_set_elem_base.cpp b/src/level_set/level_set_elem_base.cpp index b6bd6b7f..bab5b5be 100644 --- a/src/level_set/level_set_elem_base.cpp +++ b/src/level_set/level_set_elem_base.cpp @@ -35,9 +35,8 @@ MAST::LevelSetElementBase:: LevelSetElementBase(MAST::SystemInitialization& sys, - MAST::AssemblyBase& assembly, const MAST::GeomElem& elem): -MAST::ElementBase(sys, assembly, elem), +MAST::ElementBase(sys, elem), _phi_vel (nullptr), _if_propagation (true) { @@ -342,7 +341,79 @@ MAST::LevelSetElementBase::volume() { Real -MAST::LevelSetElementBase::perimeter() { +MAST::LevelSetElementBase::homogenized_volume_fraction(Real delta) { + + std::unique_ptr fe(_elem.init_fe(true, false)); + + const std::vector& JxW = fe->get_JxW(); + const unsigned int + dim = _elem.dim(); + + RealVectorX + phi = RealVectorX::Zero(1); + + Real + pi = acos(-1.), + heav = 0., + vol = 0.; + + std::vector dBmat(dim); + MAST::FEMOperatorMatrix Bmat; + + + for (unsigned int qp=0; qp fe(_elem.init_fe(true, false)); + + const std::vector& JxW = fe->get_JxW(); + const unsigned int + dim = _elem.dim(); + + RealVectorX + phi = RealVectorX::Zero(1), + dphidp = RealVectorX::Zero(1); + + Real + pi = acos(-1.), + heav = 0., + vol = 0.; + + std::vector dBmat(dim); + MAST::FEMOperatorMatrix Bmat; + + + for (unsigned int qp=0; qp fe(_elem.init_fe(true, false)); @@ -354,7 +425,6 @@ MAST::LevelSetElementBase::perimeter() { phi = RealVectorX::Zero(1); Real - d = 1.e-1, pi = acos(-1.), per = 0.; @@ -375,7 +445,7 @@ MAST::LevelSetElementBase::perimeter() { Real -MAST::LevelSetElementBase::perimeter_sensitivity() { +MAST::LevelSetElementBase::perimeter_sensitivity(Real d) { std::unique_ptr fe(_elem.init_fe(true, false)); @@ -388,7 +458,6 @@ MAST::LevelSetElementBase::perimeter_sensitivity() { dphidp = RealVectorX::Zero(1); Real - d = 1.e-1, pi = acos(-1.), dper_dp = 0.; @@ -414,7 +483,7 @@ MAST::LevelSetElementBase::perimeter_sensitivity() { Real MAST::LevelSetElementBase::volume_boundary_velocity_on_side(unsigned int s) { - std::unique_ptr fe(_elem.init_side_fe(s, true)); + std::unique_ptr fe(_elem.init_side_fe(s, true, false)); const std::vector& JxW = fe->get_JxW(); const unsigned int diff --git a/src/level_set/level_set_elem_base.h b/src/level_set/level_set_elem_base.h index e890c1f7..a8fc1721 100644 --- a/src/level_set/level_set_elem_base.h +++ b/src/level_set/level_set_elem_base.h @@ -41,7 +41,6 @@ namespace MAST { * Constructor */ LevelSetElementBase(MAST::SystemInitialization& sys, - MAST::AssemblyBase& assembly, const MAST::GeomElem& elem); @@ -149,6 +148,24 @@ namespace MAST { Real volume(); + + /*! + * Approximates the volume fraction of the element based on integration of approximated + * Heaviside function over the element. \p delta is the width over which the function + * is smoothed. + */ + Real + homogenized_volume_fraction(Real delta=0.1); + + + /*! + * Sensitivity of the homogenized volume fraction for the specified level set value and + * its sensitivity. + */ + Real + homogenized_volume_fraction_sensitivity(Real delta=0.1); + + /*! * Approximates the integral of the Dirac delta function to approximate * the perimeter. The approximation of Dirac delta function is obtained @@ -163,7 +180,7 @@ namespace MAST { * @returns the computed integral of \f$ \delta_d(\phi) \f$ */ Real - perimeter(); + perimeter(Real delta=0.1); /*! * computes the partial derivative of the integral of the Dirac @@ -171,7 +188,7 @@ namespace MAST { * set for this element. */ Real - perimeter_sensitivity(); + perimeter_sensitivity(Real delta=0.1); /*! diff --git a/src/level_set/level_set_intersected_elem.cpp b/src/level_set/level_set_intersected_elem.cpp index 959df515..0509045c 100644 --- a/src/level_set/level_set_intersected_elem.cpp +++ b/src/level_set/level_set_intersected_elem.cpp @@ -128,12 +128,14 @@ MAST::LevelSetIntersectedElem::init_fe(bool init_grads, std::unique_ptr MAST::LevelSetIntersectedElem::init_side_fe(unsigned int s, bool init_grads, + bool init_second_order_derivative, int extra_quadrature_order) const { libmesh_assert(_intersection); std::unique_ptr fe(new MAST::SubCellFE(*_sys_init, *_intersection)); fe->set_extra_quadrature_order(extra_quadrature_order); - + fe->set_evaluate_second_order_derivatives(init_second_order_derivative); + fe->init_for_side(*this, s, init_grads); return fe; diff --git a/src/level_set/level_set_intersected_elem.h b/src/level_set/level_set_intersected_elem.h index c72e88b0..e0269475 100644 --- a/src/level_set/level_set_intersected_elem.h +++ b/src/level_set/level_set_intersected_elem.h @@ -110,6 +110,7 @@ namespace MAST { virtual std::unique_ptr init_side_fe(unsigned int s, bool init_grads, + bool init_second_order_derivative, int extra_quadrature_order = 0) const; diff --git a/src/level_set/level_set_intersection.cpp b/src/level_set/level_set_intersection.cpp index 68efa87b..7c1d2958 100644 --- a/src/level_set/level_set_intersection.cpp +++ b/src/level_set/level_set_intersection.cpp @@ -36,6 +36,7 @@ _max_mesh_node_id (0), _max_elem_divs (4), _elem (nullptr), _initialized (false), +_phi (nullptr), _if_elem_on_positive_phi (false), _if_elem_on_negative_phi (false), _mode (MAST::NO_INTERSECTION), @@ -112,12 +113,21 @@ MAST::LevelSetIntersection::if_elem_on_negative_phi() const { +bool +MAST::LevelSetIntersection::if_elem_has_negative_phi_region() const { + + libmesh_assert(_initialized); + + return !_if_elem_on_positive_phi; +} + + bool MAST::LevelSetIntersection::if_elem_has_positive_phi_region() const { libmesh_assert(_initialized); - return (_if_elem_on_positive_phi || !_if_elem_on_negative_phi); + return !_if_elem_on_negative_phi; } @@ -180,6 +190,13 @@ MAST::LevelSetIntersection::get_node_phi_value(const libMesh::Node* n) const { +bool +MAST::LevelSetIntersection::if_hanging_node(const libMesh::Node* n) const { + + return _hanging_node.count(n); +} + + void MAST::LevelSetIntersection::clear() { @@ -187,6 +204,7 @@ MAST::LevelSetIntersection::clear() { _max_iters = 10; _elem = nullptr; _initialized = false; + _phi = nullptr; _if_elem_on_positive_phi = false; _if_elem_on_negative_phi = false; _mode = MAST::NO_INTERSECTION; @@ -198,6 +216,7 @@ MAST::LevelSetIntersection::clear() { _negative_phi_elems.clear(); _elem_sides_on_interface.clear(); _node_local_coords.clear(); + _hanging_node.clear(); std::vector::iterator e_it = _new_elems.begin(), @@ -216,6 +235,9 @@ MAST::LevelSetIntersection::clear() { _new_nodes.clear(); _new_elems.clear(); + + _interior_nodes.clear(); + _bounding_nodes.clear(); } @@ -234,6 +256,7 @@ MAST::LevelSetIntersection::init(const MAST::FieldFunction& phi, _max_mesh_node_id = max_node_id; _elem = &e; + _phi = φ switch (e.type()) { case libMesh::QUAD4: @@ -344,8 +367,7 @@ _init_on_first_order_ref_elem(const MAST::FieldFunction& phi, // if the sign of function on all nodes is the same, then it is assumed // that the element is not intersected - if (min_val > _tol && - max_val > _tol) { + if (min_val > _tol) { // element is completely on the positive side with no intersection _mode = MAST::NO_INTERSECTION; @@ -355,8 +377,7 @@ _init_on_first_order_ref_elem(const MAST::FieldFunction& phi, _initialized = true; return; } - else if (min_val < _tol && - max_val < _tol) { + else if (max_val < -_tol) { // element is completely on the negative side, with no intersection @@ -367,12 +388,9 @@ _init_on_first_order_ref_elem(const MAST::FieldFunction& phi, _initialized = true; return; } - else if (min_val < _tol && - max_val > _tol) { + else { // if it did not get caught in the previous two cases, then there is // an intersection. - // If it got here, then there is an intersection in the domain and the - // element is not on the positive side completely. _if_elem_on_positive_phi = false; _if_elem_on_negative_phi = false; @@ -917,6 +935,8 @@ MAST::LevelSetIntersection::_find_quad4_intersections nd->set_id(_max_mesh_node_id + node_id_incr); node_id_incr++; _new_nodes.push_back(nd); + _bounding_nodes[nd] = std::make_pair(_elem->node_ptr(ref_side%n_nodes), + _elem->node_ptr((ref_side+1)%n_nodes)); side_p0 = side_nondim_points[ref_side%n_nodes].first; side_p1 = side_nondim_points[ref_side%n_nodes].second; _node_local_coords[nd] = side_p0 + xi_ref * (side_p1 - side_p0); @@ -958,6 +978,8 @@ MAST::LevelSetIntersection::_find_quad4_intersections nd->set_id(_max_mesh_node_id + node_id_incr); node_id_incr++; _new_nodes.push_back(nd); + _bounding_nodes[nd] = std::make_pair(_elem->node_ptr((ref_side+2)%n_nodes), + _elem->node_ptr((ref_side+3)%n_nodes)); side_p0 = side_nondim_points[(ref_side+2)%n_nodes].first; side_p1 = side_nondim_points[(ref_side+2)%n_nodes].second; _node_local_coords[nd] = side_p0 + xi_other * (side_p1 - side_p0); @@ -1032,6 +1054,8 @@ MAST::LevelSetIntersection::_find_quad4_intersections nd->set_id(_max_mesh_node_id + node_id_incr); node_id_incr++; _new_nodes.push_back(nd); + _bounding_nodes[nd] = std::make_pair(_elem->node_ptr((ref_side+1)%n_nodes), + _elem->node_ptr((ref_side+2)%n_nodes)); side_p0 = side_nondim_points[(ref_side+1)%n_nodes].first; side_p1 = side_nondim_points[(ref_side+1)%n_nodes].second; _node_local_coords[nd] = side_p0 + xi_other * (side_p1 - side_p0); @@ -1045,6 +1069,8 @@ MAST::LevelSetIntersection::_find_quad4_intersections nd->set_id(_max_mesh_node_id + node_id_incr); node_id_incr++; _new_nodes.push_back(nd); + _bounding_nodes[nd] = std::make_pair(_elem->node_ptr((ref_side+2)%n_nodes), + _elem->node_ptr((ref_side+3)%n_nodes)); side_p0 = side_nondim_points[(ref_side+2)%n_nodes].first; side_p1 = side_nondim_points[(ref_side+2)%n_nodes].second; _node_local_coords[nd] = side_p1 + xi_ref * (side_p0 - side_p1); @@ -1094,6 +1120,7 @@ MAST::LevelSetIntersection::_find_quad4_intersections e2->set_node(0) = _new_nodes[0]; e2->set_node(1) = _new_nodes[2]; + _hanging_node.insert(_new_nodes[2]); e2->set_node(2) = const_cast(e.node_ptr((ref_side+3)%n_nodes)); e2->set_node(3) = const_cast(e.node_ptr(ref_side)); @@ -1318,6 +1345,8 @@ MAST::LevelSetIntersection::_find_quad4_intersections nd->set_id(_max_mesh_node_id + node_id_incr); node_id_incr++; _new_nodes.push_back(nd); + _bounding_nodes[nd] = std::make_pair(_elem->node_ptr((ref_side+1)%n_nodes), + _elem->node_ptr((ref_side+2)%n_nodes)); side_p0 = side_nondim_points[(ref_side+1)%n_nodes].first; side_p1 = side_nondim_points[(ref_side+1)%n_nodes].second; _node_local_coords[nd] = side_p0 + xi_other * (side_p1 - side_p0); @@ -1433,6 +1462,8 @@ MAST::LevelSetIntersection::_find_quad4_intersections nd->set_id(_max_mesh_node_id + node_id_incr); node_id_incr++; _new_nodes.push_back(nd); + _bounding_nodes[nd] = std::make_pair(_elem->node_ptr((ref_side+i)%n_nodes), + _elem->node_ptr((ref_side+i+1)%n_nodes)); side_p0 = side_nondim_points[(ref_side+i)%n_nodes].first; side_p1 = side_nondim_points[(ref_side+i)%n_nodes].second; _node_local_coords[nd] = side_p0 + xi_other * (side_p1 - side_p0); @@ -1628,3 +1659,134 @@ MAST::LevelSetIntersection::get_nondimensional_coordinate_for_node return it->second; } + + +bool +MAST::LevelSetIntersection::if_node_is_new(const libMesh::Node& node) const { + + libmesh_assert(_initialized); + + for (unsigned int i=0; i<_new_nodes.size(); i++) + if (&node == _new_nodes[i]) + return true; + + // if it gets here then the node was not created by this intersection + // operation + return false; +} + + + +bool +MAST::LevelSetIntersection::if_interior_node(const libMesh::Node& node) const { + + libmesh_assert(_initialized); + + return _interior_nodes.count(&node); +} + + + +std::pair +MAST::LevelSetIntersection::get_bounding_nodes_for_node(const libMesh::Node& node) const { + + libmesh_assert(_initialized); + + libmesh_assert(this->if_node_is_new(node)); + + std::map>::const_iterator + it = _bounding_nodes.find(&node); + + libmesh_assert(it != _bounding_nodes.end()); + + return it->second; +} + + +void +MAST::LevelSetIntersection:: +get_material_sides_without_intersection(std::set& sides) const { + + libmesh_assert_equal_to(sides.size(), 0); + + std::map >::const_iterator + it, + end = _node_phi_vals.end(); + + for (unsigned int i=0; i<_elem->n_sides(); i++) { + + std::unique_ptr side(_elem->side_ptr(i).release()); + + // check to see if all nodes of this side are on the material side + bool + on_material = true; + for (unsigned int j=0; jn_nodes(); j++) { + + it = _node_phi_vals.find(side->node_ptr(j)); + // the node level set value should be in the code + libmesh_assert(it != end); + + // neither on level set nor on positive side + if (!(it->second.second || it->second.first > _tol)) { + + on_material = false; + break; + } + } + + // if the on_material flag is still true then the side is added to + // the set + if (on_material) + sides.insert(i); + } +} + + +void +MAST::LevelSetIntersection:: +get_nearest_intersection_point(const libMesh::Point &p, + libMesh::Point &pt) { + + libmesh_assert(_initialized); + + // check the element nodes for closest node + std::map >::const_iterator + it = _node_phi_vals.begin(), + end = _node_phi_vals.end(); + + libMesh::Point + dp; + + Real + v = 0., + dist = 1.e12; + + for ( ; it != end; it++) { + + if (it->second.second) { // on level set + + dp = *it->first - p; + + if (dp.norm() < dist) { + pt = *it->first; + dist = dp.norm(); + } + } + } + + // check the new nodes for possible candidates + for (unsigned int i=0; i<_new_nodes.size(); i++) { + + (*_phi)(*_new_nodes[i], 0., v); + + if (std::fabs(v) <= _tol) { + + dp = *_new_nodes[i] - p; + + if (dp.norm() < dist) { + pt = *_new_nodes[i]; + dist = dp.norm(); + } + } + } +} diff --git a/src/level_set/level_set_intersection.h b/src/level_set/level_set_intersection.h index 415c53fe..72f5a87d 100644 --- a/src/level_set/level_set_intersection.h +++ b/src/level_set/level_set_intersection.h @@ -107,6 +107,14 @@ namespace MAST { */ Real get_node_phi_value(const libMesh::Node* n) const; + + /*! + * The case of two adjacent edges results in a new node on an edge that is not coincident + * with the level set interface. This will end up as a hanging node if added to the mesh. + * @returns true if this node \p n is the hanging node. + */ + bool if_hanging_node(const libMesh::Node* n) const; + /*! * @returns true if the intersection is through the element, or * has colinear edge. @@ -138,10 +146,17 @@ namespace MAST { /*! * @returns \p true if there is any portion of the element (interior - * or edge) that is on the positive side of the level set function. + * edge, or node) that is on the positive side of the level set function. */ bool if_elem_has_positive_phi_region() const; + + /*! + * @returns \p true if there is any portion of the element (interior + * edge, or node) that is on the negative side of the level set function. + */ + bool if_elem_has_negative_phi_region() const; + const std::vector& get_sub_elems_positive_phi() const; @@ -153,8 +168,8 @@ namespace MAST { /*! * @returns the id of side that is on the interface. In case the - * element does not have a side on the interface, then a negative - * value is returned. + * element does not have a side on the interface, then an error is + * thrown. */ unsigned int get_side_on_interface(const libMesh::Elem& e) const; @@ -164,6 +179,42 @@ namespace MAST { const libMesh::Point& get_nondimensional_coordinate_for_node(const libMesh::Node& n) const; + + + /*! + * identifies if the node from the subelements is a new node or + * an existing node from the parent element. + */ + bool if_node_is_new(const libMesh::Node& node) const; + + + /*! + * identifies if the new node is on an edge along the level-set method + * in the interior of the element (as opposed to on the edges of the + * original element). + */ + bool if_interior_node(const libMesh::Node& node) const; + + + /*! + * for new nodes required to create the subelements this method + * returns the nodes on an edge that bound the given node. An + * error is thrown if the node is not a + */ + std::pair + get_bounding_nodes_for_node(const libMesh::Node& node) const; + + + /*! + * identifies the sides of the element that are completely on the material side without + * any intersection on them. + */ + void + get_material_sides_without_intersection(std::set& sides) const; + + + void get_nearest_intersection_point(const libMesh::Point& p, + libMesh::Point& pt); protected: @@ -217,6 +268,8 @@ namespace MAST { const libMesh::Elem* _elem; bool _initialized; + const MAST::FieldFunction* _phi; + /*! * \p true if element is completely on the positive side of level set * with no intersection @@ -245,6 +298,9 @@ namespace MAST { std::vector _new_elems; std::map _node_local_coords; std::map > _node_phi_vals; + std::set _interior_nodes; + std::map> _bounding_nodes; + std::set _hanging_node; }; } diff --git a/src/level_set/level_set_nonlinear_implicit_assembly.h b/src/level_set/level_set_nonlinear_implicit_assembly.h index 13ee9974..0e4fa6f5 100644 --- a/src/level_set/level_set_nonlinear_implicit_assembly.h +++ b/src/level_set/level_set_nonlinear_implicit_assembly.h @@ -165,28 +165,8 @@ namespace MAST { MAST::OutputAssemblyElemOperations& output); - /*! - * Evaluates the total sensitivity of \p output wrt \p p using - * the adjoint solution provided in \p dq_dX for a linearization - * about solution \p X. - */ - /*virtual Real - calculate_output_adjoint_sensitivity(const libMesh::NumericVector& X, - const libMesh::NumericVector& dq_dX, - const MAST::FunctionBase& p, - MAST::AssemblyElemOperations& elem_ops, - MAST::OutputAssemblyElemOperations& output, - const bool include_partial_sens = true); - */ - protected: - /*Real - _adjoint_sensitivity_dot_product (const MAST::FunctionBase& f, - const libMesh::NumericVector& X, - const libMesh::NumericVector& dq_dX); - */ - bool _enable_dof_handler; bool _evaluate_output_on_negative_phi; diff --git a/src/level_set/level_set_perimeter_output.cpp b/src/level_set/level_set_perimeter_output.cpp index 78aae29a..0f6184ad 100644 --- a/src/level_set/level_set_perimeter_output.cpp +++ b/src/level_set/level_set_perimeter_output.cpp @@ -29,11 +29,11 @@ #include "libmesh/parallel.h" -MAST::LevelSetPerimeter::LevelSetPerimeter(MAST::LevelSetIntersection& intersection): +MAST::LevelSetPerimeter::LevelSetPerimeter(): MAST::OutputAssemblyElemOperations(), -_intersection (intersection), -_per (0.), -_dper_dp (0.) { +_per (0.), +_dper_dp (0.), +_heaviside_smooth_delta (0.1) { } @@ -53,7 +53,7 @@ MAST::LevelSetPerimeter::init(const MAST::GeomElem& elem) { libmesh_assert(_system); libmesh_assert(_assembly); - _physics_elem = new MAST::LevelSetElementBase(*_system, *_assembly, elem); + _physics_elem = new MAST::LevelSetElementBase(*_system, elem); } @@ -89,7 +89,7 @@ MAST::LevelSetPerimeter::output_for_elem() { MAST::LevelSetElementBase& e = dynamic_cast(*_physics_elem); - return e.perimeter(); + return e.perimeter(_heaviside_smooth_delta); } else return 0.; @@ -125,7 +125,7 @@ MAST::LevelSetPerimeter::output_sensitivity_for_elem(const MAST::FunctionBase& p MAST::LevelSetElementBase& e = dynamic_cast(*_physics_elem); - return e.perimeter_sensitivity(); + return e.perimeter_sensitivity(_heaviside_smooth_delta); } else return 0.; @@ -157,7 +157,7 @@ MAST::LevelSetPerimeter::evaluate() { MAST::LevelSetElementBase& e = dynamic_cast(*_physics_elem); - _per += e.perimeter(); + _per += e.perimeter(_heaviside_smooth_delta); } } @@ -171,6 +171,13 @@ MAST::LevelSetPerimeter::evaluate_sensitivity(const MAST::FunctionBase& f) { +void +MAST::LevelSetPerimeter::evaluate_topology_sensitivity(const MAST::FunctionBase& f) { + + libmesh_assert(false); +} + + void MAST::LevelSetPerimeter::evaluate_topology_sensitivity(const MAST::FunctionBase& f, const MAST::FieldFunction& vel) { @@ -192,7 +199,7 @@ MAST::LevelSetPerimeter::evaluate_topology_sensitivity(const MAST::FunctionBase& MAST::LevelSetElementBase& e = dynamic_cast(*_physics_elem); - _dper_dp += e.perimeter_sensitivity(); + _dper_dp += e.perimeter_sensitivity(_heaviside_smooth_delta); } } diff --git a/src/level_set/level_set_perimeter_output.h b/src/level_set/level_set_perimeter_output.h index 6fbc4448..33c544b0 100644 --- a/src/level_set/level_set_perimeter_output.h +++ b/src/level_set/level_set_perimeter_output.h @@ -42,10 +42,16 @@ namespace MAST { public: - LevelSetPerimeter(MAST::LevelSetIntersection& intersection); + LevelSetPerimeter(); virtual ~LevelSetPerimeter(); + /*! + * Sets the value of the heaviside smooth delta, which is the width +/- d of the level set function + * about which the approximate Heaviside function is smoothed. The default value is 0.1 + */ + void set_heaviside_smoothing_delta(Real d=0.1) { _heaviside_smooth_delta = d;} + /*! * virtual function, nothing to be done for level set */ @@ -156,6 +162,15 @@ namespace MAST { libmesh_assert(false); // to be implemented } + /*! + * this evaluates all relevant topological sensitivity components on + * the element. + * This is only done on the current element for which this + * object has been initialized. + */ + virtual void + evaluate_topology_sensitivity(const MAST::FunctionBase& f); + /*! * This evaluates the contribution to the topology sensitivity on the * boundary \f$ \int_\Gamma V_n~d\Gamma \f$ @@ -165,9 +180,9 @@ namespace MAST { protected: - const MAST::LevelSetIntersection& _intersection; Real _per; Real _dper_dp; + Real _heaviside_smooth_delta; }; } diff --git a/src/level_set/level_set_transient_assembly.cpp b/src/level_set/level_set_transient_assembly.cpp index 3e16bc02..5847d2d4 100644 --- a/src/level_set/level_set_transient_assembly.cpp +++ b/src/level_set/level_set_transient_assembly.cpp @@ -131,7 +131,7 @@ init(const MAST::GeomElem& elem) { discipline = dynamic_cast(*_discipline); MAST::LevelSetElementBase - *e = new MAST::LevelSetElementBase(*_system, *_assembly, elem); + *e = new MAST::LevelSetElementBase(*_system, elem); if (discipline.has_velocity_function()) e->set_velocity_function(discipline.get_velocity_function()); diff --git a/src/level_set/level_set_volume_output.cpp b/src/level_set/level_set_volume_output.cpp index 549b0c3a..1ee16fca 100644 --- a/src/level_set/level_set_volume_output.cpp +++ b/src/level_set/level_set_volume_output.cpp @@ -20,7 +20,6 @@ // MAST includes #include "level_set/level_set_volume_output.h" #include "level_set/level_set_elem_base.h" -#include "level_set/level_set_intersection.h" #include "level_set/level_set_intersected_elem.h" #include "base/system_initialization.h" #include "base/nonlinear_system.h" @@ -29,9 +28,8 @@ #include "libmesh/parallel.h" -MAST::LevelSetVolume::LevelSetVolume(MAST::LevelSetIntersection& intersection): +MAST::LevelSetVolume::LevelSetVolume(): MAST::OutputAssemblyElemOperations(), -_intersection (intersection), _vol (0.), _dvol_dp (0.) { @@ -53,7 +51,7 @@ MAST::LevelSetVolume::init(const MAST::GeomElem& elem) { libmesh_assert(_system); libmesh_assert(_assembly); - _physics_elem = new MAST::LevelSetElementBase(*_system, *_assembly, elem); + _physics_elem = new MAST::LevelSetElementBase(*_system, elem); } @@ -171,6 +169,14 @@ MAST::LevelSetVolume::evaluate_sensitivity(const MAST::FunctionBase& f) { +void +MAST::LevelSetVolume::evaluate_topology_sensitivity(const MAST::FunctionBase& f) { + + libmesh_assert(false); +} + + + void MAST::LevelSetVolume::evaluate_topology_sensitivity(const MAST::FunctionBase& f, const MAST::FieldFunction& vel) { diff --git a/src/level_set/level_set_volume_output.h b/src/level_set/level_set_volume_output.h index 13ee9db7..f5d79e9a 100644 --- a/src/level_set/level_set_volume_output.h +++ b/src/level_set/level_set_volume_output.h @@ -27,15 +27,12 @@ namespace MAST { - // Forward declerations - class LevelSetIntersection; - class LevelSetVolume: public MAST::OutputAssemblyElemOperations { public: - LevelSetVolume(MAST::LevelSetIntersection& intersection); + LevelSetVolume(); virtual ~LevelSetVolume(); @@ -149,6 +146,15 @@ namespace MAST { libmesh_assert(false); // to be implemented } + /*! + * this evaluates all relevant topological sensitivity components on + * the element. + * This is only done on the current element for which this + * object has been initialized. + */ + virtual void + evaluate_topology_sensitivity(const MAST::FunctionBase& f); + /*! * This evaluates the contribution to the topology sensitivity on the * boundary \f$ \int_\Gamma V_n~d\Gamma \f$ @@ -158,7 +164,6 @@ namespace MAST { protected: - const MAST::LevelSetIntersection& _intersection; Real _vol; Real _dvol_dp; }; diff --git a/src/level_set/sub_cell_fe.cpp b/src/level_set/sub_cell_fe.cpp index c854ea81..6277a8cd 100644 --- a/src/level_set/sub_cell_fe.cpp +++ b/src/level_set/sub_cell_fe.cpp @@ -300,6 +300,7 @@ MAST::SubCellFE::init_for_side(const MAST::GeomElem& elem, _fe->get_JxW(); if (if_calculate_dphi) _fe->get_dphi(); + if (_init_second_order_derivatives) _fe->get_d2phi(); ////////////////////////////////////////////////////////////// diff --git a/src/level_set/sub_elem_mesh_refinement.cpp b/src/level_set/sub_elem_mesh_refinement.cpp new file mode 100644 index 00000000..e8b00340 --- /dev/null +++ b/src/level_set/sub_elem_mesh_refinement.cpp @@ -0,0 +1,727 @@ +/* + * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit + * Copyright (C) 2013-2019 Manav Bhatia + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +// MAST includes +#include "level_set/sub_elem_mesh_refinement.h" +#include "level_set/level_set_intersection.h" +#include "level_set/sub_elem_node_map.h" + +// libMesh includes +#include "libmesh/mesh_communication.h" +#include "libmesh/partitioner.h" +#include "libmesh/dof_map.h" + + +MAST::SubElemMeshRefinement::SubElemMeshRefinement(libMesh::MeshBase& mesh, + libMesh::System& sys): +libMesh::System::Constraint (), +_initialized (false), +_strong_discontinuity (false), +_negative_level_set_subdomain_offset (0), +_inactive_subdomain_offset (0), +_level_set_boundary_id (0), +_mesh (mesh), +_system (sys), +_node_map (new MAST::SubElemNodeMap) { + +} + + + +MAST::SubElemMeshRefinement::~SubElemMeshRefinement() { + + this->clear_mesh(); + delete _node_map; +} + + + +bool +MAST::SubElemMeshRefinement::process_mesh(const MAST::FieldFunction& phi, + bool strong_discontinuity, + Real time, + unsigned int negative_level_set_subdomain_offset, + unsigned int inactive_subdomain_offset, + unsigned int level_set_boundary_id) { + + libmesh_assert(!_initialized); + + // currently only implemented for replicated mesh + libmesh_assert(_mesh.is_replicated()); + + // if strong discontinuity is required then coincident nodes are + // created which will need unique_id support in libMesh + if (strong_discontinuity) { +#ifndef LIBMESH_ENABLE_UNIQUE_ID + libmesh_assert(false); +#endif + } + + MAST::LevelSetIntersection intersect; + + libMesh::MeshBase::element_iterator + e_it = _mesh.active_local_elements_begin(), + e_end = _mesh.active_local_elements_end(); + + // for a replicated mesh all processors have to do the exct same operations + // to the mesh in the same order. Hence, we modify the iterators. + if (_mesh.is_replicated()) { + + e_it = _mesh.active_elements_begin(), + e_end = _mesh.active_elements_end(); + } + + // first we need to identify all the elements that will be refined. + // Then we will iterate over all of them. Otherwise, the addition of + // new elemnts can invalidate the element iterators. + std::vector + elems_to_partition; + + for ( ; e_it != e_end; e_it++) { + + libMesh::Elem* elem = *e_it; + + intersect.init(phi, *elem, time, _mesh.max_elem_id(), _mesh.max_node_id()); + + if (intersect.if_intersection_through_elem() || + ((intersect.get_intersection_mode() == MAST::COLINEAR_EDGE || + intersect.get_intersection_mode() == MAST::THROUGH_NODE) && + intersect.get_sub_elems_negative_phi().size() == 1) || + intersect.if_elem_on_negative_phi()) + elems_to_partition.push_back(elem); + + intersect.clear(); + } + + + // now we process only the selected elements + bool + mesh_changed = false; + + for (unsigned int i=0; isubdomain_id())); + elem->subdomain_id() += inactive_subdomain_offset; + mesh_changed = true; + } + else if ((intersect.get_intersection_mode() == MAST::COLINEAR_EDGE || + intersect.get_intersection_mode() == MAST::THROUGH_NODE) && + intersect.get_sub_elems_negative_phi().size() == 1) { + + if (strong_discontinuity) { + _process_negative_element(negative_level_set_subdomain_offset, + level_set_boundary_id, + *elem, + intersect); + + _old_elems.push_back(std::make_pair(elem, elem->subdomain_id())); + elem->subdomain_id() += inactive_subdomain_offset; + } + else { + + _old_elems.push_back(std::make_pair(elem, elem->subdomain_id())); + elem->subdomain_id() += negative_level_set_subdomain_offset; + + } + } + else if (intersect.if_elem_on_negative_phi()) { + // if the element has no positive region, then we set its + // subdomain id to that of negative level set offset + + _old_elems.push_back(std::make_pair(elem, elem->subdomain_id())); + elem->subdomain_id() += negative_level_set_subdomain_offset; + } + + intersect.clear(); + } + + // If the mesh changed on any processor, it changed globally + _mesh.comm().max(mesh_changed); + + // And we may need to update DistributedMesh values reflecting the changes + if (mesh_changed) + _mesh.update_parallel_id_counts(); + + if (mesh_changed && !_mesh.is_replicated()) + { + libMesh::MeshCommunication().make_elems_parallel_consistent (_mesh); + libMesh::MeshCommunication().make_new_nodes_parallel_consistent (_mesh); +#ifdef DEBUG + _mesh.libmesh_assert_valid_parallel_ids(); +#endif + } + + // If we're refining a Replicated_mesh, then we haven't yet assigned + // node processor ids. But if we're refining a partitioned + // Replicated_mesh, then we *need* to assign node processor ids. + if (mesh_changed && _mesh.is_replicated() && + (_mesh.unpartitioned_elements_begin() == + _mesh.unpartitioned_elements_end())) + libMesh::Partitioner::set_node_processor_ids(_mesh); + + if (mesh_changed) + _mesh.prepare_for_use(/*skip_renumber =*/ false); + + _strong_discontinuity = strong_discontinuity; + _negative_level_set_subdomain_offset = negative_level_set_subdomain_offset; + _inactive_subdomain_offset = inactive_subdomain_offset; + _level_set_boundary_id = level_set_boundary_id; + _initialized = true; + + return mesh_changed; +} + + +bool +MAST::SubElemMeshRefinement::clear_mesh() { + + // clear the data structure + _hanging_node.clear(); + + // modify the original element subdomain + for (unsigned int i=0; i<_old_elems.size(); i++) + _old_elems[i].first->subdomain_id() = _old_elems[i].second; + _old_elems.clear(); + + // remove all the new nodes and elements from the mesh + for (unsigned int i=0; i<_new_elems.size(); i++) { + + // Remove this element from any neighbor + // lists that point to it. + _new_elems[i]->nullify_neighbors(); + + // Remove any boundary information associated + // with this element + _mesh.get_boundary_info().remove(_new_elems[i]); + + _mesh.delete_elem(_new_elems[i]); + } + + for (unsigned int i=0; i<_new_nodes.size(); i++) + _mesh.delete_node(_new_nodes[i]); + + + bool + mesh_changed = false; + + if (_new_elems.size() || _new_nodes.size()) mesh_changed = true; + + _mesh.comm().max(mesh_changed); + + if (mesh_changed) { + + _mesh.update_parallel_id_counts(); + _new_elems.clear(); + _new_nodes.clear(); + _node_map->clear(); + _mesh.prepare_for_use(); + } + + if (mesh_changed && !_mesh.is_serial()) { + + libMesh::MeshCommunication().make_nodes_parallel_consistent (_mesh); + +#ifdef DEBUG + MeshTools::libmesh_assert_valid_procids(_mesh); +#endif + } + + _negative_level_set_ids.clear(); + _strong_discontinuity = false; + _negative_level_set_subdomain_offset = 0; + _inactive_subdomain_offset = 0; + _level_set_boundary_id = 0; + _initialized = false; + + return mesh_changed; +} + + + +void +MAST::SubElemMeshRefinement::constrain() { + + // we will constrain only if the mesh has been processed for the level set + // no constraint is to be added for weak discontinuity. + if (!_initialized || !_strong_discontinuity) return; + + // For strong discontinuity, iterate over all elements and constrain all + // dofs on them + libMesh::DofMap& dof_map = _system.get_dof_map(); + + libMesh::MeshBase::const_element_iterator el = + _system.get_mesh().active_local_elements_begin(); + const libMesh::MeshBase::const_element_iterator end_el = + _system.get_mesh().active_local_elements_end(); + + const libMesh::dof_id_type + first_dof = dof_map.first_dof(_mesh.comm().rank()), + last_dof = dof_map.end_dof(_mesh.comm().rank()); + + std::vector + dof_indices; + + for ( ; el != end_el; ++el) { + + const libMesh::Elem* elem = *el; + + if (_negative_level_set_ids.count(elem->subdomain_id())) { + + dof_indices.clear(); + dof_map.dof_indices(elem, dof_indices); + + // constrain all dofs if they have not already been constrained. + for (unsigned int i=0; i= first_dof || dof_indices[i] < last_dof) && + !dof_map.is_constrained_dof(dof_indices[i])) { + + libMesh::DofConstraintRow c_row; + dof_map.add_constraint_row(dof_indices[i], c_row, true); + } + } + } + } + + // now add constriant for the nodes identified as hanging node + std::set>>::iterator + n_it = _hanging_node.begin(), + n_end = _hanging_node.end(); + + libMesh::Point + p; + + Real + d = 0.; + + unsigned int + dof_b_node1, + dof_b_node2, + dof_node; + + for ( ; n_it != n_end; n_it++) { + + const std::pair> + &v = *n_it; + + // obtain the fraction of the node from the bounding nodes + // distance of node from first + p = *v.first - *v.second.first; + d = p.norm(); + // distance between the bounding nodes + p = *v.second.second - *v.second.first; + d /= p.norm(); + + + // we iterate over the variables in the system + // and add a constraint for each node + for (unsigned int i=0; i<_system.n_vars(); i++) { + + // identify the dofs for the ith variable on each node + // first, the node for which the constraint will be added + dof_indices.clear(); + dof_map.dof_indices(v.first, dof_indices, i); + libmesh_assert_equal_to(dof_indices.size(), 1); + dof_node = dof_indices[0]; + + // next, the first bounding node + dof_indices.clear(); + dof_map.dof_indices(v.second.first, dof_indices, i); + libmesh_assert_equal_to(dof_indices.size(), 1); + dof_b_node1 = dof_indices[0]; + + // next, the second bounding node + dof_indices.clear(); + dof_map.dof_indices(v.second.second, dof_indices, i); + libmesh_assert_equal_to(dof_indices.size(), 1); + dof_b_node2 = dof_indices[0]; + + // now create and add the constraint + if ((dof_node >= first_dof || dof_node < last_dof) && + !dof_map.is_constrained_dof(dof_node)) { + + // the constraint assumes linear variation of the value + // between the bounding nodes + // the constraint reads + // un = (1-d) ub1 + d ub2 + // or, un - (1-d) ub1 - d ub2 = 0 + libMesh::DofConstraintRow c_row; + c_row[dof_b_node1] = (1.-d); + c_row[dof_b_node2] = d; + + dof_map.add_constraint_row(dof_node, c_row, true); + } + } + } +} + + + +void +MAST::SubElemMeshRefinement::_process_sub_elements(bool strong_discontinuity, + unsigned int negative_level_set_subdomain_offset, + unsigned level_set_boundary_id, + libMesh::Elem& e, + MAST::LevelSetIntersection& intersect, + bool positive_phi, + const std::vector& elems) { + + libmesh_assert(!_initialized); + + std::map + intersection_object_to_mesh_node_map; + + std::vector> + interior_node_association; + + for (unsigned int i=0; itype()).release(); + + // set nodes for this child element + for (unsigned int j=0; jn_nodes(); j++) { + + const libMesh::Node + *sub_e_node = sub_e->node_ptr(j); + + if (!intersect.if_node_is_new(*sub_e_node)) { + + // this is a node from the parent element. So, we use is as is + child->set_node(j) = const_cast(sub_e_node); + + // keep track of nodes for the addition of interior nodes + intersection_object_to_mesh_node_map[sub_e_node] = sub_e_node; + } + else if (intersect.if_interior_node(*sub_e_node)) { + + // this node will be added after all edge nodes have been + // added. This will be added as the jth node of the + // child elem + interior_node_association.push_back + (std::tuple(sub_e_node, child, j)); + } + else { + + // this is a new node. So, we ask the intersection object + // about the bounding nodes and add them to this new node + std::pair + bounding_nodes = intersect.get_bounding_nodes_for_node(*sub_e_node); + + libMesh::Node* + child_node = _add_node(*sub_e_node, + strong_discontinuity, + positive_phi, + e.processor_id(), + bounding_nodes); + child->set_node(j) = child_node; + + // identify this node to as a hanging node + if (intersect.if_hanging_node(sub_e_node)) + _hanging_node.insert(std::make_pair(child_node, bounding_nodes)); + + // keep track for nodes for the addition of interior nodes + intersection_object_to_mesh_node_map[sub_e_node] = child_node; + } + } + + // set flags for this child element + //child->set_refinement_flag(libMesh::Elem::JUST_REFINED); + child->set_p_level(e.p_level()); + child->set_p_refinement_flag(e.p_refinement_flag()); + child->set_n_systems(e.n_systems()); + // we need to offset the subdomain id for an element type that is + // not the same as the parent element since exodus output requires + // different subdomain ids for different element types. + if (child->type() == e.type()) + child->subdomain_id() = e.subdomain_id(); + else + child->subdomain_id() = e.subdomain_id()+1; + + // the negative level set is offset by the specified value so that + // the assembly routines can deal with them separately + if (!positive_phi) { + + child->subdomain_id() += negative_level_set_subdomain_offset; + _negative_level_set_ids.insert(child->subdomain_id()); + } + +#if (LIBMESH_MAJOR_VERSION == 1 && LIBMESH_MINOR_VERSION >= 5) + libmesh_assert_equal_to (child->n_extra_integers(), + e.n_extra_integers()); + for (unsigned int j=0; j != e.n_extra_integers(); ++j) + child->set_extra_integer(j, e.get_extra_integer(j)); +#endif + _mesh.add_elem(child); + + if (intersect.has_side_on_interface(*sub_e)) + _mesh.boundary_info->add_side(child, + intersect.get_side_on_interface(*sub_e), + level_set_boundary_id); + + _new_elems.push_back(child); + } + + + // now process the interior nodes + for (unsigned int i=0; i(interior_node_association[i]); + + libMesh::Elem + *child = std::get<1>(interior_node_association[i]); + + unsigned int + node_num = std::get<2>(interior_node_association[i]); + + std::pair + bounding_nodes = intersect.get_bounding_nodes_for_node(*sub_e_node); + + // since the nodes in the map are based on newly created nodes, and + // not those created by the intersection object, we replace the + // bounding_nodes pair with those that were created here. + libmesh_assert(intersection_object_to_mesh_node_map.count(bounding_nodes.first)); + libmesh_assert(intersection_object_to_mesh_node_map.count(bounding_nodes.second)); + bounding_nodes.first = intersection_object_to_mesh_node_map[bounding_nodes.first]; + bounding_nodes.second = intersection_object_to_mesh_node_map[bounding_nodes.second]; + + libMesh::Node* + child_node = _add_node(*sub_e_node, + strong_discontinuity, + positive_phi, + e.processor_id(), + bounding_nodes); + + child->set_node(node_num) = child_node; + } +} + + + + +void +MAST::SubElemMeshRefinement::_process_negative_element(unsigned int negative_level_set_subdomain_offset, + unsigned level_set_boundary_id, + libMesh::Elem& e, + MAST::LevelSetIntersection& intersect) { + + libmesh_assert(!_initialized); + + std::set + side_nodes; + + // get the nodes on the side with the interface that will be replaced + // with new nodes on the negative phi + if (intersect.get_intersection_mode() == MAST::THROUGH_NODE) + side_nodes.insert(e.node_ptr(intersect.node_on_boundary())); + else if (intersect.get_intersection_mode() == MAST::COLINEAR_EDGE) { + + unsigned int i = intersect.edge_on_boundary(); + std::unique_ptr side(e.side_ptr(i)); + for (unsigned int j=0; jn_nodes(); j++) + side_nodes.insert(side->node_ptr(j)); + } + else { + // should not get here + libmesh_assert(false); + } + + + libMesh::Elem + *child = libMesh::Elem::build(e.type()).release(); + + // set nodes for this new element + for (unsigned int j=0; jset_node(j) = e_node; + else { + + std::pair + bounding_nodes = std::make_pair(e_node, e_node); + + libMesh::Node* + child_node = _add_node(*e_node, + true, // this method only deals with strong discontinuity + false, // and with nodes on negative level set + e.processor_id(), + bounding_nodes); + child->set_node(j) = child_node; + } + } + + // set flags for this child element + //child->set_refinement_flag(libMesh::Elem::JUST_REFINED); + child->set_p_level(e.p_level()); + child->set_p_refinement_flag(e.p_refinement_flag()); + child->set_n_systems(e.n_systems()); + // we need to offset the subdomain id for an element type that is + // not the same as the parent element since exodus output requires + // different subdomain ids for different element types. + if (child->type() == e.type()) + child->subdomain_id() = e.subdomain_id() + negative_level_set_subdomain_offset; + else + child->subdomain_id() = e.subdomain_id()+1 + negative_level_set_subdomain_offset; + + _negative_level_set_ids.insert(child->subdomain_id()); + +#if (LIBMESH_MAJOR_VERSION == 1 && LIBMESH_MINOR_VERSION >= 5) + libmesh_assert_equal_to (child->n_extra_integers(), + e.n_extra_integers()); + + for (unsigned int j=0; j != e.n_extra_integers(); ++j) + child->set_extra_integer(j, e.get_extra_integer(j)); +#endif + _mesh.add_elem(child); + + _new_elems.push_back(child); +} + + + +libMesh::Node* +MAST::SubElemMeshRefinement::_add_node(const libMesh::Point& p, + bool strong_disontinuity, + bool positive_phi, + unsigned int processor_id, + const std::pair& bounding_nodes) { + + libmesh_assert(!_initialized); + + unsigned int + id1 = std::min(bounding_nodes.first->id(), bounding_nodes.second->id()), + id2 = std::max(bounding_nodes.first->id(), bounding_nodes.second->id()); + + std::pair& + node_pair = _node_map->add(id1, id2); + + // if a weak discontinuity is requested, and if the node has already been + // created, then make sure that both nodes are the same + if (!strong_disontinuity) { + + if (node_pair.first) { + libmesh_assert_equal_to(node_pair.first, node_pair.second); + return node_pair.first; + } + else { + + // for a weak discontinuity nodes on either side of the discontinuity + // are the same + node_pair.first = _mesh.add_point(p, libMesh::DofObject::invalid_id, processor_id); + _new_nodes.push_back(node_pair.first); + + libmesh_assert(node_pair.first); + + node_pair.first->processor_id() = libMesh::DofObject::invalid_processor_id; + node_pair.second = node_pair.first; + + return node_pair.first; + } + } + else { + + if (positive_phi) { + + if (node_pair.first) + return node_pair.first; + else { + + // create and store a separate node for the positive side of the + // level set + node_pair.first = _mesh.add_point(p, libMesh::DofObject::invalid_id, processor_id); + _new_nodes.push_back(node_pair.first); + + libmesh_assert(node_pair.first); + + node_pair.first->processor_id() = libMesh::DofObject::invalid_processor_id; + + return node_pair.first; + } + } + else { // negative phi + + if (node_pair.second) + return node_pair.second; + else { + + // create and store a separate node for the positive side of the + // level set + node_pair.second = _mesh.add_point(p, libMesh::DofObject::invalid_id, processor_id); + _new_nodes.push_back(node_pair.second); + + libmesh_assert(node_pair.second); + + node_pair.second->processor_id() = libMesh::DofObject::invalid_processor_id; + + return node_pair.second; + } + } + } +} + + diff --git a/src/level_set/sub_elem_mesh_refinement.h b/src/level_set/sub_elem_mesh_refinement.h new file mode 100644 index 00000000..f2252758 --- /dev/null +++ b/src/level_set/sub_elem_mesh_refinement.h @@ -0,0 +1,122 @@ +/* + * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit + * Copyright (C) 2013-2019 Manav Bhatia + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __mast__sub_elem_mesh_refinement_h__ +#define __mast__sub_elem_mesh_refinement_h__ + +// MAST includes +#include "base/mast_data_types.h" + +// libMesh includes +#include "libmesh/mesh_base.h" +#include "libmesh/system.h" + + +namespace MAST { + + // Forward declerations + template class FieldFunction; + class LevelSetIntersection; + class SubElemNodeMap; + + class SubElemMeshRefinement: + public libMesh::System::Constraint { + + public: + + SubElemMeshRefinement(libMesh::MeshBase& mesh, + libMesh::System& sys); + + virtual ~SubElemMeshRefinement(); + + bool initialized() { return _initialized; } + + bool process_mesh(const MAST::FieldFunction& phi, + bool strong_discontinuity, + Real time, + unsigned int negative_level_set_subdomain_offset, + unsigned int inactive_subdomain_offset, + unsigned int level_set_boundary_id); + + bool clear_mesh(); + + /*! + * provides implementation of the libMesh::System::Constraint::constrain() + * virtual method + */ + virtual void + constrain (); + + protected: + + void _process_sub_elements(bool strong_discontinuity, + unsigned int negative_level_set_subdomain_offset, + unsigned int level_set_boundary_id, + libMesh::Elem& e, + MAST::LevelSetIntersection& intersect, + bool positive_phi, + const std::vector& elems); + + void _process_negative_element(unsigned int negative_level_set_subdomain_offset, + unsigned level_set_boundary_id, + libMesh::Elem& e, + MAST::LevelSetIntersection& intersect); + + /*! + * \returns a node between the bounding nodes at the specified + * location. If a node already exists between these bounding nodes the + * that node is returned. Else, a new node is created, added to the + * mesh and returned. + */ + libMesh::Node* + _add_node(const libMesh::Point& p, + bool strong_disontinuity, + bool positive_phi, + unsigned int processor_id, + const std::pair& bounding_nodes); + + libMesh::Elem* _add_elem(); + + bool _initialized; + + bool _strong_discontinuity; + + unsigned int _negative_level_set_subdomain_offset; + + unsigned int _inactive_subdomain_offset; + + unsigned int _level_set_boundary_id; + + libMesh::MeshBase& _mesh; + + libMesh::System& _system; + + // map for storing new nodes + MAST::SubElemNodeMap *_node_map; + + std::set _negative_level_set_ids; + std::vector _new_nodes; + std::vector _new_elems; + std::vector> _old_elems; + std::set>> _hanging_node; + }; +} + + +#endif // __mast__sub_elem_mesh_refinement_h__ diff --git a/src/level_set/sub_elem_node_map.cpp b/src/level_set/sub_elem_node_map.cpp new file mode 100644 index 00000000..f88766a1 --- /dev/null +++ b/src/level_set/sub_elem_node_map.cpp @@ -0,0 +1,59 @@ +/* + * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit + * Copyright (C) 2013-2019 Manav Bhatia + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +// MAST includes +#include "level_set/sub_elem_node_map.h" + + +MAST::SubElemNodeMap::SubElemNodeMap() { + +} + + +MAST::SubElemNodeMap::~SubElemNodeMap() { + +} + + + + +unsigned int +MAST::SubElemNodeMap::count(libMesh::dof_id_type bracket_node1, + libMesh::dof_id_type bracket_node2) const { + + return _map.count(std::make_pair(bracket_node1, bracket_node2)); +} + + +std::pair& +MAST::SubElemNodeMap::add(libMesh::dof_id_type bracket_node1, + libMesh::dof_id_type bracket_node2) { + + MAST::SubElemNodeMap::map_type::iterator + it = _map.find(std::make_pair(bracket_node1, bracket_node2)); + + if (it == _map.end()) { + + it = _map.insert(std::make_pair(std::make_pair(bracket_node1, bracket_node2), + std::make_pair(nullptr, nullptr))).first; + } + + return it->second; +} + diff --git a/src/level_set/sub_elem_node_map.h b/src/level_set/sub_elem_node_map.h new file mode 100644 index 00000000..a451ea68 --- /dev/null +++ b/src/level_set/sub_elem_node_map.h @@ -0,0 +1,89 @@ +/* + * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit + * Copyright (C) 2013-2019 Manav Bhatia + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __mast_sub_elem_node_map_h__ +#define __mast_sub_elem_node_map_h__ + +// C++ includes +#include +#include // std::hash + +// libMesh includes +#include "libmesh/mesh_base.h" + +namespace MAST{ + + + class SubElemNodeMap { + + // borrowing this from libMesh::TopologyMap + struct myhash { + public: + template + std::size_t operator()(const std::pair & x) const + { + return 3 * std::hash()(x.first) + std::hash()(x.second); + } + }; + + + // first pair is the key, which identifies the bounding nodes on a + // parent edge where the node is created. + // second pair is the set of nodes used by the adjacent elements on the + // positive and negative sides of the level set function. Specifying + // both to be same will allow a weak discontinuity, while specifying + // both to be different will allow a strong discontinuity + typedef + std::unordered_map + , + std::pair, MAST::SubElemNodeMap::myhash> map_type; + + + public: + + SubElemNodeMap(); + + + virtual ~SubElemNodeMap(); + + + void clear() { _map.clear(); } + + + bool empty() const { return _map.empty(); } + + + unsigned int + count(libMesh::dof_id_type bracket_node1, libMesh::dof_id_type bracket_node2) const; + + + std::pair& + add(libMesh::dof_id_type bracket_node1, libMesh::dof_id_type bracket_node2); + + + protected: + + + MAST::SubElemNodeMap::map_type _map; + }; + +} + + +#endif // __mast_sub_elem_node_map_h__ diff --git a/src/mesh/fe_base.h b/src/mesh/fe_base.h index a374f806..b15dc372 100644 --- a/src/mesh/fe_base.h +++ b/src/mesh/fe_base.h @@ -44,6 +44,8 @@ namespace MAST { virtual ~FEBase(); + bool initialized() const { return _initialized;} + /*! * this is used, in addition to \p libMesh::System::extra_quadrature_order * to set the quadrature rule. diff --git a/src/mesh/geom_elem.cpp b/src/mesh/geom_elem.cpp index f43decb1..e29a5253 100644 --- a/src/mesh/geom_elem.cpp +++ b/src/mesh/geom_elem.cpp @@ -158,11 +158,13 @@ MAST::GeomElem::init_fe(bool init_grads, std::unique_ptr MAST::GeomElem::init_side_fe(unsigned int s, bool init_grads, + bool init_second_order_derivative, int extra_quadrature_order) const { std::unique_ptr fe(new MAST::FEBase(*_sys_init)); fe->set_extra_quadrature_order(extra_quadrature_order); - + fe->set_evaluate_second_order_derivatives(init_second_order_derivative); + fe->init_for_side(*this, s, init_grads); return fe; diff --git a/src/mesh/geom_elem.h b/src/mesh/geom_elem.h index 5a21a4fe..beae4e71 100644 --- a/src/mesh/geom_elem.h +++ b/src/mesh/geom_elem.h @@ -134,6 +134,7 @@ namespace MAST { virtual std::unique_ptr init_side_fe(unsigned int s, bool init_grads, + bool init_second_order_derivative, int extra_quadrature_order = 0) const; diff --git a/src/mesh/nastran_io.cpp b/src/mesh/nastran_io.cpp index 1be1f654..494109f2 100644 --- a/src/mesh/nastran_io.cpp +++ b/src/mesh/nastran_io.cpp @@ -12,6 +12,9 @@ #include // #include +#include "base/mast_config.h" +#if MAST_ENABLE_NASTRANIO == 1 + // MAST includes. #include "mesh/nastran_io.h" #include "libfort/fort.hpp" @@ -316,3 +319,4 @@ void MAST::printNodeCoords(std::vector> nodes) } } +#endif // MAST_ENABLE_NASTRANIO diff --git a/src/mesh/nastran_io.h b/src/mesh/nastran_io.h index 6f488783..6212fa69 100644 --- a/src/mesh/nastran_io.h +++ b/src/mesh/nastran_io.h @@ -11,6 +11,9 @@ #include #include +#include "base/mast_config.h" +#if MAST_ENABLE_NASTRANIO == 1 + // Python includes. #include @@ -201,4 +204,5 @@ class NastranIO : public libMesh::MeshInput { void printNodeCoords(std::vector> nodes); } +#endif // MAST_ENABLE_NASTRANIO #endif // __mast_nastran_io_h__ diff --git a/src/optimization/function_evaluation.cpp b/src/optimization/function_evaluation.cpp index 503dba7b..0de811bf 100644 --- a/src/optimization/function_evaluation.cpp +++ b/src/optimization/function_evaluation.cpp @@ -23,11 +23,10 @@ #include // MAST includes -#include "optimization/function_evaluation.h" +#include "optimization/function_evaluation.h" // libMesh includes -#include "libmesh/parallel_implementation.h" - +#include "libmesh/parallel.h" void MAST::FunctionEvaluation::attach_optimization_interface(MAST::OptimizationInterface& opt) { @@ -514,6 +513,7 @@ MAST::FunctionEvaluation::_output_wrapper(unsigned int iter, libmesh_assert(this->comm().verify(iter)); libmesh_assert(this->comm().verify(x)); - this->output(iter, x, obj, fval, if_write_to_optim_file); + this->output(_iter, x, obj, fval, if_write_to_optim_file); + _iter++; } diff --git a/src/optimization/function_evaluation.h b/src/optimization/function_evaluation.h index a9951582..b057b735 100644 --- a/src/optimization/function_evaluation.h +++ b/src/optimization/function_evaluation.h @@ -49,6 +49,7 @@ namespace MAST { FunctionEvaluation(const libMesh::Parallel::Communicator& comm_in): libMesh::ParallelObject (comm_in), + _iter (0), _n_vars (0), _n_eq (0), _n_ineq (0), @@ -260,6 +261,8 @@ namespace MAST { protected: + unsigned int _iter; + unsigned int _n_vars; unsigned int _n_eq; diff --git a/src/solver/first_order_newmark_transient_solver.cpp b/src/solver/first_order_newmark_transient_solver.cpp index 7d34b17e..5251cf8c 100644 --- a/src/solver/first_order_newmark_transient_solver.cpp +++ b/src/solver/first_order_newmark_transient_solver.cpp @@ -364,6 +364,15 @@ elem_shape_sensitivity_calculations(const MAST::FunctionBase& f, +void +MAST::FirstOrderNewmarkTransientSolver:: +elem_topology_sensitivity_calculations(const MAST::FunctionBase& f, + RealVectorX& vec) { + libmesh_assert(false); // to be implemented +} + + + void MAST::FirstOrderNewmarkTransientSolver:: elem_topology_sensitivity_calculations(const MAST::FunctionBase& f, diff --git a/src/solver/first_order_newmark_transient_solver.h b/src/solver/first_order_newmark_transient_solver.h index 9227a7f7..a362dc8b 100644 --- a/src/solver/first_order_newmark_transient_solver.h +++ b/src/solver/first_order_newmark_transient_solver.h @@ -192,6 +192,15 @@ namespace MAST { elem_shape_sensitivity_calculations(const MAST::FunctionBase& f, RealVectorX& vec); + /*! + * performs the element topology sensitivity calculations over \p elem, + * and returns the element residual sensitivity in \p vec . + */ + virtual void + elem_topology_sensitivity_calculations(const MAST::FunctionBase& f, + RealVectorX& vec); + + /*! * performs the element topology sensitivity calculations over \p elem, * and returns the element residual sensitivity in \p vec . diff --git a/src/solver/second_order_newmark_transient_solver.cpp b/src/solver/second_order_newmark_transient_solver.cpp index 402c09c5..9addf780 100644 --- a/src/solver/second_order_newmark_transient_solver.cpp +++ b/src/solver/second_order_newmark_transient_solver.cpp @@ -462,6 +462,15 @@ elem_shape_sensitivity_calculations(const MAST::FunctionBase& f, +void +MAST::SecondOrderNewmarkTransientSolver:: +elem_topology_sensitivity_calculations(const MAST::FunctionBase& f, + RealVectorX& vec) { + libmesh_assert(false); // to be implemented +} + + + void MAST::SecondOrderNewmarkTransientSolver:: elem_topology_sensitivity_calculations(const MAST::FunctionBase& f, diff --git a/src/solver/second_order_newmark_transient_solver.h b/src/solver/second_order_newmark_transient_solver.h index 9c5b2ce3..2dae2bf1 100644 --- a/src/solver/second_order_newmark_transient_solver.h +++ b/src/solver/second_order_newmark_transient_solver.h @@ -164,6 +164,14 @@ namespace MAST { elem_shape_sensitivity_calculations(const MAST::FunctionBase& f, RealVectorX& vec); + /*! + * performs the element topology sensitivity calculations over \p elem, + * and returns the element residual sensitivity in \p vec . + */ + virtual void + elem_topology_sensitivity_calculations(const MAST::FunctionBase& f, + RealVectorX& vec); + /*! * performs the element topology sensitivity calculations over \p elem, * and returns the element residual sensitivity in \p vec . diff --git a/src/solver/stabilized_first_order_transient_sensitivity_solver.h b/src/solver/stabilized_first_order_transient_sensitivity_solver.h index fc4a7bed..9952e885 100644 --- a/src/solver/stabilized_first_order_transient_sensitivity_solver.h +++ b/src/solver/stabilized_first_order_transient_sensitivity_solver.h @@ -142,6 +142,13 @@ namespace MAST { libmesh_error(); } + virtual void + elem_topology_sensitivity_calculations(const MAST::FunctionBase& f, + RealVectorX& vec) { + libmesh_error(); + } + + virtual void elem_topology_sensitivity_calculations(const MAST::FunctionBase& f, const MAST::FieldFunction& vel, diff --git a/src/utility/plot.cpp b/src/utility/plot.cpp index 224c4016..effd888e 100644 --- a/src/utility/plot.cpp +++ b/src/utility/plot.cpp @@ -46,13 +46,13 @@ MAST::plot_elem(Gnuplot& gp, void -MAST::plot_node(Gnuplot& gp, const libMesh::Node& node) { +MAST::plot_node(Gnuplot& gp, const libMesh::Point& pt) { std::vector> xy(1); - std::get<0>(xy[0]) = node(0); - std::get<1>(xy[0]) = node(1); + std::get<0>(xy[0]) = pt(0); + std::get<1>(xy[0]) = pt(1); gp << "plot '-' with points \n"; gp.send1d(xy); diff --git a/src/utility/plot.h b/src/utility/plot.h index aa52efdf..f9a0b7d2 100644 --- a/src/utility/plot.h +++ b/src/utility/plot.h @@ -35,7 +35,7 @@ namespace MAST { void plot_elem(Gnuplot& gp, const libMesh::Elem& elem); - void plot_node(Gnuplot& gp, const libMesh::Node& node); + void plot_node(Gnuplot& gp, const libMesh::Point& point); } #endif // MAST_ENABLE_GNUPLOT diff --git a/tests/fluid/base/fluid_elem_initialization.h b/tests/fluid/base/fluid_elem_initialization.h index 5b91b649..2235a3cb 100644 --- a/tests/fluid/base/fluid_elem_initialization.h +++ b/tests/fluid/base/fluid_elem_initialization.h @@ -162,7 +162,6 @@ struct BuildFluidElem { _geom_elem = new MAST::GeomElem; _geom_elem->init(**_mesh->elements_begin(), *_sys_init); _fluid_elem = new MAST::ConservativeFluidElementBase(*_sys_init, - *_assembly, *_geom_elem, *_flight_cond); From b3ba8d7efc0b399b2d0b182d91d0266d568ee9e6 Mon Sep 17 00:00:00 2001 From: David John Neiferd <13425967+JohnDN90@users.noreply.github.com> Date: Wed, 5 Feb 2020 10:13:32 -0500 Subject: [PATCH 039/111] Added catch2 header file for new unit tests using Catch2. --- tests/catch.hpp | 17597 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 17597 insertions(+) create mode 100644 tests/catch.hpp diff --git a/tests/catch.hpp b/tests/catch.hpp new file mode 100644 index 00000000..b4eccfc1 --- /dev/null +++ b/tests/catch.hpp @@ -0,0 +1,17597 @@ +/* + * Catch v2.11.0 + * Generated: 2019-11-15 15:01:56.628356 + * ---------------------------------------------------------- + * This file has been merged from multiple headers. Please don't edit it directly + * Copyright (c) 2019 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED +#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED +// start catch.hpp + + +#define CATCH_VERSION_MAJOR 2 +#define CATCH_VERSION_MINOR 11 +#define CATCH_VERSION_PATCH 0 + +#ifdef __clang__ +# pragma clang system_header +#elif defined __GNUC__ +# pragma GCC system_header +#endif + +// start catch_suppress_warnings.h + +#ifdef __clang__ +# ifdef __ICC // icpc defines the __clang__ macro +# pragma warning(push) +# pragma warning(disable: 161 1682) +# else // __ICC +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wpadded" +# pragma clang diagnostic ignored "-Wswitch-enum" +# pragma clang diagnostic ignored "-Wcovered-switch-default" +# endif +#elif defined __GNUC__ + // Because REQUIREs trigger GCC's -Wparentheses, and because still + // supported version of g++ have only buggy support for _Pragmas, + // Wparentheses have to be suppressed globally. +# pragma GCC diagnostic ignored "-Wparentheses" // See #674 for details + +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wunused-variable" +# pragma GCC diagnostic ignored "-Wpadded" +#endif +// end catch_suppress_warnings.h +#if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER) +# define CATCH_IMPL +# define CATCH_CONFIG_ALL_PARTS +#endif + +// In the impl file, we want to have access to all parts of the headers +// Can also be used to sanely support PCHs +#if defined(CATCH_CONFIG_ALL_PARTS) +# define CATCH_CONFIG_EXTERNAL_INTERFACES +# if defined(CATCH_CONFIG_DISABLE_MATCHERS) +# undef CATCH_CONFIG_DISABLE_MATCHERS +# endif +# if !defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER) +# define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER +# endif +#endif + +#if !defined(CATCH_CONFIG_IMPL_ONLY) +// start catch_platform.h + +#ifdef __APPLE__ +# include +# if TARGET_OS_OSX == 1 +# define CATCH_PLATFORM_MAC +# elif TARGET_OS_IPHONE == 1 +# define CATCH_PLATFORM_IPHONE +# endif + +#elif defined(linux) || defined(__linux) || defined(__linux__) +# define CATCH_PLATFORM_LINUX + +#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__) +# define CATCH_PLATFORM_WINDOWS +#endif + +// end catch_platform.h + +#ifdef CATCH_IMPL +# ifndef CLARA_CONFIG_MAIN +# define CLARA_CONFIG_MAIN_NOT_DEFINED +# define CLARA_CONFIG_MAIN +# endif +#endif + +// start catch_user_interfaces.h + +namespace Catch { + unsigned int rngSeed(); +} + +// end catch_user_interfaces.h +// start catch_tag_alias_autoregistrar.h + +// start catch_common.h + +// start catch_compiler_capabilities.h + +// Detect a number of compiler features - by compiler +// The following features are defined: +// +// CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported? +// CATCH_CONFIG_WINDOWS_SEH : is Windows SEH supported? +// CATCH_CONFIG_POSIX_SIGNALS : are POSIX signals supported? +// CATCH_CONFIG_DISABLE_EXCEPTIONS : Are exceptions enabled? +// **************** +// Note to maintainers: if new toggles are added please document them +// in configuration.md, too +// **************** + +// In general each macro has a _NO_ form +// (e.g. CATCH_CONFIG_NO_POSIX_SIGNALS) which disables the feature. +// Many features, at point of detection, define an _INTERNAL_ macro, so they +// can be combined, en-mass, with the _NO_ forms later. + +#ifdef __cplusplus + +# if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) +# define CATCH_CPP14_OR_GREATER +# endif + +# if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) +# define CATCH_CPP17_OR_GREATER +# endif + +#endif + +#if defined(CATCH_CPP17_OR_GREATER) +# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS +#endif + +// We have to avoid both ICC and Clang, because they try to mask themselves +// as gcc, and we want only GCC in this block +#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) +# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic push" ) +# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic pop" ) +#endif + +#if defined(__clang__) + +# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic push" ) +# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic pop" ) + +# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + _Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) \ + _Pragma( "clang diagnostic ignored \"-Wglobal-constructors\"") + +# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ + _Pragma( "clang diagnostic ignored \"-Wparentheses\"" ) + +# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \ + _Pragma( "clang diagnostic ignored \"-Wunused-variable\"" ) + +# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ + _Pragma( "clang diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\"" ) + +# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ + _Pragma( "clang diagnostic ignored \"-Wunused-template\"" ) + +#endif // __clang__ + +//////////////////////////////////////////////////////////////////////////////// +// Assume that non-Windows platforms support posix signals by default +#if !defined(CATCH_PLATFORM_WINDOWS) + #define CATCH_INTERNAL_CONFIG_POSIX_SIGNALS +#endif + +//////////////////////////////////////////////////////////////////////////////// +// We know some environments not to support full POSIX signals +#if defined(__CYGWIN__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(__DJGPP__) + #define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS +#endif + +#ifdef __OS400__ +# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS +# define CATCH_CONFIG_COLOUR_NONE +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Android somehow still does not support std::to_string +#if defined(__ANDROID__) +# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING +# define CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Not all Windows environments support SEH properly +#if defined(__MINGW32__) +# define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH +#endif + +//////////////////////////////////////////////////////////////////////////////// +// PS4 +#if defined(__ORBIS__) +# define CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Cygwin +#ifdef __CYGWIN__ + +// Required for some versions of Cygwin to declare gettimeofday +// see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin +# define _BSD_SOURCE +// some versions of cygwin (most) do not support std::to_string. Use the libstd check. +// https://gcc.gnu.org/onlinedocs/gcc-4.8.2/libstdc++/api/a01053_source.html line 2812-2813 +# if !((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \ + && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)) + +# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING + +# endif +#endif // __CYGWIN__ + +//////////////////////////////////////////////////////////////////////////////// +// Visual C++ +#if defined(_MSC_VER) + +# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma( warning(push) ) +# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION __pragma( warning(pop) ) + +# if _MSC_VER >= 1900 // Visual Studio 2015 or newer +# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS +# endif + +// Universal Windows platform does not support SEH +// Or console colours (or console at all...) +# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) +# define CATCH_CONFIG_COLOUR_NONE +# else +# define CATCH_INTERNAL_CONFIG_WINDOWS_SEH +# endif + +// MSVC traditional preprocessor needs some workaround for __VA_ARGS__ +// _MSVC_TRADITIONAL == 0 means new conformant preprocessor +// _MSVC_TRADITIONAL == 1 means old traditional non-conformant preprocessor +# if !defined(_MSVC_TRADITIONAL) || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL) +# define CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +# endif +#endif // _MSC_VER + +#if defined(_REENTRANT) || defined(_MSC_VER) +// Enable async processing, as -pthread is specified or no additional linking is required +# define CATCH_INTERNAL_CONFIG_USE_ASYNC +#endif // _MSC_VER + +//////////////////////////////////////////////////////////////////////////////// +// Check if we are compiled with -fno-exceptions or equivalent +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +# define CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED +#endif + +//////////////////////////////////////////////////////////////////////////////// +// DJGPP +#ifdef __DJGPP__ +# define CATCH_INTERNAL_CONFIG_NO_WCHAR +#endif // __DJGPP__ + +//////////////////////////////////////////////////////////////////////////////// +// Embarcadero C++Build +#if defined(__BORLANDC__) + #define CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN +#endif + +//////////////////////////////////////////////////////////////////////////////// + +// Use of __COUNTER__ is suppressed during code analysis in +// CLion/AppCode 2017.2.x and former, because __COUNTER__ is not properly +// handled by it. +// Otherwise all supported compilers support COUNTER macro, +// but user still might want to turn it off +#if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L ) + #define CATCH_INTERNAL_CONFIG_COUNTER +#endif + +//////////////////////////////////////////////////////////////////////////////// + +// RTX is a special version of Windows that is real time. +// This means that it is detected as Windows, but does not provide +// the same set of capabilities as real Windows does. +#if defined(UNDER_RTSS) || defined(RTX64_BUILD) + #define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH + #define CATCH_INTERNAL_CONFIG_NO_ASYNC + #define CATCH_CONFIG_COLOUR_NONE +#endif + +#if defined(__UCLIBC__) +#define CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER +#endif + +// Various stdlib support checks that require __has_include +#if defined(__has_include) + // Check if string_view is available and usable + #if __has_include() && defined(CATCH_CPP17_OR_GREATER) + # define CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW + #endif + + // Check if optional is available and usable + # if __has_include() && defined(CATCH_CPP17_OR_GREATER) + # define CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL + # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) + + // Check if byte is available and usable + # if __has_include() && defined(CATCH_CPP17_OR_GREATER) + # define CATCH_INTERNAL_CONFIG_CPP17_BYTE + # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) + + // Check if variant is available and usable + # if __has_include() && defined(CATCH_CPP17_OR_GREATER) + # if defined(__clang__) && (__clang_major__ < 8) + // work around clang bug with libstdc++ https://bugs.llvm.org/show_bug.cgi?id=31852 + // fix should be in clang 8, workaround in libstdc++ 8.2 + # include + # if defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) + # define CATCH_CONFIG_NO_CPP17_VARIANT + # else + # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT + # endif // defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) + # else + # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT + # endif // defined(__clang__) && (__clang_major__ < 8) + # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) +#endif // defined(__has_include) + +#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER) +# define CATCH_CONFIG_COUNTER +#endif +#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH) && !defined(CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH) +# define CATCH_CONFIG_WINDOWS_SEH +#endif +// This is set by default, because we assume that unix compilers are posix-signal-compatible by default. +#if defined(CATCH_INTERNAL_CONFIG_POSIX_SIGNALS) && !defined(CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_POSIX_SIGNALS) +# define CATCH_CONFIG_POSIX_SIGNALS +#endif +// This is set by default, because we assume that compilers with no wchar_t support are just rare exceptions. +#if !defined(CATCH_INTERNAL_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_WCHAR) +# define CATCH_CONFIG_WCHAR +#endif + +#if !defined(CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_CPP11_TO_STRING) +# define CATCH_CONFIG_CPP11_TO_STRING +#endif + +#if defined(CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_NO_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_CPP17_OPTIONAL) +# define CATCH_CONFIG_CPP17_OPTIONAL +#endif + +#if defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) && !defined(CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS) && !defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) +# define CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS +#endif + +#if defined(CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_NO_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_CPP17_STRING_VIEW) +# define CATCH_CONFIG_CPP17_STRING_VIEW +#endif + +#if defined(CATCH_INTERNAL_CONFIG_CPP17_VARIANT) && !defined(CATCH_CONFIG_NO_CPP17_VARIANT) && !defined(CATCH_CONFIG_CPP17_VARIANT) +# define CATCH_CONFIG_CPP17_VARIANT +#endif + +#if defined(CATCH_INTERNAL_CONFIG_CPP17_BYTE) && !defined(CATCH_CONFIG_NO_CPP17_BYTE) && !defined(CATCH_CONFIG_CPP17_BYTE) +# define CATCH_CONFIG_CPP17_BYTE +#endif + +#if defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT) +# define CATCH_INTERNAL_CONFIG_NEW_CAPTURE +#endif + +#if defined(CATCH_INTERNAL_CONFIG_NEW_CAPTURE) && !defined(CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NEW_CAPTURE) +# define CATCH_CONFIG_NEW_CAPTURE +#endif + +#if !defined(CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED) && !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) +# define CATCH_CONFIG_DISABLE_EXCEPTIONS +#endif + +#if defined(CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_NO_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_POLYFILL_ISNAN) +# define CATCH_CONFIG_POLYFILL_ISNAN +#endif + +#if defined(CATCH_INTERNAL_CONFIG_USE_ASYNC) && !defined(CATCH_INTERNAL_CONFIG_NO_ASYNC) && !defined(CATCH_CONFIG_NO_USE_ASYNC) && !defined(CATCH_CONFIG_USE_ASYNC) +# define CATCH_CONFIG_USE_ASYNC +#endif + +#if defined(CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_NO_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_ANDROID_LOGWRITE) +# define CATCH_CONFIG_ANDROID_LOGWRITE +#endif + +#if defined(CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_NO_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_GLOBAL_NEXTAFTER) +# define CATCH_CONFIG_GLOBAL_NEXTAFTER +#endif + +// Even if we do not think the compiler has that warning, we still have +// to provide a macro that can be used by the code. +#if !defined(CATCH_INTERNAL_START_WARNINGS_SUPPRESSION) +# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION +#endif +#if !defined(CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION) +# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION +#endif +#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS +#endif +#if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS +#endif +#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS +#endif +#if !defined(CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS +#endif + +#if defined(__APPLE__) && defined(__apple_build_version__) && (__clang_major__ < 10) +# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS +#elif defined(__clang__) && (__clang_major__ < 5) +# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS +#endif + +#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS +#endif + +#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) +#define CATCH_TRY if ((true)) +#define CATCH_CATCH_ALL if ((false)) +#define CATCH_CATCH_ANON(type) if ((false)) +#else +#define CATCH_TRY try +#define CATCH_CATCH_ALL catch (...) +#define CATCH_CATCH_ANON(type) catch (type) +#endif + +#if defined(CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_NO_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) +#define CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#endif + +// end catch_compiler_capabilities.h +#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line +#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) +#ifdef CATCH_CONFIG_COUNTER +# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ ) +#else +# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ ) +#endif + +#include +#include +#include + +// We need a dummy global operator<< so we can bring it into Catch namespace later +struct Catch_global_namespace_dummy {}; +std::ostream& operator<<(std::ostream&, Catch_global_namespace_dummy); + +namespace Catch { + + struct CaseSensitive { enum Choice { + Yes, + No + }; }; + + class NonCopyable { + NonCopyable( NonCopyable const& ) = delete; + NonCopyable( NonCopyable && ) = delete; + NonCopyable& operator = ( NonCopyable const& ) = delete; + NonCopyable& operator = ( NonCopyable && ) = delete; + + protected: + NonCopyable(); + virtual ~NonCopyable(); + }; + + struct SourceLineInfo { + + SourceLineInfo() = delete; + SourceLineInfo( char const* _file, std::size_t _line ) noexcept + : file( _file ), + line( _line ) + {} + + SourceLineInfo( SourceLineInfo const& other ) = default; + SourceLineInfo& operator = ( SourceLineInfo const& ) = default; + SourceLineInfo( SourceLineInfo&& ) noexcept = default; + SourceLineInfo& operator = ( SourceLineInfo&& ) noexcept = default; + + bool empty() const noexcept { return file[0] == '\0'; } + bool operator == ( SourceLineInfo const& other ) const noexcept; + bool operator < ( SourceLineInfo const& other ) const noexcept; + + char const* file; + std::size_t line; + }; + + std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ); + + // Bring in operator<< from global namespace into Catch namespace + // This is necessary because the overload of operator<< above makes + // lookup stop at namespace Catch + using ::operator<<; + + // Use this in variadic streaming macros to allow + // >> +StreamEndStop + // as well as + // >> stuff +StreamEndStop + struct StreamEndStop { + std::string operator+() const; + }; + template + T const& operator + ( T const& value, StreamEndStop ) { + return value; + } +} + +#define CATCH_INTERNAL_LINEINFO \ + ::Catch::SourceLineInfo( __FILE__, static_cast( __LINE__ ) ) + +// end catch_common.h +namespace Catch { + + struct RegistrarForTagAliases { + RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ); + }; + +} // end namespace Catch + +#define CATCH_REGISTER_TAG_ALIAS( alias, spec ) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); } \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION + +// end catch_tag_alias_autoregistrar.h +// start catch_test_registry.h + +// start catch_interfaces_testcase.h + +#include + +namespace Catch { + + class TestSpec; + + struct ITestInvoker { + virtual void invoke () const = 0; + virtual ~ITestInvoker(); + }; + + class TestCase; + struct IConfig; + + struct ITestCaseRegistry { + virtual ~ITestCaseRegistry(); + virtual std::vector const& getAllTests() const = 0; + virtual std::vector const& getAllTestsSorted( IConfig const& config ) const = 0; + }; + + bool isThrowSafe( TestCase const& testCase, IConfig const& config ); + bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ); + std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ); + std::vector const& getAllTestCasesSorted( IConfig const& config ); + +} + +// end catch_interfaces_testcase.h +// start catch_stringref.h + +#include +#include +#include +#include + +namespace Catch { + + /// A non-owning string class (similar to the forthcoming std::string_view) + /// Note that, because a StringRef may be a substring of another string, + /// it may not be null terminated. + class StringRef { + public: + using size_type = std::size_t; + using const_iterator = const char*; + + private: + static constexpr char const* const s_empty = ""; + + char const* m_start = s_empty; + size_type m_size = 0; + + public: // construction + constexpr StringRef() noexcept = default; + + StringRef( char const* rawChars ) noexcept; + + constexpr StringRef( char const* rawChars, size_type size ) noexcept + : m_start( rawChars ), + m_size( size ) + {} + + StringRef( std::string const& stdString ) noexcept + : m_start( stdString.c_str() ), + m_size( stdString.size() ) + {} + + explicit operator std::string() const { + return std::string(m_start, m_size); + } + + public: // operators + auto operator == ( StringRef const& other ) const noexcept -> bool; + auto operator != (StringRef const& other) const noexcept -> bool { + return !(*this == other); + } + + auto operator[] ( size_type index ) const noexcept -> char { + assert(index < m_size); + return m_start[index]; + } + + public: // named queries + constexpr auto empty() const noexcept -> bool { + return m_size == 0; + } + constexpr auto size() const noexcept -> size_type { + return m_size; + } + + // Returns the current start pointer. If the StringRef is not + // null-terminated, throws std::domain_exception + auto c_str() const -> char const*; + + public: // substrings and searches + // Returns a substring of [start, start + length). + // If start + length > size(), then the substring is [start, size()). + // If start > size(), then the substring is empty. + auto substr( size_type start, size_type length ) const noexcept -> StringRef; + + // Returns the current start pointer. May not be null-terminated. + auto data() const noexcept -> char const*; + + constexpr auto isNullTerminated() const noexcept -> bool { + return m_start[m_size] == '\0'; + } + + public: // iterators + constexpr const_iterator begin() const { return m_start; } + constexpr const_iterator end() const { return m_start + m_size; } + }; + + auto operator += ( std::string& lhs, StringRef const& sr ) -> std::string&; + auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&; + + constexpr auto operator "" _sr( char const* rawChars, std::size_t size ) noexcept -> StringRef { + return StringRef( rawChars, size ); + } +} // namespace Catch + +constexpr auto operator "" _catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef { + return Catch::StringRef( rawChars, size ); +} + +// end catch_stringref.h +// start catch_preprocessor.hpp + + +#define CATCH_RECURSION_LEVEL0(...) __VA_ARGS__ +#define CATCH_RECURSION_LEVEL1(...) CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(__VA_ARGS__))) +#define CATCH_RECURSION_LEVEL2(...) CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(__VA_ARGS__))) +#define CATCH_RECURSION_LEVEL3(...) CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(__VA_ARGS__))) +#define CATCH_RECURSION_LEVEL4(...) CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(__VA_ARGS__))) +#define CATCH_RECURSION_LEVEL5(...) CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(__VA_ARGS__))) + +#ifdef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#define INTERNAL_CATCH_EXPAND_VARGS(...) __VA_ARGS__ +// MSVC needs more evaluations +#define CATCH_RECURSION_LEVEL6(...) CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(__VA_ARGS__))) +#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL6(CATCH_RECURSION_LEVEL6(__VA_ARGS__)) +#else +#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL5(__VA_ARGS__) +#endif + +#define CATCH_REC_END(...) +#define CATCH_REC_OUT + +#define CATCH_EMPTY() +#define CATCH_DEFER(id) id CATCH_EMPTY() + +#define CATCH_REC_GET_END2() 0, CATCH_REC_END +#define CATCH_REC_GET_END1(...) CATCH_REC_GET_END2 +#define CATCH_REC_GET_END(...) CATCH_REC_GET_END1 +#define CATCH_REC_NEXT0(test, next, ...) next CATCH_REC_OUT +#define CATCH_REC_NEXT1(test, next) CATCH_DEFER ( CATCH_REC_NEXT0 ) ( test, next, 0) +#define CATCH_REC_NEXT(test, next) CATCH_REC_NEXT1(CATCH_REC_GET_END test, next) + +#define CATCH_REC_LIST0(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ ) +#define CATCH_REC_LIST1(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0) ) ( f, peek, __VA_ARGS__ ) +#define CATCH_REC_LIST2(f, x, peek, ...) f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ ) + +#define CATCH_REC_LIST0_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ ) +#define CATCH_REC_LIST1_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0_UD) ) ( f, userdata, peek, __VA_ARGS__ ) +#define CATCH_REC_LIST2_UD(f, userdata, x, peek, ...) f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ ) + +// Applies the function macro `f` to each of the remaining parameters, inserts commas between the results, +// and passes userdata as the first parameter to each invocation, +// e.g. CATCH_REC_LIST_UD(f, x, a, b, c) evaluates to f(x, a), f(x, b), f(x, c) +#define CATCH_REC_LIST_UD(f, userdata, ...) CATCH_RECURSE(CATCH_REC_LIST2_UD(f, userdata, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) + +#define CATCH_REC_LIST(f, ...) CATCH_RECURSE(CATCH_REC_LIST2(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) + +#define INTERNAL_CATCH_EXPAND1(param) INTERNAL_CATCH_EXPAND2(param) +#define INTERNAL_CATCH_EXPAND2(...) INTERNAL_CATCH_NO## __VA_ARGS__ +#define INTERNAL_CATCH_DEF(...) INTERNAL_CATCH_DEF __VA_ARGS__ +#define INTERNAL_CATCH_NOINTERNAL_CATCH_DEF +#define INTERNAL_CATCH_STRINGIZE(...) INTERNAL_CATCH_STRINGIZE2(__VA_ARGS__) +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#define INTERNAL_CATCH_STRINGIZE2(...) #__VA_ARGS__ +#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) +#else +// MSVC is adding extra space and needs another indirection to expand INTERNAL_CATCH_NOINTERNAL_CATCH_DEF +#define INTERNAL_CATCH_STRINGIZE2(...) INTERNAL_CATCH_STRINGIZE3(__VA_ARGS__) +#define INTERNAL_CATCH_STRINGIZE3(...) #__VA_ARGS__ +#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) (INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) + 1) +#endif + +#define INTERNAL_CATCH_MAKE_NAMESPACE2(...) ns_##__VA_ARGS__ +#define INTERNAL_CATCH_MAKE_NAMESPACE(name) INTERNAL_CATCH_MAKE_NAMESPACE2(name) + +#define INTERNAL_CATCH_REMOVE_PARENS(...) INTERNAL_CATCH_EXPAND1(INTERNAL_CATCH_DEF __VA_ARGS__) + +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) decltype(get_wrapper()) +#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__)) +#else +#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) INTERNAL_CATCH_EXPAND_VARGS(decltype(get_wrapper())) +#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__))) +#endif + +#define INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(...)\ + CATCH_REC_LIST(INTERNAL_CATCH_MAKE_TYPE_LIST,__VA_ARGS__) + +#define INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_0) INTERNAL_CATCH_REMOVE_PARENS(_0) +#define INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_0, _1) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_1) +#define INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_0, _1, _2) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_1, _2) +#define INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_0, _1, _2, _3) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_1, _2, _3) +#define INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_0, _1, _2, _3, _4) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_1, _2, _3, _4) +#define INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_0, _1, _2, _3, _4, _5) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_1, _2, _3, _4, _5) +#define INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_0, _1, _2, _3, _4, _5, _6) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_1, _2, _4, _5, _6) +#define INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_0, _1, _2, _3, _4, _5, _6, _7) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_1, _2, _3, _4, _5, _6, _7) +#define INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_1, _2, _3, _4, _5, _6, _7, _8) +#define INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9) +#define INTERNAL_CATCH_REMOVE_PARENS_11_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10) + +#define INTERNAL_CATCH_VA_NARGS_IMPL(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N + +#define INTERNAL_CATCH_TYPE_GEN\ + template struct TypeList {};\ + template\ + constexpr auto get_wrapper() noexcept -> TypeList { return {}; }\ + template class...> struct TemplateTypeList{};\ + template class...Cs>\ + constexpr auto get_wrapper() noexcept -> TemplateTypeList { return {}; }\ + template\ + struct append;\ + template\ + struct rewrap;\ + template class, typename...>\ + struct create;\ + template class, typename>\ + struct convert;\ + \ + template \ + struct append { using type = T; };\ + template< template class L1, typename...E1, template class L2, typename...E2, typename...Rest>\ + struct append, L2, Rest...> { using type = typename append, Rest...>::type; };\ + template< template class L1, typename...E1, typename...Rest>\ + struct append, TypeList, Rest...> { using type = L1; };\ + \ + template< template class Container, template class List, typename...elems>\ + struct rewrap, List> { using type = TypeList>; };\ + template< template class Container, template class List, class...Elems, typename...Elements>\ + struct rewrap, List, Elements...> { using type = typename append>, typename rewrap, Elements...>::type>::type; };\ + \ + template