diff --git a/.gitignore b/.gitignore index 4a9c7db048..45b3762c08 100644 --- a/.gitignore +++ b/.gitignore @@ -81,3 +81,6 @@ proteus/mprans/cRANS3PSed.cpp proteus/mprans/cVOF3P.cpp proteus/mprans/cVOS3P.cpp proteus/superluWrappers.c +proteus/MeshAdaptPUMI/MeshAdapt.cpp +proteus/tests/ci/meshNoVessel.edge +proteus/tests/ci/meshNoVessel.neigh diff --git a/.gitmodules b/.gitmodules index baa6d7725e..e69de29bb2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "stack"] - path = stack - url = https://github.com/erdc/stack diff --git a/.travis.yml b/.travis.yml index 01febced18..d2f59ca96b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,16 +17,20 @@ jobs: install: - git lfs pull - sudo apt-get update - - wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh; - - bash miniconda.sh -b -p $HOME/miniconda - - source "$HOME/miniconda/etc/profile.d/conda.sh" + - wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh -O miniforge3.sh; + - bash miniforge3.sh -b -p $HOME/miniforge3 + - source "$HOME/miniforge3/etc/profile.d/conda.sh" + - source "$HOME/miniforge3/etc/profile.d/mamba.sh" - hash -r - conda config --set always_yes yes --set changeps1 no - - conda update -q conda - - conda info -a - - conda env create -f environment-dev.yml - - conda activate proteus-dev - - PROTEUS_OPT="-g0 -O1" N=2 make develop-conda + - mamba init + - mamba update -q conda mamba + - mamba info -a + - mamba env create -f environment-dev.yml + - mamba activate proteus-dev + - pip install -v . --no-build-isolation --no-binary=":all:" script: - export MPLBACKEND="AGG" - - py.test -n 1 --forked -v proteus/tests --ignore proteus/tests/POD + - mkdir test_output + - cd test_output + - py.test -v --forked --import-mode=importlib ../test diff --git a/Makefile b/Makefile index eccef875cc..b6baaf76a3 100644 --- a/Makefile +++ b/Makefile @@ -7,12 +7,12 @@ all: develop SHELL=/usr/bin/env bash N ?= 1 -PROTEUS ?= $(shell python3 -c "from __future__ import print_function; import os; print(os.path.realpath(os.getcwd()))") +PROTEUS ?= $(shell python3 -c "import os; print(os.path.realpath(os.getcwd()))") VER_CMD = git log -1 --pretty="%H" PROTEUS_BUILD_CMD = python3 setup.py build_ext -PROTEUS_INSTALL_CMD = pip install -v . #python3 setup.py install +PROTEUS_INSTALL_CMD = pip3 install --no-deps --no-build-isolation --no-binary=:all: -v . #python3 setup.py install PROTEUS_DEVELOP_BUILD_CMD = python3 setup.py build_ext -i -PROTEUS_DEVELOP_CMD = pip install -v -e . +PROTEUS_DEVELOP_CMD = pip3 install --no-deps --no-build-isolation --no-binary=:all: -v -e . # ifeq (${N}, 1) PROTEUS_BUILD_CMD = python3 -c "print('Letting install handle build_ext')" @@ -28,6 +28,9 @@ PROTEUS_ARCH ?= $(shell [[ $$(hostname) = centennial* ]] && echo "centennial" || PROTEUS_ARCH ?= $(shell [[ $$(hostname) = thunder* ]] && echo "thunder" || python3 -c "import sys; print(sys.platform)") PROTEUS_ARCH ?= $(shell [[ $$(hostname) = gordon* ]] && echo "gordon" || python3 -c "import sys; print(sys.platform)") PROTEUS_ARCH ?= $(shell [[ $$(hostname) = conrad* ]] && echo "conrad" || python3 -c "import sys; print(sys.platform)") +ifdef PROTEUS_PREFIX +CONDA_PREFIX='' +endif ifdef CONDA_PREFIX PROTEUS_ARCH ?= linux PROTEUS_PREFIX ?= ${CONDA_PREFIX} @@ -37,6 +40,7 @@ PROTEUS_PREFIX ?= ${PROTEUS}/${PROTEUS_ARCH} PROTEUS_PYTHON ?= ${PROTEUS_PREFIX}/bin/python3 PROTEUS_VERSION := $(shell ${VER_CMD}) endif + TEST_MARKER="' '" define show_info @@ -151,6 +155,7 @@ ${PROTEUS_PREFIX}/artifact.json: stack/default.yaml $(shell find stack -type f) @echo "************************" @echo "Dependency build complete" @echo "************************" + ${PROTEUS_PREFIX}/bin/python -m ensurepip ${PROTEUS_PREFIX}/bin/proteus_env.sh: ${PROTEUS_PREFIX}/artifact.json @echo "************************" @@ -166,7 +171,6 @@ install: ${PROTEUS_PREFIX}/bin/proteus_env.sh stack/default.yaml ${PROTEUS_PREFI @echo "Installing..." @echo "************************" $(call show_info) - ${PROTEUS_ENV} ${PROTEUS_BUILD_CMD} ${PROTEUS_ENV} ${PROTEUS_INSTALL_CMD} @echo "************************" @echo "done installing standard extension modules" @@ -193,7 +197,7 @@ develop: ${PROTEUS_PREFIX}/bin/proteus_env.sh stack/default.yaml ${PROTEUS_PREFI @echo "Installing development version" @echo "************************" $(call show_info) - ${PROTEUS_ENV} pip install py2gmsh pytest pytest-xdist pytest-cov tables future hypothesis + ${PROTEUS_ENV} pip3 install py2gmsh pytest pytest-xdist pytest-cov pytest-forked hypothesis ${PROTEUS_ENV} ${PROTEUS_DEVELOP_BUILD_CMD} ${PROTEUS_ENV} ${PROTEUS_DEVELOP_CMD} @echo "************************" @@ -217,7 +221,7 @@ develop-conda: @echo "************************************" $(call show_info) ${PROTEUS_DEVELOP_CMD} - pip install pytest-xdist-forked + pip3 install pytest-forked @echo "************************" @echo "Development installation complete" @echo "************************" @@ -319,7 +323,7 @@ ifdef CONDA_PREFIX else source ${PROTEUS_PREFIX}/bin/proteus_env.sh endif - pip install configparser ipyparallel ipython terminado jupyter ipywidgets ipyleaflet jupyter_dashboards pythreejs rise cesiumpy ipympl sympy transforms3d ipymesh voila ipyvolume ipysheet xonsh[ptk,linux,proctitle] ipytree + pip3 install configparser ipyparallel ipython terminado jupyter ipywidgets ipyleaflet jupyter_dashboards pythreejs rise cesiumpy ipympl sympy transforms3d ipymesh voila ipyvolume ipysheet xonsh[ptk,linux,proctitle] ipytree ipcluster nbextension enable --user jupyter nbextension enable --py --sys-prefix ipysheet jupyter nbextension enable --py --sys-prefix widgetsnbextension @@ -353,7 +357,7 @@ jupyterlab: @echo "************************************" @echo "Enabling jupyter lab" source ${PROTEUS_PREFIX}/bin/proteus_env.sh - pip install jupyterlab jupyterlab_latex + pip3 install jupyterlab jupyterlab_latex jupyter serverextension enable --py jupyterlab --sys-prefix jupyter serverextension enable --sys-prefix --py jupyterlab_latex jupyter labextension install @jupyter-widgets/jupyterlab-manager diff --git a/README.md b/README.md index 3b47582b03..dedd14c777 100644 --- a/README.md +++ b/README.md @@ -9,27 +9,64 @@ rapidly developing computer models and numerical methods. ```bash -conda install proteus -c conda-forge +mamba install proteus -c conda-forge ``` For a development installation, you want to install Proteus's dependencies and compile Proteus from source: ```bash -conda env create -f environment-dev.yml -conda activate proteus-dev -make develop-conda # or pip install -v -e . +mamba env create -f environment-dev.yml #environment-dev-up.yml to try unpinned dependencies +mamba activate proteus-dev +pip install -v -e . ``` -You can also build proteus and dependencies from source (without conda) with +# HPC Installation -```bash -make develop -make test +For installation on high performance environments you may want to install Proteus's dependencies from source as well. We recommend using the PETSc build system to install most of the dependencies. The following is general outline: + +Create a basic python environment you can install into: + +``` +mamba env create -f petsc-dev.yml +mamba activate petsc-dev +``` + +or + +``` +python -m venv petsc-dev +pip install setuptools make cmake cython swig pybind11 numpy +``` + +Next, build petsc from source + +``` +bash scripts/petsc_config_linux_conda_seq.sh #see https://petsc.org/release/install/ +``` + +Next, build additional C++ dependencies and install into environment prefix (e.g $CONDA_PREFIX or $VIRTUAL_ENV) + +https://github.com/projectchrono/chrono #>=9.0.1, with python bindings +https://github.com/scorec/core #>=2.2.8, shared, python bindinds not needed +https://github.com/xtensor-stack/xtl +https://github.com/xtensor-stack/xtensor +https://github.com/xtensor-stack/xtensor-python + +Finally, locally build and install remaining python dependencies into environment + +``` +CC=mpicc CXX=mpicxx MPI_DIR=$MPI_ROOT pip install -v mpi4py==3.1.6 --no-build-isolation --no-binary=:all: +PETSC_DIR=$CONDA_PREFIX PETSC_ARCH="" pip install -v ../petsc/src/binding/petsc4py --no-build-isolation --no-binary=:all: +HDF5_MPI=ON HDF5_DIR=${CONDA_PREFIX} CC=mpicc CXX=mpicxx pip install -v h5py --no-build-isolation --no-binary=:all: #note h5py depends on mpi4py for this config +CC=mpicc CXX=mpicxx pip install -v . --no-build-isolation --no-binary=:all: ``` -See https://github.com/erdc/proteus/wiki/How-to-Build-Proteus for more information on building the entire stack. +Some optional packages can be installed with pip/mamba: py2gmsh, memory_profiler, scipy, pytest. + +See https://github.com/erdc/proteus/wiki/How-to-Build-Proteus for old information on building the entire stack. # Developer Information The source code, wiki, and issue tracker are on GitHub at + https://github.com/erdc/proteus. diff --git a/docs/Doxyfile b/docs/Doxyfile index 0c810c05d5..8e5d87f13f 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = proteus # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.8.2.dev0 +PROJECT_NUMBER = 1.8.3 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/docs/source/conf.py b/docs/source/conf.py index 0d8573b055..0ce412a7f8 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -450,4 +450,4 @@ def linkcode_resolve(domain, info): # "exhaleExecutesDoxygen": True, # #"exhaleUseDoxyfile": True, # "exhaleDoxygenStdin": exhaleDoxygenStdin -#} +#} \ No newline at end of file diff --git a/environment-dev-up.yml b/environment-dev-up.yml index 00e47fd71d..8bf28894fa 100644 --- a/environment-dev-up.yml +++ b/environment-dev-up.yml @@ -1,4 +1,4 @@ -name: proteus-dev-up-240321 +name: proteus-dev-up-240912 channels: - conda-forge - defaults @@ -8,7 +8,7 @@ dependencies: - make - setuptools - cython - - daetk + - pybind11 - hdf5 =*=*mpich* - h5py =*=*mpich* - metis @@ -20,15 +20,14 @@ dependencies: - parmetis - petsc4py - petsc - - scorec - superlu - superlu_dist + - scorec >=2.2.8 - triangle - - pychrono + - pychrono >=9.0.1 - gmsh - matplotlib - mpi4py - - pytables - pytest - pytest-cov - pytest-xdist @@ -36,18 +35,12 @@ dependencies: - tetgen - ncurses - python - - future - ipyparallel - - pillow - xtensor-python - git-lfs - eigen - zoltan - hypre - - mumps-mpi - - numexpr - - ptscotch - - scalapack - tbb - zipp - parso @@ -55,5 +48,5 @@ dependencies: - ipython - decorator - cffi - - netcdf4 - - jupyterlab \ No newline at end of file + - jupyterlab + - openmp diff --git a/environment-dev.yml b/environment-dev.yml index 7b8f49105e..4df56314cd 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -5,54 +5,46 @@ channels: dependencies: - pip =24.0 - compilers =1.7.0 - - make =4.3 - - setuptools =69.2.0 - - cython =3.0.9 - - daetk =1.0.1 + - make =4.4.1 + - setuptools =73.0.1 + - cython =3.0.11 - hdf5 =1.14.3=*mpich* - - h5py =3.10.0=*mpich* + - h5py =3.11.0=*mpich* - metis =5.1.0 - - mpich =4.2.0 - - mpich-mpicc =4.2.0 - - mpich-mpicxx =4.2.0 - - numpy =1.26.4 - - openblas =0.3.26 + - mpich =4.2.2 + - mpich-mpicc =4.2.2 + - mpich-mpicxx =4.2.2 + - numpy =2.1.1 + - openblas =0.3.28 - parmetis =4.0.3 - - petsc4py =3.20.5 - - petsc =3.20.5 - - scorec =2.2.7 + - petsc4py =3.21.5 + - petsc =3.21.5 + - scorec =2.2.8 - superlu =5.2.2 - - superlu_dist =8.2.1 + - superlu_dist =9.0.0 - triangle =1.6 - - pychrono =7.0.0 + - pychrono =9.0.1 - gmsh =4.12.2 - - matplotlib =3.8.3 - - mpi4py =3.1.5 - - pytables =3.9.2 - - pytest =8.1.1 - - pytest-cov =4.1.0 - - pytest-xdist =3.5.0 - - scipy =1.12.0 + - matplotlib =3.9.2 + - mpi4py =4.0.0 + - pytest =8.3.3 + - pytest-cov =5.0.0 + - pytest-xdist =3.6.1 + - pytest-forked + - scipy =1.14.1 - tetgen =1.6.0 - - ncurses =6.4.20240210 - - python =3.10.14 - - future =1.0.0 - - ipyparallel =8.7.0 - - pillow =10.2.0 + - ncurses =6.5 + - python =3.12.5 - xtensor-python = 0.27.0 - git-lfs =3.5.1 - eigen =3.4.0 - zoltan =3.901 - - hypre =2.28.0 - - mumps-mpi =5.6.2 - - numexpr =2.9.0 - - ptscotch =7.0.4 + - hypre =2.31.0 + - mumps-mpi =5.7.3 - scalapack =2.2.0 - - tbb =2021.11.0 - - zipp =3.17.0 - - parso =0.8.3 - - pycparser =2.21 - - ipython =8.22.2 - - decorator =5.1.1 - - cffi =1.16.0 - - sympy =1.12 \ No newline at end of file + - tbb =2021.13.0 + - zipp =3.20.1 + - parso =0.8.4 + - pycparser =2.22 + - cffi =1.17.1 + - sympy =1.13.2 \ No newline at end of file diff --git a/environment-petsc-dev.yml b/environment-petsc-dev.yml new file mode 100644 index 0000000000..142c10e859 --- /dev/null +++ b/environment-petsc-dev.yml @@ -0,0 +1,15 @@ +name: petsc-dev +channels: + - conda-forge + - defaults +dependencies: + - pip + - setuptools + - make + - cmake + - cython + - swig + - numpy + - pybind11 + - openblas + - tetgen \ No newline at end of file diff --git a/petsc-dev.yml b/petsc-dev.yml new file mode 100644 index 0000000000..d4d1c353e4 --- /dev/null +++ b/petsc-dev.yml @@ -0,0 +1,16 @@ +name: petsc-dev +channels: + - conda-forge + - defaults +dependencies: + - compilers + - python + - numpy + - setuptools + - pip + - make + - cmake + - cython + - swig + - ncurses + - xtensor-python diff --git a/proteus/ADR.py b/proteus/ADR.py index f260daab31..7debc7fed5 100644 --- a/proteus/ADR.py +++ b/proteus/ADR.py @@ -1,7 +1,6 @@ """ An optimized Advection-Diffusion-Reaction module """ - import numpy as np from math import fabs import proteus diff --git a/proteus/AnalysisTools.py b/proteus/AnalysisTools.py index 234a89969d..e7182e5d55 100644 --- a/proteus/AnalysisTools.py +++ b/proteus/AnalysisTools.py @@ -1,8 +1,3 @@ -from __future__ import print_function -from __future__ import division -from builtins import zip -from builtins import range -from past.utils import old_div import numpy as np from scipy import signal as sn #from pylab import * @@ -44,7 +39,7 @@ def readProbeFile(filename): return datalist def signalFilter(time,data,minfreq,maxfreq,costapCut = False): - dt = old_div((time[-1]-time[0]),(len(time)-1)) + dt = (time[-1]-time[0])/(len(time)-1) doInterp = False data1 = np.zeros(data.shape,) @@ -69,7 +64,7 @@ def signalFilter(time,data,minfreq,maxfreq,costapCut = False): data = data1 nprobes = -1 nfft = len(time) - dt = old_div((time[-1]-time[0]),(len(time)-1)) + dt = (time[-1]-time[0])/(len(time)-1) freq = np.fft.fftfreq(nfft,dt) i1 = np.where(freq > maxfreq)[0] i3 = np.where(freq < -maxfreq)[0] @@ -150,7 +145,7 @@ def zeroCrossing(time,data,mode="mean",up=True,filt=True,minfreq=0.,maxfreq=1e30 period = np.mean(period) elif type(mode) == "int": height = np.sort(zCH) - ii = len(height) - old_div(float(len(height)),float(mode)) + ii = len(height) - float(len(height))/float(mode) height = np.mean(height[ii:]) period = np.mean(period) else: @@ -162,22 +157,22 @@ def zeroCrossing(time,data,mode="mean",up=True,filt=True,minfreq=0.,maxfreq=1e30 def pressureToHeight(data,Z,depth,wavelength,rho,g): k = 2*math.pi/wavelength Kp = rho*g*cosh(k*(depth+Z))/cosh(k*depth) - return old_div(data,Kp) + return data/Kp def ReflStat(H1,H2,H3,dx,wavelength): D = 2*math.pi*dx/wavelength - Amp =np.array([old_div(H1,2.),old_div(H2,2.),old_div(H3,2.)]) + Amp =np.array([H1/2.,H2/2.,H3/2.]) A1 = Amp[0]*Amp[0] A2 = Amp[1]*Amp[1] A3 = Amp[2]*Amp[2] - Lamda = old_div((A1 + A3 - 2.*A2*cos(2*D)),(4.*sin(D)*sin(D))) + Lamda = (A1+A3-2.*A2*cos(2*D))/(4.*sin(D)*sin(D)) Gamma = 0.5*sqrt( - (old_div((2*A2-A1-A3),(2.*sin(D)*sin(D))))**2+(old_div((A1-A3),sin(2*D)))**2) + ((2*A2-A1-A3)/(2.*sin(D)*sin(D)))**2+((A1-A3)/sin(2*D))**2) Hi = sqrt(Lamda + Gamma) + sqrt(Lamda - Gamma) Hr = sqrt(Lamda + Gamma) - sqrt(Lamda - Gamma) - Rf = old_div(Hr,(Hi+1e-15)) + Rf = Hr/(Hi+1e-15) return [Hi,Hr,Rf] # i3 = np.where(freq[np.where(freq<0)[0]] @@ -193,4 +188,3 @@ def ReflStat(H1,H2,H3,dx,wavelength): # return [time_lin,data1] - diff --git a/proteus/AnalyticalSolutions.py b/proteus/AnalyticalSolutions.py index 7d6317ea10..8b6e72d183 100644 --- a/proteus/AnalyticalSolutions.py +++ b/proteus/AnalyticalSolutions.py @@ -4,12 +4,6 @@ .. inheritance-diagram:: proteus.AnalyticalSolutions :parts: 1 """ -from __future__ import print_function -from __future__ import absolute_import -from __future__ import division -from builtins import range -from past.utils import old_div -from builtins import object from math import * from .EGeometry import * from .LinearAlgebraTools import * @@ -159,7 +153,7 @@ def __init__(self, a, p): if self.p_ == 1: self.func = lambda t: exp(-self.a_*t) else: - q = old_div(1.0, (1.0 - self.p_)) + q = 1.0/(1.0-self.p_) self.func = lambda t: max(1.0 - (1.0 - self.p_)*self.a_*t, 0.0)**q def uOfT(self, t): @@ -196,10 +190,10 @@ def __init__(self, b=1.0, a=5.0e-1): self.b_ = b self.a_ = a if b != 0.0: - self.D_ = (old_div(1.0, (exp(old_div(b, a))-1.0))) + self.D_ = (1.0/(exp(b/a)-1.0)) else: self.D_ = 0.0 - self.C_ = -self.D_*exp(old_div(b, a)) + self.C_ = -self.D_*exp(b/a) def uOfX(self, X): x = X[0] @@ -230,11 +224,11 @@ def f(rtmC): return rtmC*tanh(b*rtmC/a) - 1.0 def df(rtmC): - return rtmC*(old_div(1.0, cosh(b*rtmC/a)**2))*(old_div(b, a)) + tanh(b*rtmC/a) + return rtmC*(1.0/cosh(b*rtmC/a)**2)*(b/a) + tanh(b*rtmC/a) logEvent("Solving for sqrt(-C) for q=2,r=1") rtmC = sqrt(1.5) while abs(f(rtmC)) > 1.0e-8: - rtmC -= old_div(f(rtmC), df(rtmC)) + rtmC -= f(rtmC)/df(rtmC) logEvent("sqrt(-C)="+repr(rtmC)) self.rtmC_ = rtmC self.sol_ = lambda x: self.rtmC_ * \ @@ -245,15 +239,15 @@ def df(rtmC): logEvent("Solving for C in q=1,r=2") def f(C): - return 2.0*C*(log(C-1.0) - log(C)) + 2.0 + old_div(self.b_, self.a_) + return 2.0*C*(log(C-1.0) - log(C)) + 2.0 + self.b_/self.a_ def df(C): - return 2.0*(log(C-1.0) - log(C)) + 2.0*C*(old_div(1.0, (C-1.0)) - old_div(1.0, C)) + return 2.0*(log(C-1.0) - log(C)) + 2.0*C*(1.0/(C-1.0) - 1.0/C) C = 1.0 + 1.0e-10 f0 = f(C) print(f0) while abs(f(C)) > (1.0e-7*abs(f0) + 1.0e-7): - dC = old_div(-f(C), df(C)) + dC = -f(C)/df(C) logEvent("dc") print(dC) Ctmp = C + dC @@ -272,7 +266,7 @@ def df(C): logEvent("C="+repr(C)) self.nlC_ = C self.nlD_ = 0.5*(2.0*C*log(C*(C-1)) - - 4.0*C + 2.0 - old_div(self.b_, self.a_)) + 4.0*C + 2.0 - self.b_/self.a_) logEvent("D="+repr(self.nlD_)) # def f(C): # return (2.0*self.a_/self.b_)*(1.0 + @@ -306,7 +300,7 @@ def df(u): u = LinearAD_SteadyState.uOfX(self, X) f0 = f(u) while abs(f(u)) > 1.0e-6*abs(f0) + 1.0e-6: - u -= old_div(f(u), df(u)) + u -= f(u)/df(u) return u # def f(u): # return ((2.0*self.a_/self.b_**2)* @@ -477,11 +471,11 @@ def __init__(self, def uOfXT(self, x, T): t = T + self.tStart y = (x[:self.b_.shape[0]] - self.x0_[:self.b_.shape[0]] - self.b_*t) - exp_arg = old_div(numpy.dot(y, y), (4.0 * self.a_ * t)) + exp_arg = numpy.dot(y,y)/(4.0*self.a_*t) if exp_arg > 100: return 0.0 else: - return self.u0_*exp(-exp_arg) / (4.0*self.a_*pi*t)**(old_div(self.n_, 2.0)) + return self.u0_*exp(-exp_arg) / (4.0*self.a_*pi*t)**(self.n_/2.0) def duOfXT(self, x, T): t = T + self.tStart @@ -556,7 +550,7 @@ def uOfXT(self, x, T): t = T + self.tStart u1 = LinearAD_DiracIC.uOfXT(self, x, T) if u1 > 0.0: - return u1*exp(old_div(-(2.0*self.c_*t*pow(u1, self.d_-1.0)), (self.d_+1.0))) + return u1*exp(-(2.0*self.c_*t*pow(u1,self.d_-1.0))/(self.d_+1.0)) else: return u1 @@ -719,7 +713,7 @@ def uOfXT(self, x, t): if x[0]-self.x0 <= 0.0: return self.uL return self.uR - self.riemF.xi = old_div((x[0]-self.x0), (t-self.t0)) + self.riemF.xi = (x[0]-self.x0)/(t-self.t0) u, f = self.solver.solve(Guess_x=0.5*(self.uL+self.uR)) return u @@ -730,7 +724,7 @@ def generateAplot(self, xLeft, xRight, nnx, t, filename='Buckley_Leverett_ex.dat """ save exact solution to a file """ - dx = old_div((xRight-xLeft), (nnx-1.)) + dx = (xRight-xLeft)/(nnx-1.) fout = open(filename, 'w') for i in range(nnx): x = (xLeft+dx*i, 0.0, 0.0) @@ -748,8 +742,8 @@ class PlaneBase(SteadyState): def __init__(self, plane_theta=0.0, - plane_phi=old_div(math.pi, 2.0), - v_theta=old_div(math.pi, 2.0), + plane_phi=math.pi/2.0, + v_theta=math.pi/2.0, v_phi=None, v_norm=1.0, mu=1.0, @@ -758,17 +752,17 @@ def __init__(self, self.plane_n = numpy.array([cos(plane_theta)*sin(plane_phi), sin(plane_theta)*sin(plane_phi), cos(plane_phi)]) - if (plane_phi > old_div(-pi, 2.0) and plane_phi < old_div(pi, 2.0)): + if (plane_phi > -pi/2.0 and plane_phi < pi/2.0): if plane_phi == 0.0: logEvent("plate is in x-y plane") - v_phi = old_div(pi, 2.0) + v_phi = pi/2.0 else: v_phi = atan( - old_div(-1.0, (tan(plane_phi)*cos(v_theta-plane_theta)))) + -1.0/(tan(plane_phi)*cos(v_theta-plane_theta))) else: logEvent( "plate is is parallel to z-axis, using angle of velocity with z-axis instead of angle with x-axis") - v_theta = plane_theta - old_div(pi, 2.0) + v_theta = plane_theta - pi/2.0 self.v_n = numpy.array([cos(v_theta)*sin(v_phi), sin(v_theta)*sin(v_phi), cos(v_phi)]) @@ -808,8 +802,8 @@ class PlanePoiseuilleFlow_u2(PlaneBase): def __init__(self, plane_theta=0.0, - plane_phi=old_div(math.pi, 2.0), - v_theta=old_div(math.pi, 2.0), + plane_phi=math.pi/2.0, + v_theta=math.pi/2.0, v_phi=None, v_norm=1.0, mu=1.0, @@ -836,8 +830,8 @@ class PlanePoiseuilleFlow_v2(PlaneBase): def __init__(self, plane_theta=0.0, - plane_phi=old_div(math.pi, 2.0), - v_theta=old_div(math.pi, 2.0), + plane_phi=math.pi/2.0, + v_theta=math.pi/2.0, v_phi=None, v_norm=1.0, mu=1.0, @@ -864,8 +858,8 @@ class PlanePoiseuilleFlow_w2(PlaneBase): def __init__(self, plane_theta=0.0, - plane_phi=old_div(math.pi, 2.0), - v_theta=old_div(math.pi, 2.0), + plane_phi=math.pi/2.0, + v_theta=math.pi/2.0, v_phi=None, v_norm=1.0, mu=1.0, @@ -892,8 +886,8 @@ class PlanePoiseuilleFlow_p2(PlaneBase): def __init__(self, plane_theta=0.0, - plane_phi=old_div(math.pi, 2.0), - v_theta=old_div(math.pi, 2.0), + plane_phi=math.pi/2.0, + v_theta=math.pi/2.0, v_phi=None, v_norm=1.0, mu=1.0, @@ -961,4 +955,4 @@ def __init__(self, def uOfXT(self, x, t): # return -self.Re*0.25*(cos(2.0*x[0])+cos(2.0*x[1]))*exp(-4.0*t) - return -0.25*(cos(2.0*self.n*pi*x[0]) + cos(2.0*self.n*pi*x[1]))*exp(-4.0 * (self.n*pi)**2 * t / self.Re) + return -0.25*(cos(2.0*self.n*pi*x[0]) + cos(2.0*self.n*pi*x[1]))*exp(-4.0 * (self.n*pi)**2 * t / self.Re) \ No newline at end of file diff --git a/proteus/Archiver.py b/proteus/Archiver.py index 769057b468..ecf2841930 100644 --- a/proteus/Archiver.py +++ b/proteus/Archiver.py @@ -4,17 +4,12 @@ .. inheritance-diagram:: proteus.Archiver :parts: 1 """ -from __future__ import print_function -from __future__ import absolute_import -from builtins import zip -from builtins import str -from builtins import range -from builtins import object from . import Profiling from .Profiling import logEvent from . import Comm import numpy import os +import h5py from xml.etree.ElementTree import * memory = Profiling.memory @@ -63,7 +58,6 @@ def __init__(self,dataDir,filename, import datetime #filename += datetime.datetime.now().isoformat() self.global_sync = global_sync - import h5py comm_world = self.comm.comm.tompi4py() self.xmlHeader = "\n\n" if hotStart: @@ -2354,4 +2348,4 @@ def writeVectorFunctionXdmf_LowestOrderMixed(self,ar,u,tCount=0,init=True,spaceS ar.create_dataset_async(name+"_p"+str(ar.rank)+"_t"+str(tCount), data = tmp) else: numpy.savetxt(ar.textDataDir+"/"+name+str(tCount)+".txt",tmp) - SubElement(values,"xi:include",{"parse":"text","href":"./"+ar.textDataDir+"/"+name+str(tCount)+".txt"}) + SubElement(values,"xi:include",{"parse":"text","href":"./"+ar.textDataDir+"/"+name+str(tCount)+".txt"}) \ No newline at end of file diff --git a/proteus/AuxiliaryVariables.py b/proteus/AuxiliaryVariables.py index c4755e425b..924484c4a6 100644 --- a/proteus/AuxiliaryVariables.py +++ b/proteus/AuxiliaryVariables.py @@ -4,14 +4,6 @@ .. inheritance-diagram:: proteus.AuxiliaryVariables :parts: 1 """ -from __future__ import print_function -from __future__ import absolute_import -from __future__ import division -from builtins import zip -from builtins import str -from builtins import range -from past.utils import old_div -from builtins import object import numpy from . import Viewers from . import Archiver @@ -95,7 +87,7 @@ def calculate(self): comm.endSequential() class BoundaryForce(AV_base): def __init__(self,D=1.0,Ubar=1.0,rho=1.0): - self.C_fact = old_div(2.0,(rho*D*Ubar**2)) + self.C_fact = 2.0/(rho*D*Ubar**2) def attachModel(self,model,ar): self.model=model self.ar=ar @@ -210,7 +202,7 @@ def attachModel(self,model,ar): for nN in range(m.mesh.nNodes_global): if m.mesh.nodeMaterialTypes[nN] == self.flag: p.append(m.u[0].dof[nN]) - theta.append((old_div(180.0,math.pi))*math.atan2(m.mesh.nodeArray[nN][1]-self.center[1], + theta.append((180.0/math.pi)*math.atan2(m.mesh.nodeArray[nN][1]-self.center[1], m.mesh.nodeArray[nN][0]-self.center[0])) elif self.nd == 3: pass @@ -823,4 +815,4 @@ def calculate(self): if self.velocityPostProcessor is not None: self.writePT123MixedVelocityAsElementVelocity(self.ci) self.writePT123elementPorosity(value=1.) - #mwf stopped here + #mwf stopped here \ No newline at end of file diff --git a/proteus/BoundaryConditions.py b/proteus/BoundaryConditions.py index 886551659f..7e0231653e 100644 --- a/proteus/BoundaryConditions.py +++ b/proteus/BoundaryConditions.py @@ -123,4 +123,4 @@ def setLinearRamp(self,t1,value): value: float Variable value """ - self.uOfXT = lambda x, t, n=np.zeros(3,): min( t/t1, 1)*value + self.uOfXT = lambda x, t, n=np.zeros(3,): min( t/t1, 1)*value \ No newline at end of file diff --git a/proteus/Comm.py b/proteus/Comm.py index e3a1885971..fb7c765b3a 100644 --- a/proteus/Comm.py +++ b/proteus/Comm.py @@ -4,10 +4,6 @@ .. inheritance-diagram:: proteus.Comm :parts: 1 """ -from __future__ import absolute_import - -from builtins import range -from builtins import object import ctypes import sys diff --git a/proteus/Context.py b/proteus/Context.py index b3d7211bfb..359d1df6f1 100644 --- a/proteus/Context.py +++ b/proteus/Context.py @@ -25,7 +25,6 @@ nnx = ct.nnx """ -from __future__ import print_function from collections import namedtuple import dataclasses diff --git a/proteus/DiagUtils.py b/proteus/DiagUtils.py index 1233e01562..fabd1f15bd 100644 --- a/proteus/DiagUtils.py +++ b/proteus/DiagUtils.py @@ -4,12 +4,6 @@ .. inheritance-diagram:: proteus.DiagUtils :parts: 1 """ -from __future__ import print_function -from __future__ import absolute_import -from __future__ import division -from builtins import zip -from builtins import range -from past.utils import old_div from .EGeometry import * from .MeshTools import * from .FemTools import * @@ -140,16 +134,16 @@ def testCrRavNodalBasis(nd,verbose=0): if nd == 1: xiArray[:,0] = [0.5, 1., 0.] elif nd == 2: - xiArray[:,0:2] = [[old_div(1.,3.), old_div(1.,3.)], + xiArray[:,0:2] = [[1./3., 1./3.], [0.5, 0.5], [0., .5], [0.5, 0.]] elif nd == 3: - xiArray[:,:] = [[old_div(1.,4.), old_div(1.,4.), old_div(1.,4.)], - [old_div(1.,3.), old_div(1.,3.), old_div(1.,3.)], - [0., old_div(1.,3.), old_div(1.,3.)], - [old_div(1.,3.), 0., old_div(1.,3.)], - [old_div(1.,3.), old_div(1.,3.), 0.]] + xiArray[:,:] = [[1./4., 1./4., 1./4.], + [1./3., 1./3., 1./3.], + [0., 1./3., 1./3.], + [1./3., 0., 1./3.], + [1./3., 1./3., 0.]] #end if if verbose > 1: print('trying to get values at points \n',xiArray) @@ -177,7 +171,7 @@ def testCrRavNodalBasis(nd,verbose=0): elif nd == 2: exiArray[0,0] = 0.5 else: - exiArray[0,0:2] = [old_div(1.,3.), old_div(1.,3.)] + exiArray[0,0:2] = [1./3., 1./3.] #end else if verbose > -1: nElementBoundaries = nd+1 @@ -250,7 +244,7 @@ def testQuadNodalBasis(nd,verbose=0): elif nd == 2: exiArray[0,0] = 0.5 else: - exiArray[0,0:2] = [old_div(1.,3.), old_div(1.,3.)] + exiArray[0,0:2] = [1./3., 1./3.] #end else if verbose > -1: nElementBoundaries = nd+1 @@ -321,7 +315,7 @@ def testQuadRefMats(nd,verbose=0): lspace = QuadraticOnSimplexWithNodalBasis(nd) ndofLoc= lspace.dim - volWeights = [1.0,0.5,old_div(1.0,6.0)] + volWeights = [1.0,0.5,1.0/6.0] #compute mass matrix numerically quadRule = SimplexGaussQuadrature(nd) @@ -353,7 +347,7 @@ def testQuadDOFMap(mesh,nd,verbose=0): #dofMap = NodalDOFMap(mesh) dofMap = QuadraticLagrangeDOFMap(mesh,lspace,nd) ndofLoc= lspace.dim - volWeights = [1.0,0.5,old_div(1.0,6.0)] + volWeights = [1.0,0.5,1.0/6.0] #compute mass matrix numerically quadRule = SimplexGaussQuadrature(nd) @@ -393,4 +387,4 @@ def testQuadDOFMap(mesh,nd,verbose=0): #end testQuadDofMap -## @} +## @} \ No newline at end of file diff --git a/proteus/Domain.py b/proteus/Domain.py index 7ebd5b724e..dd140cd400 100644 --- a/proteus/Domain.py +++ b/proteus/Domain.py @@ -4,14 +4,6 @@ .. inheritance-diagram:: proteus.Domain :parts: 1 """ -from __future__ import print_function -from __future__ import division - -from builtins import zip -from builtins import str -from builtins import range -from past.utils import old_div -from builtins import object import sys import numpy as np from proteus.Profiling import logEvent @@ -381,7 +373,7 @@ def writePoly(self,fileprefix): """ self.polyfile = fileprefix #[temp] see PSLG for better implementation that checks if it already exists self.boundaryLegend = self.boundaryTags - unitesize=old_div(4.0,self.L[0]) + unitesize=4.0/self.L[0] f = open(fileprefix+".poly",'w') if self.nd==2: self.boundaryLegend = self.boundaryTags @@ -440,16 +432,16 @@ def writePoly(self,fileprefix): 'x0pL0': self.x[0]+self.L[0], 'x1pL1': self.x[1]+self.L[1], 'x2pL2': self.x[2]+self.L[2], - 'm0':old_div((self.x[0]+self.L[0]),2.0), - 'm1':old_div((self.x[1]+self.L[1]),2.0), - 'm2':old_div((self.x[2]+self.L[2]),2.0)} + 'm0':(self.x[0]+self.L[0])/2.0, + 'm1':(self.x[1]+self.L[1])/2.0, + 'm2':(self.x[2]+self.L[2])/2.0} f.write(fileString) f.close() def writeAsymptote(self, fileprefix): """ Write the rectangular domain as a box displaying the dimesions and coloring the boundaries according to the boundary flags. """ - unitsize=old_div(4.0,self.L[0]) + unitsize=4.0/self.L[0] f = open(fileprefix+".asy",'w') if self.nd==1: fileString=""" @@ -607,7 +599,7 @@ def __init__(self, geofile, he, units="m", length_scale=1.0, permute_dims=[0,1,2]): - D_base.__init__(self, 2, name, units) + D_base.__init__(self, 3, name, units) self.geofile=geofile+".geo" self.polyfile=geofile self.he = he @@ -801,7 +793,7 @@ def writeAsymptote(self,fileprefix): """ Write a representation of the PSLG in the Asymptote vector graphics language """ - unitsize=old_div(4.0,self.L[0]) + unitsize=4.0/self.L[0] f = open(fileprefix+".asy",'w') fileString=""" unitsize(4.0 inches / %(Lx)f); diff --git a/proteus/EGeometry.py b/proteus/EGeometry.py index 7b17e7d613..c90f65ff71 100644 --- a/proteus/EGeometry.py +++ b/proteus/EGeometry.py @@ -4,10 +4,6 @@ .. inheritance-diagram:: proteus.EGeometry :parts: 1 """ -from __future__ import print_function -from __future__ import division -from builtins import zip -from past.utils import old_div import math from math import * import numpy @@ -246,10 +242,10 @@ def adj(t): return trans(cof(t)) def einv(t): - return old_div(eadj(t),edet(t)) + return eadj(t)/edet(t) def inv(t): - return old_div(adj(t),det(t)) + return adj(t)/det(t) def etenten(r,t): tt = etrans(t) @@ -310,8 +306,8 @@ def etenvecdotvec(t,v,w): print('u + v = '+repr(u+v)) print('2.0*u = '+repr(2.0*u)) print('u*2.0 = '+repr(u*2.0)) - print('u/2.0 = '+repr(old_div(u,2.0))) - print('2.0/u = '+repr(old_div(2.0,u))) + print('u/2.0 = '+repr(u/2.0)) + print('2.0/u = '+repr(2.0/u)) print('-u = '+repr(-u)) print('2.0*u + v = ' + repr(2.0*u+v)) print('u - v = '+repr(u-v)) diff --git a/proteus/ErrorEstimators.py b/proteus/ErrorEstimators.py index d67c5c5cd2..a849621ddf 100644 --- a/proteus/ErrorEstimators.py +++ b/proteus/ErrorEstimators.py @@ -4,9 +4,6 @@ .. inheritance-diagram:: proteus.ErrorEstimators :parts: 1 """ -from __future__ import absolute_import -from builtins import range -from builtins import object from .Profiling import logEvent class HierarchicalMeshEstimator(object): diff --git a/proteus/FemTools.py b/proteus/FemTools.py index 75bcf34727..8bea477434 100644 --- a/proteus/FemTools.py +++ b/proteus/FemTools.py @@ -4,14 +4,6 @@ .. inheritance-diagram:: proteus.FemTools :parts: 1 """ -from __future__ import print_function -from __future__ import absolute_import -from __future__ import division -from builtins import zip -from builtins import str -from builtins import range -from past.utils import old_div -from builtins import object from .EGeometry import * from .MeshTools import * from .LinearAlgebraTools import * @@ -74,8 +66,8 @@ def __init__(self,nd=3): self.boundaryMapInverseList.append(lambda x: numpy.array([x[0]])) self.boundaryJacobianList.append(numpy.array([[ 1.0], [-1.0]])) - self.boundaryUnitNormalList.append(numpy.array([old_div(1.0,sqrt(2.0)), - old_div(1.0,sqrt(2.0))])) + self.boundaryUnitNormalList.append(numpy.array([1.0/sqrt(2.0), + 1.0/sqrt(2.0)])) #1 self.boundaryMapList.append(lambda xBar: numpy.array([0.0, xBar[0]])) @@ -115,9 +107,9 @@ def __init__(self,nd=3): self.boundaryJacobianList.append(numpy.array([[1.0 , 0.0], [0.0 , 1.0], [-1.0,-1.0]])) - self.boundaryUnitNormalList.append(numpy.array([old_div(1.0,sqrt(3.0)), - old_div(1.0,sqrt(3.0)), - old_div(1.0,sqrt(3.0))])) + self.boundaryUnitNormalList.append(numpy.array([1.0/sqrt(3.0), + 1.0/sqrt(3.0), + 1.0/sqrt(3.0)])) #1 self.boundaryMapList.append(lambda xBar: numpy.array([0.0, xBar[1], @@ -520,8 +512,8 @@ def __init__(self,nd=3, order=2): fun.append(lambda xi, xb=self.nodes[b],fc=fc: fun[fc](xi)*(xi - xb)) den = den*(self.nodes[a]-self.nodes[b]) fc=fc+1 - self. fun.append(lambda xi,fc=fc, den=den: old_div(fun[fc](xi),den)) - self.dfun.append(lambda xi,fc=fc, den=den: old_div(dfun[fc](xi),den)) + self. fun.append(lambda xi,fc=fc, den=den: fun[fc](xi)/den) + self.dfun.append(lambda xi,fc=fc, den=den: dfun[fc](xi)/den) # Define multi-dimensional stuff basis= [] @@ -627,7 +619,7 @@ class BernsteinOnCube(LocalFunctionSpace): from math import factorial def nChooseK(self,n,k): - return factorial(n)/factorial(k)/factorial(n-k) + return factorial(n)/(factorial(k)*factorial(n-k)) def __init__(self,nd=3, order=2): self.referenceElement = ReferenceCube(nd) @@ -650,7 +642,7 @@ def __init__(self,nd=3, order=2): for k in range(order+1): self.fun.append(lambda x,n=order,k=k: - self.nChooseK(n,k)*(old_div((x+1),2.))**k*(old_div((1-x),2.))**(n-k)) + self.nChooseK(n,k)*((x+1)/2.)**k*((1-x)/2.)**(n-k)) self.dfun.append(lambda x,n=order,k=k: #-2.**(-n)*(1-x)**(-1-k+n)*(1+x)**(k-1)*(-2*k+n+n*x)*self.nChooseK(n,k)) # Rule out the cases when 1-x or 1+x = 0. This is to avoid warnings due to division by zero @@ -796,7 +788,7 @@ def __init__(self,nd=3): from .RefUtils import p2refNodes self.referenceElement = ReferenceSimplex(nd) - LocalFunctionSpace.__init__(self,old_div(fact(nd+2),(2*fact(nd))), + LocalFunctionSpace.__init__(self, fact(nd+2)//(2*fact(nd)), self.referenceElement) self.gradientList=[] self.basisHessians=[] @@ -1082,7 +1074,7 @@ def __init__(self,nd=3): from .RefUtils import p2refNodes self.referenceElement = ReferenceSimplex(nd) - LocalFunctionSpace.__init__(self,old_div(fact(nd+2),(2*fact(nd))), + LocalFunctionSpace.__init__(self, fact(nd+2)//(2*fact(nd)), self.referenceElement) self.gradientList=[] self.basisHessians=[] @@ -1871,7 +1863,7 @@ def __init__(self,referenceElement): from .RefUtils import fact from .RefUtils import p2refNodes sdim = referenceElement.dim - self.nInterpNodes= old_div(fact(2+sdim),(2*fact(sdim))) + self.nInterpNodes= fact(2+sdim)//(2*fact(sdim)) InterpolationConditions.__init__(self,self.nInterpNodes,referenceElement) self.quadraturePointArray = numpy.zeros((self.nInterpNodes,3),'d') for k in range(self.nInterpNodes): @@ -1991,7 +1983,7 @@ def __init__(self,referenceElement): if referenceElement.dim == 2: #2d, interpolation points are edge barycenters ebary = EVec(0.5,0.0,0.0) elif referenceElement.dim == 3: #3d, interpolation points are face barycenters - ebary = EVec(old_div(1.,3.),old_div(1.,3.),0.0) + ebary = EVec(1.0/3.0,1.0/3.0,0.0) #end for k in referenceElement.range_nElementBoundaries: for I in range(referenceElement.dim): @@ -2053,8 +2045,8 @@ def __init__(self,referenceElement): self.quadraturePointArray[k,I]=p[I] self.nQuadraturePoints = self.quadraturePointArray.shape[0] self.vol=sum([w for w in self.quadrature.weights]) - self.functionals.append(lambda f: old_div(sum([w*f(p) for w,p in zip(self.quadrature.weights,self.quadrature.points)]),self.vol)) - self.functionalsQuadrature.append(lambda fList: old_div(sum([w*f for w,f in zip(self.quadrature.weights,fList)]),self.vol)) + self.functionals.append(lambda f: sum([w*f(p) for w,p in zip(self.quadrature.weights,self.quadrature.points)])/self.vol) + self.functionalsQuadrature.append(lambda fList: sum([w*f for w,f in zip(self.quadrature.weights,fList)])/self.vol) def quadrature2DOF_element(self,k): return 0 def definedOnLocalElementBoundary(self,k,ebN_local): @@ -2153,7 +2145,7 @@ def __init__(self,referenceElement): if referenceElement.nNodes > 5: logEvent("Haven't implemented this many nodes for nodal interpolation conditions",level=1) #bubble - dp1inv = old_div(1.0,float(self.referenceElement.nNodes)) + dp1inv = 1.0/float(self.referenceElement.nNodes) self.functionals.append(lambda f: f(self.quadraturePointArray[-1,:]) - \ dp1inv * sum([self.functionals[i](self.quadraturePointArray[-1,:]) for i in range(self.referenceElement.nNodes)])) self.functionalsQuadrature.append(lambda fList: fList[self.referenceElement.nNodes] - \ @@ -2866,7 +2858,7 @@ def getJacobianValues(self,xiArray, for n in self.referenceElement.range_dim: jacobianArray[eN,k,m,n] += self.mesh.nodeArray[J,m]*grad_psi[k,j,n] jacobianDeterminantArray[eN,k] = det(jacobianArray[eN,k]) - jacobianInverseArray[eN,k,:,:] = old_div(adj(jacobianArray[eN,k]),jacobianDeterminantArray[eN,k]) + jacobianInverseArray[eN,k,:,:] = adj(jacobianArray[eN,k])/jacobianDeterminantArray[eN,k] def getBasisValuesTraceRef(self, xiArray): n_xi = xiArray.shape[0] @@ -3976,8 +3968,8 @@ def writeFunctionGnuplot(self,u,filename): #self.viewer("set terminal x11") nx = sqrt(self.elementMaps.mesh.nNodes_global) ny = nx - x = old_div(numpy.arange(nx,dtype='i'),float(nx-1)) - y = old_div(numpy.arange(nx,dtype='i'),float(nx-1)) + x = numpy.arange(nx,dtype='i')/float(nx-1) + y = numpy.arange(nx,dtype='i')/float(nx-1) nSol = numpy.reshape(u.dof,(nx,ny)) self.viewer('set parametric') self.viewer('set data style lines') @@ -4916,8 +4908,8 @@ def writeFunctionGnuplot(self,u,filename): elif self.referenceFiniteElement.referenceElement.dim == 2: nx = sqrt(self.elementMaps.mesh.nNodes_global) ny = nx - x = old_div(numpy.arange(nx,dtype='i'),float(nx-1)) - y = old_div(numpy.arange(nx,dtype='i'),float(nx-1)) + x = numpy.arange(nx,dtype='i')/float(nx-1) + y = numpy.arange(nx,dtype='i')/float(nx-1) nSol = numpy.reshape(nodal_average,(nx,ny)) self.viewer('set parametric') self.viewer('set data style lines') @@ -5154,8 +5146,8 @@ def writeFunctionGnuplot(self,u,filename): elif self.referenceFiniteElement.referenceElement.dim == 2: nx = sqrt(self.elementMaps.mesh.nNodes_global) ny = nx - x = old_div(numpy.arange(nx,dtype='i'),float(nx-1)) - y = old_div(numpy.arange(nx,dtype='i'),float(nx-1)) + x = numpy.arange(nx,dtype='i')/float(nx-1) + y = numpy.arange(nx,dtype='i')/float(nx-1) nSol = numpy.reshape(nodal_average,(nx,ny)) self.viewer('set parametric') self.viewer('set data style lines') @@ -5764,8 +5756,8 @@ def writeFunctionGnuplot(self,u,filename): elif self.referenceFiniteElement.referenceElement.dim == 2: nx = sqrt(self.elementMaps.mesh.nNodes_global) ny = nx - x = old_div(numpy.arange(nx,dtype='i'),float(nx-1)) - y = old_div(numpy.arange(nx,dtype='i'),float(nx-1)) + x = numpy.arange(nx,dtype='i')/float(nx-1) + y = numpy.arange(nx,dtype='i')/float(nx-1) nSol = numpy.reshape(nodal_average,(nx,ny)) self.viewer('set parametric') self.viewer('set data style lines') @@ -7454,7 +7446,7 @@ def __init__(self, if rbc[(I,J)] > 0.0 - 1.0e-8 and rbc[(I,J)] < 0.0 + 1.0e-8: scaled_rbc[(I,J)] = 0.0 else: - scaled_rbc[(I,J)] = old_div(rbc[(I,J)],rbcSum[I]) + scaled_rbc[(I,J)] = rbc[(I,J)]/rbcSum[I] #now make real sparse matrices (rbc,rbczval) = SparseMatFromDict(coarseSpace.dim,fineSpace.dim,rbc) (scaled_rbc,scaled_rbczval) = SparseMatFromDict(coarseSpace.dim,fineSpace.dim,scaled_rbc) diff --git a/proteus/Gauges.py b/proteus/Gauges.py index a86510cba2..4a250cd33a 100644 --- a/proteus/Gauges.py +++ b/proteus/Gauges.py @@ -5,12 +5,6 @@ :parts: 1 """ -from __future__ import print_function -from __future__ import division -from builtins import zip -from builtins import str -from builtins import range -from past.utils import old_div import os from collections import defaultdict, OrderedDict from itertools import product @@ -603,7 +597,7 @@ def getMeshIntersections(self, line): endpoints = np.asarray(endpoints, np.double) length = norm(endpoints[1] - endpoints[0]) - length_segments = [(old_div(norm(i[0]-endpoints[0]),length), old_div(norm(i[1]-endpoints[0]),length), i) for i in intersections] + length_segments = [(norm(i[0]-endpoints[0])/length, norm(i[1]-endpoints[0])/length, i) for i in intersections] segments = self.pruneDuplicateSegments(endpoints, length_segments) return segments @@ -649,7 +643,7 @@ def buildLineIntegralGaugeOperators(self, lines, linesSegments): # only assign coefficients for locally owned points if field in point_data: pointID = point_data[field] - self.lineIntegralGaugeMats[fieldIndex].setValue(lineIndex, pointID, old_div(segmentLength,2), addv=True) + self.lineIntegralGaugeMats[fieldIndex].setValue(lineIndex, pointID, segmentLength/2, addv=True) for m in self.lineIntegralGaugeMats: m.assemble() @@ -774,4 +768,4 @@ def calculate(self): for m, dofsVec in zip(self.lineIntegralGaugeMats, self.pointGaugeVecs): m.multAdd(dofsVec, self.lineIntegralGaugesVec, self.lineIntegralGaugesVec) - self.outputRow(time) + self.outputRow(time) \ No newline at end of file diff --git a/proteus/InputTranslators.py b/proteus/InputTranslators.py index 198f27ee55..a0f2727adb 100644 --- a/proteus/InputTranslators.py +++ b/proteus/InputTranslators.py @@ -4,13 +4,6 @@ .. inheritance-diagram:: proteus.InputTranslators :parts: 1 """ -from __future__ import print_function -from __future__ import division -from builtins import zip -from builtins import str -from builtins import range -from past.utils import old_div -from builtins import object from proteus.EGeometry import * from .Profiling import logEvent @@ -737,7 +730,7 @@ def __init__(self,fileprefix,directory='.'): #generate a time entry out of hours days minutes self.time_unit = 'day' #hour, sec self.data['time'] = numpy.zeros((self.npoints),'d') - self.data['time'] = self.data['day']+old_div(self.data['hour'],24.0) + old_div(self.data['min'],(24.*60.)) + self.data['time'] = self.data['day']+self.data['hour']/24.0 + self.data['min']/(24.*60.) def getValue(self,entry,t): """ lookup value of entry at time t @@ -749,4 +742,4 @@ def getValue(self,entry,t): return self.data[entry] index = 0 interp,dinterp,index = self.piecewiseLinearTableLookup(t,self.data['time'],self.data[entry],index) - return interp + return interp \ No newline at end of file diff --git a/proteus/LatexReport.py b/proteus/LatexReport.py index 461bb51a5e..83c1edc98b 100644 --- a/proteus/LatexReport.py +++ b/proteus/LatexReport.py @@ -5,13 +5,6 @@ .. inheritance-diagram:: proteus.LatexReport :parts: 1 """ -from __future__ import division - -from future import standard_library -standard_library.install_aliases() -from builtins import range -from builtins import object -from past.utils import old_div from .Profiling import logEvent def openLatexReport(filename,reportname): @@ -176,7 +169,7 @@ def generateSpatialConvTable(self,time='Last',useRelativeError=False,relativeErr exact = self.results['errorData'][ci][nLevels-1][exkey] if abs(exact) < relativeErrorEps: exact += relativeErrorEps - error = old_div(error,exact) + error = error/exact if il == 0: row += """ & %g & %s """ % (error,'-') else: @@ -186,9 +179,9 @@ def generateSpatialConvTable(self,time='Last',useRelativeError=False,relativeErr errM=self.results['errorData'][ci][il-1][ekey] hM = self.results['simulationData']['spatialMesh'][il-1]['h'][-1] if useRelativeError == True: #only normalizing by finest mesh val - rate = old_div(math.log(old_div((old_div(errM,exact)+1.0e-24),(error+1.0e-24))),math.log(old_div(hM,h))) + rate = math.log((errM/exact+1.0e-24)/(error+1.0e-24))/math.log(hM/h) else: - rate = old_div(math.log(old_div((errM+1.0e-24),(error+1.0e-24))),math.log(old_div(hM,h))) + rate = math.log((errM+1.0e-24)/(error+1.0e-24))/math.log(hM/h) row += """& %g & %g """ % (error,rate) if computeLocalMassBalErr or computeGlobalHeavisideMassBalErr: diff --git a/proteus/LinearAlgebraTools.py b/proteus/LinearAlgebraTools.py index 619c0e2ac9..5f78815cb0 100644 --- a/proteus/LinearAlgebraTools.py +++ b/proteus/LinearAlgebraTools.py @@ -8,13 +8,6 @@ .. inheritance-diagram:: proteus.LinearAlgebraTools :parts: 1 """ -from __future__ import print_function -from __future__ import absolute_import -from __future__ import division -from builtins import zip -from builtins import range -from builtins import object -from past.utils import old_div import numpy import math import sys @@ -1434,7 +1427,7 @@ def apply(self,A,x,y): self.Np_rho.mult(tmp1,tmp2) if self.alpha is True: - tmp2.axpy(old_div(1.,self.delta_t),x_tmp) + tmp2.axpy(1./self.delta_t,x_tmp) if self.options.hasName('innerTPPCDsolver_Ap_rho_ksp_constant_null_space'): self.const_null_space.remove(tmp2) @@ -1560,7 +1553,7 @@ def l2NormAvg(x): """ Compute the arithmetic averaged l_2 norm (root mean squared norm) """ - scale = old_div(1.0,globalSum(len(x.flat))) + scale = 1.0/globalSum(len(x.flat)) return math.sqrt(scale*globalSum(numpy.dot(x,x))) @@ -1593,7 +1586,7 @@ def norm(self,y,type): self.tmp[:] = y self.tmp /= self.weight value = numpy.linalg.norm(self.tmp.flat,type) - return old_div(value,self.dim) + return value/self.dim if __name__ == '__main__': @@ -1711,4 +1704,3 @@ def norm(self,y,type): # mgits +=1 # mgv.apply(w,jits,jits,0,f[1:n-1],u[1:n-1]) # rnorm = l2Norm(resList[0]) - diff --git a/proteus/LinearSolvers.py b/proteus/LinearSolvers.py index d82e48c5bf..b15df4a9c0 100644 --- a/proteus/LinearSolvers.py +++ b/proteus/LinearSolvers.py @@ -4,14 +4,6 @@ .. inheritance-diagram:: proteus.LinearSolvers :parts: 1 """ -from __future__ import print_function -from __future__ import absolute_import -from __future__ import division -from builtins import input -from builtins import zip -from builtins import range -from builtins import object -from past.utils import old_div from .LinearAlgebraTools import * from . import LinearAlgebraTools as LAT from . import FemTools @@ -23,7 +15,7 @@ from petsc4py import PETSc as p4pyPETSc from math import * import math -from .Profiling import logEvent +from .Profiling import logEvent, memory from .mprans import cArgumentsDict class LinearSolver(object): @@ -140,7 +132,7 @@ def computeConvergenceRates(self): else: if self.its > 0: if self.norm_r < self.lastNorm_r: - self.ratio_r_current = old_div(self.norm_r,self.lastNorm_r) + self.ratio_r_current = self.norm_r/self.lastNorm_r else: self.convergenceHistoryIsCorrupt=True return @@ -150,12 +142,12 @@ def computeConvergenceRates(self): self.convergenceHistoryIsCorrupt return self.ratio_r_solve *= self.ratio_r_current - self.rReductionFactor = pow(self.ratio_r_solve,old_div(1.0,self.its)) + self.rReductionFactor = pow(self.ratio_r_solve, 1.0/self.its) if self.its > 1: - self.rReductionOrder = old_div(log_ratio_r_current, \ - self.last_log_ratio_r) + self.rReductionOrder = log_ratio_r_current/ \ + self.last_log_ratio_r if self.norm_du < self.lastNorm_du: - ratio_du_current = old_div(self.norm_du,self.lastNorm_du) + ratio_du_current = self.norm_du/self.lastNorm_du else: self.convergenceHistoryIsCorrupt=True return @@ -166,10 +158,10 @@ def computeConvergenceRates(self): return self.ratio_du_solve *= ratio_du_current self.duReductionFactor = pow(self.ratio_du_solve, - old_div(1.0,(self.its-1))) + 1.0/(self.its-1)) if self.its > 2: - self.duReductionOrder = old_div(log_ratio_du_current, \ - self.last_log_ratio_du) + self.duReductionOrder = log_ratio_du_current/ \ + self.last_log_ratio_du self.last_log_ratio_du = log_ratio_du_current self.last_log_ratio_r = log_ratio_r_current self.lastNorm_du = self.norm_du @@ -444,10 +436,12 @@ def prepare(self, newton_its=None): pc_setup_stage = p4pyPETSc.Log.Stage('pc_setup_stage') pc_setup_stage.push() + memory() self.petsc_L.zeroEntries() assert self.petsc_L.getBlockSize() == 1, "petsc4py wrappers currently require 'simple' blockVec (blockSize=1) approach" if self.petsc_L.proteus_jacobian is not None: self.csr_rep[2][self.petsc_L.nzval_proteus2petsc] = self.petsc_L.proteus_csr_rep[2][:] + logEvent(memory("init ","KSP_petsc4py")) if self.par_fullOverlap == True: self.petsc_L.setValuesLocalCSR(self.csr_rep_local[0],self.csr_rep_local[1],self.csr_rep_local[2],p4pyPETSc.InsertMode.INSERT_VALUES) else: @@ -457,21 +451,28 @@ def prepare(self, else: self.petsc_L.setOption(p4pyPETSc.Mat.Option.NEW_NONZERO_LOCATION_ERR,True) self.petsc_L.setValuesLocalCSR(self.csr_rep[0],self.csr_rep[1],self.csr_rep[2],p4pyPETSc.InsertMode.ADD_VALUES) + logEvent(memory("setValuesLocalCSR ","KSP_petsc4py")) self.petsc_L.assemblyBegin() self.petsc_L.assemblyEnd() + logEvent(memory("assmebly ","KSP_petsc4py")) self.ksp.setOperators(self.petsc_L,self.petsc_L) + logEvent(memory("setOperators ","KSP_petsc4py")) if self.pc is not None: self.pc.setOperators(self.petsc_L,self.petsc_L) self.pc.setUp() if self.preconditioner: self.preconditioner.setUp(self.ksp,newton_its) + logEvent(memory("pc/preconditioner setUp ","KSP_petsc4py")) self.ksp.setUp() + logEvent(memory("ksp.setUp ","KSP_petsc4py")) self.ksp.pc.setUp() + logEvent(memory("pc.setUp ","KSP_petsc4py")) pc_setup_stage.pop() def solve(self,u,r=None,b=None,par_u=None,par_b=None,initialGuessIsZero=True): solve_stage = p4pyPETSc.Log.Stage('lin_solve') solve_stage.push() + memory() if par_b.proteus2petsc_subdomain is not None: par_b.proteus_array[:] = par_b.proteus_array[par_b.petsc2proteus_subdomain] par_u.proteus_array[:] = par_u.proteus_array[par_u.petsc2proteus_subdomain] @@ -492,9 +493,9 @@ def solve(self,u,r=None,b=None,par_u=None,par_b=None,initialGuessIsZero=True): self.matcontext.par_b = par_b self.null_space.apply_ns(par_b) - + logEvent(memory("ksp.solve init ","KSP_petsc4py")) self.ksp.solve(par_b,par_u) - + logEvent(memory("ksp.solve ","KSP_petsc4py")) logEvent("after ksp.rtol= %s ksp.atol= %s ksp.is_converged= %s ksp.its= %s ksp.norm= %s reason = %s" % (self.ksp.rtol, self.ksp.atol, self.ksp.is_converged, @@ -502,8 +503,8 @@ def solve(self,u,r=None,b=None,par_u=None,par_b=None,initialGuessIsZero=True): self.ksp.norm, self.ksp.reason)) self.its = self.ksp.its - if self.printInfo: - self.info() + #if self.printInfo: + # self.info() if par_b.proteus2petsc_subdomain is not None: par_b.proteus_array[:] = par_b.proteus_array[par_b.proteus2petsc_subdomain] par_u.proteus_array[:] = par_u.proteus_array[par_u.proteus2petsc_subdomain] @@ -548,19 +549,19 @@ def _converged_trueRes(self,ksp,its,rnorm): ksp.atol, ksp.rtol)) else: - logEvent("NumericalAnalytics KSPOuterResidual(relative): %12.5e" %(old_div(truenorm, self.rnorm0)), level=7 ) + logEvent("NumericalAnalytics KSPOuterResidual(relative): %12.5e" %(truenorm/ self.rnorm0), level=7 ) logEvent(" KSP it %i norm(r) = %e norm(r)/|b| = %e ; atol=%e rtol=%e " % (its, truenorm, - (old_div(truenorm, self.rnorm0)), + (truenorm/self.rnorm0), ksp.atol, ksp.rtol)) return False else: logEvent("NumericalAnalytics KSPOuterResidual: %12.5e" %(truenorm), level=7) - logEvent("NumericalAnalytics KSPOuterResidual(relative): %12.5e" %(old_div(truenorm, self.rnorm0)), level=7) + logEvent("NumericalAnalytics KSPOuterResidual(relative): %12.5e" %(truenorm/ self.rnorm0), level=7) logEvent(" KSP it %i norm(r) = %e norm(r)/|b| = %e ; atol=%e rtol=%e " % (its, truenorm, - (old_div(truenorm, self.rnorm0)), + (truenorm/self.rnorm0), ksp.atol, ksp.rtol)) if truenorm < self.rnorm0*ksp.rtol: @@ -1702,19 +1703,19 @@ def _converged_trueRes(self,ksp,its,rnorm): if its == 0: self.rnorm0 = truenorm logEvent("NumericalAnalytics KSPSchurResidual: %12.5e" %(truenorm), level=7) - logEvent("NumericalAnalytics KSPSchurResidual(relative): %12.5e" %(old_div(truenorm, self.rnorm0)), level=7 ) + logEvent("NumericalAnalytics KSPSchurResidual(relative): %12.5e" %(truenorm/self.rnorm0), level=7 ) logEvent(" KSP it %i norm(r) = %e norm(r)/|b| = %e ; atol=%e rtol=%e " % (its, truenorm, - (old_div(truenorm, self.rnorm0)), + (truenorm/self.rnorm0), ksp.atol, ksp.rtol)) return False else: logEvent("NumericalAnalytics KSPSchurResidual: %12.5e" %(truenorm), level=7) - logEvent("NumericalAnalytics KSPSchurResidual(relative): %12.5e" %(old_div(truenorm, self.rnorm0)), level=7) + logEvent("NumericalAnalytics KSPSchurResidual(relative): %12.5e" %(truenorm/self.rnorm0), level=7) logEvent(" KSP it %i norm(r) = %e norm(r)/|b| = %e ; atol=%e rtol=%e " % (its, truenorm, - (old_div(truenorm, self.rnorm0)), + (truenorm/self.rnorm0), ksp.atol, ksp.rtol)) if truenorm < self.rnorm0*ksp.rtol: @@ -1984,7 +1985,7 @@ def setUp(self, self.operator_constructor.updateQ() self.Qp = self.Q.createSubMatrix(self.operator_constructor.linear_smoother.isp, self.operator_constructor.linear_smoother.isp) - self.Qp.scale(old_div(1.,self.L.pde.coefficients.nu)) + self.Qp.scale(1./self.L.pde.coefficients.nu) L_sizes = self.Qp.size # Setup a PETSc shell for the inverse Qp operator @@ -2395,9 +2396,9 @@ def __init__(self,L): print("L_sizes",L_sizes) neqns = L_sizes[0][0] print("neqns",neqns) - self.saturationDOF = numpy.arange(L_range[0],L_range[0]+old_div(neqns,2),dtype="i") + self.saturationDOF = numpy.arange(L_range[0],L_range[0]+neqns/2,dtype="i") #print "saturation",self.saturationDOF - self.pressureDOF = numpy.arange(L_range[0]+old_div(neqns,2),L_range[0]+neqns,dtype="i") + self.pressureDOF = numpy.arange(L_range[0]+neqns/2,L_range[0]+neqns,dtype="i") #print "pressure",self.pressureDOF self.pc = p4pyPETSc.PC().create() self.pc.setType('fieldsplit') @@ -2478,8 +2479,8 @@ def __init__(self,L): L_sizes = L.getSizes() L_range = L.getOwnershipRange() neqns = L_sizes[0][0] - self.saturationDOF = numpy.arange(L_range[0],L_range[0]+old_div(neqns,2),dtype="i") - self.pressureDOF = numpy.arange(L_range[0]+old_div(neqns,2),L_range[0]+neqns,dtype="i") + self.saturationDOF = numpy.arange(L_range[0],L_range[0]+neqns/2,dtype="i") + self.pressureDOF = numpy.arange(L_range[0]+neqns/2,L_range[0]+neqns,dtype="i") self.pc = p4pyPETSc.PC().create() self.pc.setType('fieldsplit') self.isp = p4pyPETSc.IS() @@ -2526,7 +2527,7 @@ def __init__(self, self.node_order=numpy.arange(self.n,dtype="i") def prepare(self,b=None): if type(self.L).__name__ == 'ndarray': - self.M = old_div(self.w,numpy.diagonal(self.L)) + self.M = self.w/numpy.diagonal(self.L) elif type(self.L).__name__ == 'SparseMatrix': self.csmoothers.jacobi_NR_prepare(self.L,self.w,1.0e-16,self.M) def solve(self,u,r=None,b=None,par_u=None,par_b=None,initialGuessIsZero=False): @@ -2578,7 +2579,7 @@ def __init__(self, self.sym=sym def prepare(self,b=None): if type(self.L).__name__ == 'ndarray': - self.M = old_div(self.w,numpy.diagonal(self.L)) + self.M = self.w/numpy.diagonal(self.L) elif type(self.L).__name__ == 'SparseMatrix': self.csmoothers.gauss_seidel_NR_prepare(self.L,self.w,1.0e-16,self.M) #self.csmoothers.jacobi_NR_prepare(self.L,self.w,1.0e-16,self.M) @@ -3070,7 +3071,7 @@ def multilevelLinearSolverChooser(linearOperatorList, if l > 0: if smootherType == Jacobi: if relaxationFactor is None: - relaxationFactor = old_div(4.0,5.0) + relaxationFactor = 4.0/5.0 preSmootherList.append(Jacobi(L=linearOperatorList[l], weight=relaxationFactor, maxIts=preSmooths, @@ -3173,7 +3174,7 @@ def multilevelLinearSolverChooser(linearOperatorList, levelLinearSolver = levelLinearSolverList elif levelLinearSolverType == Jacobi: if relaxationFactor is None: - relaxationFactor = old_div(4.0,5.0) + relaxationFactor = 4.0/5.0 for l in range(nLevels): levelLinearSolverList.append(Jacobi(L=linearOperatorList[l], weight=relaxationFactor, @@ -3280,7 +3281,7 @@ def multilevelLinearSolverChooser(linearOperatorList, gres("set terminal x11") levels = 7 n=2**levels + 1 - h =old_div(1.0,(n-1.0)) + h = 1.0/(n-1.0) freq=10 uFine = uniform(0,1,(n)) uFine[0]=0.0 @@ -3304,7 +3305,7 @@ def multilevelLinearSolverChooser(linearOperatorList, N = 2**(l+1) + 1 L = SparseMat_old(N-2,N-2,3*(N-2),sym=True) LD = Mat(N-2,N-2) - H = old_div(1.0,(N-1.0)) + H = 1.0/(N-1.0) hList.append(H) mgItsList.append(6) meshList.append(numpy.arange(0,1.0+H,H,dtype='d')[1:N-1]) @@ -3316,35 +3317,35 @@ def multilevelLinearSolverChooser(linearOperatorList, bList.append(b) beginAssembly(L) for i in range(N-2): - L[i,i] = old_div(2.0,H**2) - LD[i,i] = old_div(2.0,H**2) + L[i,i] = 2.0/H**2 + LD[i,i] = 2.0/H**2 if i > 0: - L[i,i-1] = old_div(-1.0,H**2) - LD[i,i-1] = old_div(-1.0,H**2) + L[i,i-1] = -1.0/H**2 + LD[i,i-1] = -1.0/H**2 if i < N-3: - L[i,i+1] = old_div(-1.0,H**2) - LD[i,i+1] = old_div(-1.0,H**2) + L[i,i+1] = -1.0/H**2 + LD[i,i+1] = -1.0/H**2 endAssembly(L) LList.append(L) LDList.append(LD) if l > 0: - cN = old_div((N - 1),2) + 1 + cN = (N - 1)/2 + 1 restrict = SparseMat_old(cN-2,N-2,3*(N-2)) prolong = SparseMat_old(N-2,cN-2,3*(N-2)) for i in range(cN-2): - restrict[i,2*i] = old_div(1.0,4.0) - restrict[i,2*i+1] = old_div(2.0,4.0) - restrict[i,2*i+2] = old_div(1.0,4.0) - prolong[2*i,i] = old_div(1.0,2.0) - prolong[2*i+1,i]= old_div(2.0,2.0) - prolong[2*i+2,i]= old_div(1.0,2.0) + restrict[i,2*i] = 1.0/4.0 + restrict[i,2*i+1] = 2.0/4.0 + restrict[i,2*i+2] = 1.0/4.0 + prolong[2*i,i] = 1.0/2.0 + prolong[2*i+1,i]= 2.0/2.0 + prolong[2*i+2,i]= 1.0/2.0 restrict.to_csr() restrictList.append(restrict) prolong.to_csr() prolongList.append(prolong) N = cN - preSmootherList.append(Jacobi(L,old_div(2.0,3.0),3)) - postSmootherList.append(Jacobi(L,old_div(2.0,3.0),3)) + preSmootherList.append(Jacobi(L, 2.0/3.0,3)) + postSmootherList.append(Jacobi(L, 2.0/3.0,3)) else: restrictList.append([]) prolongList.append([]) @@ -3378,7 +3379,7 @@ def multilevelLinearSolverChooser(linearOperatorList, dev = DenseEigenvalues(a) dev.computeEigenvalues() evals.append(dev.eigenvalues) - ratio = (old_div(max(abs(dev.eigenvalues)),min(abs(dev.eigenvalues))))*(h**2) + ratio = (max(abs(dev.eigenvalues))/min(abs(dev.eigenvalues)))*(h**2) print("k*h**2 %12.5E" % ratio) gevals = Gnuplot.Gnuplot() gevals("set terminal x11") @@ -4254,8 +4255,8 @@ def __init__(self, self.alpha = alpha self.beta = beta - self.relax_parameter = old_div((self.alpha + self.beta), 2.) - self.rho = old_div((self.beta - self.alpha), (self.alpha + self.beta)) + self.relax_parameter = (self.alpha + self.beta)/ 2. + self.rho = (self.beta - self.alpha)/(self.alpha + self.beta) self.diag = self.A_petsc.getDiagonal().copy() self.diag.scale(self.relax_parameter) @@ -4303,7 +4304,7 @@ def apply(self, b, x, k=5): b_copy = b.copy() for i in range(k): - w = old_div(1.,(1-old_div((self.rho**2),4.))) + w = 1./(1-(self.rho**2)/4.) self.r_petsc_array.fill(0.) self.computeResidual(self.x_k_array, self.r_petsc_array, @@ -4448,7 +4449,7 @@ def _defineNullSpaceVec(self, else: n_DOF_pressure = ksp.par_L.pde.u[0].femSpace.dofMap.nDOF tmp = null_space_vector.getArray()[0:n_DOF_pressure] - tmp[:] = old_div(1.0, (sqrt(N_DOF_pressure))) + tmp[:] = 1.0/(sqrt(N_DOF_pressure)) null_space_vector.assemblyBegin() null_space_vector.assemblyEnd() self.global_null_space = [null_space_vector] diff --git a/proteus/MeshAdaptPUMI/AdaptHelper.py b/proteus/MeshAdaptPUMI/AdaptHelper.py index 9b85ee438f..3e204f2789 100644 --- a/proteus/MeshAdaptPUMI/AdaptHelper.py +++ b/proteus/MeshAdaptPUMI/AdaptHelper.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import str -from builtins import range import proteus import sys import numpy @@ -610,7 +607,7 @@ def PUMI_estimateError(self): #For a given vertex, the i-th size_scale is roughly the desired edge length along the i-th direction specified by the size_frame for i in range(len(self.modelList[0].levelModelList[0].mesh.size_scale)): self.modelList[0].levelModelList[0].mesh.size_scale[i,0] = 1e-1 - self.modelList[0].levelModelList[0].mesh.size_scale[i,1] = (old_div(self.modelList[0].levelModelList[0].mesh.nodeArray[i,1],0.584))*1e-1 + self.modelList[0].levelModelList[0].mesh.size_scale[i,1] = (self.modelList[0].levelModelList[0].mesh.nodeArray[i,1]/0.584)*1e-1 for j in range(3): for k in range(3): if(j==k): diff --git a/proteus/MeshAdaptPUMI/Checkpoint.py b/proteus/MeshAdaptPUMI/Checkpoint.py index ddcde07c3c..4c4298b876 100644 --- a/proteus/MeshAdaptPUMI/Checkpoint.py +++ b/proteus/MeshAdaptPUMI/Checkpoint.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import str -from builtins import range import proteus import sys import numpy diff --git a/proteus/MeshAdaptPUMI/MeshConverter.cpp b/proteus/MeshAdaptPUMI/MeshConverter.cpp index 8b54de88d4..2a1166a86c 100644 --- a/proteus/MeshAdaptPUMI/MeshConverter.cpp +++ b/proteus/MeshAdaptPUMI/MeshConverter.cpp @@ -1,9 +1,10 @@ #include - +#include #include "MeshAdaptPUMI.h" -#include +#include "PCU.h" #include "mesh.h" -#include +#include "apfConvert.h" +#include "apfShape.h" #include @@ -58,21 +59,21 @@ int MeshAdaptPUMIDrvr::constructFromSerialPUMIMesh(Mesh& mesh) mesh.nEdges_global = m->count(1); -//nNodes_element for now is constant for the entire mesh, Ask proteus about using mixed meshes + //nNodes_element for now is constant for the entire mesh, Ask proteus about using mixed meshes switch (dim) { - case 2: - mesh.nNodes_element = 3; - mesh.nNodes_elementBoundary = 2; - mesh.nElementBoundaries_element = 3; - break; - case 3: - mesh.nNodes_element = 4; - mesh.nNodes_elementBoundary = 3; - mesh.nElementBoundaries_element = 4; - break; - default: - apf::fail("dimension is not 2 or 3\n"); - break; + case 2: + mesh.nNodes_element = 3; + mesh.nNodes_elementBoundary = 2; + mesh.nElementBoundaries_element = 3; + break; + case 3: + mesh.nNodes_element = 4; + mesh.nNodes_elementBoundary = 3; + mesh.nElementBoundaries_element = 4; + break; + default: + apf::fail("dimension is not 2 or 3\n"); + break; } #ifdef MESH_INFO std::cerr << "*******Proteus Mesh Stats*********\n"; @@ -150,7 +151,7 @@ int MeshAdaptPUMIDrvr::constructElements(Mesh& mesh) original comment above preserved for entertainment. This maps SCOREC's tet face numbering to that of proteus. - */ +*/ int getProteusBoundaryIdx(apf::Mesh* m, apf::MeshEntity* e, apf::MeshEntity* f) { @@ -175,8 +176,8 @@ int getProteusBoundaryIdx(apf::Mesh* m, apf::MeshEntity* e, apf::MeshEntity* f) int MeshAdaptPUMIDrvr::constructBoundaries(Mesh& mesh) { -//build face list (elementBoundary and nodeBoundary arrays) -//Enter at your own peril for those who stray will be lost + //build face list (elementBoundary and nodeBoundary arrays) + //Enter at your own peril for those who stray will be lost std::set interiorElementBoundaries; std::set exteriorElementBoundaries; @@ -199,15 +200,15 @@ int MeshAdaptPUMIDrvr::constructBoundaries(Mesh& mesh) apf::MeshEntity* f; while ((f = m->iterate(it))) { int i = localNumber(f); -// get vertices from adjacency + // get vertices from adjacency apf::Downward vs; int iNumVtx = m->getDownward(f, 0, vs); for (int iVtx = 0; iVtx < iNumVtx; ++iVtx) { int vtxID = localNumber(vs[iVtx]); mesh.elementBoundaryNodesArray[ - i * mesh.nNodes_elementBoundary + iVtx] = vtxID; + i * mesh.nNodes_elementBoundary + iVtx] = vtxID; } -//get regions from adjacency + //get regions from adjacency apf::Up rs; m->getUp(f, rs); int iNumRgn = rs.n; @@ -219,7 +220,7 @@ int MeshAdaptPUMIDrvr::constructBoundaries(Mesh& mesh) localBoundaryNumber[iRgn] = getProteusBoundaryIdx(m, rs.e[iRgn], f); assert(localBoundaryNumber[iRgn] != -1); mesh.elementBoundaryLocalElementBoundariesArray[ - i * 2 + iRgn] = localBoundaryNumber[iRgn]; + i * 2 + iRgn] = localBoundaryNumber[iRgn]; } //left and right regions are shared by this face we are currntly on int leftRgnID = RgnID[0]; int leftLocalBoundaryNumber = localBoundaryNumber[0]; @@ -228,10 +229,10 @@ int MeshAdaptPUMIDrvr::constructBoundaries(Mesh& mesh) an actual ID if this face is shared, or will contain -1 if it is an exterior face */ mesh.elementNeighborsArray[ - leftRgnID * mesh.nElementBoundaries_element + leftLocalBoundaryNumber] + leftRgnID * mesh.nElementBoundaries_element + leftLocalBoundaryNumber] = rightRgnID; mesh.elementBoundariesArray[ - leftRgnID * mesh.nElementBoundaries_element + leftLocalBoundaryNumber] + leftRgnID * mesh.nElementBoundaries_element + leftLocalBoundaryNumber] = i; /* if only 1 region is adjacent to this face, @@ -250,10 +251,10 @@ int MeshAdaptPUMIDrvr::constructBoundaries(Mesh& mesh) } else { //2 regions are shared by this face so interior face mesh.elementNeighborsArray[ - rightRgnID * mesh.nElementBoundaries_element + rightLocalBoundaryNumber] + rightRgnID * mesh.nElementBoundaries_element + rightLocalBoundaryNumber] = leftRgnID; mesh.elementBoundariesArray[ - rightRgnID * mesh.nElementBoundaries_element + rightLocalBoundaryNumber] + rightRgnID * mesh.nElementBoundaries_element + rightLocalBoundaryNumber] = i; interiorElementBoundaries.insert(i); } @@ -268,9 +269,9 @@ int MeshAdaptPUMIDrvr::constructBoundaries(Mesh& mesh) int ebNI=0,ebNE=0; for (std::set::iterator ebN=interiorElementBoundaries.begin();ebN != interiorElementBoundaries.end(); ebN++,ebNI++) - mesh.interiorElementBoundariesArray[ebNI] = *ebN; + mesh.interiorElementBoundariesArray[ebNI] = *ebN; for (std::set::iterator ebN=exteriorElementBoundaries.begin();ebN != exteriorElementBoundaries.end(); ebN++,ebNE++) - mesh.exteriorElementBoundariesArray[ebNE] = *ebN; + mesh.exteriorElementBoundariesArray[ebNE] = *ebN; return 0; } @@ -284,41 +285,41 @@ static void createStars(Mesh& mesh) std::vector > nodeStar(mesh.nNodes_global); for (int edgeN = 0; edgeN < mesh.nEdges_global; edgeN++) { nodeStar[mesh.edgeNodesArray[edgeN * 2 + 0]].insert( - mesh.edgeNodesArray[edgeN * 2 + 1]); + mesh.edgeNodesArray[edgeN * 2 + 1]); nodeStar[mesh.edgeNodesArray[edgeN * 2 + 1]].insert( - mesh.edgeNodesArray[edgeN * 2 + 0]); + mesh.edgeNodesArray[edgeN * 2 + 0]); } mesh.nodeStarOffsets = new int[mesh.nNodes_global + 1]; mesh.nodeStarOffsets[0] = 0; for (int nN = 1; nN <= mesh.nNodes_global; nN++) mesh.nodeStarOffsets[nN] = - mesh.nodeStarOffsets[nN - 1] + nodeStar[nN - 1].size(); + mesh.nodeStarOffsets[nN - 1] + nodeStar[nN - 1].size(); mesh.nodeStarArray = new int[mesh.nodeStarOffsets[mesh.nNodes_global]]; for (int nN = 0, offset = 0; nN < mesh.nNodes_global; nN++) for (std::set::iterator nN_star=nodeStar[nN].begin(); nN_star!=nodeStar[nN].end(); nN_star++, offset++) - mesh.nodeStarArray[offset] = *nN_star; + mesh.nodeStarArray[offset] = *nN_star; mesh.max_nNodeNeighbors_node = 0; for (int nN = 0; nN < mesh.nNodes_global; nN++) - mesh.max_nNodeNeighbors_node = - std::max(mesh.max_nNodeNeighbors_node, - mesh.nodeStarOffsets[nN + 1] - mesh.nodeStarOffsets[nN]); + mesh.max_nNodeNeighbors_node = + std::max(mesh.max_nNodeNeighbors_node, + mesh.nodeStarOffsets[nN + 1] - mesh.nodeStarOffsets[nN]); std::vector > nodeElementsStar(mesh.nNodes_global); for (int eN = 0; eN < mesh.nElements_global; eN++) for (int nN = 0; nN < mesh.nNodes_element; nN++) nodeElementsStar[ - mesh.elementNodesArray[eN * mesh.nNodes_element + nN] - ].insert(eN); + mesh.elementNodesArray[eN * mesh.nNodes_element + nN] + ].insert(eN); mesh.nodeElementOffsets = new int[mesh.nNodes_global + 1]; mesh.nodeElementOffsets[0] = 0; for (int nN = 0; nN < mesh.nNodes_global; nN++) - mesh.nodeElementOffsets[nN + 1] = - mesh.nodeElementOffsets[nN] + nodeElementsStar[nN].size(); + mesh.nodeElementOffsets[nN + 1] = + mesh.nodeElementOffsets[nN] + nodeElementsStar[nN].size(); mesh.nodeElementsArray = new int[mesh.nodeElementOffsets[mesh.nNodes_global]]; for (int nN=0,offset=0; nN < mesh.nNodes_global; nN++) for (std::set::iterator eN_star = nodeElementsStar[nN].begin(); @@ -398,9 +399,9 @@ int MeshAdaptPUMIDrvr::constructMaterialArrays(Mesh& mesh) * array slot. */ int MeshAdaptPUMIDrvr::updateMaterialArrays(Mesh& mesh, - int dim, - int proteus_material, - int scorec_tag) + int dim, + int proteus_material, + int scorec_tag) { //int dim = m->getDimension(); apf::ModelEntity* geomEnt = m->findModelEntity(dim, scorec_tag); @@ -408,10 +409,10 @@ int MeshAdaptPUMIDrvr::updateMaterialArrays(Mesh& mesh, apf::MeshEntity* f; if(dim==m->getDimension()){ while ((f = m->iterate(it))) { - if (m->toModel(f) == geomEnt) { - int i = localNumber(f); - mesh.elementMaterialTypes[i] = proteus_material; - } + if (m->toModel(f) == geomEnt) { + int i = localNumber(f); + mesh.elementMaterialTypes[i] = proteus_material; + } } } else{ @@ -518,7 +519,7 @@ int MeshAdaptPUMIDrvr::updateMaterialArrays2(Mesh& mesh) //The procedure is to have each vertex look for its classification. //If it is classified in the region, then it is interior. //Else, loop over adjacent faces and stop at first instance of mesh face classified on model boundary and take tag. - //If there are no such adjacent mesh faces, then set the value to be -1. This should only happen if the vertex is a shared entity. + //If there are no such adjacent mesh faces, then set the value to be -1. This should only happen if the vertex is a shared entity. //If the vertex is shared, communicate value to remote copies. //When receiving values, if the current value is -1, write to field the received value. Otherwise, do nothing. @@ -526,83 +527,83 @@ int MeshAdaptPUMIDrvr::updateMaterialArrays2(Mesh& mesh) it = m->begin(0); PCU_Comm_Begin(); while(f = m->iterate(it)) - { - geomEnt = m->toModel(f); - //if classified in a region - if(m->getModelType(geomEnt) == m->getDimension()) { - apf::setScalar(nodeMaterials,f,0,0); + geomEnt = m->toModel(f); + //if classified in a region + if(m->getModelType(geomEnt) == m->getDimension()) + { + apf::setScalar(nodeMaterials,f,0,0); + } + else + { + apf::Adjacent vert_adjFace; + m->getAdjacent(f,m->getDimension()-1,vert_adjFace); + apf::MeshEntity* face; + for(int i =0; itoModel(face); + + //IF mesh face is classified on boundary + if(m->getModelType(geomEnt) == m->getDimension()-1) + { + geomTag = m->getModelTag(geomEnt); + apf::setScalar(nodeMaterials,f,0,geomTag); + if(m->isShared(f)) + { + apf::Copies remotes; + m->getRemotes(f,remotes); + for(apf::Copies::iterator iter = remotes.begin(); iter != remotes.end(); ++iter) + { + PCU_COMM_PACK(iter->first,iter->second); + PCU_COMM_PACK(iter->first,geomTag); + } + } + break; + } + if(i == vert_adjFace.getSize()-1 ) + apf::setScalar(nodeMaterials,f,0,-1); + } + } } - else - { - apf::Adjacent vert_adjFace; - m->getAdjacent(f,m->getDimension()-1,vert_adjFace); - apf::MeshEntity* face; - for(int i =0; itoModel(face); - - //IF mesh face is classified on boundary - if(m->getModelType(geomEnt) == m->getDimension()-1) - { - geomTag = m->getModelTag(geomEnt); - apf::setScalar(nodeMaterials,f,0,geomTag); - if(m->isShared(f)) - { - apf::Copies remotes; - m->getRemotes(f,remotes); - for(apf::Copies::iterator iter = remotes.begin(); iter != remotes.end(); ++iter) - { - PCU_COMM_PACK(iter->first,iter->second); - PCU_COMM_PACK(iter->first,geomTag); - } - } - break; - } - if(i == vert_adjFace.getSize()-1 ) - apf::setScalar(nodeMaterials,f,0,-1); - } - } - } m->end(it); PCU_Comm_Send(); while(PCU_Comm_Receive()) - { - PCU_COMM_UNPACK(f); - PCU_COMM_UNPACK(geomTag); - int currentTag = apf::getScalar(nodeMaterials,f,0); - int newTag = std::min(currentTag,geomTag); - //if vertex is not interior and had no adjacent faces, take received values - //else take minimum value of all tags - if(currentTag==-1) - apf::setScalar(nodeMaterials,f,0,geomTag); - else - apf::setScalar(nodeMaterials,f,0,newTag); - } + { + PCU_COMM_UNPACK(f); + PCU_COMM_UNPACK(geomTag); + int currentTag = apf::getScalar(nodeMaterials,f,0); + int newTag = std::min(currentTag,geomTag); + //if vertex is not interior and had no adjacent faces, take received values + //else take minimum value of all tags + if(currentTag==-1) + apf::setScalar(nodeMaterials,f,0,geomTag); + else + apf::setScalar(nodeMaterials,f,0,newTag); + } //Ensure there are no mismatches across parts and then assign node materials apf::synchronize(nodeMaterials); it = m->begin(0); while(f=m->iterate(it)) - { - int vID = localNumber(f); - mesh.nodeMaterialTypes[vID] = apf::getScalar(nodeMaterials,f,0); - } + { + int vID = localNumber(f); + mesh.nodeMaterialTypes[vID] = apf::getScalar(nodeMaterials,f,0); + } m->end(it); //First iterate over all faces in 3D, get the model tag and apply to all downward adjacencies int dim = m->getDimension()-1; it = m->begin(dim); while(f = m->iterate(it)) - { - int i = localNumber(f); - geomEnt = m->toModel(f); - geomTag = m->getModelTag(geomEnt); - if(m->getModelType(geomEnt) == dim) { - mesh.elementBoundaryMaterialTypes[i] = geomTag; + int i = localNumber(f); + geomEnt = m->toModel(f); + geomTag = m->getModelTag(geomEnt); + if(m->getModelType(geomEnt) == dim) + { + mesh.elementBoundaryMaterialTypes[i] = geomTag; + } } - } m->end(it); apf::destroyField(nodeMaterials); @@ -633,180 +634,179 @@ int MeshAdaptPUMIDrvr::updateMaterialArrays2(Mesh& mesh) #include "apfConvert.h" #include "apfMesh2.h" #include "apf.h" +#include "apfConvert.h" #include "apfNumbering.h" #include namespace apf { -typedef int Gid; - -static void constructVerts( - Mesh2* m, int nverts, - int* local2globalMap, - GlobalToVert& result) -{ - ModelEntity* interior = m->findModelEntity(m->getDimension(), 0); - for (int i = 0; i < nverts; ++i) - result[local2globalMap[i]] = m->createVert_(interior); -} + static void constructVerts( + Mesh2* m, int nverts, + int* local2globalMap, + GlobalToVert& result) + { + ModelEntity* interior = m->findModelEntity(m->getDimension(), 0); + for (int i = 0; i < nverts; ++i) + result[local2globalMap[i]] = m->createVert_(interior); + } -static void constructBoundaryElements( - Mesh2* m, const Gid* conn_b, int nelem_b, int etype_b, - GlobalToVert& globalToVert) -{ - ModelEntity* interior = m->findModelEntity(m->getDimension(), 0); - int nev = apf::Mesh::adjacentCount[etype_b][0]; - for (int i = 0; i < nelem_b; ++i) { - Downward verts; - int offset = i * nev; - for (int j = 0; j < nev; ++j){ - verts[j] = globalToVert[conn_b[j + offset]]; + static void constructBoundaryElements( + Mesh2* m, const apf::Gid* conn_b, int nelem_b, int etype_b, + GlobalToVert& globalToVert) + { + ModelEntity* interior = m->findModelEntity(m->getDimension(), 0); + int nev = apf::Mesh::adjacentCount[etype_b][0]; + for (int i = 0; i < nelem_b; ++i) { + Downward verts; + int offset = i * nev; + for (int j = 0; j < nev; ++j){ + verts[j] = globalToVert[conn_b[j + offset]]; + } + //We only care about how boundary elements are created + //The intermediate entities need to inherit the classifications + if(m->getDimension()==2) + m->createEntity(etype_b,interior,verts); + else + apf::buildElement(m,interior,2,verts); } - //We only care about how boundary elements are created - //The intermediate entities need to inherit the classifications - if(m->getDimension()==2) - m->createEntity(etype_b,interior,verts); - else - apf::buildElement(m,interior,2,verts); } -} -static void constructElements( - Mesh2* m, const Gid* conn, int nelem, int etype, - GlobalToVert& globalToVert) -{ - ModelEntity* interior = m->findModelEntity(m->getDimension(), 0); - int nev = apf::Mesh::adjacentCount[etype][0]; - for (int i = 0; i < nelem; ++i) { - Downward verts; - int offset = i * nev; - for (int j = 0; j < nev; ++j) - verts[j] = globalToVert[conn[j + offset]]; - buildElement(m, interior, etype, verts); + static void constructElements( + Mesh2* m, const Gid* conn, int nelem, int etype, + GlobalToVert& globalToVert) + { + ModelEntity* interior = m->findModelEntity(m->getDimension(), 0); + int nev = apf::Mesh::adjacentCount[etype][0]; + for (int i = 0; i < nelem; ++i) { + Downward verts; + int offset = i * nev; + for (int j = 0; j < nev; ++j) + verts[j] = globalToVert[conn[j + offset]]; + buildElement(m, interior, etype, verts); + } } -} -static Gid getMax(const GlobalToVert& globalToVert) -{ - Gid max = -1; - APF_CONST_ITERATE(GlobalToVert, globalToVert, it) - max = std::max(max, it->first); - return PCU_Max_Int(max); // this is type-dependent -} + static apf::Gid getMax(const GlobalToVert& globalToVert) + { + apf::Gid max = -1; + APF_CONST_ITERATE(GlobalToVert, globalToVert, it) + max = std::max(max, it->first); + return PCU_Max_Int(max); // this is type-dependent + } -/* algorithm courtesy of Sebastian Rettenberger: - use brokers/routers for the vertex global ids. - Although we have used this trick before (see mpas/apfMPAS.cc), - I didn't think to use it here, so credit is given. */ -static void constructResidence(Mesh2* m, GlobalToVert& globalToVert) -{ - Gid max = getMax(globalToVert); - Gid total = max + 1; - int peers = PCU_Comm_Peers(); - int quotient = total / peers; - int remainder = total % peers; - int mySize = quotient; - int self = PCU_Comm_Self(); - if (self == (peers - 1)) - mySize += remainder; - typedef std::vector< std::vector > TmpParts; - TmpParts tmpParts(mySize); - /* if we have a vertex, send its global id to the - broker for that global id */ - PCU_Comm_Begin(); - APF_ITERATE(GlobalToVert, globalToVert, it) { - int gid = it->first; - int to = std::min(peers - 1, gid / quotient); - PCU_COMM_PACK(to, gid); - } - PCU_Comm_Send(); - int myOffset = self * quotient; - /* brokers store all the part ids that sent messages - for each global id */ - while (PCU_Comm_Receive()) { - int gid; - PCU_COMM_UNPACK(gid); - int from = PCU_Comm_Sender(); - tmpParts.at(gid - myOffset).push_back(from); - } - /* for each global id, send all associated part ids - to all associated parts */ - PCU_Comm_Begin(); - for (int i = 0; i < mySize; ++i) { - std::vector& parts = tmpParts[i]; - for (size_t j = 0; j < parts.size(); ++j) { - int to = parts[j]; - int gid = i + myOffset; - int nparts = parts.size(); + /* algorithm courtesy of Sebastian Rettenberger: + use brokers/routers for the vertex global ids. + Although we have used this trick before (see mpas/apfMPAS.cc), + I didn't think to use it here, so credit is given. */ + static void constructResidence(Mesh2* m, GlobalToVert& globalToVert) + { + Gid max = getMax(globalToVert); + Gid total = max + 1; + int peers = PCU_Comm_Peers(); + int quotient = total / peers; + int remainder = total % peers; + int mySize = quotient; + int self = PCU_Comm_Self(); + if (self == (peers - 1)) + mySize += remainder; + typedef std::vector< std::vector > TmpParts; + TmpParts tmpParts(mySize); + /* if we have a vertex, send its global id to the + broker for that global id */ + PCU_Comm_Begin(); + APF_ITERATE(GlobalToVert, globalToVert, it) { + int gid = it->first; + int to = std::min(peers - 1, gid / quotient); PCU_COMM_PACK(to, gid); - PCU_COMM_PACK(to, nparts); - for (size_t k = 0; k < parts.size(); ++k) - PCU_COMM_PACK(to, parts[k]); } - } - PCU_Comm_Send(); - /* receiving a global id and associated parts, - lookup the vertex and classify it on the partition - model entity for that set of parts */ - while (PCU_Comm_Receive()) { - int gid; - PCU_COMM_UNPACK(gid); - int nparts; - PCU_COMM_UNPACK(nparts); - Parts residence; - for (int i = 0; i < nparts; ++i) { - int part; - PCU_COMM_UNPACK(part); - residence.insert(part); + PCU_Comm_Send(); + int myOffset = self * quotient; + /* brokers store all the part ids that sent messages + for each global id */ + while (PCU_Comm_Receive()) { + int gid; + PCU_COMM_UNPACK(gid); + int from = PCU_Comm_Sender(); + tmpParts.at(gid - myOffset).push_back(from); } - MeshEntity* vert = globalToVert[gid]; - m->setResidence(vert, residence); - } -} - -/* given correct residence from the above algorithm, - negotiate remote copies by exchanging (gid,pointer) - pairs with parts in the residence of the vertex */ -static void constructRemotes(Mesh2* m, GlobalToVert& globalToVert) -{ - int self = PCU_Comm_Self(); - PCU_Comm_Begin(); - APF_ITERATE(GlobalToVert, globalToVert, it) { - int gid = it->first; - MeshEntity* vert = it->second; - Parts residence; - m->getResidence(vert, residence); - APF_ITERATE(Parts, residence, rit) - if (*rit != self) { - PCU_COMM_PACK(*rit, gid); - PCU_COMM_PACK(*rit, vert); + /* for each global id, send all associated part ids + to all associated parts */ + PCU_Comm_Begin(); + for (int i = 0; i < mySize; ++i) { + std::vector& parts = tmpParts[i]; + for (size_t j = 0; j < parts.size(); ++j) { + int to = parts[j]; + int gid = i + myOffset; + int nparts = parts.size(); + PCU_COMM_PACK(to, gid); + PCU_COMM_PACK(to, nparts); + for (size_t k = 0; k < parts.size(); ++k) + PCU_COMM_PACK(to, parts[k]); + } + } + PCU_Comm_Send(); + /* receiving a global id and associated parts, + lookup the vertex and classify it on the partition + model entity for that set of parts */ + while (PCU_Comm_Receive()) { + int gid; + PCU_COMM_UNPACK(gid); + int nparts; + PCU_COMM_UNPACK(nparts); + Parts residence; + for (int i = 0; i < nparts; ++i) { + int part; + PCU_COMM_UNPACK(part); + residence.insert(part); } + MeshEntity* vert = globalToVert[gid]; + m->setResidence(vert, residence); + } } - PCU_Comm_Send(); - while (PCU_Comm_Receive()) { - int gid; - PCU_COMM_UNPACK(gid); - MeshEntity* remote; - PCU_COMM_UNPACK(remote); - int from = PCU_Comm_Sender(); - MeshEntity* vert = globalToVert[gid]; - m->addRemote(vert, from, remote); + + /* given correct residence from the above algorithm, + negotiate remote copies by exchanging (gid,pointer) + pairs with parts in the residence of the vertex */ + static void constructRemotes(Mesh2* m, GlobalToVert& globalToVert) + { + int self = PCU_Comm_Self(); + PCU_Comm_Begin(); + APF_ITERATE(GlobalToVert, globalToVert, it) { + int gid = it->first; + MeshEntity* vert = it->second; + Parts residence; + m->getResidence(vert, residence); + APF_ITERATE(Parts, residence, rit) + if (*rit != self) { + PCU_COMM_PACK(*rit, gid); + PCU_COMM_PACK(*rit, vert); + } + } + PCU_Comm_Send(); + while (PCU_Comm_Receive()) { + int gid; + PCU_COMM_UNPACK(gid); + MeshEntity* remote; + PCU_COMM_UNPACK(remote); + int from = PCU_Comm_Sender(); + MeshEntity* vert = globalToVert[gid]; + m->addRemote(vert, from, remote); + } } -} -void construct(Mesh2* m, const int* conn, const int* conn_b, int nelem, - int nelem_b, int nverts,int etype, int etype_b, int* local2globalMap, - GlobalToVert& globalToVert) -{ - constructVerts(m, nverts,local2globalMap,globalToVert); - constructBoundaryElements(m, conn_b, nelem_b, etype_b, globalToVert); - constructElements(m, conn, nelem, etype, globalToVert); - constructResidence(m, globalToVert); - constructRemotes(m, globalToVert); - stitchMesh(m); - m->acceptChanges(); -} + void construct(Mesh2* m, const Gid* conn, const Gid* conn_b, int nelem, + int nelem_b, int nverts,int etype, int etype_b, int* local2globalMap, + GlobalToVert& globalToVert) + { + constructVerts(m, nverts,local2globalMap,globalToVert); + constructBoundaryElements(m, conn_b, nelem_b, etype_b, globalToVert); + constructElements(m, conn, nelem, etype, globalToVert); + constructResidence(m, globalToVert); + constructRemotes(m, globalToVert); + stitchMesh(m); + m->acceptChanges(); + } } @@ -836,18 +836,18 @@ void construct(Mesh2* m, const int* conn, const int* conn_b, int nelem, useModel=False */ -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "apf.h" +#include "gmi_null.h" +#include "gmi_mesh.h" +#include "gmi.h" +#include "apfMDS.h" +#include "apfMesh2.h" +#include "apfConvert.h" +#include "ma.h" +#include "PCU.h" #include -#include +#include "gmi_lookup.h" //Function to transfer some model information from NumericalSolution into the //MeshAdaptPUMIDrvr class. @@ -946,19 +946,19 @@ int MeshAdaptPUMIDrvr::reconstructFromProteus(Mesh& mesh, Mesh& globalMesh,int h gmi_base_reserve(gMod_base,AGM_VERTEX,numModelTotals[0]); if(numDim==2){ - //gedges + //gedges gmi_base_reserve(gMod_base,AGM_EDGE,numModelTotals[2]); - //gfaces + //gfaces gmi_base_reserve(gMod_base,AGM_FACE,numModelTotals[3]); - //gregions + //gregions gmi_base_reserve(gMod_base,AGM_REGION,0); } else if(numDim==3){ - //gedges + //gedges gmi_base_reserve(gMod_base,AGM_EDGE,numModelTotals[1]); - //gfaces + //gfaces gmi_base_reserve(gMod_base,AGM_FACE,numModelTotals[2]); - //gregions + //gregions gmi_base_reserve(gMod_base,AGM_REGION,numModelTotals[3]); } @@ -985,21 +985,21 @@ int MeshAdaptPUMIDrvr::reconstructFromProteus(Mesh& mesh, Mesh& globalMesh,int h //create the mappings from proteus data structures - int* local2global_elementBoundaryNodes; - local2global_elementBoundaryNodes = (int*) malloc(sizeof(int)*mesh.nElementBoundaries_global*apf::Mesh::adjacentCount[etype_b][0]); + apf::Gid* local2global_elementBoundaryNodes; + local2global_elementBoundaryNodes = (apf::Gid*) malloc(sizeof(apf::Gid)*mesh.nElementBoundaries_global*apf::Mesh::adjacentCount[etype_b][0]); for(int i=0;igetAdjacent(ent,1,adj_edges); for(int i=0;igetModelType(m->toModel(adj_edges[i]))>m->getModelType(gEnt) || (m->getModelType(m->toModel(adj_edges[i]))==0)){ edg_gEnt = m->findModelEntity(1,edgCounter); m->setModelEntity(adj_edges[i],edg_gEnt); @@ -1259,10 +1259,10 @@ int MeshAdaptPUMIDrvr::reconstructFromProteus(Mesh& mesh, Mesh& globalMesh,int h apf::Adjacent adj_edges; m->getAdjacent(ent,1,adj_edges); for(int i=0;igetModelType(m->toModel(adj_edges[i]))>m->getModelType(gEnt) || (m->getModelType(m->toModel(adj_edges[i]))==0)){ m->setModelEntity(adj_edges[i],gEnt); - //if the owner and entity is shared, share the model classification with other entities + //if the owner and entity is shared, share the model classification with other entities if(m->isOwned(adj_edges[i]) && m->isShared(adj_edges[i])){ apf::Copies remotes; m->getRemotes(ent,remotes); @@ -1333,78 +1333,82 @@ int MeshAdaptPUMIDrvr::reconstructFromProteus(Mesh& mesh, Mesh& globalMesh,int h int MeshAdaptPUMIDrvr::reconstructFromProteus2(Mesh& mesh,int* isModelVert,int* bFaces){ -//This function only applies for 3D meshes + //This function only applies for 3D meshes - int dim; - int elementType; - if(mesh.nNodes_element == 3){ - dim = 2; - elementType = apf::Mesh::TRIANGLE; - } - else{ - dim = 3; - elementType = apf::Mesh::TET; - } + int dim; + int elementType; + if(mesh.nNodes_element == 3){ + dim = 2; + elementType = apf::Mesh::TRIANGLE; + } + else{ + dim = 3; + elementType = apf::Mesh::TET; + } - isReconstructed = 2; - int nBFaces = mesh.nExteriorElementBoundaries_global; - bool isModelVert_bool[mesh.nNodes_global]; - for(int i=0;i elementNodesArray(mesh.nElements_global*apf::Mesh::adjacentCount[elementType][0]); + for(int i=0;i globalToRegion; - apf::MeshIterator* it = m->begin(dim); - apf::MeshEntity* ent; - int counter = 0; - while( ent = m->iterate(it) ){ - globalToRegion.insert(std::pair (counter,ent )); - counter++; - } + std::map globalToRegion; + apf::MeshIterator* it = m->begin(dim); + apf::MeshEntity* ent; + int counter = 0; + while( ent = m->iterate(it) ){ + globalToRegion.insert(std::pair (counter,ent )); + counter++; + } - if(dim == 2) - apf::derive2DMdlFromManifold(m,isModelVert_bool,nBFaces,bEdges_1D,outMap,globalToRegion); - else - apf::deriveMdlFromManifold(m,isModelVert_bool,nBFaces,bFaces_2D,outMap,globalToRegion); - m->writeNative("Reconstructed.smb"); - gmi_write_dmg(m->getModel(),"Reconstructed.dmg"); - std::cout<<"Finished Reconstruction, terminating program. Rerun with PUMI workflow\n"; - std::exit(0); + if(dim == 2) + apf::derive2DMdlFromManifold(m,isModelVert_bool,nBFaces,bEdges_1D,outMap,globalToRegion); + else + apf::deriveMdlFromManifold(m,isModelVert_bool,nBFaces,bFaces_2D,outMap,globalToRegion); + m->writeNative("Reconstructed.smb"); + gmi_write_dmg(m->getModel(),"Reconstructed.dmg"); + std::cout<<"Finished Reconstruction, terminating program. Rerun with PUMI workflow\n"; + std::exit(0); } diff --git a/proteus/MeshAdaptPUMI/__init__.py b/proteus/MeshAdaptPUMI/__init__.py index 5da937f7b4..d2f27de6a2 100644 --- a/proteus/MeshAdaptPUMI/__init__.py +++ b/proteus/MeshAdaptPUMI/__init__.py @@ -2,4 +2,4 @@ Modules for interfacing to PUMI """ -__all__ = ["MeshAdaptPUMI"] +__all__ = ["MeshAdaptPUMI"] \ No newline at end of file diff --git a/proteus/MeshTools.py b/proteus/MeshTools.py index f919cffb08..e1b83c5d2f 100644 --- a/proteus/MeshTools.py +++ b/proteus/MeshTools.py @@ -4,16 +4,6 @@ .. inheritance-diagram:: proteus.MeshTools :parts: 1 """ -from __future__ import print_function -from __future__ import absolute_import -from __future__ import division -from builtins import input -from builtins import zip -from builtins import next -from builtins import str -from builtins import range -from past.utils import old_div -from builtins import object from .EGeometry import * import numpy as np import array @@ -128,23 +118,23 @@ def computeGeometricInfo(self): self.basis = [self.nodes[1].p - self.nodes[0].p, Edge.yUnitVector, Edge.zUnitVector] - self.barycenter = old_div((self.nodes[0].p + self.nodes[1].p),2.0) + self.barycenter = (self.nodes[0].p+self.nodes[1].p)/2.0 self.length = enorm(self.basis[0]) self.normal = EVec(-self.basis[0][Y], self.basis[0][X],0.0) norm = enorm(self.normal) if norm: - self.unitNormal = old_div(self.normal,norm) + self.unitNormal = self.normal/norm else: #in 3D edge normals don't make sense in general so above #may divide by zero if edge has zero projection onto x-y plane self.normal = EVec(0.0, -self.basis[0][Z], self.basis[0][Y]) - self.unitNormal = old_div(self.normal,enorm(self.normal)) + self.unitNormal = self.normal/enorm(self.normal) self.diameter=self.length self.innerDiameter = self.length self.hasGeometricInfo = True self.nodeUnitNormalList=[] - self.nodeUnitNormalList.append(old_div(-self.basis[0],self.length)) - self.nodeUnitNormalList.append(old_div(self.basis[0],self.length)) + self.nodeUnitNormalList.append(-self.basis[0]/self.length) + self.nodeUnitNormalList.append(self.basis[0]/self.length) self.elementBoundaryUnitNormalList=self.nodeUnitNormalList self.elementBoundaryJacobianList=[Edge.xUnitVector,Edge.xUnitVector] def getNodesFromEdges(edges): @@ -202,15 +192,13 @@ def __init__(self,triangleNumber=0,nodes=[],edgeDict=None): def computeGeometricInfo(self): if not self.hasGeometricInfo: - self.barycenter = old_div((self.nodes[0].p + - self.nodes[1].p + - self.nodes[2].p),3.0) + self.barycenter = (self.nodes[0].p+self.nodes[1].p+self.nodes[2].p)/3.0 self.basis = [ n.p - self.nodes[0].p for n in self.nodes[1:]] self.basis.append(Triangle.zUnitVector) self.linearMap = ETen(self.basis[0],self.basis[1],self.basis[2]) self.normal = ecross(self.basis[0],self.basis[1]) normNormal = enorm(self.normal) - self.unitNormal = old_div(self.normal,normNormal) + self.unitNormal = self.normal/normNormal self.area = 0.5*normNormal for e in self.edges: e.computeGeometricInfo() self.diameter = max([e.length for e in self.edges]) @@ -379,8 +367,8 @@ def computeGeometricInfo(self): self.ymax = node.p[Y] else: pass - self.xmid = old_div((self.xmin+self.xmax),2.) - self.ymid = old_div((self.ymin+self.ymax),2.) + self.xmid = (self.xmin+self.xmax)/2. + self.ymid = (self.ymin+self.ymax)/2. self.zmid = 0. class Polyhedron(Element): @@ -457,13 +445,10 @@ def __init__(self,tetrahedronNumber,nodes,edgeDict=None,triangleDict=None): def computeGeometricInfo(self): if not self.hasGeometricInfo: for t in self.triangles: t.computeGeometricInfo() - self.barycenter =old_div((self.nodes[0].p + - self.nodes[1].p + - self.nodes[2].p + - self.nodes[3].p),4.0) + self.barycenter =(self.nodes[0].p+self.nodes[1].p+self.nodes[2].p+self.nodes[3].p)/4.0 self.basis = [n.p - self.nodes[0].p for n in self.nodes[1:]] self.linearMap = ETen(self.basis[0],self.basis[1],self.basis[2]) - self.volume = old_div(abs(edet(self.linearMap)),6.0) + self.volume = abs(edet(self.linearMap))/6.0 self.diameter = max([t.diameter for t in self.triangles]) #Zhang's formula for rho=innerDiameter of a simplex self.innerDiameter = 6.0*self.volume/sum([t.area for t in @@ -1449,7 +1434,7 @@ def viewTetrahedraMatlab(self,filename): yedges=filename+'_y' zedges=filename+'_z' #the following is for debugging: plot each tet seperately - nT = old_div(len(self.edgeList),6) + nT = len(self.edgeList)//6 plotcommand = "-r \"load " + xfile + \ ", load " + yfile + \ ", load " + zfile @@ -1769,7 +1754,7 @@ def __init__(self,nx=2,Lx=1.0): self.eRange_x = list(range(self.ex)) #lengths self.Lx=Lx - self.dx = old_div(Lx,self.ex) + self.dx = Lx/self.ex #node coordinates self.nodeGridArray = np.zeros((self.nx,3),'d') for i in self.nRange_x: @@ -1794,7 +1779,7 @@ def __init__(self,nx=2,Lx=1.0): #fine grid index of edge nodes for rn,rnii in enumerate(refEdge_nodeIndeces): nii = rnii + ii - edgeNodeNumbers[rn]=old_div(nii,2) + edgeNodeNumbers[rn]=nii//2 self.edgeNodesArray[eN,:]=edgeNodeNumbers #Mesh interface self.nNodes_global=self.nx @@ -1837,8 +1822,8 @@ def __init__(self,nx=2,ny=2,Lx=1.0,Ly=1.0): #lengths self.Lx=Lx self.Ly=Ly - self.dx = old_div(Lx,self.eXx) - self.dy = old_div(Ly,self.eYy) + self.dx = Lx/self.eXx + self.dy = Ly/self.eYy #node coordinates self.nodeGridArray=np.zeros((nx,ny,3),'d') for i in self.nRange_x: @@ -1895,14 +1880,14 @@ def __init__(self,nx=2,ny=2,Lx=1.0,Ly=1.0): for rn,rniijj in enumerate(refQuad_NodeIndeces): nii = rniijj[I] + ii njj = rniijj[J] + jj - nN = (old_div(nii,2))*self.ny + old_div(njj,2) + nN = (nii//2)*self.ny + njj//2 quadNodeNumbers[rn]=nN self.quadrilateralNodesArray[qN][:]=quadNodeNumbers #edges for re,reiijj in enumerate(refQuad_EdgeIndeces): eii = reiijj[I] + ii ejj = reiijj[J] + jj - eN = (old_div(eii,2))*self.eXYy + (eii%2)*self.eYy + old_div(ejj,2) + eN = (eii//2)*self.eXYy + (eii%2)*self.eYy + ejj//2 quadEdgeNumbers[re]=eN #nodes for n,rn in enumerate(refQuad_EdgeNodes[re]): @@ -2011,15 +1996,15 @@ def __init__(self,nx=1,ny=1,nz=1,Lx=1.0,Ly=1.0,Lz=1.0): #dimensions of hexahedra if self.nHx>0: - hx = old_div(float(Lx),(nx-1)) + hx = float(Lx)/(nx-1) else: hx = 1.0 if self.nHy>0: - hy = old_div(float(Ly),(ny-1)) + hy = float(Ly)/(ny-1) else: hy=1.0 if self.nHz>0: - hz = old_div(float(Lz),(nz-1)) + hz = float(Lz)/(nz-1) else: hz=1.0 self.nodeDict={} @@ -2374,7 +2359,7 @@ def finalize(self): T.computeGeometricInfo() self.hMax = max(T.diameter,self.hMax) self.hMin = min(T.diameter,self.hMin) - self.sigmaMax = max(old_div(T.diameter,T.innerDiameter),self.sigmaMax) + self.sigmaMax = max(T.diameter/T.innerDiameter,self.sigmaMax) self.totalVolume += T.volume def buildLists(self): self.buildListsNodes() @@ -2891,7 +2876,7 @@ def finalize(self): T.computeGeometricInfo() self.hMax = max(T.diameter,self.hMax) self.hMin = min(T.diameter,self.hMin) - self.sigmaMax = max(old_div(T.diameter,T.innerDiameter),self.sigmaMax) + self.sigmaMax = max(T.diameter/T.innerDiameter,self.sigmaMax) self.totalVolume += T.volume def buildLists(self): @@ -4184,8 +4169,8 @@ def buildLevelSetMesh(self,value,nodalValues): nodes[newNode] = newNode self.levelSetNodeNumbers.add(nr.N) else: - wr = old_div((value - vl), (vr - vl)) - wl = old_div((value - vr), (vl - vr)) + wr = (value-vl)/(vr-vl) + wl = (value-vr)/(vl-vr) newPoint = nl.p*wl + nr.p*wr newNode = Node(len(levelSetMesh.nodeDict), newPoint[X], @@ -4431,7 +4416,7 @@ def writeAsymptote(self,fileprefix,L,x,units="m"): """ Write a representation of the triangular mesh in the Asymptote vector graphics language """ - unitsize=old_div(4.0,L[0]) + unitsize=4.0/L[0] f = open(fileprefix+".asy",'w') fileString=""" unitsize(4.0 inches / %(Lx)f); @@ -5056,9 +5041,9 @@ def __init__(self, self.meshList[0].elementOffsets_subdomain_owned[-1] = self.meshList[0].nElements_global for node in range(self.meshList[0].nNodes_global): - self.meshList[0].nodeNumbering_subdomain2global.itemset(node,node) + self.meshList[0].nodeNumbering_subdomain2global[node] = node for element in range(self.meshList[0].nElements_global): - self.meshList[0].elementNumbering_subdomain2global.itemset(element,element) + self.meshList[0].elementNumbering_subdomain2global[element] = element self.meshList[0].buildNodeStarArrays() for l in range(1,refinementLevels): @@ -5122,9 +5107,9 @@ def refine(self): self.meshList[-1].elementOffsets_subdomain_owned[-1] = self.meshList[-1].nElements_global for node in range(self.meshList[-1].nNodes_global): - self.meshList[-1].nodeNumbering_subdomain2global.itemset(node,node) + self.meshList[-1].nodeNumbering_subdomain2global[node]=node for element in range(self.meshList[-1].nElements_global): - self.meshList[-1].elementNumbering_subdomain2global.itemset(element,element) + self.meshList[-1].elementNumbering_subdomain2global[element]=element self.elementChildren.append(childrenDict) @@ -5245,7 +5230,7 @@ def setMeshBathymetry_localAveraging(self,mesh): eN = self.pointElementsArray[pN] if eN >= 0: if mesh.nPoints_element[eN] > 0: - mesh.elementMeanZ[eN] += old_div(self.domain.bathy[pN,2],float(mesh.nPoints_element[eN])) + mesh.elementMeanZ[eN] += self.domain.bathy[pN,2]/float(mesh.nPoints_element[eN]) mesh.nodeArray[mesh.elementNodesArray[eN,0],2] = 0.0 mesh.nodeArray[mesh.elementNodesArray[eN,1],2] = 0.0 mesh.nodeArray[mesh.elementNodesArray[eN,2],2] = 0.0 @@ -5280,9 +5265,9 @@ def setMeshBathymetry_localAveraging(self,mesh): J = mesh.elementNodesArray[eN,0] inverseJacobian = inv(jacobian) area = 0.5*det(jacobian) - sumArray[mesh.elementNodesArray[eN,0]] += old_div(area,mesh.nodeSupportArray[mesh.elementNodesArray[eN,0]]) - sumArray[mesh.elementNodesArray[eN,1]] += old_div(area,mesh.nodeSupportArray[mesh.elementNodesArray[eN,1]]) - sumArray[mesh.elementNodesArray[eN,2]] += old_div(area,mesh.nodeSupportArray[mesh.elementNodesArray[eN,2]]) + sumArray[mesh.elementNodesArray[eN,0]] += area/mesh.nodeSupportArray[mesh.elementNodesArray[eN,0]] + sumArray[mesh.elementNodesArray[eN,1]] += area/mesh.nodeSupportArray[mesh.elementNodesArray[eN,1]] + sumArray[mesh.elementNodesArray[eN,2]] += area/mesh.nodeSupportArray[mesh.elementNodesArray[eN,2]] mesh.nodeArray[mesh.elementNodesArray[eN,0],2] += area*mesh.elementMeanZ[eN]/mesh.nodeSupportArray[mesh.elementNodesArray[eN,0]] mesh.nodeArray[mesh.elementNodesArray[eN,1],2] += area*mesh.elementMeanZ[eN]/mesh.nodeSupportArray[mesh.elementNodesArray[eN,1]] mesh.nodeArray[mesh.elementNodesArray[eN,2],2] += area*mesh.elementMeanZ[eN]/mesh.nodeSupportArray[mesh.elementNodesArray[eN,2]] @@ -5580,7 +5565,7 @@ def tagElements(self,mesh): errorL2 += (mesh.errorAverage_element[eN])**2 * mesh.area_element[eN] if mesh.errorAverage_element[eN] >= 1.0: mesh.elementTags[eN] = 1 - errorL2 = old_div(sqrt(errorL2),self.totalArea)#normalize by domain error to make error have units of length + errorL2 = sqrt(errorL2)/self.totalArea#normalize by domain error to make error have units of length return errorL2 else: print("Interpolation Error, L_infty ",errorInfty) @@ -6302,7 +6287,7 @@ def intersectEdge(line, edge): return None # two lines are parallel, solve for x - x = old_div(norm(x_vl_cross_ve),norm(vl_cross_ve)) + x = norm(x_vl_cross_ve)/norm(vl_cross_ve) intersect = a + x*(b-a) @@ -6350,7 +6335,7 @@ def intersectPolyhedron(line, polyhedron): else: # the line is in or on the face, ignore this face continue - t = old_div(ndotba, float(d)) + t = ndotba/float(d) if d < 0: # segment is entering polyhedron across this facet t_e = max(t_e, t) @@ -6613,10 +6598,10 @@ def setTriangleOptions(self, triangleOptions=None): assert self.triangle_string is not None, 'triangle_string must be set before setting triangle options' if self.nd == 2: self.triangleOptions = self.triangle_string + '%8.8f' \ - % (old_div(self.he**2,2.),) + % (self.he**2/2.,) elif self.nd == 3: self.triangleOptions = self.triangle_string + '%21.16e' \ - % (old_div(self.he**3,6.),) + % (self.he**3/6.,) def setMeshGenerator(self, generator): """ diff --git a/proteus/NonlinearSolvers.py b/proteus/NonlinearSolvers.py index 846a366589..f068d9923d 100644 --- a/proteus/NonlinearSolvers.py +++ b/proteus/NonlinearSolvers.py @@ -4,15 +4,6 @@ .. inheritance-diagram:: proteus.NonlinearSolvers :parts: 1 """ -from __future__ import print_function -from __future__ import absolute_import -from __future__ import division - -from builtins import str -from builtins import zip -from builtins import range -from past.utils import old_div -from builtins import object import numpy import numpy as np from math import * @@ -104,7 +95,7 @@ def __init__(self, self.gustafsson_alpha = -12345.0 self.gustafsson_norm_du_last = -12345.0 #mwf end hacks for conv. rate - self.W = old_div(1.0,float(self.F.dim)) + self.W = 1.0/float(self.F.dim) self.kappa_current = 0.0 #condition number self.kappa_max = 0.0 self.norm_2_J_current = 0.0 @@ -209,7 +200,7 @@ def computeConvergenceRates(self): #import pdb #pdb.set_trace() if self.gustafsson_norm_du_last >= 0.0: - tmp = old_div(self.norm_du, (self.gustafsson_norm_du_last + 1.0e-16)) + tmp = self.norm_du/(self.gustafsson_norm_du_last+1.0e-16) self.gustafsson_alpha = max(self.gustafsson_alpha,tmp) # if self.its > 0: @@ -217,7 +208,7 @@ def computeConvergenceRates(self): #mwf end hack for conv. rate if self.convergingIts > 0: if self.norm_r < self.lastNorm_r: - self.ratio_r_current = old_div(self.norm_r,self.lastNorm_r) + self.ratio_r_current = self.norm_r/self.lastNorm_r else: logEvent("residual increase %s" % self.norm_r) self.convergingIts=0 @@ -237,12 +228,11 @@ def computeConvergenceRates(self): self.last_log_ratior_du = 1.0 return self.ratio_r_solve *= self.ratio_r_current - self.rReductionFactor = pow(self.ratio_r_solve,old_div(1.0,self.convergingIts)) + self.rReductionFactor = pow(self.ratio_r_solve,1.0/self.convergingIts) if self.convergingIts > 1: - self.rReductionOrder = old_div(log_ratio_r_current, \ - self.last_log_ratio_r) + self.rReductionOrder = log_ratio_r_current/self.last_log_ratio_r if self.norm_du < self.lastNorm_du: - ratio_du_current = old_div(self.norm_du,self.lastNorm_du) + ratio_du_current = self.norm_du/self.lastNorm_du else: logEvent("du increase norm(du_last)=%12.5e, norm(du)=%12.5e, its=%d, convergingIts=%d" % (self.lastNorm_du,self.norm_du,self.its,self.convergingIts)) self.convergingIts=0 @@ -263,14 +253,13 @@ def computeConvergenceRates(self): return self.ratio_du_solve *= ratio_du_current self.duReductionFactor = pow(self.ratio_du_solve, - old_div(1.0,(self.convergingIts-1))) + 1.0/(self.convergingIts-1)) if self.duReductionFactor < 1.0: - self.s = old_div(self.duReductionFactor,(1.0-self.duReductionFactor)) + self.s = self.duReductionFactor/(1.0-self.duReductionFactor) else: self.s=100.0 if self.convergingIts > 2: - self.duReductionOrder = old_div(log_ratio_du_current, \ - self.last_log_ratio_du) + self.duReductionOrder = log_ratio_du_current/self.last_log_ratio_du self.last_log_ratio_du = log_ratio_du_current self.last_log_ratio_r = log_ratio_r_current self.lastNorm_du = self.norm_du @@ -507,15 +496,17 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None,linear=False): self.norm_du_hist = [] self.gammaK_max=0.0 self.linearSolverFailed = False + logEvent(memory("Newton-PRELOOP",self.F.name),level=4) while (not self.converged(r) and not self.failed()): logEvent(" NumericalAnalytics NewtonIteration: %d, NewtonNorm: %12.5e" %(self.its-1, self.norm_r), level=7) logEvent(" Newton it %d norm(r) = %12.5e \t\t norm(r)/(rtol*norm(r0)+atol) = %g test=%s" - % (self.its-1,self.norm_r,(old_div(self.norm_r,(self.rtol_r*self.norm_r0+self.atol_r))),self.convergenceTest),level=1) + % (self.its-1,self.norm_r,(self.norm_r/(self.rtol_r*self.norm_r0+self.atol_r)),self.convergenceTest),level=1) if self.updateJacobian or self.fullNewton: self.updateJacobian = False self.F.getJacobian(self.J) + memory() if self.linearSolver.computeEigenvalues: logEvent("Calculating eigenvalues of J^t J") self.JLast[:]=self.J @@ -524,13 +515,15 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None,linear=False): self.JLsolver.prepare()#eigenvalue calc happens in prepare self.norm_2_J_current = sqrt(max(self.JLsolver.eigenvalues_r)) try: - self.norm_2_Jinv_current = old_div(1.0,sqrt(min(self.JLsolver.eigenvalues_r))) + self.norm_2_Jinv_current = 1.0/sqrt(min(self.JLsolver.eigenvalues_r)) except: logEvent("Norm of J_inv_current is singular to machine prection 1/sqrt("+repr(min(self.JLsolver.eigenvalues_r))+")") self.norm_2_Jinv_current = np.inf self.kappa_current = self.norm_2_J_current*self.norm_2_Jinv_current self.betaK_current = self.norm_2_Jinv_current self.linearSolver.prepare(b=r,newton_its=self.its-1) + logEvent(memory("Newton-pepare",self.F.name),level=4) + memory() self.du[:]=0.0 if not self.directSolver: if self.EWtol: @@ -542,11 +535,13 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None,linear=False): if par_u is not None: par_u.scatter_forward_insert() + logEvent(memory("Newton-solve",self.F.name),level=4) if linear: r[:]=0 self.computeRates = False else: self.computeResidual(u,r,b) + memory() if par_r is not None: #no overlap if not self.par_fullOverlap: @@ -564,7 +559,7 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None,linear=False): self.dJLsolver.prepare() self.norm_2_dJ_current = sqrt(max(self.dJLsolver.eigenvalues_r)) self.etaK_current = self.W*self.norm(self.du) - self.gammaK_current = old_div(self.norm_2_dJ_current,self.etaK_current) + self.gammaK_current = self.norm_2_dJ_current/self.etaK_current self.gammaK_max = max(self.gammaK_current,self.gammaK_max) self.norm_r_hist.append(self.W*self.norm(r)) self.norm_du_hist.append(self.W*self.unorm(self.du)) @@ -582,12 +577,12 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None,linear=False): print("kappa(cond(J))",self.kappa_current) if self.betaK_current*self.etaK_current*self.gammaK_current <= 0.5: try: - print("r ",old_div((1.0+sqrt(1.0-2.0*self.betaK_current*self.etaK_current*self.gammaK_current)),(self.betaK_current*self.gammaK_current))) + print("r ",(1.0+sqrt(1.0-2.0*self.betaK_current*self.etaK_current*self.gammaK_current))/(self.betaK_current*self.gammaK_current)) except: pass if self.betaK_current*self.etaK_current*self.gammaK_max <= 0.5: try: - print("r_max ",old_div((1.0+sqrt(1.0-2.0*self.betaK_current*self.etaK_current*self.gammaK_max)),(self.betaK_current*self.gammaK_max))) + print("r_max ",(1.0+sqrt(1.0-2.0*self.betaK_current*self.etaK_current*self.gammaK_max))/(self.betaK_current*self.gammaK_max)) except: pass print("lambda_max",max(self.linearSolver.eigenvalues_r)) @@ -626,13 +621,15 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None,linear=False): self.rtol_r)) if ls_its > 0: logEvent("Linesearches = %i" % ls_its,level=3) + logEvent(memory("Newton-rest of loop",self.F.name),level=4) else: + memory() if self.linearSolver.computeEigenvalues: try: if self.betaK_0*self.etaK_0*self.gammaK_max <= 0.5: - print("r_{-,0} ",old_div((1.0+sqrt(1.0-2.0*self.betaK_0*self.etaK_0*self.gammaK_max)),(self.betaK_0*self.gammaK_max))) + print("r_{-,0} ",(1.0+sqrt(1.0-2.0*self.betaK_0*self.etaK_0*self.gammaK_max))/(self.betaK_0*self.gammaK_max)) if self.betaK_1*self.etaK_1*self.gammaK_max <= 0.5 and self.its > 1: - print("r_{-,1} ",old_div((1.0+sqrt(1.0-2.0*self.betaK_1*self.etaK_1*self.gammaK_max)),(self.betaK_1*self.gammaK_max))) + print("r_{-,1} ",(1.0+sqrt(1.0-2.0*self.betaK_1*self.etaK_1*self.gammaK_max))/(self.betaK_1*self.gammaK_max)) except: pass print("beta0*eta0*gamma ",self.betaK_0*self.etaK_0*self.gammaK_max) @@ -640,7 +637,7 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None,linear=False): max_r = max(1.0,max(self.linearSolver.eigenvalues_r)) max_i = max(1.0,max(self.linearSolver.eigenvalues_i)) for lambda_r,lambda_i in zip(self.linearSolver.eigenvalues_r,self.linearSolver.eigenvalues_i): - Viewers.datFile.write("%12.5e %12.5e \n" % (old_div(lambda_r,max_r),old_div(lambda_i,max_i))) + Viewers.datFile.write("%12.5e %12.5e \n" % (lambda_r/max_r,lambda_i/max_i)) Viewers.datFile.write("\n \n") cmd = "set term x11 %i; plot \'%s\' index %i with points title \"%s\" \n" % (Viewers.windowNumber, Viewers.datFilename, @@ -651,7 +648,7 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None,linear=False): Viewers.newPlot() Viewers.newWindow() for it,r in zip(list(range(len(self.norm_r_hist))),self.norm_r_hist): - Viewers.datFile.write("%12.5e %12.5e \n" % (it,math.log(old_div(r,self.norm_r_hist[0])))) + Viewers.datFile.write("%12.5e %12.5e \n" % (it,math.log(r/self.norm_r_hist[0]))) Viewers.datFile.write("\n \n") cmd = "set term x11 %i; plot \'%s\' index %i with linespoints title \"%s\" \n" % (Viewers.windowNumber, Viewers.datFilename, @@ -662,7 +659,7 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None,linear=False): Viewers.newPlot() Viewers.newWindow() for it,du in zip(list(range(len(self.norm_du_hist))),self.norm_du_hist): - Viewers.datFile.write("%12.5e %12.5e \n" % (it,math.log(old_div(du,self.norm_du_hist[0])))) + Viewers.datFile.write("%12.5e %12.5e \n" % (it,math.log(du/self.norm_du_hist[0]))) Viewers.datFile.write("\n \n") cmd = "set term x11 %i; plot \'%s\' index %i with linespoints title \"%s\" \n" % (Viewers.windowNumber, Viewers.datFilename, @@ -673,21 +670,23 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None,linear=False): Viewers.newPlot() Viewers.newWindow() #raw_input("wait") + logEvent(memory("Newton-exit of loop",self.F.name),level=4) logEvent(" NumericalAnalytics NewtonIteration: %d, NewtonNorm: %12.5e" %(self.its-1, self.norm_r), level=7) logEvent(" Newton it %d norm(r) = %12.5e \t\t norm(r)/(rtol*norm(r0)+atol) = %12.5e" - % (self.its,self.norm_r,(old_div(self.norm_r,(self.rtol_r*self.norm_r0+self.atol_r)))),level=1) - logEvent(memory("Newton","Newton"),level=4) + % (self.its,self.norm_r,(self.norm_r/(self.rtol_r*self.norm_r0+self.atol_r))),level=1) + memory() if hasattr(self.F.coefficients,'FCT') and self.F.coefficients.FCT==True: logEvent("FCT Step After Newton") self.F.FCTStep() u[:] = self.F.u[0].dof + logEvent(memory("Newton-FCT",self.F.name),level=4) return self.failedFlag logEvent(" NumericalAnalytics NewtonIteration: %d, NewtonNorm: %12.5e" %(self.its-1, self.norm_r), level=7) logEvent(" Newton it %d norm(r) = %12.5e \t\t norm(r)/(rtol*norm(r0)+atol) = %12.5e" - % (self.its,self.norm_r,(old_div(self.norm_r,(self.rtol_r*self.norm_r0+self.atol_r)))),level=1) - logEvent(memory("Newton","Newton"),level=4) + % (self.its,self.norm_r,(self.norm_r/(self.rtol_r*self.norm_r0+self.atol_r))),level=1) + logEvent(memory("Newton",self.F.name),level=4) class AddedMassNewton(Newton): def solve(self,u,r=None,b=None,par_u=None,par_r=None): @@ -1095,7 +1094,7 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): while (not self.converged(r) and not self.failed()): logEvent(" Newton it %d norm(r) = %12.5e \t\t norm(r)/(rtol*norm(r0)+atol) = %g test=%s" - % (self.its-1,self.norm_r,(old_div(self.norm_r,(self.rtol_r*self.norm_r0+self.atol_r))),self.convergenceTest),level=1) + % (self.its-1,self.norm_r,(self.norm_r/(self.rtol_r*self.norm_r0+self.atol_r)),self.convergenceTest),level=1) if self.updateJacobian or self.fullNewton: self.updateJacobian = False self.F.getJacobian(self.J) @@ -1114,7 +1113,7 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): self.JLsolver.prepare()#eigenvalue calc happens in prepare self.norm_2_J_current = sqrt(max(self.JLsolver.eigenvalues_r)) try: - self.norm_2_Jinv_current = old_div(1.0,sqrt(min(self.JLsolver.eigenvalues_r))) + self.norm_2_Jinv_current = 1.0/sqrt(min(self.JLsolver.eigenvalues_r)) except: logEvent("Norm of J_inv_current is singular to machine prection 1/sqrt("+repr(min(self.JLsolver.eigenvalues_r))+")") self.norm_2_Jinv_current = np.inf @@ -1144,8 +1143,8 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): par_r.scatter_forward_insert() else: logEvent(" Newton it %d norm(r) = %12.5e \t\t norm(r)/(rtol*norm(r0)+atol) = %12.5e" - % (self.its,self.norm_r,(old_div(self.norm_r,(self.rtol_r*self.norm_r0+self.atol_r)))),level=1) - logEvent(memory("Newton","Newton"),level=4) + % (self.its,self.norm_r,(self.norm_r/(self.rtol_r*self.norm_r0+self.atol_r))),level=1) + logEvent(memory("Newton",self.F.name),level=4) if (self.failedFlag == True): return self.failedFlag else: @@ -1185,8 +1184,8 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): self.F.coefficients.vofModel.u[0].dof[:] = self.F.limited_L2p_vof_mass_correction logEvent(" Newton it %d norm(r) = %12.5e \t\t norm(r)/(rtol*norm(r0)+atol) = %12.5e" - % (self.its,self.norm_r,(old_div(self.norm_r,(self.rtol_r*self.norm_r0+self.atol_r)))),level=1) - logEvent(memory("Newton","Newton"),level=4) + % (self.its,self.norm_r,(self.norm_r/(self.rtol_r*self.norm_r0+self.atol_r))),level=1) + logEvent(memory("Newton",self.F.name),level=4) # Nonlinear solved finished. # L2 projection of corrected VOF solution at quad points @@ -1232,17 +1231,17 @@ def getNormalReconstruction(self,u,r=None,b=None,par_u=None,par_r=None): # TODO: After 1st paper is accepted we need to delete # timeStage, timeOrder and tStar vectors. Now we always use: CN+pre-stage if self.F.timeStage==1: - self.F.projected_qx_tn[:] = old_div(self.F.rhs_qx,self.F.weighted_lumped_mass_matrix) - self.F.projected_qy_tn[:] = old_div(self.F.rhs_qy,self.F.weighted_lumped_mass_matrix) - self.F.projected_qz_tn[:] = old_div(self.F.rhs_qz,self.F.weighted_lumped_mass_matrix) + self.F.projected_qx_tn[:] = self.F.rhs_qx/self.F.weighted_lumped_mass_matrix + self.F.projected_qy_tn[:] = self.F.rhs_qy/self.F.weighted_lumped_mass_matrix + self.F.projected_qz_tn[:] = self.F.rhs_qz/self.F.weighted_lumped_mass_matrix # Update parallel vectors self.F.par_projected_qx_tn.scatter_forward_insert() self.F.par_projected_qy_tn.scatter_forward_insert() self.F.par_projected_qz_tn.scatter_forward_insert() else: - self.F.projected_qx_tStar[:] = old_div(self.F.rhs_qx,self.F.weighted_lumped_mass_matrix) - self.F.projected_qy_tStar[:] = old_div(self.F.rhs_qy,self.F.weighted_lumped_mass_matrix) - self.F.projected_qz_tStar[:] = old_div(self.F.rhs_qz,self.F.weighted_lumped_mass_matrix) + self.F.projected_qx_tStar[:] = self.F.rhs_qx/self.F.weighted_lumped_mass_matrix + self.F.projected_qy_tStar[:] = self.F.rhs_qy/self.F.weighted_lumped_mass_matrix + self.F.projected_qz_tStar[:] = self.F.rhs_qz/self.F.weighted_lumped_mass_matrix # Update parallel vectors self.F.par_projected_qx_tStar.scatter_forward_insert() self.F.par_projected_qy_tStar.scatter_forward_insert() @@ -1264,7 +1263,7 @@ def getNormalReconstruction(self,u,r=None,b=None,par_u=None,par_r=None): self.linearSolver.solve(u=self.du,b=r,par_u=self.par_du,par_b=par_r) self.linearSolverFailed = self.linearSolver.failed() high_order_solution[:] = self.du - low_order_solution[:] = old_div(self.F.rhs_qx,self.F.weighted_lumped_mass_matrix) + low_order_solution[:] = self.F.rhs_qx/self.F.weighted_lumped_mass_matrix # FCT STEP # if self.F.timeStage==1: self.F.FCTStep(self.F.projected_qx_tn, @@ -1289,7 +1288,7 @@ def getNormalReconstruction(self,u,r=None,b=None,par_u=None,par_r=None): self.linearSolver.solve(u=self.du,b=r,par_u=self.par_du,par_b=par_r) self.linearSolverFailed = self.linearSolver.failed() high_order_solution[:] = self.du - low_order_solution[:] = old_div(self.F.rhs_qy,self.F.weighted_lumped_mass_matrix) + low_order_solution[:] = self.F.rhs_qy/self.F.weighted_lumped_mass_matrix # FCT STEP # if self.F.timeStage==1: self.F.FCTStep(self.F.projected_qy_tn, @@ -1315,7 +1314,7 @@ def getNormalReconstruction(self,u,r=None,b=None,par_u=None,par_r=None): self.linearSolver.solve(u=self.du,b=r,par_u=self.par_du,par_b=par_r) self.linearSolverFailed = self.linearSolver.failed() high_order_solution[:] = self.du - low_order_solution[:] = old_div(self.F.rhs_qz,self.F.weighted_lumped_mass_matrix) + low_order_solution[:] = self.F.rhs_qz/self.F.weighted_lumped_mass_matrix # FCT STEP # if self.F.timeStage==1: self.F.FCTStep(self.F.projected_qz_tn, @@ -1335,7 +1334,7 @@ def getNormalReconstruction(self,u,r=None,b=None,par_u=None,par_r=None): def project_disc_ICs(self,u,r=None,b=None,par_u=None,par_r=None): self.F.getRhsL2Proj() - self.F.projected_disc_ICs[:] = old_div(self.F.rhs_l2_proj,self.F.lumped_mass_matrix) + self.F.projected_disc_ICs[:] = self.F.rhs_l2_proj/self.F.lumped_mass_matrix self.F.par_projected_disc_ICs.scatter_forward_insert() # output of this function u[:] = self.F.projected_disc_ICs @@ -1571,7 +1570,7 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): while (not self.converged(pod_r) and not self.failed()): logEvent(" Newton it %d norm(r) = %12.5e \t\t norm(r)/(rtol*norm(r0)+atol) = %g test=%s" - % (self.its-1,self.norm_r,(old_div(self.norm_r,(self.rtol_r*self.norm_r0+self.atol_r))),self.convergenceTest),level=1) + % (self.its-1,self.norm_r,(self.norm_r/(self.rtol_r*self.norm_r0+self.atol_r)),self.convergenceTest),level=1) if self.updateJacobian or self.fullNewton: self.updateJacobian = False self.pod_J[:] = 0.0 @@ -1600,10 +1599,10 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): r[:] = np.dot(self.U,pod_r) else: logEvent(" Newton it %d norm(r) = %12.5e \t\t norm(r)/(rtol*norm(r0)+atol) = %12.5e" - % (self.its,self.norm_r,(old_div(self.norm_r,(self.rtol_r*self.norm_r0+self.atol_r)))),level=1) + % (self.its,self.norm_r,(self.norm_r/(self.rtol_r*self.norm_r0+self.atol_r))),level=1) return self.failedFlag logEvent(" Newton it %d norm(r) = %12.5e \t\t norm(r)/(rtol*norm(r0)+atol) = %12.5e" - % (self.its,self.norm_r,(old_div(self.norm_r,(self.rtol_r*self.norm_r0+self.atol_r)))),level=1) + % (self.its,self.norm_r,(self.norm_r/(self.rtol_r*self.norm_r0+self.atol_r))),level=1) class POD_DEIM_Newton(Newton): """Newton's method on the reduced order system based on POD""" @@ -1756,7 +1755,7 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): while (not self.converged(pod_r) and not self.failed()): logEvent(" Newton it %d norm(r) = %12.5e \t\t norm(r)/(rtol*norm(r0)+atol) = %g test=%s" - % (self.its-1,self.norm_r,(old_div(self.norm_r,(self.rtol_r*self.norm_r0+self.atol_r))),self.convergenceTest),level=1) + % (self.its-1,self.norm_r,(self.norm_r/(self.rtol_r*self.norm_r0+self.atol_r)),self.convergenceTest),level=1) if self.updateJacobian or self.fullNewton: self.updateJacobian = False self.F.getJacobian(self.J) @@ -1785,10 +1784,10 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): r[:] = np.dot(self.U,pod_r) else: logEvent(" Newton it %d norm(r) = %12.5e \t\t norm(r)/(rtol*norm(r0)+atol) = %12.5e" - % (self.its,self.norm_r,(old_div(self.norm_r,(self.rtol_r*self.norm_r0+self.atol_r)))),level=1) + % (self.its,self.norm_r,(self.norm_r/(self.rtol_r*self.norm_r0+self.atol_r))),level=1) return self.failedFlag logEvent(" Newton it %d norm(r) = %12.5e \t\t norm(r)/(rtol*norm(r0)+atol) = %12.5e" - % (self.its,self.norm_r,(old_div(self.norm_r,(self.rtol_r*self.norm_r0+self.atol_r)))),level=1) + % (self.its,self.norm_r,(self.norm_r/(self.rtol_r*self.norm_r0+self.atol_r))),level=1) def solveDEIM(self,u,r=None,b=None,par_u=None,par_r=None): """ Solve F(u) = b @@ -1827,7 +1826,7 @@ def solveDEIM(self,u,r=None,b=None,par_u=None,par_r=None): while (not self.converged(pod_r) and not self.failed()): logEvent(" Newton it %d norm(r) = %12.5e \t\t norm(r)/(rtol*norm(r0)+atol) = %g test=%s" - % (self.its-1,self.norm_r,(old_div(self.norm_r,(self.rtol_r*self.norm_r0+self.atol_r))),self.convergenceTest),level=1) + % (self.its-1,self.norm_r,(self.norm_r/(self.rtol_r*self.norm_r0+self.atol_r)),self.convergenceTest),level=1) if self.updateJacobian or self.fullNewton: self.updateJacobian = False #go ahead and evaluate spatial grid on fine grid for now @@ -1913,10 +1912,10 @@ def solveDEIM(self,u,r=None,b=None,par_u=None,par_r=None): r[:] = np.dot(self.U,pod_r) else: logEvent(" Newton it %d norm(r) = %12.5e \t\t norm(r)/(rtol*norm(r0)+atol) = %12.5e" - % (self.its,self.norm_r,(old_div(self.norm_r,(self.rtol_r*self.norm_r0+self.atol_r)))),level=1) + % (self.its,self.norm_r,(self.norm_r/(self.rtol_r*self.norm_r0+self.atol_r))),level=1) return self.failedFlag logEvent(" Newton it %d norm(r) = %12.5e \t\t norm(r)/(rtol*norm(r0)+atol) = %12.5e" - % (self.its,self.norm_r,(old_div(self.norm_r,(self.rtol_r*self.norm_r0+self.atol_r)))),level=1) + % (self.its,self.norm_r,(self.norm_r/(self.rtol_r*self.norm_r0+self.atol_r))),level=1) class NewtonNS(NonlinearSolver): @@ -2000,12 +1999,12 @@ def setLinearSolverTolerance(self,r): def converged(self,r): self.convergedFlag = False self.norm_r = self.norm(r) - self.norm_cont_r = self.norm_function(r[:old_div(self.F.dim_proc,4)]) - self.norm_mom_r = self.norm_function(r[old_div(self.F.dim_proc,4):self.F.dim_proc]) + self.norm_cont_r = self.norm_function(r[:self.F.dim_proc//4]) + self.norm_mom_r = self.norm_function(r[self.F.dim_proc//4:self.F.dim_proc]) #self.norm_cont_r = self.norm(r[:r.shape[0]/4]) #self.norm_mom_r = self.norm(r[r.shape[0]/4:]) - self.norm_du= old_div(1.0,float(self.its+2)) + self.norm_du= 1.0/float(self.its+2) if self.computeRates == True: self.computeConvergenceRates() if self.convergenceTest == 'its' or self.convergenceTest == 'rits': @@ -2052,8 +2051,8 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): par_r.scatter_forward_insert() - self.norm_cont_r0 = self.norm_function(r[:old_div(self.F.dim_proc,4)]) - self.norm_mom_r0 = self.norm_function(r[old_div(self.F.dim_proc,4):self.F.dim_proc]) + self.norm_cont_r0 = self.norm_function(r[:self.F.dim_proc//4]) + self.norm_mom_r0 = self.norm_function(r[self.F.dim_proc//4:self.F.dim_proc]) self.norm_r_hist = [] self.norm_du_hist = [] @@ -2079,7 +2078,7 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): self.JLsolver.prepare() self.JLsolver.calculateEigenvalues() self.norm_2_J_current = sqrt(max(self.JLsolver.eigenvalues_r)) - self.norm_2_Jinv_current = old_div(1.0,sqrt(min(self.JLsolver.eigenvalues_r))) + self.norm_2_Jinv_current = 1.0/sqrt(min(self.JLsolver.eigenvalues_r)) self.kappa_current = self.norm_2_J_current*self.norm_2_Jinv_current self.betaK_current = self.norm_2_Jinv_current self.linearSolver.prepare(b=r,newton_its=self.its-1) @@ -2118,7 +2117,7 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): self.dJLsolver.calculateEigenvalues() self.norm_2_dJ_current = sqrt(max(self.dJLsolver.eigenvalues_r)) self.etaK_current = self.W*self.norm(self.du) - self.gammaK_current = old_div(self.norm_2_dJ_current,self.etaK_current) + self.gammaK_current = self.norm_2_dJ_current/self.etaK_current self.gammaK_max = max(self.gammaK_current,self.gammaK_max) self.norm_r_hist.append(self.W*self.norm(r)) self.norm_du_hist.append(self.W*self.unorm(self.du)) @@ -2138,9 +2137,9 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): print("gammaM(Lip J')",self.gammaK_max) print("kappa(cond(J))",self.kappa_current) if self.betaK_current*self.etaK_current*self.gammaK_current <= 0.5: - print("r ",old_div((1.0+sqrt(1.0-2.0*self.betaK_current*self.etaK_current*self.gammaK_current)),(self.betaK_current*self.gammaK_current))) + print("r ",(1.0+sqrt(1.0-2.0*self.betaK_current*self.etaK_current*self.gammaK_current))/(self.betaK_current*self.gammaK_current)) if self.betaK_current*self.etaK_current*self.gammaK_max <= 0.5: - print("r_max ",old_div((1.0+sqrt(1.0-2.0*self.betaK_current*self.etaK_current*self.gammaK_max)),(self.betaK_current*self.gammaK_max))) + print("r_max ",(1.0+sqrt(1.0-2.0*self.betaK_current*self.etaK_current*self.gammaK_max))/(self.betaK_current*self.gammaK_max)) print("lambda_max",max(self.linearSolver.eigenvalues_r)) print("lambda_i_max",max(self.linearSolver.eigenvalues_i)) print("norm_J",self.norm_2_J_current) @@ -2181,15 +2180,15 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): else: if self.linearSolver.computeEigenvalues: if self.betaK_0*self.etaK_0*self.gammaK_max <= 0.5: - print("r_{-,0} ",old_div((1.0+sqrt(1.0-2.0*self.betaK_0*self.etaK_0*self.gammaK_max)),(self.betaK_0*self.gammaK_max))) + print("r_{-,0} ",(1.0+sqrt(1.0-2.0*self.betaK_0*self.etaK_0*self.gammaK_max))/(self.betaK_0*self.gammaK_max)) if self.betaK_1*self.etaK_1*self.gammaK_max <= 0.5 and self.its > 1: - print("r_{-,1} ",old_div((1.0+sqrt(1.0-2.0*self.betaK_1*self.etaK_1*self.gammaK_max)),(self.betaK_1*self.gammaK_max))) + print("r_{-,1} ",(1.0+sqrt(1.0-2.0*self.betaK_1*self.etaK_1*self.gammaK_max))/(self.betaK_1*self.gammaK_max)) print("beta0*eta0*gamma ",self.betaK_0*self.etaK_0*self.gammaK_max) if Viewers.viewerType == 'gnuplot': max_r = max(1.0,max(self.linearSolver.eigenvalues_r)) max_i = max(1.0,max(self.linearSolver.eigenvalues_i)) for lambda_r,lambda_i in zip(self.linearSolver.eigenvalues_r,self.linearSolver.eigenvalues_i): - Viewers.datFile.write("%12.5e %12.5e \n" % (old_div(lambda_r,max_r),old_div(lambda_i,max_i))) + Viewers.datFile.write("%12.5e %12.5e \n" % (lambda_r/max_r,lambda_i/max_i)) Viewers.datFile.write("\n \n") cmd = "set term x11 %i; plot \'%s\' index %i with points title \"%s\" \n" % (Viewers.windowNumber, Viewers.datFilename, @@ -2200,7 +2199,7 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): Viewers.newPlot() Viewers.newWindow() for it,r in zip(list(range(len(self.norm_r_hist))),self.norm_r_hist): - Viewers.datFile.write("%12.5e %12.5e \n" % (it,math.log(old_div(r,self.norm_r_hist[0])))) + Viewers.datFile.write("%12.5e %12.5e \n" % (it,math.log(r/self.norm_r_hist[0]))) Viewers.datFile.write("\n \n") cmd = "set term x11 %i; plot \'%s\' index %i with linespoints title \"%s\" \n" % (Viewers.windowNumber, Viewers.datFilename, @@ -2211,7 +2210,7 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): Viewers.newPlot() Viewers.newWindow() for it,du in zip(list(range(len(self.norm_du_hist))),self.norm_du_hist): - Viewers.datFile.write("%12.5e %12.5e \n" % (it,math.log(old_div(du,self.norm_du_hist[0])))) + Viewers.datFile.write("%12.5e %12.5e \n" % (it,math.log(du/self.norm_du_hist[0]))) Viewers.datFile.write("\n \n") cmd = "set term x11 %i; plot \'%s\' index %i with linespoints title \"%s\" \n" % (Viewers.windowNumber, Viewers.datFilename, @@ -2225,7 +2224,7 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): logEvent(" Final Mom. norm(r) = %12.5e %12.5e" % (self.norm_mom_r,self.rtol_r*self.norm_mom_r0 + self.atol_r),level=1) logEvent(" Final Cont. norm(r) = %12.5e %12.5e" % (self.norm_cont_r,self.rtol_r*self.norm_mom_r0 + self.atol_r),level=1) - logEvent(memory("NSNewton","NSNewton"),level=4) + logEvent(memory("NSNewton",self.F.name),level=4) class SSPRKNewton(Newton): """ @@ -2306,7 +2305,7 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): self.JLsolver.prepare() self.JLsolver.calculateEigenvalues() self.norm_2_J_current = sqrt(max(self.JLsolver.eigenvalues_r)) - self.norm_2_Jinv_current = old_div(1.0,sqrt(min(self.JLsolver.eigenvalues_r))) + self.norm_2_Jinv_current = 1.0/sqrt(min(self.JLsolver.eigenvalues_r)) self.kappa_current = self.norm_2_J_current*self.norm_2_Jinv_current self.betaK_current = self.norm_2_Jinv_current self.linearSolver.prepare(b=r) @@ -2339,7 +2338,7 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): self.dJLsolver.calculateEigenvalues() self.norm_2_dJ_current = sqrt(max(self.dJLsolver.eigenvalues_r)) self.etaK_current = self.W*self.norm(self.du) - self.gammaK_current = old_div(self.norm_2_dJ_current,self.etaK_current) + self.gammaK_current = self.norm_2_dJ_current/self.etaK_current self.gammaK_max = max(self.gammaK_current,self.gammaK_max) self.norm_r_hist.append(self.W*self.norm(r)) self.norm_du_hist.append(self.W*self.norm(self.du)) @@ -2359,9 +2358,9 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): print("gammaM(Lip J')",self.gammaK_max) print("kappa(cond(J))",self.kappa_current) if self.betaK_current*self.etaK_current*self.gammaK_current <= 0.5: - print("r ",old_div((1.0+sqrt(1.0-2.0*self.betaK_current*self.etaK_current*self.gammaK_current)),(self.betaK_current*self.gammaK_current))) + print("r ",(1.0+sqrt(1.0-2.0*self.betaK_current*self.etaK_current*self.gammaK_current))/(self.betaK_current*self.gammaK_current)) if self.betaK_current*self.etaK_current*self.gammaK_max <= 0.5: - print("r_max ",old_div((1.0+sqrt(1.0-2.0*self.betaK_current*self.etaK_current*self.gammaK_max)),(self.betaK_current*self.gammaK_max))) + print("r_max ",(1.0+sqrt(1.0-2.0*self.betaK_current*self.etaK_current*self.gammaK_max))/(self.betaK_current*self.gammaK_max)) print("lambda_max",max(self.linearSolver.eigenvalues_r)) print("lambda_i_max",max(self.linearSolver.eigenvalues_i)) print("norm_J",self.norm_2_J_current) @@ -2374,7 +2373,7 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): #print norm_r_cur,self.atol_r,self.rtol_r while ( (norm_r_cur >= 0.99 * self.norm_r + self.atol_r) and (ls_its < self.maxLSits) and - old_div(norm_r_cur,norm_r_last) < 1.0): + norm_r_cur/norm_r_last < 1.0): self.convergingIts = 0 ls_its +=1 self.du *= 0.5 @@ -2398,15 +2397,15 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): else: if self.linearSolver.computeEigenvalues: if self.betaK_0*self.etaK_0*self.gammaK_max <= 0.5: - print("r_{-,0} ",old_div((1.0+sqrt(1.0-2.0*self.betaK_0*self.etaK_0*self.gammaK_max)),(self.betaK_0*self.gammaK_max))) + print("r_{-,0} ",(1.0+sqrt(1.0-2.0*self.betaK_0*self.etaK_0*self.gammaK_max))/(self.betaK_0*self.gammaK_max)) if self.betaK_1*self.etaK_1*self.gammaK_max <= 0.5 and self.its > 1: - print("r_{-,1} ",old_div((1.0+sqrt(1.0-2.0*self.betaK_1*self.etaK_1*self.gammaK_max)),(self.betaK_1*self.gammaK_max))) + print("r_{-,1} ",(1.0+sqrt(1.0-2.0*self.betaK_1*self.etaK_1*self.gammaK_max))/(self.betaK_1*self.gammaK_max)) print("beta0*eta0*gamma ",self.betaK_0*self.etaK_0*self.gammaK_max) if Viewers.viewerType == 'gnuplot': max_r = max(1.0,max(self.linearSolver.eigenvalues_r)) max_i = max(1.0,max(self.linearSolver.eigenvalues_i)) for lambda_r,lambda_i in zip(self.linearSolver.eigenvalues_r,self.linearSolver.eigenvalues_i): - Viewers.datFile.write("%12.5e %12.5e \n" % (old_div(lambda_r,max_r),old_div(lambda_i,max_i))) + Viewers.datFile.write("%12.5e %12.5e \n" % (lambda_r/max_r,lambda_i/max_i)) Viewers.datFile.write("\n \n") cmd = "set term x11 %i; plot \'%s\' index %i with points title \"%s\" \n" % (Viewers.windowNumber, Viewers.datFilename, @@ -2417,7 +2416,7 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): Viewers.newPlot() Viewers.newWindow() for it,r in zip(list(range(len(self.norm_r_hist))),self.norm_r_hist): - Viewers.datFile.write("%12.5e %12.5e \n" % (it,log(old_div(r,self.norm_r_hist[0])))) + Viewers.datFile.write("%12.5e %12.5e \n" % (it,log(r/self.norm_r_hist[0]))) Viewers.datFile.write("\n \n") cmd = "set term x11 %i; plot \'%s\' index %i with linespoints title \"%s\" \n" % (Viewers.windowNumber, Viewers.datFilename, @@ -2428,7 +2427,7 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): Viewers.newPlot() Viewers.newWindow() for it,du in zip(list(range(len(self.norm_du_hist))),self.norm_du_hist): - Viewers.datFile.write("%12.5e %12.5e \n" % (it,log(old_div(du,self.norm_du_hist[0])))) + Viewers.datFile.write("%12.5e %12.5e \n" % (it,log(du/self.norm_du_hist[0]))) Viewers.datFile.write("\n \n") cmd = "set term x11 %i; plot \'%s\' index %i with linespoints title \"%s\" \n" % (Viewers.windowNumber, Viewers.datFilename, @@ -2513,10 +2512,10 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): not self.failed()): if self.maxIts>1: logEvent(" Newton it %d norm(r) = %12.5e %12.5g \t\t norm(r)/(rtol*norm(r0)+atol) = %g" - % (self.its-1,self.norm_r,100*(old_div(self.norm_r,self.norm_r0)),(old_div(self.norm_r,(self.rtol_r*self.norm_r0+self.atol_r)))),level=1) + % (self.its-1,self.norm_r,100*(self.norm_r/self.norm_r0),(self.norm_r/(self.rtol_r*self.norm_r0+self.atol_r))),level=1) if self.updateJacobian or self.fullNewton: self.updateJacobian = False - if self.usePicard and (self.its < self.picardIts or old_div(self.norm_r,(self.rtol_r*self.norm_r0+self.atol_r)) > self.picardTol): + if self.usePicard and (self.its < self.picardIts or self.norm_r/(self.rtol_r*self.norm_r0+self.atol_r) > self.picardTol): print("Picard iteration") self.F.getJacobian(self.J,self.usePicard) else: @@ -2529,7 +2528,7 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): self.JLsolver.prepare() self.JLsolver.calculateEigenvalues() self.norm_2_J_current = sqrt(max(self.JLsolver.eigenvalues_r)) - self.norm_2_Jinv_current = old_div(1.0,sqrt(min(self.JLsolver.eigenvalues_r))) + self.norm_2_Jinv_current = 1.0/sqrt(min(self.JLsolver.eigenvalues_r)) self.kappa_current = self.norm_2_J_current*self.norm_2_Jinv_current self.betaK_current = self.norm_2_Jinv_current self.linearSolver.prepare(b=r) @@ -2564,7 +2563,7 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): self.dJLsolver.calculateEigenvalues() self.norm_2_dJ_current = sqrt(max(self.dJLsolver.eigenvalues_r)) self.etaK_current = self.W*self.norm(self.du) - self.gammaK_current = old_div(self.norm_2_dJ_current,self.etaK_current) + self.gammaK_current = self.norm_2_dJ_current/self.etaK_current self.gammaK_max = max(self.gammaK_current,self.gammaK_max) self.norm_r_hist.append(self.W*self.norm(r)) self.norm_du_hist.append(self.W*self.unorm(self.du)) @@ -2584,9 +2583,9 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): print("gammaM(Lip J')",self.gammaK_max) print("kappa(cond(J))",self.kappa_current) if self.betaK_current*self.etaK_current*self.gammaK_current <= 0.5: - print("r ",old_div((1.0+sqrt(1.0-2.0*self.betaK_current*self.etaK_current*self.gammaK_current)),(self.betaK_current*self.gammaK_current))) + print("r ",(1.0+sqrt(1.0-2.0*self.betaK_current*self.etaK_current*self.gammaK_current))/(self.betaK_current*self.gammaK_current)) if self.betaK_current*self.etaK_current*self.gammaK_max <= 0.5: - print("r_max ",old_div((1.0+sqrt(1.0-2.0*self.betaK_current*self.etaK_current*self.gammaK_max)),(self.betaK_current*self.gammaK_max))) + print("r_max ",(1.0+sqrt(1.0-2.0*self.betaK_current*self.etaK_current*self.gammaK_max))/(self.betaK_current*self.gammaK_max)) print("lambda_max",max(self.linearSolver.eigenvalues_r)) print("lambda_i_max",max(self.linearSolver.eigenvalues_i)) print("norm_J",self.norm_2_J_current) @@ -2625,15 +2624,15 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): else: if self.linearSolver.computeEigenvalues: if self.betaK_0*self.etaK_0*self.gammaK_max <= 0.5: - print("r_{-,0} ",old_div((1.0+sqrt(1.0-2.0*self.betaK_0*self.etaK_0*self.gammaK_max)),(self.betaK_0*self.gammaK_max))) + print("r_{-,0} ",(1.0+sqrt(1.0-2.0*self.betaK_0*self.etaK_0*self.gammaK_max))/(self.betaK_0*self.gammaK_max)) if self.betaK_1*self.etaK_1*self.gammaK_max <= 0.5 and self.its > 1: - print("r_{-,1} ",old_div((1.0+sqrt(1.0-2.0*self.betaK_1*self.etaK_1*self.gammaK_max)),(self.betaK_1*self.gammaK_max))) + print("r_{-,1} ",(1.0+sqrt(1.0-2.0*self.betaK_1*self.etaK_1*self.gammaK_max))/(self.betaK_1*self.gammaK_max)) print("beta0*eta0*gamma ",self.betaK_0*self.etaK_0*self.gammaK_max) if Viewers.viewerType == 'gnuplot': max_r = max(1.0,max(self.linearSolver.eigenvalues_r)) max_i = max(1.0,max(self.linearSolver.eigenvalues_i)) for lambda_r,lambda_i in zip(self.linearSolver.eigenvalues_r,self.linearSolver.eigenvalues_i): - Viewers.datFile.write("%12.5e %12.5e \n" % (old_div(lambda_r,max_r),old_div(lambda_i,max_i))) + Viewers.datFile.write("%12.5e %12.5e \n" % (lambda_r/max_r,lambda_i/max_i)) Viewers.datFile.write("\n \n") cmd = "set term x11 %i; plot \'%s\' index %i with points title \"%s\" \n" % (Viewers.windowNumber, Viewers.datFilename, @@ -2644,7 +2643,7 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): Viewers.newPlot() Viewers.newWindow() for it,r in zip(list(range(len(self.norm_r_hist))),self.norm_r_hist): - Viewers.datFile.write("%12.5e %12.5e \n" % (it,math.log(old_div(r,self.norm_r_hist[0])))) + Viewers.datFile.write("%12.5e %12.5e \n" % (it,math.log(r/self.norm_r_hist[0]))) Viewers.datFile.write("\n \n") cmd = "set term x11 %i; plot \'%s\' index %i with linespoints title \"%s\" \n" % (Viewers.windowNumber, Viewers.datFilename, @@ -2655,7 +2654,7 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): Viewers.newPlot() Viewers.newWindow() for it,du in zip(list(range(len(self.norm_du_hist))),self.norm_du_hist): - Viewers.datFile.write("%12.5e %12.5e \n" % (it,math.log(old_div(du,self.norm_du_hist[0])))) + Viewers.datFile.write("%12.5e %12.5e \n" % (it,math.log(du/self.norm_du_hist[0]))) Viewers.datFile.write("\n \n") cmd = "set term x11 %i; plot \'%s\' index %i with linespoints title \"%s\" \n" % (Viewers.windowNumber, Viewers.datFilename, @@ -2667,7 +2666,7 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): Viewers.newWindow() if self.maxIts>1: logEvent(" Newton it %d norm(r) = %12.5e %12.5g \t\t norm(r)/(rtol*norm(r0)+atol) = %g" - % (self.its-1,self.norm_r,100*(old_div(self.norm_r,self.norm_r0)),(old_div(self.norm_r,(self.rtol_r*self.norm_r0+self.atol_r)))),level=1) + % (self.its-1,self.norm_r,100*(self.norm_r/self.norm_r0),(self.norm_r/(self.rtol_r*self.norm_r0+self.atol_r))),level=1) return self.failedFlag class NLJacobi(NonlinearSolver): @@ -2677,7 +2676,7 @@ class NLJacobi(NonlinearSolver): def __init__(self, F,J,du, - weight=old_div(4.0,5.0), + weight=4.0/5.0, rtol_r = 1.0e-4, atol_r = 1.0e-16, rtol_du = 1.0e-4, @@ -2714,7 +2713,7 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): self.updateJacobian = False self.F.getJacobian(self.J) if type(self.J).__name__ == 'ndarray': - self.M = old_div(self.w,numpy.diagonal(self.J)) + self.M = self.w/numpy.diagonal(self.J) elif type(self.J).__name__ == 'SparseMatrix': csmoothers.jacobi_NR_prepare(self.J,self.w,1.0e-16,self.M) if type(self.J).__name__ == 'ndarray': @@ -2776,7 +2775,7 @@ def solve(self,u,r=None,b=None,par_u=None,par_r=None): self.updateJacobian = False self.F.getJacobian(self.J) if type(self.J).__name__ == 'ndarray': - self.M = old_div(self.w,numpy.diagonal(self.J)) + self.M = self.w/numpy.diagonal(self.J) elif type(self.J).__name__ == 'SparseMatrix': dtol = min(numpy.absolute(r))*1.0e-8 csmoothers.gauss_seidel_NR_prepare(self.J,self.w,dtol,self.M) @@ -3338,7 +3337,7 @@ def multilevelNonlinearSolverChooser(nonlinearOperatorList, if l > 0: if smootherType == NLJacobi: if relaxationFactor is None: - relaxationFactor = old_div(2.0,5.0)#4.0/5.0 + relaxationFactor = 2.0/5.0#4.0/5.0 preSmootherList.append(NLJacobi(F=nonlinearOperatorList[l], J=jacobianList[l], du=duList[l], @@ -3359,7 +3358,7 @@ def multilevelNonlinearSolverChooser(nonlinearOperatorList, fullNewton=smootherFullNewtonFlag)) elif smootherType == NLGaussSeidel: if relaxationFactor is None: - relaxationFactor = old_div(3.0,5.0) + relaxationFactor = 3.0/5.0 preSmootherList.append(NLGaussSeidel(connectionList = connectionListList[l], F=nonlinearOperatorList[l], J=jacobianList[l], @@ -3382,7 +3381,7 @@ def multilevelNonlinearSolverChooser(nonlinearOperatorList, fullNewton=smootherFullNewtonFlag)) elif smootherType == NLStarILU: if relaxationFactor is None: - relaxationFactor = old_div(2.0,5.0) + relaxationFactor = 2.0/5.0 preSmootherList.append(NLStarILU(connectionList = connectionListList[l], F = nonlinearOperatorList[l], J = jacobianList[l], @@ -3408,7 +3407,7 @@ def multilevelNonlinearSolverChooser(nonlinearOperatorList, else: if smootherType == NLJacobi: if relaxationFactor is None: - relaxationFactor = old_div(4.0,5.0) + relaxationFactor = 4.0/5.0 coarseSolver = NLJacobi(F=nonlinearOperatorList[l], J=jacobianList[l], du=duList[l], @@ -3421,7 +3420,7 @@ def multilevelNonlinearSolverChooser(nonlinearOperatorList, norm = nonlinearSolverNorm) elif smootherType == NLGaussSeidel: if relaxationFactor is None: - relaxationFactor = old_div(3.0,5.0) + relaxationFactor = 3.0/5.0 coarseSolver = NLGaussSeidel(connectionList = connectionListList[l], F=nonlinearOperatorList[l], J=jacobianList[l], @@ -3435,7 +3434,7 @@ def multilevelNonlinearSolverChooser(nonlinearOperatorList, norm = nonlinearSolverNorm) elif smootherType == NLStarILU: if relaxationFactor is None: - relaxationFactor = old_div(2.0,5.0) + relaxationFactor = 2.0/5.0 coarseSolver = NLStarILU(connectionList = connectionListList[l], F = nonlinearOperatorList[l], J = jacobianList[l], @@ -3530,7 +3529,7 @@ def multilevelNonlinearSolverChooser(nonlinearOperatorList, maxLSits=maxLSits )) elif levelNonlinearSolverType == NLJacobi: if relaxationFactor is None: - relaxationFactor = old_div(4.0,5.0) + relaxationFactor = 4.0/5.0 for l in range(nLevels): levelNonlinearSolverList.append(NLJacobi(F=nonlinearOperatorList[l], J=jacobianList[l], @@ -3546,7 +3545,7 @@ def multilevelNonlinearSolverChooser(nonlinearOperatorList, fullNewton=levelSolverFullNewtonFlag)) elif levelNonlinearSolverType == NLGaussSeidel: if relaxationFactor is None: - relaxationFactor = old_div(4.0,5.0) + relaxationFactor = 4.0/5.0 for l in range(nLevels): levelNonlinearSolverList.append(NLGaussSeidel(F=nonlinearOperatorList[l], J=jacobianList[l], @@ -3562,7 +3561,7 @@ def multilevelNonlinearSolverChooser(nonlinearOperatorList, fullNewton=levelSolverFullNewtonFlag)) elif levelNonlinearSolverType == NLStarILU: if relaxationFactor is None: - relaxationFactor = old_div(3.0,5.0) + relaxationFactor = 3.0/5.0 for l in range(nLevels): levelNonlinearSolverList.append(NLStarILU(F=nonlinearOperatorList[l], J=jacobianList[l], @@ -3699,4 +3698,4 @@ def multilevelNonlinearSolverChooser(nonlinearOperatorList, #add minimal configuration for parallel? for levelSolver in multilevelNonlinearSolver.solverList: levelSolver.par_fullOverlap = parallelUsesFullOverlap - return multilevelNonlinearSolver + return multilevelNonlinearSolver \ No newline at end of file diff --git a/proteus/Norms.py b/proteus/Norms.py index b8c99b6462..d2c0180a3f 100644 --- a/proteus/Norms.py +++ b/proteus/Norms.py @@ -4,8 +4,6 @@ .. inheritance-diagram:: proteus.Norms :parts: 1 """ -from __future__ import absolute_import -from builtins import range from .FemTools import * from .Quadrature import * from .Comm import globalSum,globalMax diff --git a/proteus/NumericalFlux.py b/proteus/NumericalFlux.py index eeb7efa198..5d78d909c8 100644 --- a/proteus/NumericalFlux.py +++ b/proteus/NumericalFlux.py @@ -4,10 +4,6 @@ .. inheritance-diagram:: proteus.NumericalFlux :parts: 1 """ -from __future__ import absolute_import -from builtins import zip -from builtins import range -from builtins import object from . import cfemIntegrals,cnumericalFlux import numpy from .Profiling import logEvent,memory diff --git a/proteus/NumericalSolution.py b/proteus/NumericalSolution.py index 4a3b39d0c2..ddd422911d 100644 --- a/proteus/NumericalSolution.py +++ b/proteus/NumericalSolution.py @@ -4,16 +4,6 @@ .. inheritance-diagram:: proteus.NumericalSolution :parts: 1 """ -from __future__ import print_function -from __future__ import absolute_import -from __future__ import division - -from builtins import zip -from builtins import str -from builtins import input -from builtins import range -from builtins import object -from past.utils import old_div import os import numpy from subprocess import check_call, check_output diff --git a/proteus/ObjectiveFunctions.py b/proteus/ObjectiveFunctions.py index 2bc1bae081..d817b879d1 100644 --- a/proteus/ObjectiveFunctions.py +++ b/proteus/ObjectiveFunctions.py @@ -5,10 +5,6 @@ .. inheritance-diagram:: proteus.ObjectiveFunctions :parts: 1 """ -from __future__ import absolute_import -from __future__ import division -from builtins import object -from past.utils import old_div from .Optimizers import ObjectiveFunction_base #John Chrispell, Summer 07 import math @@ -33,14 +29,14 @@ class SimpelFunc3(ObjectiveFunction_base): def __init__(self,LHS_x,RHS_x): ObjectiveFunction_base.__init__(self,LHS_x,RHS_x) def getResidual(self,x): - return (old_div((x**2.0),(x**2.0+0.5*((1.0-x)**2.0)))) + return ((x**2.0)/(x**2.0+0.5*((1.0-x)**2.0))) # BuckleyLeverett Function with the choice of alpha=1/2 class BuckleyLeverett(object): def __init__(self,alpha): self.alpha=alpha def getFlux(self,s): - return (old_div((s**2.0),(s**2.0+self.alpha*((1.0-s)**2.0)))) + return ((s**2.0)/(s**2.0+self.alpha*((1.0-s)**2.0))) # A function used to find solution for the nonconvex scalar # Riemann problem with arbitrary data LHS_s, and RHS_s. @@ -48,7 +44,7 @@ class OsherFunc(ObjectiveFunction_base): def __init__(self,LHS_s,RHS_s,fFunc,t,x): ObjectiveFunction_base.__init__(self,LHS_s,RHS_s) self.fFunc = fFunc - self.xi = old_div(x,t) + self.xi = x/t if(LHS_s < RHS_s): self.getResidual = self.Argmin else: @@ -64,7 +60,7 @@ def Argmax(self,s): class OsherFuncCoef(ObjectiveFunction_base): def __init__(self,LHS_s,RHS_s,fFunc,t,x,useShallowCopy=True): ObjectiveFunction_base.__init__(self,LHS_s,RHS_s) - self.xi = old_div(x,t) + self.xi = x/t self.t = t self.x = x # The next bit is a one dimensional dictionary for the coefficents @@ -103,4 +99,4 @@ def Argmax(self,s): self.fFunc.evaluate(self.t,self.c) m = self.c[('m',0)][0] f = self.c[('f',0)][0,0] - return self.xi*m - f + return self.xi*m - f \ No newline at end of file diff --git a/proteus/Optimizers.py b/proteus/Optimizers.py index d4c25103c7..423128624a 100644 --- a/proteus/Optimizers.py +++ b/proteus/Optimizers.py @@ -4,14 +4,7 @@ .. inheritance-diagram:: proteus.Optimizers :parts: 1 """ -from __future__ import print_function -from __future__ import absolute_import -from __future__ import division #John Chrispell, Summer 07 -from builtins import input -from builtins import range -from past.utils import old_div -from builtins import object class ObjectiveFunction_base(object): def __init__(self,LHS_x,RHS_x): self.LHS_x=LHS_x @@ -152,7 +145,7 @@ def solve(self,Guess_x=0.38196601): # Test parameters LHS_x = -1.0 RHS_x = 2.0 - Guess_x = old_div((RHS_x + LHS_x),2.0) + Guess_x = (RHS_x+LHS_x)/2.0 Tol = 1e-6 RefnVal = 100 @@ -167,7 +160,7 @@ def solve(self,Guess_x=0.38196601): # ------ Plotting ------- # xLeft=LHS_x - dx = old_div((abs(RHS_x-LHS_x)),RefnVal) + dx = (abs(RHS_x-LHS_x))/RefnVal xVec=[] fVec=[] for i in range(RefnVal+1): diff --git a/proteus/PostProcessingTools.py b/proteus/PostProcessingTools.py index 2f5a2972b8..0ffeb19d4a 100644 --- a/proteus/PostProcessingTools.py +++ b/proteus/PostProcessingTools.py @@ -6,13 +6,6 @@ .. inheritance-diagram:: proteus.PostProcessingTools :parts: 1 """ -from __future__ import print_function -from __future__ import absolute_import -from __future__ import division -from builtins import str -from builtins import range -from past.utils import old_div -from builtins import object import numpy from . import FemTools from . import LinearSolvers @@ -1597,7 +1590,7 @@ def getInteriorDivFreeElement(self): self.weightedInteriorDivFreeElement[eN,k,j,i] += self.interiorDivFreeElement[eN,k,h,i]*self.q['J'][eN][k][j][h] for i in range(self.get_num_sigmaBasisElements()): # scale by Jacobian - self.weightedInteriorDivFreeElement[eN,k,j,i] *= old_div(1.,self.vt.q['abs(det(J))'][eN][k]) + self.weightedInteriorDivFreeElement[eN,k,j,i] *= 1./self.vt.q['abs(det(J))'][eN][k] # scale with quadrature weight self.weightedInteriorDivFreeElement[eN,k,j,i] *= self.vt.q['dV'][eN][k] @@ -1609,7 +1602,7 @@ def getInteriorDivFreeElement(self): for eN in range(self.vt.mesh.nElements_global): for k in range(self.vt.nQuadraturePoints_element): - for i in range(old_div(self.dim, self.vt.nSpace_global)): + for i in range(self.dim//self.vt.nSpace_global): for j in range(self.vt.nSpace_global): self.piola_trial_function[eN,k,i*self.vt.nSpace_global+j,j] = self.q[('w',self.BDMcomponent)][eN][k][i] @@ -1725,7 +1718,7 @@ def getAverageFlux(self,ci): self.vt.ebq[('velocity',ci)][element][local_edge_num][pt][comp] ) for edge in range(num_edges): if edge in self.vt.mesh.interiorElementBoundariesArray: - self.flux_average[edge] = old_div((flux_array[edge][0] + flux_array[edge][1]), 2.0) + self.flux_average[edge] = (flux_array[edge][0]+flux_array[edge][1])/2.0 else: self.flux_average[edge] = flux_array[edge][0] @@ -2155,21 +2148,21 @@ def __init__(self,vectorTransport=None,vtComponents=[0]): if self.vt.nSpace_global == 2: volFact = 0.5 if self.vt.nSpace_global == 3: - volFact = old_div(1.0,6.0); areaFact = 0.5 + volFact = 1.0/6.0; areaFact = 0.5 for ebNI in range(self.vt.mesh.nInteriorElementBoundaries_global): ebN = self.vt.mesh.interiorElementBoundariesArray[ebNI] eN_left = self.vt.mesh.elementBoundaryElementsArray[ebN,0] eN_right= self.vt.mesh.elementBoundaryElementsArray[ebN,1] ebN_element_left = self.vt.mesh.elementBoundaryLocalElementBoundariesArray[ebN,0] area_face= areaFact*self.vt.ebq['sqrt(det(g))'][eN_left,ebN_element_left,0] - self.ebq_global['pwc-corr'][ebN,0] = old_div(1.0,area_face) - self.ebq_global['pwc-corr'][ebN,1] =old_div(-1.0,area_face) + self.ebq_global['pwc-corr'][ebN,0] = 1.0/area_face + self.ebq_global['pwc-corr'][ebN,1] =-1.0/area_face for ebNE in range(self.vt.mesh.nExteriorElementBoundaries_global): ebN = self.vt.mesh.exteriorElementBoundariesArray[ebNE] eN_left = self.vt.mesh.elementBoundaryElementsArray[ebN,0] ebN_element_left = self.vt.mesh.elementBoundaryLocalElementBoundariesArray[ebN,0] area_face= areaFact*self.vt.ebq['sqrt(det(g))'][eN_left,ebN_element_left,0] - self.ebq_global['pwc-corr'][ebN,0] = old_div(1.0,area_face) + self.ebq_global['pwc-corr'][ebN,0] = 1.0/area_face #end ebNE for ci in self.vtComponents: @@ -2375,7 +2368,7 @@ def __init__(self,vectorTransport=None,vtComponents=[0]): if self.vt.nSpace_global == 2: volFact = 0.5 if self.vt.nSpace_global == 3: - volFact = old_div(1.0,6.0); areaFact = 0.5 + volFact = 1.0/6.0; areaFact = 0.5 for ebNI in range(self.vt.mesh.nInteriorElementBoundaries_global): ebN = self.vt.mesh.interiorElementBoundariesArray[ebNI] @@ -2387,8 +2380,8 @@ def __init__(self,vectorTransport=None,vtComponents=[0]): area_face= areaFact*self.vt.ebq['sqrt(det(g))'][eN_left,ebN_element_left,0] #this is valid for # w_e = -\frac{|\Omega_e|}{|\gamma|_f}\vec n_f \cdot \vec n_e - self.ebq_global['sun-glob-corr'][ebN,0] = old_div(-vol_left,area_face) - self.ebq_global['sun-glob-corr'][ebN,1] = old_div(vol_right,area_face) + self.ebq_global['sun-glob-corr'][ebN,0] = -vol_left/area_face + self.ebq_global['sun-glob-corr'][ebN,1] = vol_right/area_face for ebNE in range(self.vt.mesh.nExteriorElementBoundaries_global): ebN = self.vt.mesh.exteriorElementBoundariesArray[ebNE] eN_left = self.vt.mesh.elementBoundaryElementsArray[ebN,0] @@ -2397,7 +2390,7 @@ def __init__(self,vectorTransport=None,vtComponents=[0]): area_face= areaFact*self.vt.ebq['sqrt(det(g))'][eN_left,ebN_element_left,0] #this is valid for # w_e = -\frac{|\Omega_e|}{|\gamma|_f}\vec n_f \cdot \vec n_e - self.ebq_global['sun-glob-corr'][ebN,0] = old_div(-vol_left,area_face) + self.ebq_global['sun-glob-corr'][ebN,0] = -vol_left/area_face #end ebNE for ci in self.vtComponents: @@ -2632,7 +2625,7 @@ def __init__(self,vectorTransport=None,vtComponents=[0]): if self.vt.nSpace_global == 2: volFact = 0.5 if self.vt.nSpace_global == 3: - volFact = old_div(1.0,6.0); areaFact = 0.5 + volFact = 1.0/6.0; areaFact = 0.5 for ebNI in range(self.vt.mesh.nInteriorElementBoundaries_global): ebN = self.vt.mesh.interiorElementBoundariesArray[ebNI] eN_left = self.vt.mesh.elementBoundaryElementsArray[ebN,0] @@ -2645,8 +2638,8 @@ def __init__(self,vectorTransport=None,vtComponents=[0]): #weighted harmonic average, should be what Sun-Wheeler use but doesn't seem to work as well as # the weighted arithmetic average does #note signs are opposite of our paper formulation - self.ebq_global['sun-gs-alpha'][ebN,0]= old_div(vol_right,(area_face*(vol_left+vol_right))) - self.ebq_global['sun-gs-alpha'][ebN,1]= old_div(-vol_left,(area_face*(vol_left+vol_right))) + self.ebq_global['sun-gs-alpha'][ebN,0]= vol_right/(area_face*(vol_left+vol_right)) + self.ebq_global['sun-gs-alpha'][ebN,1]= -vol_left/(area_face*(vol_left+vol_right)) #weighted arithmetic average basically #self.ebq_global['sun-gs-alpha'][ebN,0]= vol_left/(area_face*(vol_left+vol_right)) #self.ebq_global['sun-gs-alpha'][ebN,1]= -vol_right/(area_face*(vol_left+vol_right)) @@ -4198,7 +4191,7 @@ def __init__(self,postProcessingTypes=None,vectorTransport=None,vtComponents=[0] if self.vt.nSpace_global == 2: volFact = 0.5 if self.vt.nSpace_global == 3: - volFact = old_div(1.0,6.0); areaFact = 0.5 + volFact = 1.0/6.0; areaFact = 0.5 for ebNI in range(self.vt.mesh.nInteriorElementBoundaries_global): ebN = self.vt.mesh.interiorElementBoundariesArray[ebNI] eN_left = self.vt.mesh.elementBoundaryElementsArray[ebN,0] @@ -4211,8 +4204,8 @@ def __init__(self,postProcessingTypes=None,vectorTransport=None,vtComponents=[0] #weighted harmonic average, should be what Sun-Wheeler use but doesn't seem to work as well as # the weighted arithmetic average does #note signs are opposite of our paper formulation - self.ebq_global['sun-gs-alpha'][ebN,0]= old_div(vol_right,(area_face*(vol_left+vol_right))) - self.ebq_global['sun-gs-alpha'][ebN,1]= old_div(-vol_left,(area_face*(vol_left+vol_right))) + self.ebq_global['sun-gs-alpha'][ebN,0]= vol_right/(area_face*(vol_left+vol_right)) + self.ebq_global['sun-gs-alpha'][ebN,1]= -vol_left/(area_face*(vol_left+vol_right)) #weighted arithmetic average basically #self.ebq_global['sun-gs-alpha'][ebN,0]= vol_left/(area_face*(vol_left+vol_right)) #self.ebq_global['sun-gs-alpha'][ebN,1]= -vol_right/(area_face*(vol_left+vol_right)) @@ -4227,7 +4220,7 @@ def __init__(self,postProcessingTypes=None,vectorTransport=None,vtComponents=[0] if self.vt.nSpace_global == 2: volFact = 0.5 if self.vt.nSpace_global == 3: - volFact = old_div(1.0,6.0); areaFact = 0.5 + volFact = 1.0/6.0; areaFact = 0.5 #use same correction everywhere since just going to overwrite Neumann boundaries self.ebq_global['sun-glob-corr'] = numpy.zeros((self.vt.mesh.nElementBoundaries_global, 2),'d') @@ -4243,8 +4236,8 @@ def __init__(self,postProcessingTypes=None,vectorTransport=None,vtComponents=[0] area_face= areaFact*self.vt.ebq['sqrt(det(g))'][eN_left,ebN_element_left,0] #this is valid for # w_e = -\frac{|\Omega_e|}{|\gamma|_f}\vec n_f \cdot \vec n_e - self.ebq_global['sun-glob-corr'][ebN,0] = old_div(-vol_left,area_face) - self.ebq_global['sun-glob-corr'][ebN,1] = old_div(vol_right,area_face) + self.ebq_global['sun-glob-corr'][ebN,0] = -vol_left/area_face + self.ebq_global['sun-glob-corr'][ebN,1] = vol_right/area_face for ebNE in range(self.vt.mesh.nExteriorElementBoundaries_global): ebN = mesh.exteriorElementBoundariesArray[ebNE] eN_left = mesh.elementBoundaryElementsArray[ebN,0] @@ -4253,7 +4246,7 @@ def __init__(self,postProcessingTypes=None,vectorTransport=None,vtComponents=[0] area_face= areaFact*self.vt.ebq['sqrt(det(g))'][eN_left,ebN_element_left,0] #this is valid for # w_e = -\frac{|\Omega_e|}{|\gamma|_f}\vec n_f \cdot \vec n_e - self.ebq_global['sun-glob-corr'][ebN,0] = old_div(-vol_left,area_face) + self.ebq_global['sun-glob-corr'][ebN,0] = -vol_left/area_face #end ebNE for ci in sunWheelerGlobalComponents: sunWheelerGlobalDict = {} @@ -4337,21 +4330,21 @@ def __init__(self,postProcessingTypes=None,vectorTransport=None,vtComponents=[0] if self.vt.nSpace_global == 2: volFact = 0.5 if self.vt.nSpace_global == 3: - volFact = old_div(1.0,6.0); areaFact = 0.5 + volFact = 1.0/6.0; areaFact = 0.5 for ebNI in range(self.vt.mesh.nInteriorElementBoundaries_global): ebN = mesh.interiorElementBoundariesArray[ebNI] eN_left = mesh.elementBoundaryElementsArray[ebN,0] eN_right= mesh.elementBoundaryElementsArray[ebN,1] ebN_element_left = mesh.elementBoundaryLocalElementBoundariesArray[ebN,0] area_face= areaFact*self.vt.ebq['sqrt(det(g))'][eN_left,ebN_element_left,0] - self.ebq_global['pwc-corr'][ebN,0] = old_div(1.0,area_face) - self.ebq_global['pwc-corr'][ebN,1] =old_div(-1.0,area_face) + self.ebq_global['pwc-corr'][ebN,0] = 1.0/area_face + self.ebq_global['pwc-corr'][ebN,1] =-1.0/area_face for ebNE in range(self.vt.mesh.nExteriorElementBoundaries_global): ebN = mesh.exteriorElementBoundariesArray[ebNE] eN_left = mesh.elementBoundaryElementsArray[ebN,0] ebN_element_left = mesh.elementBoundaryLocalElementBoundariesArray[ebN,0] area_face= areaFact*self.vt.ebq['sqrt(det(g))'][eN_left,ebN_element_left,0] - self.ebq_global['pwc-corr'][ebN,0] = old_div(1.0,area_face) + self.ebq_global['pwc-corr'][ebN,0] = 1.0/area_face #end ebNE for ci in pwcComponents: pwcMatGlobalDict = {} @@ -5444,4 +5437,4 @@ def addBoundaryFluxesBackToResidual(self,ci,flag_elementBoundaries=None): self.w_dS[ci],#vt.ebq[('w*dS_u',ci)], self.elementResidualPWL[ci])#vt.elementResidual[ci]) - #end add boundary fluxes + #end add boundary fluxes \ No newline at end of file diff --git a/proteus/Profiling.py b/proteus/Profiling.py index 09be18cc43..5c74a4fbec 100644 --- a/proteus/Profiling.py +++ b/proteus/Profiling.py @@ -4,14 +4,6 @@ .. inheritance-diagram:: proteus.Profiling :parts: 1 """ -from __future__ import division -from future import standard_library -standard_library.install_aliases() -from builtins import zip -from builtins import str -from builtins import range -from builtins import object -from past.utils import old_div import gc import inspect import pstats @@ -250,8 +242,8 @@ def profile_function(self, func, args, kwargs, profile_name): fname=f[-1].strip("<").strip(">") else: fname="function '{2:s}' at {0:s}:{1:d}".format(*f) - msg+=("{0:11.1%} {1:s}\n".format(old_div(statsm[f][2],stats.__dict__['total_tt']),str(fname))) - total += old_div(statsm[f][2],stats.__dict__['total_tt']) + msg+=("{0:11.1%} {1:s}\n".format(statsm[f][2]/stats.__dict__['total_tt'],str(fname))) + total += statsm[f][2]/stats.__dict__['total_tt'] logEvent(msg) logEvent("Representing "+repr(total*100.)+"%") return func_return diff --git a/proteus/Quadrature.py b/proteus/Quadrature.py index 5a87d87b07..1288dcb346 100644 --- a/proteus/Quadrature.py +++ b/proteus/Quadrature.py @@ -4,12 +4,6 @@ .. inheritance-diagram:: proteus.Quadrature :parts: 1 """ -from __future__ import absolute_import -from __future__ import division -from builtins import zip -from builtins import range -from past.utils import old_div -from builtins import object from .EGeometry import * from .Profiling import logEvent from math import * @@ -64,25 +58,25 @@ def __init__(self,order=1): [p8,w8]=numpy.polynomial.legendre.leggauss(8); p8=0.5*(p8+1); w8=0.5*w8 [p9,w9]=numpy.polynomial.legendre.leggauss(9); p9=0.5*(p9+1); w9=0.5*w9 #mwf for convenience, see Ern and Guermond - a1 = 0.5*sqrt(old_div((15.0+2.0*sqrt(30)),35.0)) - a2 = 0.5*sqrt(old_div((15.0-2.0*sqrt(30)),35.0)) - w1 = 0.25 - old_div(sqrt(old_div(5.,6.)),12.) - w2 = 0.25 + old_div(sqrt(old_div(5.,6.)),12.) + a1 = 0.5*sqrt((15.0+2.0*sqrt(30))/35.0) + a2 = 0.5*sqrt((15.0-2.0*sqrt(30))/35.0) + w1 = 0.25 - sqrt(5./6.)/12. + w2 = 0.25 + sqrt(5./6.)/12. Q_base.__init__(self,order) self.pointsAll=( (EVec(0.5),), #n=1 - (EVec(old_div((sqrt(3.0)-1.0),(2.0*sqrt(3.0)))), #n=2 - EVec(old_div((sqrt(3.0)+1.0),(2.0*sqrt(3.0))))), - (EVec(old_div((sqrt(5.0) - sqrt(3.0)),(2.0*sqrt(5)))), #n=3 + (EVec((sqrt(3.0)-1.0)/(2.0*sqrt(3.0))), #n=2 + EVec((sqrt(3.0)+1.0)/(2.0*sqrt(3.0)))), + (EVec((sqrt(5.0)-sqrt(3.0))/(2.0*sqrt(5))), #n=3 EVec(0.5), - EVec(old_div((sqrt(5.0) + sqrt(3.0)),(2.0*sqrt(5))))), + EVec((sqrt(5.0)+sqrt(3.0))/(2.0*sqrt(5)))), (EVec(0.5+a1),EVec(0.5-a1), #n=4 EVec(0.5+a2),EVec(0.5-a2)), (EVec(0.5), #n=5 - EVec(0.5*(old_div(sqrt(5.0-2.0*sqrt(old_div(10.0,7.0))),3.0)) + 0.5), - EVec(0.5*(old_div(-sqrt(5.0-2.0*sqrt(old_div(10.0,7.0))),3.0)) + 0.5), - EVec(0.5*(old_div(sqrt(5.0+2.0*sqrt(old_div(10.0,7.0))),3.0)) + 0.5), - EVec(0.5*(old_div(-sqrt(5.0+2.0*sqrt(old_div(10.0,7.0))),3.0)) + 0.5)), + EVec(0.5*(sqrt(5.0-2.0*sqrt(10.0/7.0))/3.0) + 0.5), + EVec(0.5*(-sqrt(5.0-2.0*sqrt(10.0/7.0))/3.0) + 0.5), + EVec(0.5*(sqrt(5.0+2.0*sqrt(10.0/7.0))/3.0) + 0.5), + EVec(0.5*(-sqrt(5.0+2.0*sqrt(10.0/7.0))/3.0) + 0.5)), (EVec(p6[0]), #n=6 EVec(p6[1]), EVec(p6[2]), @@ -118,11 +112,11 @@ def __init__(self,order=1): (1.0,), #n=1 (0.5, #n=2 0.5), - (old_div(5.0,18.0), #n=3 - old_div(8.0,18.0), - old_div(5.0,18.0)), + (5.0/18.0, #n=3 + 8.0/18.0, + 5.0/18.0), (w1,w1,w2,w2), #n=4 - (0.5*(old_div(128.0,225.0)), #n=5 + (0.5*(128.0/225.0), #n=5 0.5*(322.0+13.0*sqrt(70.0))/900.0, 0.5*(322.0+13.0*sqrt(70.0))/900.0, 0.5*(322.0-13.0*sqrt(70.0))/900.0, @@ -151,7 +145,7 @@ class LobattoEdge(Q_base): def __init__(self,order=1): Q_base.__init__(self,order) a1 = 0.2*sqrt(5.0) - a2 = old_div(sqrt(21.0),7.0) + a2 = sqrt(21.0)/7.0 self.pointsAll=( (EVec(0.0),EVec(1.0)), (EVec(0.0),EVec(0.5),EVec(1.0)), @@ -160,9 +154,9 @@ def __init__(self,order=1): ) self.weightsAll=( (0.5,0.5), - (old_div(1.0,6.0), old_div(4.0,6.0), old_div(1.0,6.0)), - (old_div(1.0,12.0), old_div(5.0,12.0),old_div(5.0,12.0),old_div(1.0,12.0)), - (old_div(1.0,20.0),old_div(49.0,180.0),old_div(32.0,90.0),old_div(49.0,180.0),old_div(1.0,20.0)) + (1.0/6.0, 4.0/6.0, 1.0/6.0), + (1.0/12.0, 5.0/12.0,5.0/12.0,1.0/12.0), + (1.0/20.0,49.0/180.0,32.0/90.0,49.0/180.0,1.0/20.0) ) self.setOrder(order) @@ -173,7 +167,7 @@ class LobattoEdgeAlt(Q_base): def __init__(self,order=1): Q_base.__init__(self,order) a1 = 0.2*sqrt(5.0) - a2 = old_div(sqrt(21),7.0) + a2 = sqrt(21)/7.0 self.pointsAll=( (EVec(-1.0),EVec(1.0)), (EVec(-1.0),EVec(0.0),EVec(1.0)), @@ -181,9 +175,9 @@ def __init__(self,order=1): (EVec(-1.0),EVec(-a2),EVec(0.0),EVec(a2),EVec(1.0)),) self.weightsAll=( (1.0,1.0), - (old_div(1.0,3.0), old_div(4.0,3.0), old_div(1.0,3.0)), - (old_div(1.0,6.0), old_div(5.0,6.0),old_div(5.0,6.0),old_div(1.0,6.0)), - (old_div(1.0,10.0),old_div(49.0,90.0),old_div(32.0,45.0),old_div(49.0,90.0),old_div(1.0,10.0)),) + (1.0/3.0, 4.0/3.0, 1.0/3.0), + (1.0/6.0, 5.0/6.0,5.0/6.0,1.0/6.0), + (1.0/10.0,49.0/90.0,32.0/45.0,49.0/90.0,1.0/10.0),) self.setOrder(order) @@ -199,7 +193,7 @@ def __init__(self,order=1,maxOrder=20): pointsList = [] weightsList= [] for nintervals in range(1,self.maxOrder+1): - dx = old_div(1.0,float(nintervals)) + dx = 1.0/float(nintervals) points=numpy.arange(nintervals+1,dtype='d')*dx weights=numpy.zeros(nintervals+1,'d'); weights.fill(dx) weights[0] *= 0.5; weights[-1] *= 0.5 @@ -241,14 +235,14 @@ def __init__(self,order=1): w1 = 0.223381589678010*0.5 w2 = 0.109951743655322*0.5 #5th order - a5= (old_div((6.-sqrt(15.0)),21.0),old_div((6. + sqrt(15.0)),21.0)) + a5= ((6.-sqrt(15.0))/21.0,(6.+sqrt(15.0))/21.0) w5= (0.5*(155. - sqrt(15))/1200.,0.5*(155. + sqrt(15))/1200.) fifthOrderPoints = []; fifthOrderWeights = [] for i in range(2): fifthOrderPoints.append((a5[i],a5[i])); fifthOrderWeights.append(w5[i]) fifthOrderPoints.append((1.-2.*a5[i],a5[i])); fifthOrderWeights.append(w5[i]) fifthOrderPoints.append((a5[i],1.-2.*a5[i])); fifthOrderWeights.append(w5[i]) - fifthOrderPoints.append((old_div(1.,3.),old_div(1.,3.))); fifthOrderWeights.append(0.5*9.0/40.0) + fifthOrderPoints.append((1./3.,1./3.)); fifthOrderWeights.append(0.5*9.0/40.0) #6th order a6 = (0.063089014491502,0.249286745170910) @@ -268,9 +262,9 @@ def __init__(self,order=1): Q_base.__init__(self,order) self.pointsAll=( - ( EVec(old_div(1.0,3.0),old_div(1.0,3.0)),), - ( EVec(old_div(1.0,2.0),old_div(1.0,2.0)), EVec(0.0,old_div(1.0,2.0)), EVec(old_div(1.0,2.0),0.0)), - ( EVec(old_div(1.0,3.0),old_div(1.0,3.0)), EVec(old_div(3.0,5.0),old_div(1.0,5.0)), EVec(old_div(1.0,5.0),old_div(3.0,5.0)),EVec(old_div(1.0,5.0),old_div(1.0,5.0))), + ( EVec(1.0/3.0,1.0/3.0),), + ( EVec(1.0/2.0,1.0/2.0), EVec(0.0,1.0/2.0), EVec(1.0/2.0,0.0)), + ( EVec(1.0/3.0,1.0/3.0), EVec(3.0/5.0,1.0/5.0), EVec(1.0/5.0,3.0/5.0),EVec(1.0/5.0,1.0/5.0)), ( EVec(a1,a1),EVec(1.0-2.0*a1,a1),EVec(a1,1.0-2.0*a1), EVec(a2,a2),EVec(1.0-2.0*a2,a2),EVec(a2,1.0-2.0*a2)), tuple(EVec(p[0],p[1]) for p in fifthOrderPoints), @@ -279,8 +273,8 @@ def __init__(self,order=1): self.weightsAll=( (0.5,), - (old_div(1.0,6.0), old_div(1.0,6.0), old_div(1.0,6.0)), - (old_div(-27.0,96.0), old_div(25.0,96.0), old_div(25.0,96.0), old_div(25.0,96.0)), + (1.0/6.0, 1.0/6.0, 1.0/6.0), + (-27.0/96.0, 25.0/96.0, 25.0/96.0, 25.0/96.0), (w1,w1,w1,w2,w2,w2), tuple(fifthOrderWeights), tuple(sixthOrderWeights) @@ -296,8 +290,8 @@ class CompositeTriangle(Q_base): # uniform refine the reference cell until size < hk. def __init__(self,quad_rule,hk): - N = int(floor(old_div(1.0,hk))) - h1= old_div(1.0,N) + N = int(floor(1.0/hk)) + h1= 1.0/N h2= 1.0/N/N npt = len(quad_rule.points) @@ -343,7 +337,7 @@ def get_h_of_Tetrahedron(self, simplex_nodes): return max([h1, h2, h3, h4, h5, h6]) def get_max_h_of_all_tetrahedron(self, all_tet): - n_tet = old_div(all_tet.shape[0], 4) + n_tet = all_tet.shape[0]//4 h = [] for i in range(n_tet): h.append(self.get_h_of_Tetrahedron(all_tet[i * 4:(i + 1) * 4, :])) @@ -412,7 +406,7 @@ def get_8_sub_simplex(self, simplex_nodes): def get_sub_tet_of_all_tet(self, all_tet): - n_tet = old_div(all_tet.shape[0], 4) + n_tet = all_tet.shape[0]//4 all_sub_tet = numpy.zeros((n_tet * 8 * 4, 3), 'd') for i in range(n_tet): all_sub_tet[i * 8 * 4:(i + 1) * 8 * 4, @@ -437,7 +431,7 @@ def __init__(self, quad_rule, hk): self.h = max_h - n_tet = old_div(all_tetrahedron.shape[0], 4) + n_tet = all_tetrahedron.shape[0]//4 quad_weights = numpy.asarray(quad_rule.weights, 'd') quad_points = numpy.asarray(quad_rule.points, 'd') n_quad_per_tet = quad_weights.shape[0] @@ -472,12 +466,12 @@ def __init__(self,order=1): a = 0.2763932023; b = 1.0-a; wv = 0.03333333333333*0.25; wab = 0.16666666666667*0.25 self.pointsAll=( ( EVec(0.0,0.0),EVec(1.0,0.0),EVec(0.0,1.0)), - ( EVec(old_div(1.0,3.0),old_div(1.0,3.0)), + ( EVec(1.0/3.0,1.0/3.0), EVec(0.,0.),EVec(1.0,0.0),EVec(0.0,1.0), EVec(0,a),EVec(b,0),EVec(a,b),EVec(a,0.),EVec(b,a),EVec(0,b)), ) self.weightsAll=( - (old_div(1.0,6.0),old_div(1.0,6.0),old_div(1.0,6.0)), + (1.0/6.0,1.0/6.0,1.0/6.0), (0.5-3.0*wv-6*wab, wv,wv,wv, wab,wab,wab,wab,wab,wab), @@ -505,7 +499,7 @@ def __init__(self,order=1,maxOrder=20): weightsList= [] parentArea = 0.5 for nintervals in range(1,self.maxOrder+1): - dx = old_div(1.0,float(nintervals)) + dx = 1.0/float(nintervals) #uniform subdivisions in terms of barycentric coordinates baryvals = numpy.arange(nintervals+1,dtype='d')*dx combos = []; weights = [] @@ -516,14 +510,14 @@ def __init__(self,order=1,maxOrder=20): if i == 0 or i == nintervals: iInBoundary = 1 if j == 0 or j == nintervals-i: jInBoundary = 1 if iInBoundary+jInBoundary == 2: - weights.append(old_div(parentArea,3.0)) + weights.append(parentArea/3.0) elif iInBoundary+jInBoundary == 1: weights.append(parentArea) else: weights.append(parentArea*2.0) pointsList.append([tuple(p) for p in combos]) weightsList.append([w for w in weights]) - parentArea = 0.5*(old_div(1.0,float(nintervals+1)))**2 + parentArea = 0.5*(1.0/float(nintervals+1))**2 self.pointsAll =tuple(tuple(pL) for pL in pointsList) self.weightsAll=tuple(tuple(wL) for wL in weightsList) self.setOrder(order) @@ -539,10 +533,10 @@ def __init__(self,order=1): order=1 Q_base.__init__(self,order) self.pointsAll=( - ( EVec(old_div(1.0,2.0),old_div(1.0,2.0)), EVec(0.0,old_div(1.0,2.0)), EVec(old_div(1.0,2.0),0.0)), + ( EVec(1.0/2.0,1.0/2.0), EVec(0.0,1.0/2.0), EVec(1.0/2.0,0.0)), ) self.weightsAll=( - (old_div(1.0,6.0), old_div(1.0,6.0), old_div(1.0,6.0)), + (1.0/6.0, 1.0/6.0, 1.0/6.0), ) self.setOrder(order) def setOrder(self,k): @@ -556,10 +550,10 @@ class GaussTetrahedron(Q_base): def __init__(self,order=1): Q_base.__init__(self,order) #mwf for convenience, see Guern Ermond 360 - a1=old_div((7.0-sqrt(15.)),34.0) - a2=old_div((7.0+sqrt(15.)),34.0) - a =old_div((10.0-2.0*sqrt(5.)),40.0) - Vf=old_div(1.0,6.0) + a1=(7.0-sqrt(15.))/34.0 + a2=(7.0+sqrt(15.))/34.0 + a =(10.0-2.0*sqrt(5.))/40.0 + Vf=1.0/6.0 w1=(2665.0+14.0*sqrt(15.0))/37800.0*Vf w2=(2665.0-14.0*sqrt(15.0))/37800.0*Vf wa=10.0/189.0*Vf @@ -571,10 +565,10 @@ def __init__(self,order=1): EVec(0.138196601125011,0.138196601125011,0.585410196624969), EVec(0.138196601125011,0.138196601125011,0.138196601125011)), (EVec(0.25,0.25,0.25),#3rd degree - EVec(old_div(1.0,2.0), old_div(1.0,6.0), old_div(1.0,6.0)), - EVec(old_div(1.0,6.0), old_div(1.0,2.0), old_div(1.0,6.0)), - EVec(old_div(1.0,6.0), old_div(1.0,6.0), old_div(1.0,2.0)), - EVec(old_div(1.0,6.0), old_div(1.0,6.0), old_div(1.0,6.0))), + EVec(1.0/2.0, 1.0/6.0, 1.0/6.0), + EVec(1.0/6.0, 1.0/2.0, 1.0/6.0), + EVec(1.0/6.0, 1.0/6.0, 1.0/2.0), + EVec(1.0/6.0, 1.0/6.0, 1.0/6.0)), (EVec(0.50,0.50,0.0),#4th degree EVec(0.50,0.0,0.50), EVec(0.0,0.50,0.50), @@ -735,16 +729,16 @@ def __init__(self,order=1): # EVec(a,0.5-a,0.5-a), # EVec(0.5-a,a,0.5-a))) self.weightsAll=( - (old_div(1.0,6.0),), - (old_div(1.0,24.0),#2nd degree - old_div(1.0,24.0), - old_div(1.0,24.0), - old_div(1.0,24.0)), - (old_div(-4.0,30.0),#3rd degree - old_div(9.0,120.0), - old_div(9.0,120.0), - old_div(9.0,120.0), - old_div(9.0,120.0)), + (1.0/6.0,), + (1.0/24.0,#2nd degree + 1.0/24.0, + 1.0/24.0, + 1.0/24.0), + (-4.0/30.0,#3rd degree + 9.0/120.0, + 9.0/120.0, + 9.0/120.0, + 9.0/120.0), (0.317460317460317450e-2, #4th degree 0.317460317460317450e-2, 0.317460317460317450e-2, @@ -908,7 +902,7 @@ def __init__(self,order=1): EVec(0.0,1.0,0.0), EVec(0.0,0.0,1.0)),) self.weightsAll=( - (old_div(1.0,24.0),old_div(1.0,24.0),old_div(1.0,24.0),old_div(1.0,24.0)),) + (1.0/24.0,1.0/24.0,1.0/24.0,1.0/24.0),) self.setOrder(order) def setOrder(self,k): self.order = 1 @@ -920,10 +914,10 @@ def __init__(self,order=1): order=1 Q_base.__init__(self,order) self.pointsAll=( - ( EVec(old_div(1.0,3.0),old_div(1.0,3.0),old_div(1.0,3.0)), EVec(0.0,old_div(1.0,3.0),old_div(1.,3.)), EVec(old_div(1.0,3.0),0.0,old_div(1.0,3.0)),EVec(old_div(1.,3.),old_div(1.,3.),0.0)), + ( EVec(1.0/3.0,1.0/3.0,1.0/3.0), EVec(0.0,1.0/3.0,1./3.), EVec(1.0/3.0,0.0,1.0/3.0),EVec(1./3.,1./3.,0.0)), ) self.weightsAll=( - (old_div(1.0,24.0), old_div(1.0,24.0), old_div(1.0,24.0)), + (1.0/24.0, 1.0/24.0, 1.0/24.0), ) self.setOrder(order) def setOrder(self,k): @@ -1080,4 +1074,3 @@ def buildUnion(quadratureDict): return (quadraturePoints,quadratureWeights,quadraturePointIndeces) ## @} - diff --git a/proteus/RefUtils.py b/proteus/RefUtils.py index 33d8e69597..5253363a1d 100644 --- a/proteus/RefUtils.py +++ b/proteus/RefUtils.py @@ -6,9 +6,6 @@ .. inheritance-diagram:: proteus.RefUtils :parts: 1 """ -from __future__ import print_function -from __future__ import absolute_import -from builtins import range from .EGeometry import * from .Quadrature import * diff --git a/proteus/SWFlow/SWFlowProblem.py b/proteus/SWFlow/SWFlowProblem.py index 575fe05955..c40a4e9773 100644 --- a/proteus/SWFlow/SWFlowProblem.py +++ b/proteus/SWFlow/SWFlowProblem.py @@ -1,5 +1,3 @@ -from __future__ import division -from past.utils import old_div from proteus import FemTools as ft from proteus import MeshTools as mt @@ -136,7 +134,7 @@ def getOutputStepping(self): # COMPUTE dt_init # dt_init = min(0.1 * self.dt_output, self.dt_init) if self.nDTout is None: - self.nDTout = int(round(old_div(self.final_time, self.dt_output))) + self.nDTout = int(round(self.final_time/self.dt_output)) else: self.dt_output = float(self.final_time) / float(self.nDTout) # diff --git a/proteus/SWFlow/models/GN_sw_n.py b/proteus/SWFlow/models/GN_sw_n.py index 49dbfd507f..c273cabc34 100644 --- a/proteus/SWFlow/models/GN_sw_n.py +++ b/proteus/SWFlow/models/GN_sw_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * from GN_sw_p import * diff --git a/proteus/SWFlow/models/GN_sw_p.py b/proteus/SWFlow/models/GN_sw_p.py index 2ccd3de4e3..77bf797055 100644 --- a/proteus/SWFlow/models/GN_sw_p.py +++ b/proteus/SWFlow/models/GN_sw_p.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import object -from past.utils import old_div from proteus import * from proteus.default_p import * from proteus.mprans import GN_SW2DCV diff --git a/proteus/SWFlow/models/sw_n.py b/proteus/SWFlow/models/sw_n.py index 2f9b69fabf..386ab6a379 100644 --- a/proteus/SWFlow/models/sw_n.py +++ b/proteus/SWFlow/models/sw_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * from sw_p import * diff --git a/proteus/SWFlow/models/sw_p.py b/proteus/SWFlow/models/sw_p.py index e31e04a626..4ee91449c3 100644 --- a/proteus/SWFlow/models/sw_p.py +++ b/proteus/SWFlow/models/sw_p.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import object -from past.utils import old_div from proteus import * from proteus.default_p import * from proteus.mprans import SW2DCV diff --git a/proteus/SWFlow/utils/SWEs_so.py b/proteus/SWFlow/utils/SWEs_so.py index 809676662a..601703108d 100644 --- a/proteus/SWFlow/utils/SWEs_so.py +++ b/proteus/SWFlow/utils/SWEs_so.py @@ -1,8 +1,6 @@ """ Split operator module for SWFlow: SWEs or Dispersive SWEs """ -from __future__ import absolute_import -from builtins import range import os from proteus.default_so import * from proteus import Context diff --git a/proteus/ShockCapturing.py b/proteus/ShockCapturing.py index 282bb8c4f2..6687ffe48f 100644 --- a/proteus/ShockCapturing.py +++ b/proteus/ShockCapturing.py @@ -4,10 +4,6 @@ .. inheritance-diagram:: proteus.ShockCapturing :parts: 1 """ -from __future__ import print_function -from __future__ import absolute_import -from builtins import range -from builtins import object import numpy from . import cshockCapturing class ShockCapturing_base(object): diff --git a/proteus/SimTools.py b/proteus/SimTools.py index e5b42c7f13..c6d5b8c16b 100644 --- a/proteus/SimTools.py +++ b/proteus/SimTools.py @@ -4,13 +4,6 @@ .. inheritance-diagram:: proteus.SimTools :parts: 1 """ -from __future__ import print_function -from __future__ import absolute_import -from __future__ import division -from builtins import input -from builtins import range -from past.utils import old_div -from builtins import object from . import Norms import numpy import numpy as np @@ -788,7 +781,7 @@ def uOfXT(self,X,T): self.errorData[ci][il][kexa].append(exa) if self.flags['echo']: if self.flags['echoRelativeErrors']: - logEvent("""\nt= %g; %s[%d][%d]= %g; relative_error= %g;""" % (tsim,kerr,ci,il,err,old_div(err,(exa+1E-15))),level=0) + logEvent("""\nt= %g; %s[%d][%d]= %g; relative_error= %g;""" % (tsim,kerr,ci,il,err,err/(exa+1E-15)),level=0) else: logEvent("""\nt= %g; %s[%d][%d]= %g;""" % (tsim,kerr,ci,il,err),level=0) #end if @@ -821,7 +814,7 @@ def uOfXT(self,X,T): self.errorData[ci][il][kexa].append(exa) if self.flags['echo']: if self.flags['echoRelativeErrors']: - logEvent("""\nt= %g; %s[%d][%d]= %g; relative_error= %g;""" % (tsim,kerr,ci,il,err,old_div(err,(exa+1E-15))),level=0) + logEvent("""\nt= %g; %s[%d][%d]= %g; relative_error= %g;""" % (tsim,kerr,ci,il,err,err/(exa+1E-15)),level=0) else: logEvent("""\nt= %g; %s[%d][%d]= %g;""" % (tsim,kerr,ci,il,err),level=0) #end if @@ -851,7 +844,7 @@ def uOfXT(self,X,T): self.errorData[ci][il][kexa].append(exa) if self.flags['echo']: if self.flags['echoRelativeErrors']: - logEvent("""\nt= %g; %s[%d][%d]= %g; relative_error= %g;""" % (tsim,kerr,ci,il,err,old_div(err,(exa+1E-15))),level=0) + logEvent("""\nt= %g; %s[%d][%d]= %g; relative_error= %g;""" % (tsim,kerr,ci,il,err,err/(exa+1E-15)),level=0) else: logEvent("""\nt= %g; %s[%d][%d]= %g;""" % (tsim,kerr,ci,il,err),level=0) #end if @@ -911,7 +904,7 @@ def uOfXT(self,X,T): self.errorData[ci][il][kexa].append(exa) if self.flags['echo']: if self.flags['echoRelativeErrors']: - logEvent("""\nt= %g; %s[%d][%d]= %g; relative_error= %g;""" % (tsim,kerr,ci,il,err,old_div(err,(exa+1E-15))),level=0) + logEvent("""\nt= %g; %s[%d][%d]= %g; relative_error= %g;""" % (tsim,kerr,ci,il,err,err/(exa+1E-15)),level=0) else: logEvent("""\nt= %g; %s[%d][%d]= %g;""" % (tsim,kerr,ci,il,err),level=0) #end if @@ -948,7 +941,7 @@ def uOfXT(self,X,T): self.errorData[ci][il][kexa].append(exa) if self.flags['echo']: if self.flags['echoRelativeErrors']: - logEvent("""\nt= %g; %s[%d][%d]= %g; relative_error= %g;""" % (tsim,kerr,ci,il,err,old_div(err,(exa+1E-15))),level=0) + logEvent("""\nt= %g; %s[%d][%d]= %g; relative_error= %g;""" % (tsim,kerr,ci,il,err,err/(exa+1E-15)),level=0) else: logEvent("""\nt= %g; %s[%d][%d]= %g;""" % (tsim,kerr,ci,il,err),level=0) #end if @@ -1006,7 +999,7 @@ def uOfXT(self,X,T): self.errorData[ci][il][kexa].append(exa) if self.flags['echo']: if self.flags['echoRelativeErrors']: - logEvent("""\nt= %g; %s[%d][%d]= %g; relative_error= %g;""" % (tsim,kerr,ci,il,err,old_div(err,(exa+1E-15))),level=0) + logEvent("""\nt= %g; %s[%d][%d]= %g; relative_error= %g;""" % (tsim,kerr,ci,il,err,err/(exa+1E-15)),level=0) else: logEvent("""\nt= %g; %s[%d][%d]= %g;""" % (tsim,kerr,ci,il,err),level=0) #end if @@ -1042,7 +1035,7 @@ def uOfXT(self,X,T): self.errorData[ci][il][kexa].append(exa) if self.flags['echo']: if self.flags['echoRelativeErrors']: - logEvent("""\nt= %g; %s[%d][%d]= %g; relative_error= %g;""" % (tsim,kerr,ci,il,err,old_div(err,(exa+1E-15))),level=0) + logEvent("""\nt= %g; %s[%d][%d]= %g; relative_error= %g;""" % (tsim,kerr,ci,il,err,err/(exa+1E-15)),level=0) else: logEvent("""\nt= %g; %s[%d][%d]= %g;""" % (tsim,kerr,ci,il,err),level=0) #end if @@ -1082,7 +1075,7 @@ def uOfXT(self,X,T): self.errorData[ci][il][kexa].append(exa) if self.flags['echo']: if self.flags['echoRelativeErrors']: - logEvent("""\nt= %g; %s[%d][%d]= %g; relative_error= %g;""" % (tsim,kerr,ci,il,err,old_div(err,(exa+1E-15))),level=0) + logEvent("""\nt= %g; %s[%d][%d]= %g; relative_error= %g;""" % (tsim,kerr,ci,il,err,err/(exa+1E-15)),level=0) else: logEvent("""\nt= %g; %s[%d][%d]= %g;""" % (tsim,kerr,ci,il,err),level=0) #end if @@ -1122,7 +1115,7 @@ def uOfXT(self,X,T): self.errorData[ci][il][kexa].append(exa) if self.flags['echo']: if self.flags['echoRelativeErrors']: - logEvent("""\nt= %g; %s[%d][%d]= %g; relative_error= %g;""" % (tsim,kerr,ci,il,err,old_div(err,(exa+1E-15))),level=0) + logEvent("""\nt= %g; %s[%d][%d]= %g; relative_error= %g;""" % (tsim,kerr,ci,il,err,err/(exa+1E-15)),level=0) else: logEvent("""\nt= %g; %s[%d][%d]= %g;""" % (tsim,kerr,ci,il,err),level=0) #end if @@ -1159,7 +1152,7 @@ def uOfXT(self,X,T): self.errorData[ci][il][kexa].append(exa) if self.flags['echo']: if self.flags['echoRelativeErrors']: - logEvent("""\nt= %g; %s[%d][%d]= %g; relative_error= %g;""" % (tsim,kerr,ci,il,err,old_div(err,(exa+1E-15))),level=0) + logEvent("""\nt= %g; %s[%d][%d]= %g; relative_error= %g;""" % (tsim,kerr,ci,il,err,err/(exa+1E-15)),level=0) else: logEvent("""\nt= %g; %s[%d][%d]= %g;""" % (tsim,kerr,ci,il,err),level=0) #end if @@ -1194,7 +1187,7 @@ def uOfXT(self,X,T): self.errorData[ci][il][kexa].append(exa) if self.flags['echo']: if self.flags['echoRelativeErrors']: - logEvent("""\nt= %g; %s[%d][%d]= %g; relative_error= %g;""" % (tsim,kerr,ci,il,err,old_div(err,(exa+1E-15))),level=0) + logEvent("""\nt= %g; %s[%d][%d]= %g; relative_error= %g;""" % (tsim,kerr,ci,il,err,err/(exa+1E-15)),level=0) else: logEvent("""\nt= %g; %s[%d][%d]= %g;""" % (tsim,kerr,ci,il,err),level=0) #end if @@ -1766,7 +1759,7 @@ def plotVectorElementQuantityEnsight(self,ckey,mlvt,tsim,scaleOutput=None): for eN in range(mlvt.levelModelList[-1].mesh.nElements_global): for k in range(mlvt.levelModelList[-1].nQuadraturePoints_element): for i in range(mlvt.levelModelList[-1].q[ckey].shape[-1]): - uOut.write('%12.5e' % (old_div(mlvt.levelModelList[-1].q[ckey][eN,k,i],vmax))) + uOut.write('%12.5e' % (mlvt.levelModelList[-1].q[ckey][eN,k,i]/vmax)) for i in range(mlvt.levelModelList[-1].q[ckey].shape[-1],3): uOut.write('%12.5e' % (0.0)) if n%2==1: @@ -1848,7 +1841,7 @@ def plotVectorGlobalElementBoundaryQuantityEnsight(self,ckey,mlvt,tsim,scaleOutp for ebN in range(mlvt.levelModelList[-1].mesh.nElementBoundaries_global): for k in range(mlvt.levelModelList[-1].nElementBoundaryQuadraturePoints_elementBoundary): for i in range(mlvt.levelModelList[-1].ebq_global[ckey].shape[-1]): - uOut.write('%12.5e' % (old_div(mlvt.levelModelList[-1].ebq_global[ckey][ebN,k,i],vmax))) + uOut.write('%12.5e' % (mlvt.levelModelList[-1].ebq_global[ckey][ebN,k,i]/vmax)) for i in range(mlvt.levelModelList[-1].ebq_global[ckey].shape[-1],3): uOut.write('%12.5e' % (0.0)) if n%2==1: @@ -2097,8 +2090,8 @@ def projectVelocityToFinestLevelNC(mlTransport,level,ci=0,tsim=0.0,verbose=0): x = mFine.q['x'][eN,iq,:] v = velciprojFine[eN,iq,:] Viewers.datFile.write("%12.5e %12.5e %12.5e %12.5e \n" % (x[0],x[1], - old_div(v[0],scale), - old_div(v[1],scale))) + v[0]/scale, + v[1]/scale)) Viewers.datFile.write("\n \n#end velciproj ci=%d level=%d" % (ci,level)) title = "velciproj ci=%d level=%d " % (ci,level) cmd = "set term x11 %i; plot \'%s\' index %i with vectors title \"%s\" \n" % (Viewers.windowNumber, @@ -2121,8 +2114,8 @@ def projectVelocityToFinestLevelNC(mlTransport,level,ci=0,tsim=0.0,verbose=0): x = mCoarse.q['x'][eN,iq,:] v = mCoarse.q[('velocity',ci)][eN,iq,:] Viewers.datFile.write("%12.5e %12.5e %12.5e %12.5e \n" % (x[0],x[1], - old_div(v[0],scale), - old_div(v[1],scale))) + v[0]/scale, + v[1]/scale)) Viewers.datFile.write("\n \n#end coarse velocity ci=%d level=%d" % (ci,level)) title = "coarse velocity ci=%d level=%d " % (ci,level) cmd = "set term x11 %i; plot \'%s\' index %i with vectors title \"%s\" \n" % (Viewers.windowNumber, @@ -2137,4 +2130,4 @@ def projectVelocityToFinestLevelNC(mlTransport,level,ci=0,tsim=0.0,verbose=0): #end gnuplot #end verbose - return velciprojFine + return velciprojFine \ No newline at end of file diff --git a/proteus/SpatialTools.py b/proteus/SpatialTools.py index d1446211c6..cd9cbe4921 100644 --- a/proteus/SpatialTools.py +++ b/proteus/SpatialTools.py @@ -28,13 +28,6 @@ :parts: 1 """ -from __future__ import print_function -from __future__ import division - -#from builtins import str -from builtins import range -from past.utils import old_div -from builtins import object from math import cos, sin, sqrt import math import sys @@ -453,9 +446,9 @@ def __init__(self, domain, dim=(0., 0., 0.), coords=(0., 0., 0.), self.barycenter = np.array(coords) else: self.barycenter = np.array(barycenter) - self.It = np.array([[old_div((W**2.+H**2.),12.), 0, 0], - [0, old_div((L**2.+H**2.),12.), 0], - [0, 0, old_div((W**2.+L**2.),12.)]]) + self.It = np.array([[(W**2.+H**2.)/12., 0, 0], + [0, (L**2.+H**2.)/12., 0], + [0, 0, (W**2.+L**2.)/12.]]) def setDimensions(self, dim): """ @@ -593,8 +586,8 @@ def constructShape(self): nN+=1 - hxi = old_div(radius,(math.sqrt(2.0)*float(nSectors))); - heta = old_div(radius,(math.sqrt(2.0)*float(nSectors))); + hxi = radius/(math.sqrt(2.0)*float(nSectors)); + heta = radius/(math.sqrt(2.0)*float(nSectors)); #now loop over grains #top half sphere nodes top_nodes = {} @@ -617,7 +610,7 @@ def constructShape(self): y0s = (ii-nSectors)*heta r0s = math.sqrt(x0s**2 + y0s**2) theta0s = math.atan2(y0s,x0s) - theta1s = theta0s - old_div(math.pi,4.0) + theta1s = theta0s - math.pi/4.0 r1s = r0s x1s = r1s*math.cos(theta1s) y1s = r1s*math.sin(theta1s) @@ -672,7 +665,7 @@ def constructShape(self): y0s = (ii-nSectors)*heta r0s = math.sqrt(x0s**2 + y0s**2) theta0s = math.atan2(y0s,x0s) - theta1s = theta0s - old_div(math.pi,4.0) + theta1s = theta0s - math.pi/4.0 r1s = r0s x1s = r1s*math.cos(theta1s) y1s = r1s*math.sin(theta1s) @@ -795,7 +788,7 @@ def __init__(self, domain, dim=(0., 0.), coords=(0., 0.), barycenter=None): self.BC['y+'], self.BC['x-']] # self.BC = BCContainer(self.BC_dict) - self.It = old_div((L**2+H**2),12) + self.It = (L**2+H**2)/12 def setDimensions(self, dim): """ @@ -847,7 +840,7 @@ def __init__(self, domain, radius, height, nPoints, coords=(0.,0.,0.), barycente def constructShape(self): h_offset = np.array([0., 0., self.height]) arc = 2.*np.pi*self.radius/self.nPoints - ang = old_div(arc,self.radius) + ang = arc/self.radius vert = [] facets = [] segs = [] @@ -868,7 +861,7 @@ def constructShape(self): for i in range(len(vert_bottom)-1): facets += [[[i, i+1, i+nvb+1, i+nvb]]] facets += [[[i+1, 0, nvb, i+1+nvb]]] # last facet - self.vertices = np.vstack((vert_bottom, vert_top))-old_div(h_offset,2.)+np.array(self.coords) + self.vertices = np.vstack((vert_bottom, vert_top))-h_offset/2.+np.array(self.coords) self.segments = np.vstack((segs_bottom, segs_top)) self.segmentFlags = np.array([1 for i in range(len(segs_bottom))]+[2 for i in range(len(segs_top))]) self.facets = facets @@ -911,7 +904,7 @@ def __init__(self, domain, radius, coords, barycenter, nPoints, boundaryTag=None self.coords = xc, yc = np.array(coords) self.nPoints = nPoints self.arc=2.0*pi*self.radius/self.nPoints - self.ang=old_div(self.arc,self.radius) + self.ang=self.arc/self.radius verti=[] segm=[] @@ -1284,15 +1277,15 @@ def rotation3D(points, rot, axis=(0., 0., 1.), pivot=(0., 0., 0.)): # make axis a unity vector axis = np.array(axis) r = np.linalg.norm(axis) - axis = old_div(axis,r) + axis = axis/r # get values for rotation matrix cx, cy, cz = axis d = sqrt(cy**2+cz**2) # rotation matrices if d != 0: Rx = np.array([[1, 0, 0, 0], - [0, old_div(cz,d), old_div(cy,d), 0], - [0, old_div(-cy,d), old_div(cz,d), 0], + [0, cz/d, cy/d, 0], + [0, -cy/d, cz/d, 0], [0, 0, 0, 1]]) else: # special case: rotation axis aligned with x axis Rx = np.array([[1, 0, 0, 0], @@ -1678,5 +1671,5 @@ def extrude2Dto3D(extrusion, vertices, segments, facets, regions=None): regions_extruded = copy.deepcopy(regions) if regions is not None: for region in regions_extruded: - region += old_div(extrusion,2.) - return vertices, segments, facets, regions_extruded + region += extrusion/2. + return vertices, segments, facets, regions_extruded \ No newline at end of file diff --git a/proteus/SplitOperator.py b/proteus/SplitOperator.py index 9f5c7bb84d..3c82840e56 100644 --- a/proteus/SplitOperator.py +++ b/proteus/SplitOperator.py @@ -4,12 +4,6 @@ .. inheritance-diagram:: proteus.SplitOperator :parts: 1 """ -from __future__ import absolute_import -from __future__ import division -from builtins import str -from builtins import range -from past.utils import old_div -from builtins import object from .Profiling import logEvent class System(object): @@ -58,15 +52,15 @@ def stepExact_system(self,tExact): logEvent("===========================================================dt system orig" + str(self.dt_system),level=5) self.dt_system = tExact - self.t_system_last logEvent("=========================================================dt system final" + str(self.dt_system),level=5) - elif( tExact*(1.0+self.stepExactEps) - (self.t_system_last + self.dt_system) < old_div(self.dt_system,2.0) ): #if next step would be within dt/2 ball go ahead and cut a little bit + elif( tExact*(1.0+self.stepExactEps) - (self.t_system_last + self.dt_system) < self.dt_system/2.0 ): #if next step would be within dt/2 ball go ahead and cut a little bit logEvent("===========================================================dt system orig" + str(self.dt_system),level=5) - self.dt_system = old_div((tExact - self.t_system_last),2.0) + self.dt_system = (tExact - self.t_system_last)/2.0 logEvent("=========================================================dt system final" + str(self.dt_system),level=5) if (self.dt_system < 0.0): if(self.t_system_last + self.dt_system <= tExact*(1.0 + self.stepExactEps)): self.dt_system = tExact - self.t_system_last - elif( tExact - (self.t_system_last + self.dt_system) > old_div(self.dt_system,2.0) ): #if next step would be within dt/2 ball go ahead and cut a little bit - self.dt_system = old_div((tExact - self.t_system_last),2.0) + elif( tExact - (self.t_system_last + self.dt_system) > self.dt_system/2.0 ): #if next step would be within dt/2 ball go ahead and cut a little bit + self.dt_system = (tExact - self.t_system_last)/2.0 self.t_system = self.t_system_last + self.dt_system self.stepSequence=[(self.t_system,m) for m in self.modelList] for model in self.modelList: @@ -234,15 +228,15 @@ def stepExact_system(self,tExact): logEvent("===========================================================dt system orig" + str(self.dt_system),level=5) self.dt_system = tExact - self.t_system_last logEvent("=========================================================dt system final" + str(self.dt_system),level=5) - elif( tExact - (self.t_system_last + self.dt_system) < old_div(self.dt_system,2.0) ): #if next step would be within dt/2 ball go ahead and cut a little bit + elif( tExact - (self.t_system_last + self.dt_system) < self.dt_system/2.0 ): #if next step would be within dt/2 ball go ahead and cut a little bit logEvent("===========================================================dt system orig" + str(self.dt_system),level=5) - self.dt_system = old_div((tExact - self.t_system_last),2.0) + self.dt_system = (tExact - self.t_system_last)/2.0 logEvent("=========================================================dt system final" + str(self.dt_system),level=5) if (self.dt_system < 0.0): if(self.t_system_last + self.dt_system <= tExact*(1.0 + self.stepExactEps)): self.dt_system = tExact - self.t_system_last - elif( tExact - (self.t_system_last + self.dt_system) > old_div(self.dt_system,2.0) ): #if next step would be within dt/2 ball go ahead and cut a little bit - self.dt_system = old_div((tExact - self.t_system_last),2.0) + elif( tExact - (self.t_system_last + self.dt_system) > self.dt_system/2.0 ): #if next step would be within dt/2 ball go ahead and cut a little bit + self.dt_system = (tExact - self.t_system_last)/2.0 self.dt_system = tExact - self.t_system_last self.t_system = self.t_system_last + self.dt_system self.stepSequence=[(self.t_system,m) for m in self.modelList] @@ -300,15 +294,15 @@ def stepExact_system(self,tExact): logEvent("===========================================================dt system orig" + str(self.dt_system),level=5) self.dt_system = tExact - self.t_system_last logEvent("=========================================================dt system final" + str(self.dt_system),level=5) - elif( tExact - (self.t_system_last + self.dt_system) < old_div(self.dt_system,2.0) ): #if next step would be within dt/2 ball go ahead and cut a little bit + elif( tExact - (self.t_system_last + self.dt_system) < self.dt_system/2.0 ): #if next step would be within dt/2 ball go ahead and cut a little bit logEvent("===========================================================dt system orig" + str(self.dt_system),level=5) - self.dt_system = old_div((tExact - self.t_system_last),2.0) + self.dt_system = (tExact - self.t_system_last)/2.0 logEvent("=========================================================dt system final" + str(self.dt_system),level=5) if (self.dt_system < 0.0): if(self.t_system_last + self.dt_system <= tExact*(1.0 + self.stepExactEps)): self.dt_system = tExact - self.t_system_last - elif( tExact - (self.t_system_last + self.dt_system) > old_div(self.dt_system,2.0) ): #if next step would be within dt/2 ball go ahead and cut a little bit - self.dt_system = old_div((tExact - self.t_system_last),2.0) + elif( tExact - (self.t_system_last + self.dt_system) > self.dt_system/2.0 ): #if next step would be within dt/2 ball go ahead and cut a little bit + self.dt_system = (tExact - self.t_system_last)/2.0 self.t_system = self.t_system_last + self.dt_system self.stepSequence=[(self.t_system,m) for m in self.modelList] for model in self.modelList: @@ -487,15 +481,15 @@ def stepExact_system(self,tExact): logEvent("===========================================================dt system orig" + str(self.dt_system),level=5) self.dt_system = tExact - self.t_system_last logEvent("=========================================================dt system final" + str(self.dt_system),level=5) - elif( tExact - (self.t_system_last + self.dt_system) < old_div(self.dt_system,2.0) ): #if next step would be within dt/2 ball go ahead and cut a little bit + elif( tExact - (self.t_system_last + self.dt_system) < self.dt_system/2.0 ): #if next step would be within dt/2 ball go ahead and cut a little bit logEvent("===========================================================dt system orig" + str(self.dt_system),level=5) - self.dt_system = old_div((tExact - self.t_system_last),2.0) + self.dt_system = (tExact - self.t_system_last)/2.0 logEvent("=========================================================dt system final" + str(self.dt_system),level=5) if (self.dt_system < 0.0): if(self.t_system_last + self.dt_system <= tExact*(1.0 + self.stepExactEps)): self.dt_system = tExact - self.t_system_last - elif( tExact - (self.t_system_last + self.dt_system) > old_div(self.dt_system,2.0) ): #if next step would be within dt/2 ball go ahead and cut a little bit - self.dt_system = old_div((tExact - self.t_system_last),2.0) + elif( tExact - (self.t_system_last + self.dt_system) > self.dt_system/2.0 ): #if next step would be within dt/2 ball go ahead and cut a little bit + self.dt_system = (tExact - self.t_system_last)/2.0 self.t_system = self.t_system_last + self.dt_system self.stepSequence=[(self.t_system,m) for m in self.modelList] for model in self.modelList: @@ -618,15 +612,15 @@ def stepExact_system(self,tExact): logEvent("===========================================================dt system orig" + str(self.dt_system),level=5) self.dt_system = tExact - self.t_system_last logEvent("=========================================================dt system final" + str(self.dt_system),level=5) - elif( tExact - (self.t_system_last + self.dt_system) < old_div(self.dt_system,2.0) ): #if next step would be within dt/2 ball go ahead and cut a little bit + elif( tExact - (self.t_system_last + self.dt_system) < self.dt_system/2.0 ): #if next step would be within dt/2 ball go ahead and cut a little bit logEvent("===========================================================dt system orig" + str(self.dt_system),level=5) - self.dt_system = old_div((tExact - self.t_system_last),2.0) + self.dt_system = (tExact - self.t_system_last)/2.0 logEvent("=========================================================dt system final" + str(self.dt_system),level=5) if (self.dt_system < 0.0): if(self.t_system_last + self.dt_system <= tExact*(1.0 + self.stepExactEps)): self.dt_system = tExact - self.t_system_last - elif( tExact - (self.t_system_last + self.dt_system) > old_div(self.dt_system,2.0) ): #if next step would be within dt/2 ball go ahead and cut a little bit - self.dt_system = old_div((tExact - self.t_system_last),2.0) + elif( tExact - (self.t_system_last + self.dt_system) > self.dt_system/2.0 ): #if next step would be within dt/2 ball go ahead and cut a little bit + self.dt_system = (tExact - self.t_system_last)/2.0 self.t_system = self.t_system_last + self.dt_system self.stepSequence=[(self.t_system,m) for m in self.modelList] for model in self.modelList: @@ -747,15 +741,15 @@ def stepExact_system(self,tExact): logEvent("===========================================================dt system orig" + str(self.dt_system),level=5) self.dt_system = tExact - self.t_system_last logEvent("=========================================================dt system final" + str(self.dt_system),level=5) - elif( tExact - (self.t_system_last + self.dt_system) < old_div(self.dt_system,2.0) ): #if next step would be within dt/2 ball go ahead and cut a little bit + elif( tExact - (self.t_system_last + self.dt_system) < self.dt_system/2.0 ): #if next step would be within dt/2 ball go ahead and cut a little bit logEvent("===========================================================dt system orig" + str(self.dt_system),level=5) - self.dt_system = old_div((tExact - self.t_system_last),2.0) + self.dt_system = (tExact - self.t_system_last)/2.0 logEvent("=========================================================dt system final" + str(self.dt_system),level=5) if (self.dt_system < 0.0): if(self.t_system_last + self.dt_system <= tExact*(1.0 + self.stepExactEps)): self.dt_system = tExact - self.t_system_last - elif( tExact - (self.t_system_last + self.dt_system) > old_div(self.dt_system,2.0) ): #if next step would be within dt/2 ball go ahead and cut a little bit - self.dt_system = old_div((tExact - self.t_system_last),2.0) + elif( tExact - (self.t_system_last + self.dt_system) > self.dt_system/2.0): #if next step would be within dt/2 ball go ahead and cut a little bit + self.dt_system = (tExact - self.t_system_last)/2.0 self.t_system = self.t_system_last + self.dt_system self.stepSequence=[(self.t_system,m) for m in self.modelList] for model in self.modelList: @@ -951,4 +945,4 @@ def initialize_dt_system(self,t0,tOut): logEvent("Initializing step sequence for system %s to %s" % (self.system.name, self.stepSequence), - level=1) + level=1) \ No newline at end of file diff --git a/proteus/StepControl.py b/proteus/StepControl.py index 8f186c7436..fac2533f4e 100644 --- a/proteus/StepControl.py +++ b/proteus/StepControl.py @@ -4,14 +4,7 @@ .. inheritance-diagram:: proteus.StepControl :parts: 1 """ -from __future__ import absolute_import -from __future__ import division -from builtins import zip -from builtins import range -from past.utils import old_div -from builtins import object from .Profiling import logEvent -#mwf add Comm for saving info about time step in separate file from . import Comm from petsc4py import PETSc from .Comm import globalMax @@ -247,7 +240,7 @@ def updateSubstep(self): self.res0 = self.model.solver.solverList[-1].norm_r0 res = self.model.solver.solverList[-1].norm_r0 #print "res dt",res,self.dt_model,self.res0,self.rtol,self.atol - ssError = old_div(res,(self.res0*self.rtol + self.atol)) + ssError = res/(self.res0*self.rtol + self.atol) #print "ssError",ssError for m in self.model.levelModelList: m.updateTimeHistory(self.t_model) @@ -331,7 +324,7 @@ def updateSubstep(self): self.res0 = self.model.solver.solverList[-1].norm_r0 res = self.model.solver.solverList[-1].norm_r0 #print "res0",res - ssError = old_div(res,(self.res0*self.rtol + self.atol)) + ssError = res/(self.res0*self.rtol + self.atol) #print "ssError",ssError for m in self.model.levelModelList: m.updateTimeHistory(self.t_model) @@ -416,7 +409,7 @@ def updateSubstep(self): for m in self.model.levelModelList: m.timeIntegration.choose_dt() res = self.model.solver.solverList[-1].norm_r0 - ssError = old_div(res,(self.res0*self.rtol + self.atol)) + ssError = res/(self.res0*self.rtol + self.atol) for m in self.model.levelModelList: m.updateTimeHistory(self.t_model) m.timeIntegration.updateTimeHistory() @@ -511,7 +504,7 @@ def updateSubstep(self): self.dt_model = self.start_ratio*self.model.levelModelList[0].timeIntegration.dt res = self.model.solver.solverList[-1].norm_r0 - ssError = old_div(res,(self.res0*self.rtol + self.atol)) + ssError = res/(self.res0*self.rtol + self.atol) for m in self.model.levelModelList: m.updateTimeHistory(self.t_model) m.timeIntegration.updateTimeHistory() @@ -529,7 +522,7 @@ def updateSubstep(self): self.substeps.append(self.substeps[0]) - logEvent("Osher-PsiTC iteration %d dt = %12.5e |res| = %12.5e %g " %(self.nSteps,self.dt_model,res,(old_div(res,self.res0))*100.0),level=1) + logEvent("Osher-PsiTC iteration %d dt = %12.5e |res| = %12.5e %g " %(self.nSteps,self.dt_model,res,(res/self.res0)*100.0),level=1) elif self.nSteps >= self.nStepsMax: logEvent("Osher-PsiTC DID NOT Converge |res| = %12.5e but quitting anyway" %(res,)) self.nSteps=0 @@ -645,10 +638,10 @@ def initialize_dt_model(self,t0,tOut): for ci in range(m.nc): if ci in self.cfl: maxCFL = max(maxCFL,globalMax(self.cfl[ci].max())) - self.dt_model = old_div(self.runCFL,maxCFL) + self.dt_model = self.runCFL/maxCFL if self.dt_model_last is None: self.dt_model_last = self.dt_model - if old_div(self.dt_model,self.dt_model_last) > self.dt_ratio_max: + if self.dt_model/self.dt_model_last > self.dt_ratio_max: self.dt_model = self.dt_model_last*self.dt_ratio_max self.set_dt_allLevels() self.substeps = [self.t_model] @@ -664,10 +657,10 @@ def choose_dt_model(self): for ci in range(m.nc): if ci in self.cfl: maxCFL = max(maxCFL,globalMax(self.cfl[ci].max())) - self.dt_model = old_div(self.runCFL,maxCFL) + self.dt_model = self.runCFL/maxCFL if self.dt_model_last is None: self.dt_model_last = self.dt_model - if old_div(self.dt_model,self.dt_model_last) > self.dt_ratio_max: + if self.dt_model/self.dt_model_last > self.dt_ratio_max: self.dt_model = self.dt_model_last*self.dt_ratio_max self.set_dt_allLevels() #self.substeps=[self.t_model] @@ -916,7 +909,7 @@ def setInitialGuess(self,uList,rList): for m,r,u,un,unm1 in zip(self.model.levelModelList,rList,uList,self.uListSave,self.unm1ListSave): u[:] = un[:] u -= unm1 - u *= old_div((self.t_model-self.t_model_last),(self.dt_nm1 + 1.0e-16)) + u *= (self.t_model-self.t_model_last)/(self.dt_nm1 + 1.0e-16) u += un m.setFreeDOF(u) m.getResidual(u,r) @@ -1101,7 +1094,7 @@ def setInitialGuess(self,uList,rList): for m,r,u,un,unm1 in zip(self.model.levelModelList,rList,uList,self.uListSave,self.unm1ListSave): u[:] = un[:] u -= unm1 - u *= old_div((self.t_model-self.t_model_last),(self.dt_nm1 + 1.0e-16)) + u *= (self.t_model-self.t_model_last)/(self.dt_nm1 + 1.0e-16) u += un m.setFreeDOF(u) m.getResidual(u,r) @@ -1149,10 +1142,10 @@ def choose_dt_solverFailure(self,dt): r_a = 1.0 if alpha_ref > alpha: assert nnl > 0.0 - r_a = self.phi(old_div(nnl_ref,nnl)) + r_a = self.phi(nnl_ref/nnl) else: assert alpha > 0.0 - r_a = self.phi(old_div(alpha_ref,alpha)) + r_a = self.phi(alpha_ref/alpha) r = min(self.nonlinearGrowthRateMax,max(self.nonlinearGrowthRateMin,r_a)) dtout = dt*r #mwf debug @@ -1171,7 +1164,7 @@ def choose_dt_solverSuccess(self,dt): if alpha <= 0.0: r_a = self.nonlinearGrowthRateMax #could use nnl here else: - r_a = self.phi(old_div(alpha_ref,alpha)) + r_a = self.phi(alpha_ref/alpha) r = min(self.nonlinearGrowthRateMax,max(self.nonlinearGrowthRateMin,r_a)) dtout = dt*r logEvent("Gustafsson solver success dt_in= %s alpha=%s alpha_ref=%s nnl=%s nnl_ref=%s r_a=%s, dtout=%s " % (dt,alpha,alpha_ref,nnl,nnl_ref,r_a,dtout),level=1) @@ -1237,9 +1230,9 @@ def choose_dt_fromError(self,dtIn): if (not mFine.timeIntegration.provides_dt_estimate and mFine.timeIntegration.error_estimate is not None): - ordInv = old_div(1.0,(mFine.timeIntegration.timeOrder+1.)) + ordInv = 1.0/(mFine.timeIntegration.timeOrder+1.) minErr = max(self.errorEstimate,self.timeEps) - r = self.errorSafetyFactor*(old_div(self.timeErrorTolerance,minErr))**ordInv + r = self.errorSafetyFactor*(self.timeErrorTolerance/minErr)**ordInv r_e = min(self.errorGrowthRateMax,max(self.errorGrowthRateMin,r)) dt_e = r_e*dtIn logEvent("Gustafsson choose_dt_fromError self t=%s dt=%s error= %s minErr= %s r_e=%s r= %s" % (self.t_model,self.dt_model, @@ -1266,7 +1259,7 @@ def initialize_dt_model(self,t0,tOut): maxCFL=max(maxCFL,globalMax(m.q[('cfl',ci)].max())) #mwf debug logEvent("Gustafsson cfl initial step ci = %s maxCFL= %s " % (ci,maxCFL)) - self.dt_model = min(old_div(self.cfl_for_initial_dt,maxCFL),m.timeIntegration.dt) + self.dt_model = min(self.cfl_for_initial_dt/maxCFL,m.timeIntegration.dt) else: self.dt_model = m.timeIntegration.dt #put safety factor in as in FLCBDF? diff --git a/proteus/SubgridError.py b/proteus/SubgridError.py index 0cae1a0177..28b7a53f9d 100644 --- a/proteus/SubgridError.py +++ b/proteus/SubgridError.py @@ -4,12 +4,6 @@ .. inheritance-diagram:: proteus.SubgridError :parts: 1 """ -from __future__ import print_function -from __future__ import absolute_import -from __future__ import division -from builtins import range -from past.utils import old_div -from builtins import object import numpy from . import csubgridError from . import FemTools @@ -1795,7 +1789,7 @@ def calculateSubgridError(self,q): dt = self.timeIntegration.dt assert dt > 0.0 - dtInv = old_div(1.0,dt) + dtInv = 1.0/dt self.subgridTmp[ci] *= dtInv self.subgridTmp[ci] *= self.subgridErrorMassCoef_last[ci]#decide what time level to use @@ -1825,7 +1819,7 @@ def calculateSubgridError(self,q): assert tau.max() * dm_subgrid.max() /dt <= 1.0, "Subgrid scales, modified tau_t.max() = %s dt = %s dm_subgrid.max() = %s tau.m'/dt = %s must be less than 1 " % (tau.max(), dt, dm_subgrid.max(), - old_div(tau.max(),dt)) + tau.max()/dt) # for cj in range(self.nc): if ('dpdeResidual',ci,cj) in q: @@ -1848,7 +1842,7 @@ def accumulateSubgridMassHistory(self,q): self.subgridTmp[ci][:] = self.subgridError_last[ci] dt = self.timeIntegration.dt assert dt > 0.0 - dtInv = old_div(1.0,dt) + dtInv = 1.0/dt self.subgridTmp[ci] *= dtInv self.subgridTmp[ci] *= self.subgridErrorMassCoef_last[ci]#decide how to approximate logEvent("ADR trackSubScales accumulating delta u^n.abs.max= %s dm.max=%s " % (max(numpy.absolute(self.subgridTmp[ci].flat)), @@ -2173,7 +2167,7 @@ def calculateSubgridErrorInterpolants(self,ci): #unless accumulate subgrid term has been callled this will miss old subgrid mass dt = self.timeIntegration.dt assert dt > 0.0 - dtInv = old_div(1.0,dt) + dtInv = 1.0/dt self.subgridTmp2_ip[ci][:] = self.subgridError_ip_last[ci] self.subgridTmp2_ip[ci] *= dtInv self.subgridTmp2_ip[ci] *= self.subgridErrorMassCoef_ip_last[ci]#figure this out @@ -2253,7 +2247,7 @@ def calculateSubgridError(self,q): #would be nice to have dt^{n+1} alone, try to get this from timeIntegration directly? dt = self.timeIntegration.dt assert dt > 0.0 - dtInv = old_div(1.0,dt) + dtInv = 1.0/dt #calculate \tilde{R}_h = R_h - \delta m^{n}/dt^{n+1} self.subgridTmp[ci][:] = self.subgridError_last[ci] self.subgridTmp[ci] *= dtInv @@ -2361,7 +2355,7 @@ def accumulateSubgridMassHistory(self,q): #would be nice to have dt^{n+1} alone dt = self.timeIntegration.dt assert dt > 0.0 - dtInv = old_div(1.0,dt) + dtInv = 1.0/dt self.subgridTmp[ci] *= dtInv self.subgridTmp[ci] *= self.subgridErrorMassCoef_last[ci]#figure this out #mwf debug @@ -2451,7 +2445,7 @@ def accumulateSubgridMassHistory(self,q): self.subgridTmp[ci][:] = self.subgridError_last[ci] dt = self.timeIntegration.dt assert dt > 0.0 - dtInv = old_div(1.0,dt) + dtInv = 1.0/dt self.subgridTmp[ci] *= dtInv self.subgridTmp[ci] *= self.subgridErrorMassCoef_last[ci]#decide how to approximate logEvent("NS_ASGS trackSubScales accumulating delta u^n ci=%s .abs.max= %s dm.max=%s " % (ci,max(numpy.absolute(self.subgridTmp[ci].flat)), @@ -2525,7 +2519,7 @@ def calculateSubgridError(self,q): if self.trackSubScales: dt = self.timeIntegration.dt assert dt > 0.0 - dtInv = old_div(1.0,dt) + dtInv = 1.0/dt #pressure, # \delta p = -tau_1*(1+tau_0/dt)*R^{n+1}_p + tau_1*tau_0/dt*R^n_p #recall that code is expecting subgridError to be tau*R instead of -tau*R @@ -2572,7 +2566,7 @@ def calculateSubgridError(self,q): assert tau0.max() * dm_subgrid.max() /dt <= 1.0, "Subgrid scales, modified tau_t.max() = %s dt = %s dm_subgrid.max() = %s tau.m'/dt = %s must be less than 1 " % (tau.max(), dt, dm_subgrid.max(), - old_div(tau.max(),dt)) + tau.max()/dt) # #account for old subgrid error in momentum strong residual for ci in range(1,self.nc): @@ -2636,4 +2630,4 @@ def calculateSubgridError(self,q): elif self.nd == 3: assert False for ci in range(self.nd): - q[('cfl',ci+1)][:] = q[('cfl',0)] + q[('cfl',ci+1)][:] = q[('cfl',0)] \ No newline at end of file diff --git a/proteus/SubsurfaceTransportCoefficients.py b/proteus/SubsurfaceTransportCoefficients.py index 4b39f8269d..e4b8951d4d 100644 --- a/proteus/SubsurfaceTransportCoefficients.py +++ b/proteus/SubsurfaceTransportCoefficients.py @@ -5,13 +5,6 @@ :parts: 1 """ -from __future__ import print_function -from __future__ import absolute_import -from __future__ import division -from builtins import zip -from builtins import range -from past.utils import old_div -from builtins import object from math import * from .TransportCoefficients import TC_base import numpy @@ -1017,12 +1010,12 @@ def __init__(self, self.g = dimensionless_gravity ##fluid properties #normalized density terms - self.rhon = old_div(density_n,density_w) - self.rhow = old_div(density_w,density_w) - self.b = old_div(density_n,density_w) + self.rhon = density_n/density_w + self.rhow = density_w/density_w + self.b = density_n/density_w #normalized viscosities - self.muw= old_div(viscosity_w,viscosity_w) - self.mun= old_div(viscosity_n,viscosity_w) + self.muw= viscosity_w/viscosity_w + self.mun= viscosity_n/viscosity_w #density eos options self.density_types={'Exponential':1, 'IdealGas':2} @@ -1036,15 +1029,15 @@ def __init__(self, ['rwork_density_w','rwork_density_n']): if params is not None: if params['model'] == 'Exponential': - setattr(self,rwork,numpy.array([old_div(params['rho_0'],params['rho_0']),#normalize by phase density + setattr(self,rwork,numpy.array([params['rho_0']/params['rho_0'],#normalize by phase density params['psi_0'], params['beta']],dtype='d')) elif params['model'] == 'IdealGas': setattr(self,rwork,numpy.array([params['T'], - old_div(params['W'],params['rho_0']),#normalize by phase density + params['W']/params['rho_0'],#normalize by phase density params['R'], params['headToPressure'], - old_div(params['rho_0'],params['rho_0']),#normalize by phase density + params['rho_0']/params['rho_0'],#normalize by phase density params['psi_0']],dtype='d')) else: assert False, 'TwophaseDarcy_base density params= %s not found ' % params @@ -1488,10 +1481,10 @@ def __init__(self, for input in [vgm_n_types,vgm_alpha_types,thetaR_types,thetaSR_types]: assert len(input)==self.nMaterialTypes - vgm_m_types = 1.0-old_div(1.0,vgm_n_types) + vgm_m_types = 1.0-1.0/vgm_n_types thetaS_types = thetaSR_types + thetaR_types Sw_max_types = numpy.ones((self.nMaterialTypes,),'d') - Sw_min_types = old_div(thetaR_types,thetaS_types) + Sw_min_types = thetaR_types/thetaS_types self.psk_tolerances['VGM']['eps_small']=vgm_small_eps self.psk_tolerances['VGM']['ns_del'] =vgm_ns_del if self.use_spline: @@ -1586,7 +1579,7 @@ def __init__(self, thetaS_types = thetaSR_types + thetaR_types Sw_max_types = numpy.ones((self.nMaterialTypes,),'d') - Sw_min_types = old_div(thetaR_types,thetaS_types) + Sw_min_types = thetaR_types/thetaS_types self.setMaterialTypes(Ksw_types=Ksw_types, omega_types=thetaS_types, Sw_max_types=Sw_max_types, @@ -1894,10 +1887,10 @@ def __init__(self, for input in [vgm_n_types,vgm_alpha_types,thetaR_types,thetaSR_types]: assert len(input)==self.nMaterialTypes - vgm_m_types = 1.0-old_div(1.0,vgm_n_types) + vgm_m_types = 1.0-1.0/vgm_n_types thetaS_types = thetaSR_types + thetaR_types Sw_max_types = numpy.ones((self.nMaterialTypes,),'d') - Sw_min_types = old_div(thetaR_types,thetaS_types) + Sw_min_types = thetaR_types/thetaS_types self.psk_tolerances['VGM']['eps_small']=vgm_small_eps self.psk_tolerances['VGM']['ns_del'] =vgm_ns_del if self.use_spline: @@ -1998,7 +1991,7 @@ def __init__(self, thetaS_types = thetaSR_types + thetaR_types Sw_max_types = numpy.ones((self.nMaterialTypes,),'d') - Sw_min_types = old_div(thetaR_types,thetaS_types) + Sw_min_types = thetaR_types/thetaS_types self.setMaterialTypes(Ksw_types=Ksw_types, omega_types=thetaS_types, Sw_max_types=Sw_max_types, @@ -3318,7 +3311,7 @@ def initializeElementQuadrature(self,t,cq): #set up dummy values in case we're not running the other model self.q_s_w = numpy.zeros(cq[('u',0)].shape,'d') self.q_s_w[:] = self.swConstant - for i in range(old_div(len(self.q_s_w.flat),2),len(self.q_s_w.flat)): + for i in range(len(self.q_s_w.flat)//2,len(self.q_s_w.flat)): self.q_s_w.flat[i] = 1.0e-4 self.q_grad_psic = numpy.zeros(cq[('f',0)].shape,'d') self.q_psic = numpy.zeros(cq[('u',0)].shape,'d') @@ -3930,10 +3923,10 @@ def __init__(self, for input in [vgm_n_types,vgm_alpha_types,thetaR_types,thetaSR_types]: assert len(input)==self.nMaterialTypes - vgm_m_types = 1.0-old_div(1.0,vgm_n_types) + vgm_m_types = 1.0-1.0/vgm_n_types thetaS_types = thetaSR_types + thetaR_types Sw_max_types = numpy.ones((self.nMaterialTypes,),'d') - Sw_min_types = old_div(thetaR_types,thetaS_types) + Sw_min_types = thetaR_types/thetaS_types #mwf debug #import pdb #pdb.set_trace() @@ -3990,10 +3983,10 @@ def __init__(self, for input in [vgm_n_types,vgm_alpha_types,thetaR_types,thetaSR_types]: assert len(input)==self.nMaterialTypes - vgm_m_types = 1.0-old_div(1.0,vgm_n_types) + vgm_m_types = 1.0-1.0/vgm_n_types thetaS_types = thetaSR_types + thetaR_types Sw_max_types = numpy.ones((self.nMaterialTypes,),'d') - Sw_min_types = old_div(thetaR_types,thetaS_types) + Sw_min_types = thetaR_types/thetaS_types #mwf debug #import pdb #pdb.set_trace() @@ -4172,10 +4165,10 @@ def __init__(self, for input in [vgm_n_types,vgm_alpha_types,thetaR_types,thetaSR_types]: assert len(input)==self.nMaterialTypes - vgm_m_types = 1.0-old_div(1.0,vgm_n_types) + vgm_m_types = 1.0-1.0/vgm_n_types thetaS_types = thetaSR_types + thetaR_types Sw_max_types = numpy.ones((self.nMaterialTypes,),'d') - Sw_min_types = old_div(thetaR_types,thetaS_types) + Sw_min_types = thetaR_types/thetaS_types #mwf debug #import pdb #pdb.set_trace() @@ -4239,10 +4232,10 @@ def __init__(self, for input in [vgm_n_types,vgm_alpha_types,thetaR_types,thetaSR_types]: assert len(input)==self.nMaterialTypes - vgm_m_types = 1.0-old_div(1.0,vgm_n_types) + vgm_m_types = 1.0-1.0/vgm_n_types thetaS_types = thetaSR_types + thetaR_types Sw_max_types = numpy.ones((self.nMaterialTypes,),'d') - Sw_min_types = old_div(thetaR_types,thetaS_types) + Sw_min_types = thetaR_types/thetaS_types #mwf debug #import pdb #pdb.set_trace() @@ -4295,7 +4288,7 @@ def __init__(self, thetaS_types = thetaSR_types + thetaR_types Sw_max_types = numpy.ones((self.nMaterialTypes,),'d') - Sw_min_types = old_div(thetaR_types,thetaS_types) + Sw_min_types = thetaR_types/thetaS_types #mwf debug #import pdb #pdb.set_trace() @@ -4345,10 +4338,10 @@ def __init__(self, for input in [thetaR_types,thetaSR_types]: assert len(input)==self.nMaterialTypes - vgm_m_types = 1.0-old_div(1.0,vgm_n_types) + vgm_m_types = 1.0-1.0/vgm_n_types thetaS_types = thetaSR_types + thetaR_types Sw_max_types = numpy.ones((self.nMaterialTypes,),'d') - Sw_min_types = old_div(thetaR_types,thetaS_types) + Sw_min_types = thetaR_types/thetaS_types #mwf debug #import pdb #pdb.set_trace() @@ -4401,10 +4394,10 @@ def __init__(self, for input in [vgm_n_types,vgm_alpha_types,thetaR_types,thetaSR_types]: assert len(input)==self.nMaterialTypes - vgm_m_types = 1.0-old_div(1.0,vgm_n_types) + vgm_m_types = 1.0-1.0/vgm_n_types thetaS_types = thetaSR_types + thetaR_types Sw_max_types = numpy.ones((self.nMaterialTypes,),'d') - Sw_min_types = old_div(thetaR_types,thetaS_types) + Sw_min_types = thetaR_types/thetaS_types #mwf debug #import pdb #pdb.set_trace() @@ -4461,10 +4454,10 @@ def __init__(self, for input in [vgm_n_types,vgm_alpha_types,thetaR_types,thetaSR_types]: assert len(input)==self.nMaterialTypes - vgm_m_types = 1.0-old_div(1.0,vgm_n_types) + vgm_m_types = 1.0-1.0/vgm_n_types thetaS_types = thetaSR_types + thetaR_types Sw_max_types = numpy.ones((self.nMaterialTypes,),'d') - Sw_min_types = old_div(thetaR_types,thetaS_types) + Sw_min_types = thetaR_types/thetaS_types #mwf debug #import pdb #pdb.set_trace() @@ -4856,4 +4849,3 @@ def evaluate(self,t,c): c[('df',ci,ci)], c[('a',ci,ci)]) - diff --git a/proteus/TimeIntegration.py b/proteus/TimeIntegration.py index d179ff1e39..64db42bc1d 100644 --- a/proteus/TimeIntegration.py +++ b/proteus/TimeIntegration.py @@ -4,14 +4,6 @@ .. inheritance-diagram:: proteus.TimeIntegration :parts: 1 """ -from __future__ import print_function -from __future__ import absolute_import -from __future__ import division -from builtins import zip -from builtins import str -from builtins import range -from past.utils import old_div -from builtins import object from .LinearAlgebraTools import * import sys,math from . import Profiling @@ -316,7 +308,7 @@ def updateTimeHistory(self,resetFromDOF=False): self.m_ip_last[ci].flat[:] = self.m_ip_tmp[ci].flat def calculateCoefs(self): #for bdf interface - dtInv = old_div(1.0,self.dt) + dtInv = 1.0/self.dt self.alpha_bdf = dtInv for ci in list(self.m_last.keys()): self.beta_bdf[ci].flat[:] = self.m_last[ci].flat @@ -342,10 +334,10 @@ def choose_dt(self): if ci in self.cfl: maxCFL=max(maxCFL,globalMax(self.cfl[ci].max())) #print "mac cfl component ci",maxCFL,ci - self.dt = old_div(self.runCFL,maxCFL) + self.dt = self.runCFL/maxCFL if self.dtLast is None: self.dtLast = self.dt - if old_div(self.dt,self.dtLast) > self.dtRatioMax: + if self.dt/self.dtLast > self.dtRatioMax: self.dt = self.dtLast*self.dtRatioMax self.t = self.tLast + self.dt def initialize_dt(self,t0,tOut,q): @@ -753,10 +745,10 @@ def choose_dt(self): for ci in range(self.nc): if ci in self.cfl: maxCFL=max(maxCFL,globalMax(self.cfl[ci].max())) - self.dt = old_div(self.runCFL,maxCFL) + self.dt = self.runCFL/maxCFL if self.dtLast is None: self.dtLast = self.dt - if old_div(self.dt,self.dtLast) > self.dtRatioMax: + if self.dt/self.dtLast > self.dtRatioMax: self.dt = self.dtLast*self.dtRatioMax self.t = self.tLast + self.dt def initialize_dt(self,t0,tOut,q): @@ -934,10 +926,10 @@ def choose_dt(self): for ci in range(self.nc): if ci in self.cfl: maxCFL=max(maxCFL,globalMax(self.cfl[ci].max())) - self.dt = old_div(self.runCFL,maxCFL) + self.dt = self.runCFL/maxCFL if self.dtLast is None: self.dtLast = self.dt - if old_div(self.dt,self.dtLast) > self.dtRatioMax: + if self.dt/self.dtLast > self.dtRatioMax: self.dt = self.dtLast*self.dtRatioMax self.t = self.tLast + self.dt def updateStage(self): @@ -1133,10 +1125,10 @@ def choose_dt(self): if ci in self.cfl: maxCFL=globalMax(self.cfl[ci].max()) #end has key - self.dt = old_div(self.runCFL,maxCFL) + self.dt = self.runCFL/maxCFL if self.dtLast is None: self.dtLast = self.dt - if old_div(self.dt,self.dtLast) > self.dtRatioMax: + if self.dt/self.dtLast > self.dtRatioMax: self.dt = self.dtLast*self.dtRatioMax self.t = self.tLast + self.dt def updateTimeHistory(self,resetFromDOF=False): @@ -1287,10 +1279,10 @@ def choose_dt(self): for ci in range(self.nc): if ci in self.cfl: maxCFL=max(maxCFL,globalMax(self.cfl[ci].max())) - self.dt = old_div(self.runCFL,maxCFL) + self.dt = self.runCFL/maxCFL if self.dtLast is None: self.dtLast = self.dt - if old_div(self.dt,self.dtLast) > self.dtRatioMax: + if self.dt/self.dtLast > self.dtRatioMax: self.dt = self.dtLast*self.dtRatioMax self.t = self.tLast + self.dt def updateTimeHistory(self,resetFromDOF=False): @@ -1545,7 +1537,7 @@ def computeErrorEstimate(self): #import pdb #pdb.set_trace() if self.timeOrder == 2: - r = old_div(self.dt,self.dt_history[0]) + r = self.dt/self.dt_history[0] for ci in list(self.mt_tmp.keys()): self.error_estimate[ci].flat[:] = self.m_history[1][ci].flat self.error_estimate[ci] *= r @@ -1553,7 +1545,7 @@ def computeErrorEstimate(self): self.work[ci] *= -(1.0+r) self.error_estimate[ci] += self.work[ci] self.error_estimate[ci] += self.m_tmp[ci] - self.error_estimate[ci] *= old_div(r,(1.0+r)) + self.error_estimate[ci] *= r/(1.0+r) # else: for ci in list(self.mt_tmp.keys()): @@ -1574,9 +1566,9 @@ def calculatePredictor(self): def calculateCoefs(self): if self.needToCalculateBDFCoefs: - dtInv = old_div(1.0,self.dt) + dtInv = 1.0/self.dt if self.timeOrder == 2: - r = old_div(self.dt,self.dt_history[0]) + r = self.dt/self.dt_history[0] self.alpha_bdf = (1.0+2.0*r)/(1.0+r)*dtInv b0 =-(1.0+r)*dtInv @@ -2026,10 +2018,10 @@ def choose_dt(self): self.transport.q[('dH',ci,ci)], self.transport.q[('cfl',ci)]) maxCFL=max(globalMax(self.cfl[ci].max()),maxCFL) - self.dt = old_div(self.runCFL,maxCFL) + self.dt = self.runCFL/maxCFL if self.dtLast is None: self.dtLast = self.dt - if old_div(self.dt,self.dtLast) > self.dtRatioMax: + if self.dt/self.dtLast > self.dtRatioMax: self.dt = self.dtLast*self.dtRatioMax self.generateSubsteps([self.tLast+self.dt]) self.t = self.substeps[0] @@ -2188,13 +2180,13 @@ def setCoefficients(self): elif stages == 2: self.alpha[1,0] = 0.5; self.alpha[1,1] = 0.5 elif stages == 3: - self.alpha[2,0] = old_div(1.,3.); self.alpha[2,1] = old_div(1.,2.); self.alpha[2,2] = old_div(1.,6.) + self.alpha[2,0] = 1./3.; self.alpha[2,1] = 1./2.; self.alpha[2,2] = 1./6. elif stages == 4: - self.alpha[3,0] = old_div(3.,8.); self.alpha[3,1] = old_div(1.,3.); self.alpha[3,2] = old_div(1.,4.); - self.alpha[3,3] = old_div(1.,24.); + self.alpha[3,0] = 3./8.; self.alpha[3,1] = 1./3.; self.alpha[3,2] = 1./4.; + self.alpha[3,3] = 1./24.; elif stages == 5: - self.alpha[4,0] = old_div(11.,30.); self.alpha[4,1] = old_div(3.,8.); self.alpha[4,2] = old_div(1.,6.); - self.alpha[4,3] = old_div(1.,12.); self.alpha[4,4] = old_div(1.,120.) + self.alpha[4,0] = 11./30.; self.alpha[4,1] = 3./8.; self.alpha[4,2] = 1./6.; + self.alpha[4,3] = 1./12.; self.alpha[4,4] = 1./120. # self.beta = numpy.zeros((stages,stages),'d') for l in range(stages-1): @@ -2300,7 +2292,7 @@ def setCoefficients(self): self.alpha[0,0] = 1.0; self.alpha[1,0] = 0.5; self.alpha[1,1] = 0.5 elif order == 3: self.alpha[0,0] = 1.0; self.alpha[1,0] = 0.75; self.alpha[1,1] = 0.25; - self.alpha[2,0] = old_div(1.,3.); self.alpha[2,1] = 0.0; self.alpha[2,2] = old_div(2.,3.) + self.alpha[2,0] = 1./3.; self.alpha[2,1] = 0.0; self.alpha[2,2] = 2./3. self.beta = numpy.zeros((stages,stages),'d') if order == 1: @@ -2308,7 +2300,7 @@ def setCoefficients(self): elif order == 2: self.beta[0,0] = 1.0; self.beta[1,1] = 0.5 elif order == 3: - self.beta[0,0] = 1.0; self.beta[1,1] = 0.25; self.beta[2,2] = old_div(2.0,3.0) + self.beta[0,0] = 1.0; self.beta[1,1] = 0.25; self.beta[2,2] = 2.0/3.0 # #1st order t = [t^{n+1}] #2nd order t = [t^{n+1},t^{n+1}] @@ -2573,8 +2565,7 @@ def projectToLimitedSpace(self,solndofs,ci=0): x0 = self.mesh.nodeArray[self.mesh.elementNodesArray[eN,0],0] x1 = self.mesh.nodeArray[self.mesh.elementNodesArray[eN,1],0] dx = x1-x0; du = solndofs[self.l2gSolution[ci][eN,1]]-solndofs[self.l2gSolution[ci][eN,0]] - uBar = old_div((solndofs[self.l2gSolution[ci][eN,0]] + solndofs[self.l2gSolution[ci][eN,1]] + - 4.0*solndofs[self.l2gSolution[ci][eN,2]]),6.0) #simpson's rule + uBar = (solndofs[self.l2gSolution[ci][eN,0]]+solndofs[self.l2gSolution[ci][eN,1]]+4.0*solndofs[self.l2gSolution[ci][eN,2]])/6.0 #simpson's rule xbar = self.mesh.elementBarycentersArray[eN,0] self.ulim[ci].dof[self.l2gLimiting[ci][eN,0]] = uBar + (x0-xbar)*du/dx self.ulim[ci].dof[self.l2gLimiting[ci][eN,1]] = uBar + (x1-xbar)*du/dx @@ -2817,10 +2808,10 @@ def initializeMeshInfo(self,verbose=0): #try each local interpolant for ebN in range(self.mesh.nElementBoundaries_element): ebN_1 = int(fmod(ebN+1,self.mesh.nElementBoundaries_element)) - xbar_ebN = old_div((self.mesh.elementBarycentersArray[eN].flat+xbar[ebN].flat+xbar[ebN_1].flat),3.0) + xbar_ebN = (self.mesh.elementBarycentersArray[eN].flat+xbar[ebN].flat+xbar[ebN_1].flat)/3.0 gradU.flat[:] = uEn*self.elementNeighborShapeGradients[eN,ebN,0,:]+ubar[ebN]*self.elementNeighborShapeGradients[eN,ebN,1,:]\ +ubar[ebN_1]*self.elementNeighborShapeGradients[eN,ebN,2,:] - uout = old_div((uEn+ubar[ebN]+ubar[ebN_1]),3.0) + gradU[0]*(x[0]-xbar_ebN[0])+gradU[1]*(x[1]-xbar_ebN[1]) + uout = (uEn+ubar[ebN]+ubar[ebN_1])/3.0 + gradU[0]*(x[0]-xbar_ebN[0])+gradU[1]*(x[1]-xbar_ebN[1]) uex = 3.0*x[0] + 2.0*x[1] assert abs(uout-uex) < 1.0e-4, "mistake eN=%d nN=%d ebN=%d uout=%s uex=%g " % (eN,nN,ebN,uout,uex) #ebN @@ -2979,7 +2970,7 @@ def applySlopeLimiting(self,uIn,uDofOut): #for debugging uavIn = 0.0; uavgOut = 0.0 for eN in range(self.mesh.nElements_global): - uBar = old_div((uDofIn[l2g[eN,0]]+uDofIn[l2g[eN,1]]+uDofIn[l2g[eN,2]]),3.0) #P1 2d + uBar = (uDofIn[l2g[eN,0]]+uDofIn[l2g[eN,1]]+uDofIn[l2g[eN,2]])/3.0 #P1 2d uavgIn = uBar deltaU.fill(0.0) tdeltaU.fill(0.0) @@ -2991,8 +2982,8 @@ def applySlopeLimiting(self,uIn,uDofOut): ip2= int(fmod(i+2,self.mesh.nElementBoundaries_element)) uM[i] = 0.5*(uDofIn[l2g[eN,ip1]]+uDofIn[l2g[eN,ip2]]) eN1 = self.alphaNeighbors[eN,i,0]; eN2 = self.alphaNeighbors[eN,i,1] - uBar1 = old_div((uDofIn[l2g[eN1,0]]+uDofIn[l2g[eN1,1]]+uDofIn[l2g[eN1,2]]),3.0) #P1 2d - uBar2 = old_div((uDofIn[l2g[eN2,0]]+uDofIn[l2g[eN2,1]]+uDofIn[l2g[eN2,2]]),3.0) #P1 2d + uBar1 = (uDofIn[l2g[eN1,0]]+uDofIn[l2g[eN1,1]]+uDofIn[l2g[eN1,2]])/3.0 #P1 2d + uBar2 = (uDofIn[l2g[eN2,0]]+uDofIn[l2g[eN2,1]]+uDofIn[l2g[eN2,2]])/3.0 #P1 2d dUi = self.alphas[eN,i,0]*(uBar1-uBar)+self.alphas[eN,i,1]*(uBar2-uBar) deltaU[i],tag_eN[i] = self.limiter(uM[i]-uBar,self.nu*dUi) tdeltaU[i] = deltaU[i] @@ -3003,7 +2994,7 @@ def applySlopeLimiting(self,uIn,uDofOut): posi = [max(0.0,deltaU[i]) for i in range(self.mesh.nElementBoundaries_element)] negi = [max(0.0,-deltaU[i]) for i in range(self.mesh.nElementBoundaries_element)] pos = sum(posi); neg = sum(negi) - thp= min(1.,old_div(neg,(pos+1.0e-8))); thm = min(1.0,old_div(pos,(neg+1.0e-8))) + thp= min(1.,neg/(pos+1.0e-8)); thm = min(1.0,pos/(neg+1.0e-8)) for i in range(self.mesh.nElementBoundaries_element): tdeltaU[i] = thp*posi[i] - thm*negi[i] tag_eN[i]=1 @@ -3019,7 +3010,7 @@ def applySlopeLimiting(self,uIn,uDofOut): uDofOut[ci][l2g[eN,i]] = uMlim[ip1]+uMlim[ip2]-uMlim[i] #i #for debugging - uavgOut = old_div((uDofOut[ci][l2g[eN,0]]+uDofOut[ci][l2g[eN,1]]+uDofOut[ci][l2g[eN,2]]),3.0) + uavgOut = (uDofOut[ci][l2g[eN,0]]+uDofOut[ci][l2g[eN,1]]+uDofOut[ci][l2g[eN,2]])/3.0 assert abs(uavgOut-uavgIn) < 1.0e-6, "eN=%d uavgOut=%s uavgIn=%s" % (eN,uavgOut,uavgIn) #eN #end else @@ -3891,7 +3882,7 @@ def calculateSolution(self,tIn,tOut): if nssteps == 0: res0 = solver.norm_r res = solver.norm_r - ssError = old_div(res,(res0*self.steadyStateRtol + self.steadyStateAtol)) + ssError = res/(res0*self.steadyStateRtol+self.steadyStateAtol) converged = ssError < 1.0 #mwf hack #converged = False @@ -3936,7 +3927,7 @@ def calculateSolution(self,tIn,tOut): if nssteps == 0: res0 = self.mlNL.solverList[-1].norm_r res = self.mlNL.solverList[-1].norm_r - ssError = old_div(res,(res0*self.steadyStateRtol + self.steadyStateAtol)) + ssError = res/(res0*self.steadyStateRtol+self.steadyStateAtol) converged = ssError < 1.0 #mwf hack #converged = False @@ -4156,7 +4147,7 @@ def updateTimeHistory(self,resetFromDOF=False): self.mt1_last[ci].flat[:] = self.mt1_tmp[ci].flat def calculateCoefs(self): #for bdf interface - dtInv = old_div(1.0,self.dt**2) + dtInv = 1.0/self.dt**2 self.alpha_bdf = dtInv for ci in list(self.m_last.keys()): self.beta_bdf[ci].flat[:] = self.m_last[ci].flat diff --git a/proteus/Transport.py b/proteus/Transport.py index 027e16fbe5..1dda63a5b1 100644 --- a/proteus/Transport.py +++ b/proteus/Transport.py @@ -9,15 +9,7 @@ .. inheritance-diagram:: proteus.Transport :parts: 1 """ -from __future__ import absolute_import -from __future__ import division -from builtins import str -from builtins import zip -from builtins import range -from builtins import object -from past.utils import old_div from math import * - from .EGeometry import * from .LinearAlgebraTools import * from .LinearSolvers import * @@ -1586,14 +1578,14 @@ def findReferenceComponent_phi(diffusion): if 'penalty' in self.ebq_global: for ebN in range(self.mesh.nElementBoundaries_global): for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebq_global['penalty'][ebN,k] = old_div(self.numericalFlux.penalty_constant,(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power)) + self.ebq_global['penalty'][ebN,k] = self.numericalFlux.penalty_constant/(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) #penalty term #cek move to Numerical flux initialization if 'penalty' in self.ebqe: for ebNE in range(self.mesh.nExteriorElementBoundaries_global): ebN = self.mesh.exteriorElementBoundariesArray[ebNE] for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebqe['penalty'][ebNE,k] = old_div(self.numericalFlux.penalty_constant,self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) + self.ebqe['penalty'][ebNE,k] = self.numericalFlux.penalty_constant/self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power logEvent(memory("numericalFlux","OneLevelTransport"),level=4) self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray #use post processing tools to get conservative fluxes, None by default @@ -3655,7 +3647,7 @@ def calculateElementQuadrature(self): if self.tLast_mesh is not None: self.q['xt'][:]=self.q['x'] self.q['xt']-=self.q['x_last'] - alpha = old_div(1.0,(self.t_mesh - self.tLast_mesh)) + alpha = 1.0/(self.t_mesh-self.tLast_mesh) self.q['xt']*=alpha else: self.q['xt'][:]=0.0 @@ -3831,7 +3823,7 @@ def calculateElementBoundaryQuadrature(self): if self.tLast_mesh is not None: self.ebq['xt'][:]=self.ebq['x'] self.ebq['xt']-=self.ebq['x_last'] - alpha = old_div(1.0,(self.t_mesh - self.tLast_mesh)) + alpha = 1.0/(self.t_mesh-self.tLast_mesh) self.ebq['xt']*=alpha else: self.ebq['xt'][:]=0.0 @@ -4060,7 +4052,7 @@ def calculateExteriorElementBoundaryQuadrature(self): if self.tLast_mesh is not None: self.ebqe['xt'][:]=self.ebqe['x'] self.ebqe['xt']-=self.ebqe['x_last'] - alpha = old_div(1.0,(self.t_mesh - self.tLast_mesh)) + alpha = 1.0/(self.t_mesh-self.tLast_mesh) self.ebqe['xt']*=alpha else: self.ebqe['xt'][:]=0.0 @@ -4817,7 +4809,7 @@ def viewSolution(self,plotOffSet=None,titleModifier='',dgridnx=50,dgridny=50,dgr L = min((max(self.mesh.nodeArray[:,0]),max(self.mesh.nodeArray[:,1]))) scale=10.0*max((scale_x,scale_y,1.0e-16))/L for x,y,u,v in zip(self.mesh.nodeArray[:,0],self.mesh.nodeArray[:,1],self.u[self.coefficients.vectorComponents[0]].dof,self.u[self.coefficients.vectorComponents[1]].dof): - Viewers.datFile.write("%12.5e %12.5e %12.5e %12.5e \n" % (x,y,old_div(u,scale),old_div(v,scale))) + Viewers.datFile.write("%12.5e %12.5e %12.5e %12.5e \n" % (x,y,u/scale,v/scale)) Viewers.datFile.write("\n \n") cmd = "set term x11 %i; plot \'%s\' index %i with vectors title \"%s\" \n" % (Viewers.windowNumber, Viewers.datFilename, @@ -4828,7 +4820,7 @@ def viewSolution(self,plotOffSet=None,titleModifier='',dgridnx=50,dgridny=50,dgr Viewers.newPlot() Viewers.newWindow() elif self.nSpace_global == 3: - (slice_x,slice_y,slice_z) = self.mesh.nodeArray[old_div(self.mesh.nodeArray.shape[0],2),:] + (slice_x,slice_y,slice_z) = self.mesh.nodeArray[self.mesh.nodeArray.shape[0]//2,:] for ci in range(self.coefficients.nc): if (isinstance(self.u[ci].femSpace,C0_AffineLinearOnSimplexWithNodalBasis) or isinstance(self.u[ci].femSpace,C0_AffineQuadraticOnSimplexWithNodalBasis)): @@ -5244,7 +5236,7 @@ def viewSolutionVTK(self,plotOffSet=None,titleModifier='',dgridnx=50,dgridny=50, Viewers.newPlot() Viewers.newWindow() elif self.nSpace_global == 3: - (slice_x,slice_y,slice_z) = self.mesh.nodeArray[old_div(self.mesh.nodeArray.shape[0],2),:] + (slice_x,slice_y,slice_z) = self.mesh.nodeArray[self.mesh.nodeArray.shape[0]//2,:] for ci in range(self.coefficients.nc): title = self.coefficients.variableNames[ci]+titleModifier if isinstance(self.u[ci].femSpace,C0_AffineLinearOnSimplexWithNodalBasis): @@ -5382,8 +5374,8 @@ def write_ebq_velocity_Ensight(self,filename,nOutput,append=False,firstVariable= vmax =max(self.q[('velocity',0)].flat)+1.0e-8 for eN in range(self.mesh.nElements_global): for k in range(self.nQuadraturePoints_element): - uOut.write('%12.5e%12.5e%12.5e' % (old_div(self.q[('velocity',0)][eN,k,0],vmax), - old_div(self.q[('velocity',0)][eN,k,1],vmax), + uOut.write('%12.5e%12.5e%12.5e' % (self.q[('velocity',0)][eN,k,0]/vmax, + self.q[('velocity',0)][eN,k,1]/vmax, 0.0)) if n%2==1: uOut.write('\n') diff --git a/proteus/TransportCoefficients.py b/proteus/TransportCoefficients.py index d3fd1a5d3d..4137bb3d4b 100644 --- a/proteus/TransportCoefficients.py +++ b/proteus/TransportCoefficients.py @@ -7,13 +7,6 @@ .. inheritance-diagram:: proteus.TransportCoefficients :parts: 1 """ -from __future__ import print_function -from __future__ import absolute_import -from __future__ import division -from builtins import zip -from builtins import range -from builtins import object -from past.utils import old_div from math import * from warnings import warn import numpy @@ -268,7 +261,7 @@ def allocateDummyCoefficients(self,c=None,nPoints=101,uMax=1.0,uMin=0.0,nSpace=1 ctemp = {} for ci in range(self.nc): ctemp[('u',ci)] = numpy.zeros(nPoints,'d') - delta_u = old_div((uMax-uMin),float(nPoints-1)) + delta_u = (uMax-uMin)/(nPoints-1) for i in range(nPoints): ctemp[('u',ci)] = i*delta_u + uMin for ci,cjDict in self.mass.items(): @@ -302,7 +295,7 @@ def allocateDummyCoefficients(self,c=None,nPoints=101,uMax=1.0,uMin=0.0,nSpace=1 for ci in range(self.nc): uMin = min(c[('u',ci)].flat) uMax = max(c[('u',ci)].flat) - delta_u = old_div((uMax-uMin),float(nPoints-1)) + delta_u = (uMax-uMin)/(nPoints-1) for i in range(nPoints): ctemp[('u',ci)].flat[i]=i*delta_u+uMin return ctemp @@ -2741,9 +2734,9 @@ def initializeElementQuadrature(self,t,cq): y = cq['x'].flat[i*3+1] u =x-0.5 v =y-0.5 - self.q_phi_s.flat[i] = math.sqrt(u**2 + v**2) - old_div(0.25,2.0) - self.q_n_s.flat[2*i+0] = old_div(u,math.sqrt(u**2 + v**2)) - self.q_n_s.flat[2*i+1] = old_div(v,math.sqrt(u**2 + v**2)) + self.q_phi_s.flat[i] = math.sqrt(u**2 + v**2) - 0.25/2.0 + self.q_n_s.flat[2*i+0] = u/math.sqrt(u**2+v**2) + self.q_n_s.flat[2*i+1] = v/math.sqrt(u**2+v**2) else: try: self.defaultSolidProfile(t,cq['x'],self.q_phi_s,self.q_n_s) @@ -2774,9 +2767,9 @@ def initializeElementBoundaryQuadrature(self,t,cebq,cebq_global): y = cebq['x'].flat[i*3+1] u =x-0.5 v =y-0.5 - self.ebq_phi_s.flat[i] = math.sqrt(u**2 + v**2) - old_div(0.25,2.0) - self.ebq_n_s.flat[2*i+0] = old_div(u,math.sqrt(u**2 + v**2)) - self.ebq_n_s.flat[2*i+1] = old_div(v,math.sqrt(u**2 + v**2)) + self.ebq_phi_s.flat[i] = math.sqrt(u**2 + v**2) - 0.25/2.0 + self.ebq_n_s.flat[2*i+0] = u/math.sqrt(u**2+v**2) + self.ebq_n_s.flat[2*i+1] = v/math.sqrt(u**2+v**2) else: try: self.defaultSolidProfile(t,cebq['x'],self.ebq_phi_s,self.ebq_n_s) @@ -2807,9 +2800,9 @@ def initializeGlobalExteriorElementBoundaryQuadrature(self,t,cebqe): y = cebqe['x'].flat[i*3+1] u =x-0.5 v =y-0.5 - self.ebqe_phi_s.flat[i] = math.sqrt(u**2 + v**2) - old_div(0.25,2.0) - self.ebqe_n_s.flat[2*i+0] = old_div(u,math.sqrt(u**2 + v**2)) - self.ebqe_n_s.flat[2*i+1] = old_div(v,math.sqrt(u**2 + v**2)) + self.ebqe_phi_s.flat[i] = math.sqrt(u**2 + v**2) - 0.25/2.0 + self.ebqe_n_s.flat[2*i+0] = u/math.sqrt(u**2+v**2) + self.ebqe_n_s.flat[2*i+1] = v/math.sqrt(u**2+v**2) else: try: self.defaultSolidProfile(t,cebqe['x'],self.ebqe_phi_s,self.ebqe_n_s) @@ -4436,7 +4429,7 @@ def evaluate(self,t,c): if c[('f',0)].shape[2] == 2: volFact =0.5 elif c[('f',0)].shape[2] == 3: - volFact = old_div(1.,6.) + volFact = 1./6. for eN in range(c[('dV_u',0)].shape[0]): vol = 0.0; for k in range(c[('dV_u',0)].shape[1]): @@ -4782,27 +4775,27 @@ def evaluate(self,t,c): def VGM_to_BCB_Simple(vgm_alpha,vgm_n): bcb_lambda = vgm_n-1 - bcb_pd = old_div(1.0,vgm_alpha) + bcb_pd = 1.0/vgm_alpha return (bcb_lambda,bcb_pd) def BCB_to_VGM_Simple(bcb_pd,bcb_lambda): vgm_n = bcb_lambda + 1 - vgm_alpha = old_div(1.0,bcb_pd) + vgm_alpha = 1.0/bcb_pd return (vgm_alpha,vgm_n) def VGM_to_BCB_Johns(vgm_alpha,vgm_n): - vgm_m = 1.0 - old_div(1.0,vgm_n) - bcb_lambda = vgm_m/(1.0-vgm_m)*(1.0-(0.5)**(old_div(1.0,vgm_m))) + vgm_m = 1.0 - 1.0/vgm_n + bcb_lambda = vgm_m/(1.0-vgm_m)*(1.0-(0.5)**(1.0/vgm_m)) thetaStar=0.72-0.35*exp(-vgm_n**4); - bcb_pd = (thetaStar**(old_div(1.0,bcb_lambda)))/vgm_alpha*(thetaStar**(old_div(-1.0,vgm_m))-1.0)**( 1.0-vgm_m) + bcb_pd = (thetaStar**(1.0/bcb_lambda))/vgm_alpha*(thetaStar**(-1.0/vgm_m)-1.0)**( 1.0-vgm_m) return (bcb_lambda,bcb_pd) def VGM_to_BCB_MorelSeytoux(vgm_alpha,vgm_n): - vgm_m = 1.0 - old_div(1.0,vgm_n) - p = 1.0 + old_div(2.0,vgm_m) - bcb_pd = ((old_div(1.0,vgm_alpha))* - (old_div((p+3.0),((2.0*p)*(p-1.0))))* - (old_div((147.8 + 8.1*p + 0.092*p**2),(55.6+7.4*p+p**2)))) - bcb_lambda = old_div(2.0,(p-3.0)) + vgm_m = 1.0 - 1.0/vgm_n + p = 1.0 + 2.0/vgm_m + bcb_pd = ((1.0/vgm_alpha)* + ((p+3.0)/((2.0*p)*(p-1.0)))* + ((147.8+8.1*p+0.092*p**2)/(55.6+7.4*p+p**2))) + bcb_lambda = 2.0/(p-3.0) return (bcb_lambda,bcb_pd) from .ctransportCoefficients import conservativeHeadRichardsBrooksCoreyBurdineHomEvaluate @@ -9608,7 +9601,7 @@ class DiffusiveWave_1D(TC_base): This implements the regularized formulation in M. Santillana's thesis (ref). """ - def __init__(self,alpha=old_div(5.0,3.0),gamma=0.5,epsilon=1.0e-6,bathymetryFunc=None, reactionFunc=None, analyticalSoln=None): + def __init__(self,alpha=5.0/3.0,gamma=0.5,epsilon=1.0e-6,bathymetryFunc=None, reactionFunc=None, analyticalSoln=None): """ Construct a coefficients object given the parameters of the Manning/Chezy formula and the regularization parameter. @@ -9715,7 +9708,7 @@ class DiffusiveWave_2D(TC_base): This implements the regularized formulation in M. Santillana's thesis (ref). """ - def __init__(self,nd=2,alpha=old_div(5.0,3.0),gamma=0.5,epsilon=1.0e-6,bathymetryFunc=None, bathymetryGradientFunc=None): + def __init__(self,nd=2,alpha=5.0/3.0,gamma=0.5,epsilon=1.0e-6,bathymetryFunc=None, bathymetryGradientFunc=None): """ Construct a coefficients object given the parameters of the Manning/Chezy formula and the regularization parameter. @@ -10063,4 +10056,4 @@ def evaluate(self,t,c): c[('df',2,3)], c[('df',3,1)], c[('df',3,2)], - c[('df',3,3)]) + c[('df',3,3)]) \ No newline at end of file diff --git a/proteus/TwoPhaseFlow/TwoPhaseFlowProblem.py b/proteus/TwoPhaseFlow/TwoPhaseFlowProblem.py index 475b50de6e..bbd36dea64 100644 --- a/proteus/TwoPhaseFlow/TwoPhaseFlowProblem.py +++ b/proteus/TwoPhaseFlow/TwoPhaseFlowProblem.py @@ -1,11 +1,8 @@ -from __future__ import division -from past.utils import old_div from proteus import FemTools as ft from proteus import MeshTools as mt from proteus import SplitOperator from proteus.Archiver import ArchiveFlags from proteus.Profiling import logEvent -from builtins import object from proteus.TwoPhaseFlow.utils import Parameters from proteus.defaults import System_base import collections @@ -231,7 +228,7 @@ def setOutputStepping(self): # COMPUTE dt_init # self.dt_init = min(self.dt_output, self.dt_init) if self.nDTout is None: - self.nDTout = int(round(old_div(self.final_time, self.dt_output))) + self.nDTout = int(round(self.final_time/self.dt_output)) else: self.dt_output = float(self.final_time)/float(self.nDTout) # diff --git a/proteus/TwoPhaseFlow/documentation/example/risingBubble.py b/proteus/TwoPhaseFlow/documentation/example/risingBubble.py index 4dd867a63e..82488cfe06 100644 --- a/proteus/TwoPhaseFlow/documentation/example/risingBubble.py +++ b/proteus/TwoPhaseFlow/documentation/example/risingBubble.py @@ -1,8 +1,6 @@ """ Rising Bubble Benchmarks """ -from __future__ import division -from past.utils import old_div import numpy as np from proteus import (Domain, Context, MeshTools as mt) @@ -68,9 +66,9 @@ domain.writePoly("mesh") domain.writePLY("mesh") domain.writeAsymptote("mesh") - he = old_div(tank_dim[0], float(4 * refinement - 1)) + he = tank_dim[0]/float(4*refinement-1) domain.MeshOptions.he = he - domain.MeshOptions.triangleOptions = "VApq30Dena%8.8f" % (old_div((he ** 2), 2.0),) + domain.MeshOptions.triangleOptions = "VApq30Dena%8.8f" % ((he**2)/2.0,) # ****************************** # # ***** INITIAL CONDITIONS ***** # diff --git a/proteus/TwoPhaseFlow/utils/Parameters.py b/proteus/TwoPhaseFlow/utils/Parameters.py index 03c4082c7f..cef30abb0e 100644 --- a/proteus/TwoPhaseFlow/utils/Parameters.py +++ b/proteus/TwoPhaseFlow/utils/Parameters.py @@ -1,6 +1,3 @@ -from __future__ import division -from past.utils import old_div -from builtins import object import numpy as np from petsc4py import PETSc from proteus.Profiling import logEvent diff --git a/proteus/TwophaseDarcyCoefficients.py b/proteus/TwophaseDarcyCoefficients.py index 00beb39fa3..e4dd60d690 100644 --- a/proteus/TwophaseDarcyCoefficients.py +++ b/proteus/TwophaseDarcyCoefficients.py @@ -4,12 +4,6 @@ .. inheritance-diagram:: proteus.TwophaseDarcyCoefficients :parts: 1 """ -from __future__ import print_function -from __future__ import absolute_import -from __future__ import division -from builtins import zip -from builtins import range -from past.utils import old_div from math import * from .TransportCoefficients import TC_base import numpy @@ -27,7 +21,7 @@ def __init__(self, psk_model='VGM', vg_alpha = 5.0, vg_m = 0.75, - bc_pd = old_div(1.0,5.47), + bc_pd = 1.0/5.47, bc_lambda = 0.5, omega = 1.0, Sw_max = 1.0, @@ -60,11 +54,11 @@ def __init__(self, self.Sw_min = Sw_min self.Sw_max = Sw_max #set fluid properies - self.b = old_div(rhon,rhow) #normalize density - self.rhon=old_div(rhon,rhon) - self.rhow=old_div(rhow,rhow) - self.muw=old_div(muw,muw) - self.mun=old_div(mun,muw) + self.b = rhon/rhow #normalize density + self.rhon=rhon/rhon + self.rhow=rhow/rhow + self.muw=muw/muw + self.mun=mun/muw #setup rwork arrays for homogeneous media, make heterogeneity later if self.psk_model == 'simp': self.len_rwork_psk=2 @@ -222,7 +216,7 @@ def __init__(self, psk_model='VGM', vg_alpha = 5.0, vg_m = 0.75, - bc_pd = old_div(1.0,5.47), + bc_pd = 1.0/5.47, bc_lambda = 0.5, omega = 1.0, Sw_max = 1.0, @@ -297,15 +291,15 @@ def __init__(self, ['rwork_density_w','rwork_density_n']): if params is not None: if params['model'] == 'Exponential': - setattr(self,rwork,numpy.array([old_div(params['rho_0'],params['rho_0']),#normalize by phase density + setattr(self,rwork,numpy.array([params['rho_0']/params['rho_0'],#normalize by phase density params['psi_0'], params['beta']],dtype='d')) elif params['model'] == 'IdealGas': setattr(self,rwork,numpy.array([params['T'], - old_div(params['W'],params['rho_0']),#normalize by phase density + params['W']/params['rho_0'],#normalize by phase density params['R'], params['headToPressure'], - old_div(params['rho_0'],params['rho_0']),#normalize by phase density + params['rho_0']/params['rho_0'],#normalize by phase density params['psi_0']],dtype='d')) else: assert False, 'TwophaseDarcy_fc density params= %s not found ' % params @@ -373,7 +367,7 @@ def __init__(self, psk_model='VGM', vg_alpha = 5.0, vg_m = 0.75, - bc_pd = old_div(1.0,5.47), + bc_pd = 1.0/5.47, bc_lambda = 0.5, omega = 1.0, Sw_max = 1.0, @@ -457,7 +451,7 @@ def initializeElementQuadrature(self,t,cq): #set up dummy values in case we're not running the other model self.q_s_w = numpy.zeros(cq[('u',0)].shape,'d') self.q_s_w[:] = self.swConstant - for i in range(old_div(len(self.q_s_w.flat),2),len(self.q_s_w.flat)): + for i in range(len(self.q_s_w.flat)//2,len(self.q_s_w.flat)): self.q_s_w.flat[i] = 1.0e-4 self.q_grad_psic = numpy.zeros(cq[('f',0)].shape,'d') self.q_psic = numpy.zeros(cq[('u',0)].shape,'d') @@ -469,7 +463,7 @@ def initializeElementBoundaryQuadrature(self,t,cebq,cebq_global): #set up dummy values in case we're not running the other model self.ebq_s_w = numpy.zeros(cebq[('u',0)].shape,'d') self.ebq_s_w[:]=self.swConstant - for i in range(old_div(len(self.ebq_s_w.flat),2),len(self.ebq_s_w.flat)): + for i in range(len(self.ebq_s_w.flat)//2,len(self.ebq_s_w.flat)): self.ebq_s_w.flat[i] = 1.0e-4 self.ebq_grad_psic = numpy.zeros(cebq[('f',0)].shape,'d') self.ebq_psic = numpy.zeros(cebq[('u',0)].shape,'d') @@ -484,7 +478,7 @@ def initializeGlobalExteriorElementBoundaryQuadrature(self,t,cebqe): #set up dummy values in case we're not running the other model self.ebqe_s_w = numpy.zeros(cebqe[('u',0)].shape,'d') self.ebqe_s_w[:]=self.swConstant - for i in range(old_div(len(self.ebqe_s_w.flat),2),len(self.ebqe_s_w.flat)): + for i in range(len(self.ebqe_s_w.flat)//2,len(self.ebqe_s_w.flat)): self.ebqe_s_w.flat[i] = 1.0e-4 self.ebqe_grad_psic = numpy.zeros(cebqe[('f',0)].shape,'d') self.ebqe_psic = numpy.zeros(cebqe[('u',0)].shape,'d') @@ -495,7 +489,7 @@ def initializeGeneralizedInterpolationPointQuadrature(self,t,cip): #set up dummy values in case we're not running the other model self.ip_s_w = numpy.zeros(cip[('u',0)].shape,'d') self.ip_s_w[:]=self.swConstant - for i in range(old_div(len(self.ip_s_w.flat),2),len(self.ip_s_w.flat)): + for i in range(len(self.ip_s_w.flat)//2,len(self.ip_s_w.flat)): self.ip_s_w.flat[i] = 1.0e-4 self.ip_grad_psic = numpy.zeros(cip[('f',0)].shape,'d') self.ip_psic = numpy.zeros(cip[('u',0)].shape,'d') @@ -563,7 +557,7 @@ def __init__(self, psk_model='VGM', vg_alpha = 5.0, vg_m = 0.75, - bc_pd = old_div(1.0,5.47), + bc_pd = 1.0/5.47, bc_lambda = 0.5, omega = 1.0, Sw_max = 1.0, @@ -702,4 +696,4 @@ def evaluate(self,t,c): c[('f',0)], c[('df',0,0)], c[('a',0,0)], - c[('da',0,0,0)]) + c[('da',0,0,0)]) \ No newline at end of file diff --git a/proteus/Viewers.py b/proteus/Viewers.py index df2bb80ee3..b95bab4723 100644 --- a/proteus/Viewers.py +++ b/proteus/Viewers.py @@ -9,13 +9,7 @@ .. inheritance-diagram:: proteus.Viewers :parts: 1 """ -from __future__ import print_function -from __future__ import absolute_import -from __future__ import division -from builtins import range -from builtins import object -from past.utils import old_div -import subprocess +import subprocess import numpy cmdFile=None @@ -256,7 +250,7 @@ def stepPlotExact(self,mlvt,tsim): newWindow() #end 2d elif vt.nSpace_global == 3: - (slice_x,slice_y,slice_z) = vt.mesh.nodeArray[old_div(vt.mesh.nodeArray.shape[0],2),:] + (slice_x,slice_y,slice_z) = vt.mesh.nodeArray[vt.mesh.nodeArray.shape[0]//2,:] for x in vt.mesh.nodeArray[:,:]: uex = self.p.analyticalSolution[ci].uOfXT(x,tsim) if x[0] == slice_x: @@ -350,7 +344,7 @@ def stepPlotExact(self,mlvt,tsim): for k in range(vt.nQuadraturePoints_element): xtmp = vt.q['x'][eN,k,:]; vtmp = v[eN,k,:] - self.datFile.write("%12.5e %12.5e \n" % (xtmp[0],old_div(vtmp[0],scale))) + self.datFile.write("%12.5e %12.5e \n" % (xtmp[0],vtmp[0]/scale)) cmd = "set term x11 %i; plot \'%s\' index %i with linespoints title \"%s\" \n" % (self.windowNumber(), self.datFilename, self.plotNumber(), @@ -375,7 +369,7 @@ def stepPlotExact(self,mlvt,tsim): xtmp = vt.q['x'][eN,k,:]; vtmp = v[eN,k,:] self.datFile.write("%12.5e %12.5e %12.5e %12.5e \n" % (xtmp[0],xtmp[1], - old_div(vtmp[0],scale),old_div(vtmp[1],scale))) + vtmp[0]/scale,vtmp[1]/scale)) self.datFile.write("\n \n") cmd = "set term x11 %i; plot \'%s\' index %i with vectors title \"%s\" \n" % (self.windowNumber(), self.datFilename, @@ -388,7 +382,7 @@ def stepPlotExact(self,mlvt,tsim): newWindow() elif vt.nSpace_global == 3: max_u = 0.0; max_v =0.0; max_w = 0.0; - (slice_x,slice_y,slice_z) = vt.mesh.nodeArray[old_div(vt.mesh.nodeArray.shape[0],2),:] + (slice_x,slice_y,slice_z) = vt.mesh.nodeArray[vt.mesh.nodeArray.shape[0]/2,:] for eN in range(vt.mesh.nElements_global): for k in range(vt.nQuadraturePoints_element): xtmp = vt.q['x'][eN,k,:]; @@ -405,7 +399,7 @@ def stepPlotExact(self,mlvt,tsim): vtmp = v[eN,k,:] if abs(xtmp[0]- slice_x) < vt.mesh.h: self.datFile.write("%12.5e %12.5e %12.5e %12.5e \n" % (xtmp[1],xtmp[2], - old_div(vtmp[1],scale),old_div(vtmp[2],scale))) + vtmp[1]/scale,vtmp[2]/scale)) self.datFile.write("\n \n") cmd = "set term x11 %i; plot \'%s\' index %i with vectors title \"%s\" \n" % (self.windowNumber(), self.datFilename, @@ -422,7 +416,7 @@ def stepPlotExact(self,mlvt,tsim): vtmp = v[eN,k,:] if abs(xtmp[1]- slice_y) < vt.mesh.h: self.datFile.write("%12.5e %12.5e %12.5e %12.5e \n" % (xtmp[0],xtmp[2], - old_div(vtmp[0],scale),old_div(vtmp[2],scale))) + vtmp[0]/scale,vtmp[2]/scale)) self.datFile.write("\n \n") cmd = "set term x11 %i; plot \'%s\' index %i with vectors title \"%s\" \n" % (self.windowNumber(), self.datFilename, @@ -439,7 +433,7 @@ def stepPlotExact(self,mlvt,tsim): vtmp = v[eN,k,:] if abs(xtmp[2]- slice_z) < vt.mesh.h: self.datFile.write("%12.5e %12.5e %12.5e %12.5e \n" % (xtmp[0],xtmp[1], - old_div(vtmp[0],scale),old_div(vtmp[1],scale))) + vtmp[0]/scale,vtmp[1]/scale)) self.datFile.write("\n \n") cmd = "set term x11 %i; plot \'%s\' index %i with vectors title \"%s\" \n" % (self.windowNumber(), self.datFilename, @@ -492,7 +486,7 @@ def stepPlotExact(self,mlvt,tsim): newPlot() newWindow() elif vt.nSpace_global == 3: - (slice_x,slice_y,slice_z) = vt.mesh.nodeArray[old_div(vt.mesh.nodeArray.shape[0],2),:] + (slice_x,slice_y,slice_z) = vt.mesh.nodeArray[vt.mesh.nodeArray.shape[0]/2,:] uci = vt.coefficients.vectorComponents[0]; vci = vt.coefficients.vectorComponents[1] wci = vt.coefficients.vectorComponents[2] plotVector = (uci in self.s.viewComponents and vci in self.s.viewComponents and @@ -650,7 +644,7 @@ def plotScalarElementQuantity(self,ckey,mlvt,tsim): newWindow() #end 2d elif vt.nSpace_global == 3: - (slice_x,slice_y,slice_z) = vt.mesh.nodeArray[old_div(vt.mesh.nodeArray.shape[0],2),:] + (slice_x,slice_y,slice_z) = vt.mesh.nodeArray[vt.mesh.nodeArray.shape[0]/2,:] for eN in range(vt.q['x'].shape[0]): for k in range(vt.q['x'].shape[1]): if vt.q['x'][eN,k,0] == slice_x: @@ -766,7 +760,7 @@ def plotVectorGlobalElementBoundaryQuantity(self,ckey,mlvt,tsim): xandu = [(vt.ebq_global['x'].flat[i*3+0],vt.ebq_global[ckey].flat[i]) for i in range(npoints)] xandu.sort() for xu in xandu: - self.datFile.write("%12.5e %12.5e \n" % (xu[0],old_div(xu[1],scale))) + self.datFile.write("%12.5e %12.5e \n" % (xu[0],xu[1]/scale)) self.datFile.write("\n \n") cmd = "set term x11 %i; plot \'%s\' index %i with linespoints title \"%s\" \n" % (self.windowNumber(), self.datFilename, @@ -788,7 +782,7 @@ def plotVectorGlobalElementBoundaryQuantity(self,ckey,mlvt,tsim): for k in range(vt.ebq_global[ckey].shape[1]): xtmp =vt.ebq_global['x'][ebN,k,:]; vtmp = vt.ebq_global[ckey][ebN,k,:] self.datFile.write("%12.5e %12.5e %12.5e %12.5e \n" % (xtmp[0],xtmp[1], - old_div(vtmp[0],scale),old_div(vtmp[1],scale))) + vtmp[0]/scale,vtmp[1]/scale)) self.datFile.write("\n \n") cmd = "set term x11 %i; plot \'%s\' index %i with vectors title \"%s\" \n" % (self.windowNumber(), self.datFilename, @@ -802,7 +796,7 @@ def plotVectorGlobalElementBoundaryQuantity(self,ckey,mlvt,tsim): #raw_input('simTools coef press return to continue\n') #end 2d elif vt.nSpace_global == 3: - (slice_x,slice_y,slice_z) = vt.mesh.nodeArray[old_div(vt.mesh.nodeArray.shape[0],2),:] + (slice_x,slice_y,slice_z) = vt.mesh.nodeArray[vt.mesh.nodeArray.shape[0]//2,:] max_u=max(numpy.absolute(numpy.take(vt.ebq_global[ckey],[0],2).flat)) max_v=max(numpy.absolute(numpy.take(vt.ebq_global[ckey],[1],2).flat)) max_w=max(numpy.absolute(numpy.take(vt.ebq_global[ckey],[2],2).flat)) @@ -817,7 +811,7 @@ def plotVectorGlobalElementBoundaryQuantity(self,ckey,mlvt,tsim): xtmp = vt.ebq_global['x'][ebN,k,:]; vtmp = vt.ebq_global[ckey][ebN,k,:] if abs(xtmp[0]-slice_x) < vt.mesh.h: self.datFile.write("%12.5e %12.5e %12.5e %12.5e \n" % (xtmp[1],xtmp[2], - old_div(vtmp[1],scale),old_div(vtmp[2],scale))) + vtmp[1]/scale,vtmp[2]/scale)) self.datFile.write("\n \n") cmd = "set term x11 %i; plot \'%s\' index %i with vectors title \"%s\" \n" % (self.windowNumber(), @@ -836,7 +830,7 @@ def plotVectorGlobalElementBoundaryQuantity(self,ckey,mlvt,tsim): xtmp = vt.ebq_global['x'][ebN,k,:]; vtmp = vt.ebq_global[ckey][ebN,k,:] if abs(xtmp[0]-slice_y) < vt.mesh.h: self.datFile.write("%12.5e %12.5e %12.5e %12.5e \n" % (xtmp[1],xtmp[2], - old_div(vtmp[1],scale),old_div(vtmp[2],scale))) + vtmp[1]/scale,vtmp[2]/scale)) self.datFile.write("\n \n") cmd = "set term x11 %i; plot \'%s\' index %i with vectors title \"%s\" \n" % (self.windowNumber(), @@ -854,7 +848,7 @@ def plotVectorGlobalElementBoundaryQuantity(self,ckey,mlvt,tsim): xtmp = vt.ebq_global['x'][ebN,k,:]; vtmp = vt.ebq_global[ckey][ebN,k,:] if abs(xtmp[0]-slice_z) < vt.mesh.h: self.datFile.write("%12.5e %12.5e %12.5e %12.5e \n" % (xtmp[1],xtmp[2], - old_div(vtmp[1],scale),old_div(vtmp[2],scale))) + vtmp[1]/scale,vtmp[2]/scale)) self.datFile.write("\n \n") cmd = "set term x11 %i; plot \'%s\' index %i with vectors title \"%s\" \n" % (self.windowNumber(), @@ -879,7 +873,7 @@ def plotVectorGlobalElementBoundaryQuantity(self,ckey,mlvt,tsim): scale = 1.0 npoints = vt.ebq_global['x'].shape[0]*vt.ebq_global['x'].shape[1] xvals = [vt.ebq_global['x'].flat[i*3+0] for i in range(npoints)] - yvals = [old_div(vt.ebq_global[ckey].flat[i],scale) for i in range(npoints)] + yvals = [vt.ebq_global[ckey].flat[i]/scale for i in range(npoints)] vtkViewers.viewScalar_1D(xvals,yvals,"x",ckey[0],title,self.windowNumber(), Pause=self.s.viewerPause,sortPoints=True) newPlot() @@ -896,8 +890,8 @@ def plotVectorGlobalElementBoundaryQuantity(self,ckey,mlvt,tsim): # x = [vt.ebq_global['x'].flat[i*3+0] for i in range(npoints)] # y = [vt.ebq_global['x'].flat[i*3+1] for i in range(npoints)] # z = [vt.ebq_global['x'].flat[i*3+2] for i in range(npoints)] - xvals= [old_div(vt.ebq_global[ckey].flat[i*2+0],scale) for i in range(npoints)] - yvals= [old_div(vt.ebq_global[ckey].flat[i*2+1],scale) for i in range(npoints)] + xvals= [vt.ebq_global[ckey].flat[i*2+0]/scale for i in range(npoints)] + yvals= [vt.ebq_global[ckey].flat[i*2+1]/scale for i in range(npoints)] nodes = vt.ebq_global['x'].flat[:] vtkViewers.viewVector_pointSet_2D(nodes,xvals,yvals,None,title,self.windowNumber(), arrows=True,streamlines=False, @@ -920,9 +914,9 @@ def plotVectorGlobalElementBoundaryQuantity(self,ckey,mlvt,tsim): # y = [vt.ebq_global['x'].flat[i*3+1] for i in range(npoints)] # z = [vt.ebq_global['x'].flat[i*3+2] for i in range(npoints)] nodes = vt.ebq_global['x'].flat[:] - xvals= [old_div(vt.ebq_global[ckey].flat[i*3+0],scale) for i in range(npoints)] - yvals= [old_div(vt.ebq_global[ckey].flat[i*3+1],scale) for i in range(npoints)] - zvals= [old_div(vt.ebq_global[ckey].flat[i*3+2],scale) for i in range(npoints)] + xvals= [vt.ebq_global[ckey].flat[i*3+0]/scale for i in range(npoints)] + yvals= [vt.ebq_global[ckey].flat[i*3+1]/scale for i in range(npoints)] + zvals= [vt.ebq_global[ckey].flat[i*3+2]/scale for i in range(npoints)] vtkViewers.viewVector_pointSet_3D(nodes,xvals,yvals,zvals,title,self.windowNumber(), arrows=True,streamlines=False, Pause=self.s.viewerPause) @@ -962,7 +956,7 @@ def plotVectorElementQuantity(self,ckey,mlvt,tsim,nVectorPlotPointsPerElement=1) xandu = [(vt.q['x'].flat[i*3+0],vt.q[ckey].flat[i]) for i in range(npoints)] xandu.sort() for xu in xandu: - self.datFile.write("%12.5e %12.5e \n" % (xu[0],old_div(xu[1],scale))) + self.datFile.write("%12.5e %12.5e \n" % (xu[0],xu[1]/scale)) self.datFile.write("\n \n") ptitle = title+" max= %g" % max_u cmd = "set term x11 %i; plot \'%s\' index %i with linespoints title \"%s\" \n" % (self.windowNumber(), @@ -985,7 +979,7 @@ def plotVectorElementQuantity(self,ckey,mlvt,tsim,nVectorPlotPointsPerElement=1) for k in range(min(nVectorPlotPointsPerElement,vt.nQuadraturePoints_element)): xtmp = vt.q['x'][eN,k,:]; vtmp = vt.q[ckey][eN,k,:] self.datFile.write("%12.5e %12.5e %12.5e %12.5e \n" % (xtmp[0],xtmp[1], - old_div(vtmp[0],scale),old_div(vtmp[1],scale))) + vtmp[0]/scale,vtmp[1]/scale)) self.datFile.write("\n \n") ptitle = title + "max=(%s,%s)" % (max_u,max_v) cmd = "set term x11 %i; plot \'%s\' index %i with vectors title \"%s\" \n" % (self.windowNumber(), @@ -998,7 +992,7 @@ def plotVectorElementQuantity(self,ckey,mlvt,tsim,nVectorPlotPointsPerElement=1) newPlot() newWindow() elif vt.nSpace_global == 3: - (slice_x,slice_y,slice_z) = vt.mesh.nodeArray[old_div(vt.mesh.nodeArray.shape[0],2),:] + (slice_x,slice_y,slice_z) = vt.mesh.nodeArray[vt.mesh.nodeArray.shape[0]//2,:] max_u=max(numpy.absolute(numpy.take(vt.q[ckey],[0],2).flat)) max_v=max(numpy.absolute(numpy.take(vt.q[ckey],[1],2).flat)) max_w=max(numpy.absolute(numpy.take(vt.q[ckey],[2],2).flat)) @@ -1013,7 +1007,7 @@ def plotVectorElementQuantity(self,ckey,mlvt,tsim,nVectorPlotPointsPerElement=1) xtmp = vt.q['x'][eN,k,:]; vtmp = vt.q[ckey][eN,k,:] if abs(xtmp[0]-slice_x) < vt.mesh.h: self.datFile.write("%12.5e %12.5e %12.5e %12.5e \n" % (xtmp[1],xtmp[2], - old_div(vtmp[1],scale),old_div(vtmp[2],scale))) + vtmp[1]/scale,vtmp[2]/scale)) self.datFile.write("\n \n") ptitle = title + " max=(%s,%s,%s) " % (max_u,max_v,max_w)+" : x-slice" cmd = "set term x11 %i; plot \'%s\' index %i with vectors title \"%s\" \n" % (self.windowNumber(), @@ -1031,7 +1025,7 @@ def plotVectorElementQuantity(self,ckey,mlvt,tsim,nVectorPlotPointsPerElement=1) xtmp = vt.q['x'][eN,k,:]; vtmp = vt.q[ckey][eN,k,:] if abs(xtmp[1]-slice_y) < vt.mesh.h: self.datFile.write("%12.5e %12.5e %12.5e %12.5e \n" % (xtmp[0],xtmp[2], - old_div(vtmp[0],scale),old_div(vtmp[2],scale))) + vtmp[0]/scale,vtmp[2]/scale)) self.datFile.write("\n \n") ptitle = title + " max=(%s,%s,%s) " % (max_u,max_v,max_w)+" : y-slice" cmd = "set term x11 %i; plot \'%s\' index %i with vectors title \"%s\" \n" % (self.windowNumber(), @@ -1049,7 +1043,7 @@ def plotVectorElementQuantity(self,ckey,mlvt,tsim,nVectorPlotPointsPerElement=1) xtmp = vt.q['x'][eN,k,:]; vtmp = vt.q[ckey][eN,k,:] if abs(xtmp[2]-slice_z) < vt.mesh.h: self.datFile.write("%12.5e %12.5e %12.5e %12.5e \n" % (xtmp[0],xtmp[1], - old_div(vtmp[0],scale),old_div(vtmp[1],scale))) + vtmp[0]/scale,vtmp[1]/scale)) self.datFile.write("\n \n") ptitle = title + " max=(%s,%s,%s) " % (max_u,max_v,max_w)+" : z-slice" cmd = "set term x11 %i; plot \'%s\' index %i with vectors title \"%s\" \n" % (self.windowNumber(), @@ -1086,7 +1080,7 @@ def plotVectorElementQuantity(self,ckey,mlvt,tsim,nVectorPlotPointsPerElement=1) scale = 1.0 npoints = vt.q['x'].shape[0]*vt.q['x'].shape[1] xvals = [vt.q['x'].flat[i*3+0] for i in range(npoints)] - yvals = [old_div(vt.q[ckey].flat[i],scale) for i in range(npoints)] + yvals = [vt.q[ckey].flat[i]/scale for i in range(npoints)] vtkViewers.viewVector_1D(xvals,yvals,"x",ckey[0],title,self.windowNumber(), Pause=self.s.viewerPause) newPlot() diff --git a/proteus/WaveTools.py b/proteus/WaveTools.py index 6284ba9d21..7a4a8b342d 100644 --- a/proteus/WaveTools.py +++ b/proteus/WaveTools.py @@ -6,15 +6,6 @@ components of water waves. These can be used as boundary conditions, wave generation sources, and validation solutions for numerical wave codes. """ -from __future__ import print_function -from __future__ import absolute_import -from __future__ import division - -from builtins import str -from builtins import zip -from builtins import range -#from builtins import object -from past.utils import old_div import cython import numpy as np import cmath as cmat @@ -79,7 +70,7 @@ def fastcos_test(phase,sinus=False): """ if(sinus): - phase = old_div(np.pi,2.) - phase + phase = np.pi/2. - phase return fastcos(phase,True) def fastcosh_test(k,Z,fast=True): """Fast hyperbolic cosine function with Taylor approximation - TO BE USED FOR TESTING" @@ -132,8 +123,8 @@ def coshkzd_test(k,Z,d, fast=True): cosh(k*(z+d))/sinh(kd) for Z>-d/2, 0 otherwise """ - if (Z > old_div(-d,2.)): - return old_div(fastcosh_test(k,Z,fast), np.tanh(k*d)) + fastsinh_test(k,Z,fast) + if (Z > -d/2.): + return fastcosh_test(k,Z,fast)/np.tanh(k*d) + fastsinh_test(k,Z,fast) else: return 0. @@ -155,8 +146,8 @@ def sinhkzd_test(k,Z,d,fast=True): """ - if (Z> old_div(-d,2.)): - return fastcosh_test(k,Z,fast) + old_div(fastsinh_test(k,Z,fast), np.tanh(k*d)) + if (Z> -d/2.): + return fastcosh_test(k,Z,fast) + fastsinh_test(k,Z,fast)/np.tanh(k*d) else: return 0. @@ -210,7 +201,7 @@ def setVertDir(g): numpy.ndarray """ - return -np.array(old_div(g,(sqrt(g[0]**2 + g[1]**2 + g[2]**2)))) + return -np.array(g/(sqrt(g[0]**2+g[1]**2+g[2]**2))) def setDirVector(vector): @@ -226,7 +217,7 @@ def setDirVector(vector): numpy.ndarray """ - return old_div(vector,(sqrt(vector[0]**2 + vector[1]**2 + vector[2]**2))) + return vector/(sqrt(vector[0]**2+vector[1]**2+vector[2]**2)) def dirCheck(v1, v2): """ Checks if two vectors are vertical raises SystemError if True @@ -341,7 +332,7 @@ def normIntegral(f,dom): -------- numpy.ndarray """ - G0 = old_div(1.,sum(returnRectangles(f,dom))) + G0 = 1./sum(returnRectangles(f,dom)) return G0*f @@ -434,8 +425,8 @@ def vel_mode(x, t, kDir, kAbs, omega, phi, amplitude, mwl, depth, vDir, gA ii=0. UH=amplitude*omega*cosh(kAbs*(Z + depth))*cos( phase )/sinh(kAbs*depth) UV=amplitude*omega*sinh(kAbs*(Z + depth))*sin( phase )/sinh(kAbs*depth) - waveDir = old_div(kDir,kAbs) - UH = UH - Udrift(amplitude,gAbs,old_div(omega,kAbs),depth) + waveDir = kDir/kAbs + UH = UH - Udrift(amplitude,gAbs,omega/kAbs,depth) #waves(period = 1./self.fi[ii], waveHeight = 2.*self.ai[ii],mwl = self.mwl, depth = self.d,g = self.g,waveDir = self.waveDir,wavelength=self.wi[ii], phi0 = self.phi[ii]).u(x,y,z,t) V = np.array([UH*waveDir[0]+UV*vDir[0], UH*waveDir[1]+UV*vDir[1], @@ -491,9 +482,9 @@ def JONSWAP(f,f0,Hs,gamma=3.3,TMA=False, depth = None): 1D Numpy array of the spectrum in frequency domain """ - Tp = old_div(1.,f0) - bj = 0.0624*(1.094-0.01915*log(gamma))/(0.23+0.0336*gamma-old_div(0.185,(1.9+gamma))) - r = np.exp(old_div(-(Tp*f-1.)**2,(2.*sigma(f,f0)**2))) + Tp = 1./f0 + bj = 0.0624*(1.094-0.01915*log(gamma))/(0.23+0.0336*gamma-0.185/(1.9+gamma)) + r = np.exp(-(Tp*f-1.)**2/(2.*sigma(f,f0)**2)) tma = 1. if TMA: if (depth is None): @@ -503,7 +494,7 @@ def JONSWAP(f,f0,Hs,gamma=3.3,TMA=False, depth = None): k = dispersion(2*M_PI*f,depth) tma = np.tanh(k*depth)*np.tanh(k*depth)/(1.+ 2.*k*depth/np.sinh(2.*k*depth)) - return tma * bj*(Hs**2)*(old_div(1.,((Tp**4) *(f**5))))*np.exp(-1.25*(old_div(1.,(Tp*f)**(4.))))*(gamma**r) + return tma * bj*(Hs**2)*(1./((Tp**4)*(f**5)))*np.exp(-1.25*(1./(Tp*f)**(4.)))*(gamma**r) def PM_mod(f,f0,Hs): """Calculates the Pierson-Moskovitz spectrum (or Bretschneider or ISSC) @@ -527,7 +518,7 @@ def PM_mod(f,f0,Hs): 1D Numpy array of the spectrum in frequency domain """ - return (old_div(5.0,16.0))*Hs**2*(old_div(f0**4,f**5))*np.exp((old_div(-5.0,4.0))*(old_div(f0,f))**4) + return (5.0/16.0)*Hs**2*(f0**4/f**5)*np.exp((-5.0/4.0)*(f0/f)**4) def cos2s(theta,f,s=10): """Calculates the cos-2s directional spreading function @@ -605,9 +596,9 @@ def dispersion(w,d, g = 9.81,niter = 1000): Wavenumber as a float or 1D array for multiple frequencies """ w_aux = np.array(w) - K = old_div(w_aux**2,g) + K = w_aux**2/g for jj in range(niter): - K = old_div(w_aux**2,(g*np.tanh(K*d))) + K = w_aux**2/(g*np.tanh(K*d)) if type(K) is float: return K[0] else: @@ -685,7 +676,7 @@ def decompose_tseries(time,eta,dt): fft_x = np.fft.fft(eta,nfft) freq = np.fft.fftfreq(nfft,dt) #%complex spectrum iend = np.where(freq<0)[0][0] - setup = old_div(np.real(fft_x[0]),nfft) + setup = np.real(fft_x[0])/nfft fft_x = fft_x[1:iend] freq = freq[1:iend] #%retaining only first half of the spectrum @@ -814,7 +805,7 @@ def __init__(self, self.c = np.sqrt(self.gAbs * (depth+self.H)) self.mwl = mwl self.depth = depth - self.K = old_div(np.sqrt(3. *self.H/ (4. * self.depth)),self.depth) + self.K = np.sqrt(3.*self.H/(4.*self.depth))/self.depth self.d2 = depth*depth self.d3 = self.d2 * depth #Checking if g and waveDir are perpendicular @@ -863,7 +854,7 @@ def u(self,x,t): 2.0 * self.d3 + self.d2 * self.H + 12.0 * self.depth * self.H * Z + 6.0 * self.H * Z**2.0 + (2.0 * self.d3 - self.d2 * self.H - 6.0 * self.depth * self.H * Z - 3.0 * self.H * Z**2 ) * a1)/(a2)**4 - Uvert = 1.0 / ( 4.0 * np.sqrt(self.gAbs* self.depth) ) * np.sqrt(3.0) * self.gAbs * (old_div(self.H, self.depth**3.0))** 1.5 * (self.depth + Z)*( + Uvert = 1.0 / ( 4.0 * np.sqrt(self.gAbs* self.depth) ) * np.sqrt(3.0) * self.gAbs * (self.H/self.depth**3.0)** 1.5 * (self.depth + Z)*( 2.0 * self.depth**3 - 7.0 * self.depth**2.0 * self.H + 10.0 * self.depth * self.H * Z + 5.0 * self.H * Z**2.0 + (2.0 * self.depth**3.0 + self.depth**2.0 * self.H - 2.0 * self.depth * self.H * Z - self.H * Z**2.0)* cosh(np.sqrt( 3.0 * self.H / self.depth**3.0) * phase ))/( @@ -1230,13 +1221,13 @@ def __cinit__(self, self.Hs = Hs self.depth = depth self.Tp = Tp - self.fp = old_div(1.,Tp) + self.fp = 1./Tp self.bandFactor = bandFactor self.N = N self.mwl = mwl fmax = self.bandFactor*self.fp - fmin = old_div(self.fp,self.bandFactor) - self.df = old_div((fmax-fmin),float(self.N-1)) + fmin = self.fp/self.bandFactor + self.df = (fmax-fmin)/float(self.N-1) self.fi = np.linspace(fmin,fmax,self.N) self.omega = 2.*M_PI*self.fi self.ki = dispersion(self.omega,self.depth,g=self.gAbs) @@ -1377,13 +1368,13 @@ def writeEtaSeries(self,Tstart,Tend,x0,fname,Lgen= np.array([0.,0,0])): if sum(Lgen[:]*self.waveDir[:])< 0 : logEvent('ERROR! Wavetools.py: Location vector of generation zone should not be opposite to the wave direction') sys.exit(1) - dt = old_div(self.Tp,50.) + dt = self.Tp/50. Tlag = np.zeros(len(self.omega),) for j in range(len(self.omega)): - Tlag[j] = old_div(sum(self.kDir[j,:]*Lgen[:]),self.omega[j]) + Tlag[j] = sum(self.kDir[j,:]*Lgen[:])/self.omega[j] Tlag = max(Tlag) Tstart = Tstart - Tlag - Np = int(old_div((Tend - Tstart),dt)) + Np = int((Tend-Tstart)/dt) time = np.linspace(Tstart,Tend,Np ) etaR = np.zeros(len(time), ) for jj in range(len(time)): @@ -1462,15 +1453,15 @@ def __cinit__(self, self.Hs = Hs self.depth = depth self.Tp = Tp - self.fp = old_div(1.,Tp) + self.fp = 1./Tp self.bandFactor = bandFactor self.N = N if spec_fun.__name__=="custom": self.N =len(f_c) self.mwl = mwl fmax = self.bandFactor*self.fp - fmin = old_div(self.fp,self.bandFactor) - self.df = old_div((fmax-fmin),float(self.N-1)) + fmin = self.fp/self.bandFactor + self.df = (fmax-fmin)/float(self.N-1) if spec_fun.__name__=="custom": self.df = f_c[1]-f_c[0] self.fi = np.linspace(fmin,fmax,self.N) @@ -1635,13 +1626,13 @@ def writeEtaSeries(self,Tstart,Tend,x0,fname,Lgen= np.array([0.,0,0])): if sum(Lgen[:]*self.waveDir[:])< 0 : logEvent('ERROR! Wavetools.py: Location vector of generation zone should not be opposite to the wave direction') sys.exit(1) - dt = old_div(self.Tp,50.) + dt = self.Tp/50. Tlag = np.zeros(len(self.omega),) for j in range(len(self.omega)): - Tlag[j] = old_div(sum(self.kDir[j,:]*Lgen[:]),self.omega[j]) + Tlag[j] = sum(self.kDir[j,:]*Lgen[:])/self.omega[j] Tlag = max(Tlag) Tstart = Tstart - Tlag - Np = int(old_div((Tend - Tstart),dt)) + Np = int((Tend-Tstart)/dt) time = np.linspace(Tstart,Tend,Np ) etaR = np.zeros(len(time), ) for jj in range(len(time)): @@ -1776,7 +1767,7 @@ def __cinit__(self, for ij in range(self.Nall): for kk in range(3): self.kDir_cM[3*ij+kk] = self.kDirM[ij,kk] - self.waveDir_cM[3*ij+kk] = old_div(self.kDirM[ij,kk], self.kiM[ij]) + self.waveDir_cM[3*ij+kk] = self.kDirM[ij,kk]/self.kiM[ij] self.omega_cM[ij] = self.omegaM[ij] self.ki_cM[ij] =self.kiM[ij] self.tanh_cM[ij] = self.tanhFM[ij] @@ -1944,7 +1935,7 @@ def __cinit__(self, # Directional waves propagate usually in a plane -90 to 90 deg with respect to the direction vector, normal to the gavity direction. Rotating the waveDir0 vector around the g vector to produce the directional space from .SpatialTools import rotation3D - thetas = np.linspace(old_div(-M_PI,2),old_div(M_PI,2),2*M+1) + thetas = np.linspace(-M_PI/2,M_PI/2,2*M+1) dth = (thetas[1] - thetas[0]) self.waveDirs = np.zeros((2*M+1,3),) self.phiDirs = np.zeros((2*M+1,N),) @@ -2199,7 +2190,7 @@ def __init__(self, logEvent("ERROR! Wavetools.py: Timeseries file (%s) must have only two columns [time, eta]" % (timeSeriesFile),level=0) sys.exit(1) time_temp = tdata[:,0] - self.dt = old_div((time_temp[-1]-time_temp[0]),(len(time_temp)-1)) + self.dt = (time_temp[-1]-time_temp[0])/(len(time_temp)-1) @@ -2245,8 +2236,8 @@ def __init__(self, decomp = decompose_tseries(self.time,self.etaS,self.dt) self.ai = decomp[1] ipeak = np.where(self.ai == max(self.ai))[0][0] - imax = min(ipeak + old_div(Nf,2),len(self.ai)) - imin = max(0,ipeak - old_div(Nf,2)) + imax = min(ipeak + Nf//2,len(self.ai)) + imin = max(0,ipeak - Nf//2) self.ai = self.ai[imin:imax] self.omega = decomp[0][imin:imax] self.phi = - decomp[2][imin:imax] @@ -2325,16 +2316,16 @@ def __init__(self, # Portion of window filtered with the Costap filter # Setting the handover time, either at the middle of the overlap or just after the filter - self.handover = max(1.1 *self.cutoff, old_div(self.overlap, 2.)) + self.handover = max(1.1 *self.cutoff, self.overlap/2.) if (self.handover > 0.9 * self.overlap): logEvent("ERROR! Wavetools.py: Window handover is not optimal as the cutoff is too close to the overlap. Decrease cutoff or increase overlap") sys.exit(1) self.Twindow = self.Tm * self.Nwaves # setting the window duration (approx.). Twindow = Tmean * Nwaves self.Toverlap = self.overlap * self.Twindow - self.Nwindows = int( old_div((self.tlength - self.Twindow ), (self.Twindow - self.Toverlap)) ) + 1 #Getting the actual number of windows (N-1) * (Twindow - Toverlap) + Twindow = total time - self.Twindow = old_div(self.tlength,(1. + (1. - self.overlap)*(self.Nwindows-1))) # Correct Twindow and Toverlap for duration and integer number of windows + self.Nwindows = int( (self.tlength-self.Twindow)/(self.Twindow-self.Toverlap) ) + 1 #Getting the actual number of windows (N-1) * (Twindow - Toverlap) + Twindow = total time + self.Twindow = self.tlength/(1.+(1.-self.overlap)*(self.Nwindows-1)) # Correct Twindow and Toverlap for duration and integer number of windows self.Toverlap = self.overlap*self.Twindow - logEvent("INFO: Wavetools.py: Correcting window duration for matching the exact time range of the series. Window duration correspond to %s waves approx." %(old_div(self.Twindow, self.Tm)) ) + logEvent("INFO: Wavetools.py: Correcting window duration for matching the exact time range of the series. Window duration correspond to %s waves approx." %(self.Twindow/self.Tm) ) diff = (self.Nwindows-1.)*(self.Twindow -self.Toverlap)+self.Twindow - self.tlength logEvent("INFO: Wavetools.py: Checking duration of windowed time series: %s per cent difference from original duration" %(100*diff) ) logEvent("INFO: Wavetools.py: Using %s windows for reconstruction with %s sec duration and %s per cent overlap" %(self.Nwindows, self.Twindow,100*self.overlap )) @@ -2370,8 +2361,8 @@ def __init__(self, self.N = min(self.N, len(decomp[0])) Nftemp = self.N ipeak = np.where(decomp[1] == max(decomp[1]))[0][0] - imax = min(ipeak + old_div(Nftemp,2),len(decomp[1])) - imin = max(0,ipeak - old_div(Nftemp,2)) + imax = min(ipeak + Nftemp//2,len(decomp[1])) + imin = max(0,ipeak - Nftemp//2) self.Nf = imax-imin if (self.Nf < self.N): if imin == 0: @@ -2388,9 +2379,9 @@ def __init__(self, Tlag = np.zeros(ki.shape,) for ii in range(len(ki)): kDir[ii,:] = ki[ii]*self.waveDir[:] - Tlag[ii] = old_div(sum(Lgen[:]*kDir[ii,:]),decomp[0][ii]) + Tlag[ii] = sum(Lgen[:]*kDir[ii,:])/decomp[0][ii] self.Tlag = max(Tlag) - if self.Tlag > (old_div(self.Toverlap,2.) - self.cutoff*self.Twindow): + if self.Tlag > (self.Toverlap/2. - self.cutoff*self.Twindow): logEvent("ERROR!: WaveTools.py: Relaxation zone lenght does not allow for spatial coherency in the windows method.Please a) increase number of waves per window or b) increase overlap or c) decrease lenght of the relaxation zone") sys.exit(1) decomp.append(kDir) @@ -2692,13 +2683,13 @@ def __init__(self, self.series = RW.writeEtaSeries(Tstart,Tend,x0,fname,4.*self.Lgen) self.cutoff = max(0.2*self.Tp , cutoff_win*Nwaves*Tp) duration = (self.series[-1,0]-self.series[0,0]) - self.cutoff = old_div(self.cutoff, duration) - Tm = old_div(self.Tp,1.1) + self.cutoff = self.cutoff/duration + Tm = self.Tp/1.1 #Checking if there are enough windows - Nwaves_tot = round(old_div((self.series[-1,0]-self.series[0,0]),Tm)) + Nwaves_tot = round((self.series[-1,0]-self.series[0,0])/Tm) Nwaves = min(Nwaves,Nwaves_tot) - self.Nwind = int(old_div(Nwaves_tot,Nwaves)) + self.Nwind = int(Nwaves_tot/Nwaves) self.rec_d = False if self.Nwind < 3: logEvent("ERROR!: WaveTools.py: Found too few windows in RandomWavesFast. Consider increasing Tend (this is independent from the duration of the simulation)") @@ -2738,7 +2729,7 @@ def __init__(self, errors = np.zeros(len(self.series),) for ii in range(i1,i2): errors[ii] = abs(self.series[ii,1]-TS.eta(x0,self.series[ii,0]) ) - self.er1 = old_div(max(errors[:]),self.Hs) + self.er1 = max(errors[:])/self.Hs if self.er1 > 0.01 and checkAcc: logEvent('ERROR!: WaveTools.py: Found large errors error={s}) during window reconstruction at RandomWavesFast. Please a) Increase Nfreq, b) Decrease waves per window to decrease error < 1%. You can set checkAcc = False if you want to proceed with these errors',level=0) sys.exit(1) @@ -2998,7 +2989,7 @@ def eta_setUp(self,x,t): EtasetUp = 0. for i in range(0,self.N): - wwi_setUp = old_div((self.ai[i]**2*self.ki[i]),(2*sinh(2*self.ki[i]*self.depth))) + wwi_setUp = (self.ai[i]**2*self.ki[i])/(2*sinh(2*self.ki[i]*self.depth)) EtasetUp += wwi_setUp return EtasetUp @@ -3072,11 +3063,11 @@ def writeEtaSeries(self,Tstart,Tend,dt,x0,fname, mode="all",setUp=False, Lgen=np Tlag = np.zeros(len(self.omega),) for j in range(len(self.omega)): - Tlag[j] = old_div(sum(self.kDir[j,:]*Lgen[:]),self.omega[j]) + Tlag[j] = sum(self.kDir[j,:]*Lgen[:])/self.omega[j] Tlag = max(Tlag) Tstart = Tstart - Tlag - Nseries = int(old_div((Tend - Tstart),dt)) + 1 + Nseries = int((Tend-Tstart)/dt) + 1 timelst=np.linspace(Tstart, Tend, Nseries) series = np.zeros((Nseries,2),) series[:,0] = timelst @@ -3206,22 +3197,22 @@ def __init__(self, Tmax = NLongW*Tp/1.1 modes = ["short","linear","long"] - periods = [Tp/2./1.1,old_div(Tp,1.1), Tmax] + periods = [Tp/2./1.1,Tp/1.1, Tmax] self.TS= [] ii = -1 for mode in modes: logEvent("INFO: Calculating nonlinear corrections for "+mode+" waves. This may take a while") ii+=1 fname = "randomNLWaves_"+mode+".csv" - dt = old_div(periods[ii],50.) + dt = periods[ii]/50. series = aRN.writeEtaSeries(Tstart,Tend,dt,x0,fname,mode,False,Lgen) Tstart_temp = series[0,0] cutoff = 0.2*periods[ii]/(Tend-Tstart_temp) #Checking if there are enough windows - Nwaves_tot = int(old_div((Tend-Tstart_temp),periods[ii])) + Nwaves_tot = int((Tend-Tstart_temp)/periods[ii]) Nwaves = min(Nwaves,Nwaves_tot) - Nwind = int(old_div(Nwaves_tot,Nwaves)) + Nwind = int(Nwaves_tot/Nwaves) if Nwind < 3: rec_d = True else: @@ -3348,4 +3339,3 @@ def u(self,x,t): for cond in self.waveList: u += cond.u(x,t) return u - diff --git a/proteus/__init__.py b/proteus/__init__.py index 5f45bd7cc2..0dbbcf7d7d 100644 --- a/proteus/__init__.py +++ b/proteus/__init__.py @@ -9,7 +9,7 @@ import pkgutil __path__ = pkgutil.extend_path(__path__, __name__) -__version__ = '1.8.2.dev0' +__version__ = '1.8.3' __all__ = ["Archiver", "Domain", @@ -68,28 +68,3 @@ "BoundaryConditions", "SpatialTools", "defaults"] - -def test(verbose=False, cleanup=True): - """Run all proteus tests - - Parameters - ---------- - verbose : bool - Print verbose testing information - cleanup : bool - Remove the temporary directory containing output - """ - from os import path - from tempfile import mkdtemp - from shutil import rmtree - import pytest - flags="--boxed " - if verbose: - flags+="-v " - original_dir = os.get_cwd() - tmp_dir = mkdtemp() - os.chdir(tmp_dir) - pytest.main(flags+path.join(path.dirname(__file__),'tests')) - os.chdir(original_dir) - if cleanup: - rmtree(tmp_dir) diff --git a/proteus/config/__init__.py b/proteus/config/__init__.py index 3464a08137..d60ecbe3d0 100644 --- a/proteus/config/__init__.py +++ b/proteus/config/__init__.py @@ -1,10 +1,11 @@ -from __future__ import absolute_import import os if 'PROTEUS_ARCH' in os.environ and os.environ['PROTEUS_ARCH'].startswith('mike'): from .mike import * elif 'PROTEUS_ARCH' in os.environ and os.environ['PROTEUS_ARCH'].startswith('koehr'): from .koehr import * +elif 'PROTEUS_ARCH' in os.environ and os.environ['PROTEUS_ARCH'].startswith('gaffney'): + from .gaffney import * elif 'PROTEUS_ARCH' in os.environ and os.environ['PROTEUS_ARCH'].startswith('centennial'): from .centennial import * elif 'PROTEUS_ARCH' in os.environ and os.environ['PROTEUS_ARCH'].startswith('jim'): diff --git a/proteus/config/centennial.py b/proteus/config/centennial.py index 7fd3a8d138..b3aec817e7 100644 --- a/proteus/config/centennial.py +++ b/proteus/config/centennial.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from .default import * PROTEUS_PRELOAD_LIBS=['/p/app/sgi/mpt/mpt-2.15/lib/libmpi.so','/p/app/sgi/mpt/mpt-2.15/lib/libmpi_lustre.so'] diff --git a/proteus/config/centos.py b/proteus/config/centos.py index b78acc128b..14c37a0b7f 100644 --- a/proteus/config/centos.py +++ b/proteus/config/centos.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import import os from .default import * diff --git a/proteus/config/copper.py b/proteus/config/copper.py index 37aa0583f3..6cbde6fca4 100644 --- a/proteus/config/copper.py +++ b/proteus/config/copper.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from .default import * #PROTEUS_PRELOAD_LIBS=['/opt/cray/ugni/5.0-1.0402.7551.1.10.gem/lib64/libugni.so.0.5.0','/opt/cray/mpt/6.0.0/gni/mpich2-gnu/48/lib/libmpich.so.2.0.0'] diff --git a/proteus/config/default.py b/proteus/config/default.py index f11006213e..d028a5afbb 100644 --- a/proteus/config/default.py +++ b/proteus/config/default.py @@ -4,7 +4,6 @@ import platform import site PROTEUS_PRELOAD_LIBS=[] - prefix = os.getenv('PROTEUS_PREFIX') if not prefix: prefix = sys.exec_prefix @@ -60,6 +59,7 @@ def get_flags(package): return include_dir, lib_dir PROTEUS_BLAS_INCLUDE_DIR, PROTEUS_BLAS_LIB_DIR = get_flags('blas') +PROTEUS_EXTRA_LINK_ARGS=[] if sys.platform == 'darwin': PROTEUS_BLAS_LIB ='m' @@ -70,7 +70,6 @@ def get_flags(package): PROTEUS_BLAS_LIB ='openblas' PROTEUS_BLAS_INCLUDE_DIR, PROTEUS_BLAS_LIB_DIR = get_flags('blas') -PROTEUS_EXTRA_LINK_ARGS=[] PROTEUS_CHRONO_INCLUDE_DIR, PROTEUS_CHRONO_LIB_DIR = get_flags('chrono') @@ -78,6 +77,8 @@ def get_flags(package): chrono_cmake_file_path = os.path.join(PROTEUS_CHRONO_LIB_DIR,'cmake','Chrono','ChronoConfig.cmake') if not os.path.isfile(chrono_cmake_file_path): chrono_cmake_file_path = os.path.join(PROTEUS_CHRONO_LIB_DIR,'cmake','ChronoConfig.cmake') + if not os.path.isfile(chrono_cmake_file_path): + chrono_cmake_file_path = os.path.join(PROTEUS_CHRONO_LIB_DIR,'cmake','Chrono','chrono-config.cmake') with open(chrono_cmake_file_path,'r') as f: for l in f: if 'set(CHRONO_CXX_FLAGS' in l: @@ -137,7 +138,7 @@ def get_flags(package): PROTEUS_PARMETIS_INCLUDE_DIR, PROTEUS_PARMETIS_LIB_DIR = get_flags('parmetis') PROTEUS_ZOLTAN_INCLUDE_DIR, PROTEUS_ZOLTAN_LIB_DIR = get_flags('zoltan') PROTEUS_SCOREC_INCLUDE_DIRS = [PROTEUS_SCOREC_INCLUDE_DIR, PROTEUS_PETSC_INCLUDE_DIR, PROTEUS_ZOLTAN_INCLUDE_DIR, PROTEUS_PARMETIS_INCLUDE_DIR, PROTEUS_MPI_INCLUDE_DIR, PROTEUS_LAPACK_INCLUDE_DIR, PROTEUS_BLAS_INCLUDE_DIR] -PROTEUS_SCOREC_LIB_DIRS = [PROTEUS_SCOREC_LIB_DIR, PROTEUS_PETSC_LIB_DIR, PROTEUS_ZOLTAN_LIB_DIR, PROTEUS_PARMETIS_LIB_DIR, PROTEUS_MPI_LIB_DIR, PROTEUS_LAPACK_LIB_DIR, PROTEUS_BLAS_LIB_DIR] +PROTEUS_SCOREC_LIB_DIRS = [PROTEUS_SCOREC_LIB_DIR, PROTEUS_PETSC_LIB_DIR, PROTEUS_ZOLTAN_LIB_DIR, PROTEUS_PARMETIS_LIB_DIR, PROTEUS_MPI_LIB_DIR, PROTEUS_LAPACK_LIB_DIR, PROTEUS_BLAS_LIB_DIR,'/usr/lib/x86_64-linux-gnu/'] PROTEUS_SCOREC_LIBS = [ 'spr', 'ma', @@ -176,6 +177,7 @@ def get_flags(package): PROTEUS_SUPERLU_INCLUDE_DIR = PROTEUS_PETSC_INCLUDE_DIR PROTEUS_SUPERLU_LIB_DIR = pjoin(prefix, 'lib64') +PROTEUS_SUPERLU_LIB_DIR = pjoin(prefix, 'lib') PROTEUS_SUPERLU_H = r'"slu_ddefs.h"' PROTEUS_SUPERLU_LIB = 'superlu' diff --git a/proteus/config/excalibur.py b/proteus/config/excalibur.py index 9f9fa4d887..5670091f7d 100644 --- a/proteus/config/excalibur.py +++ b/proteus/config/excalibur.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from .default import * PROTEUS_PRELOAD_LIBS=[] diff --git a/proteus/config/gaffney.py b/proteus/config/gaffney.py index 44ed5cfc48..bb190f7a70 100644 --- a/proteus/config/gaffney.py +++ b/proteus/config/gaffney.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import from .default import * -PROTEUS_PRELOAD_LIBS=['/p/app/hpe/mpt-2.21/lib/libmpi.so','/p/app/hpe/mpt-2.21/lib/libmpi_lustre.so'] +PROTEUS_PRELOAD_LIBS=['/p/app/gnu/10.1.0/lib64/libstdc++.so','/p/app/hpe/mpt-2.21/lib/libmpi.so', '/p/app/hpe/mpt-2.21/lib/libmpi++.so','/p/app/hpe/mpt-2.21/lib/libmpi_lustre.so'] + diff --git a/proteus/config/garnet.py b/proteus/config/garnet.py index b1921d2264..2b75fe80ce 100644 --- a/proteus/config/garnet.py +++ b/proteus/config/garnet.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from .default import * PROTEUS_PRELOAD_LIBS=['/opt/cray/ugni/5.0-1.0402.7551.1.10.gem/lib64/libugni.so.0.5.0','/opt/cray/mpt/6.0.0/gni/mpich2-gnu/48/lib/libmpich.so.2.0.0'] diff --git a/proteus/config/jim.py b/proteus/config/jim.py index 01fa0c4fc8..653cf5cdb3 100644 --- a/proteus/config/jim.py +++ b/proteus/config/jim.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from .default import * PROTEUS_PRELOAD_LIBS=['/p/home/apps/hpe/mpt-2.21/lib/libmpi.so', '/opt/hpe/hpc/mpt/mpt-2.21/lib/libmpi_lustre.so'] diff --git a/proteus/config/koehr.py b/proteus/config/koehr.py index 8679b2cdb7..bb190f7a70 100644 --- a/proteus/config/koehr.py +++ b/proteus/config/koehr.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import from .default import * -PROTEUS_PRELOAD_LIBS=['/p/app/hpe/mpt-2.21/lib/libmpi.so'] +PROTEUS_PRELOAD_LIBS=['/p/app/gnu/10.1.0/lib64/libstdc++.so','/p/app/hpe/mpt-2.21/lib/libmpi.so', '/p/app/hpe/mpt-2.21/lib/libmpi++.so','/p/app/hpe/mpt-2.21/lib/libmpi_lustre.so'] + diff --git a/proteus/config/lightning.py b/proteus/config/lightning.py index 2f200defa8..ed82fac737 100644 --- a/proteus/config/lightning.py +++ b/proteus/config/lightning.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from .default import * PROTEUS_PRELOAD_LIBS=[] diff --git a/proteus/config/mike.py b/proteus/config/mike.py index c4cf1dd8b1..41af6114c8 100644 --- a/proteus/config/mike.py +++ b/proteus/config/mike.py @@ -1,7 +1,7 @@ -from __future__ import absolute_import from .default import * PROTEUS_BLAS_LIB = 'mkl_sequential' PROTEUS_LAPACK_LIB = 'mkl_sequential' PROTEUS_MPI_INCLUDE_DIRS = ['/usr/local/packages/mvapich2/2.3.7/intel-2021.5.0/include'] PROTEUS_MPI_LIB_DIRS = ['/usr/local/packages/mvapich2/2.3.7/intel-2021.5.0/lib'] +PROTEUS_SCOREC_INCLUDE_DIRS += ['/usr/local/packages/mvapich2/2.3.7/intel-2021.5.0/include/'] diff --git a/proteus/config/mustang.py b/proteus/config/mustang.py index e20d65b6c9..92f82e3f6c 100644 --- a/proteus/config/mustang.py +++ b/proteus/config/mustang.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from .default import * PROTEUS_PRELOAD_LIBS=['/p/app/hpe/mpt-2.20/lib/libmpi.so','/p/app/hpe/mpt-2.20/lib/libmpi_lustre.so'] diff --git a/proteus/config/onyx.py b/proteus/config/onyx.py index 5670091f7d..174ef85e0b 100644 --- a/proteus/config/onyx.py +++ b/proteus/config/onyx.py @@ -10,4 +10,4 @@ PROTEUS_MPI_INCLUDE_DIRS = [os.path.join(os.getenv("CRAY_MPICH2_DIR"),'include')] PROTEUS_MPI_LIB_DIRS = [os.path.join(os.getenv("CRAY_MPICH2_DIR"),'lib')] PROTEUS_MPI_LIBS =[] -PROTEUS_SUPERLU_LIB_DIR = os.path.join(prefix,'lib64') +PROTEUS_SUPERLU_LIB_DIR = os.path.join(prefix,'lib64') \ No newline at end of file diff --git a/proteus/config/spirit.py b/proteus/config/spirit.py index f9120c16f7..f4d88aa985 100644 --- a/proteus/config/spirit.py +++ b/proteus/config/spirit.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from .default import * PROTEUS_PRELOAD_LIBS=[] diff --git a/proteus/config/stampede.py b/proteus/config/stampede.py index f2d2457ba1..804af6f906 100644 --- a/proteus/config/stampede.py +++ b/proteus/config/stampede.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from .default import * platform_extra_link_args = ['-Wl,'+ "-L" + PROTEUS_LIB_DIR] diff --git a/proteus/config/tamucluster.py b/proteus/config/tamucluster.py index d35796a0b1..78ca5644e2 100644 --- a/proteus/config/tamucluster.py +++ b/proteus/config/tamucluster.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from .default import * PROTEUS_MPI_INCLUDE_DIR, PROTEUS_MPI_LIB_DIR = get_flags('mpi') diff --git a/proteus/config/thunder.py b/proteus/config/thunder.py index 4caae73a4a..ff2c3d2219 100644 --- a/proteus/config/thunder.py +++ b/proteus/config/thunder.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from .default import * #platform_extra_compile_args = ['-DPETSC_INCLUDE_AS_C'] diff --git a/proteus/config/topaz.py b/proteus/config/topaz.py index 3eb157d08b..1840c04ebc 100644 --- a/proteus/config/topaz.py +++ b/proteus/config/topaz.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from .default import * platform_extra_compile_args = ['-DPETSC_INCLUDE_AS_C'] diff --git a/proteus/config/viutill.py b/proteus/config/viutill.py index f62dc253b3..deef8bf26c 100644 --- a/proteus/config/viutill.py +++ b/proteus/config/viutill.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from .default import * PROTEUS_PRELOAD_LIBS=[] diff --git a/proteus/default_n.py b/proteus/default_n.py index dba5584b28..310e71f4e5 100644 --- a/proteus/default_n.py +++ b/proteus/default_n.py @@ -5,7 +5,6 @@ Clean up default_n.py, finish documenting, decide on tolerance scheme """ -from __future__ import absolute_import try: from importlib import reload except: diff --git a/proteus/default_p.py b/proteus/default_p.py index 933b26aaa6..2f74bd3e8b 100644 --- a/proteus/default_p.py +++ b/proteus/default_p.py @@ -1,7 +1,6 @@ """ The default values for problem definition modules """ -from __future__ import absolute_import try: from importlib import reload except: diff --git a/proteus/default_s.py b/proteus/default_s.py index 448264d1e6..0ecaa8cb66 100644 --- a/proteus/default_s.py +++ b/proteus/default_s.py @@ -29,4 +29,4 @@ #Logging # logAllProcesses=False -flushBuffer=True +flushBuffer=True \ No newline at end of file diff --git a/proteus/default_so.py b/proteus/default_so.py index 0969ede279..a749c716f9 100644 --- a/proteus/default_so.py +++ b/proteus/default_so.py @@ -1,7 +1,6 @@ """ The default values for so-files describing split operator formulations """ -from __future__ import absolute_import try: from importlib import reload except: diff --git a/proteus/defaults.py b/proteus/defaults.py index ad1795778d..3a965218bf 100644 --- a/proteus/defaults.py +++ b/proteus/defaults.py @@ -1,4 +1,4 @@ -import sys, os, imp, copy, inspect, dataclasses +import sys, os, copy, inspect, dataclasses from . import (TransportCoefficients, Transport, default_p, @@ -23,6 +23,18 @@ from .Profiling import logEvent import sys +import importlib.util +import importlib.machinery + +def load_source(modname, filename): + loader = importlib.machinery.SourceFileLoader(modname, filename) + spec = importlib.util.spec_from_file_location(modname, filename, loader=loader) + module = importlib.util.module_from_spec(spec) + # The module is always executed and not cached in sys.modules. + # Uncomment the following line to cache the module. + # sys.modules[module.__name__] = module + loader.exec_module(module) + return module if sys.version_info.major < 3: # Python 2? # Using exec avoids a SyntaxError in Python 3. @@ -102,7 +114,7 @@ def reset_default_p(): def load_physics(pModule, path='.'): reset_default_p() sys.path.append(path) - p = imp.load_source(pModule, os.path.join(path, pModule+".py")) + p = load_source(pModule, os.path.join(path, pModule+".py")) sys.path.remove(path) physics_object = Physics_base() for k,v in p.__dict__.items(): @@ -193,7 +205,7 @@ def reset_default_n(): def load_numerics(nModule, path='.'): reset_default_n() sys.path.append(path) - n = imp.load_source(nModule, os.path.join(path, nModule+".py")) + n = load_source(nModule, os.path.join(path, nModule+".py")) sys.path.remove(path) numerics_object = Numerics_base() for k,v in n.__dict__.items(): @@ -234,11 +246,10 @@ def reset_default_so(): def load_system(soModule, path='.'): reset_default_so() sys.path.append(path) - so = imp.load_source(soModule, os.path.join(path, soModule+".py")) + so = load_source(soModule, os.path.join(path, soModule+".py")) sys.path.remove(path) system_object = System_base() for k,v in so.__dict__.items(): if k not in system_excluded_keys: system_object.__dict__[k] = v return system_object - diff --git a/proteus/deim_utils.py b/proteus/deim_utils.py index fb05a6563d..4dc46002ed 100644 --- a/proteus/deim_utils.py +++ b/proteus/deim_utils.py @@ -2,9 +2,6 @@ """ utility module for generating deim interpolants """ -from __future__ import division -from builtins import range -from past.utils import old_div import numpy as np def read_from_hdf5(hdfFile,label,dof_map=None): @@ -14,7 +11,7 @@ def read_from_hdf5(hdfFile,label,dof_map=None): If dof_map is not none, this determines shape of the output array """ assert hdfFile is not None, "requires hdf5 for heavy data" - vals = hdfFile.get_node(label).read() + vals = hdfFile[label][:] if dof_map is not None: dof = vals[dof_map] else: @@ -29,7 +26,7 @@ def read_snapshots(archive,nsnap,val_name): loads these into a matrix and returns """ - label_base="/%s%d" + label_base="/%s_t%d" u = read_from_hdf5(archive.hdfFile,label_base % (val_name,0)) S = np.reshape(u,(u.shape[0],1)) for i in range(1,nsnap): @@ -77,7 +74,7 @@ def calculate_deim_indices(Uin): Up=U[rho]#Up= np.dot(Pt,U) up=u[rho]#up= np.dot(Pt,u) if j==1: - c=old_div(up,Up) + c=up/Up r=u-U*c else: c =np.linalg.solve(Up,up) diff --git a/proteus/elastoplastic/ElastoPlastic.py b/proteus/elastoplastic/ElastoPlastic.py index 9c22465c56..c2ed0eb180 100644 --- a/proteus/elastoplastic/ElastoPlastic.py +++ b/proteus/elastoplastic/ElastoPlastic.py @@ -1,8 +1,3 @@ -from __future__ import print_function -from __future__ import division -from builtins import str -from builtins import range -from past.utils import old_div import proteus from proteus import FemTools, Archiver from .cElastoPlastic import * @@ -144,8 +139,8 @@ def postStep(self,t,firstStep=False): for it in range(self.materialProperties.shape[0]): #cek hack for veg on levees if it != 7: - self.materialProperties[it,5] = atan(old_div(tan(self.materialProperties_default[it,5]),self.SRF))#phi_mc - self.materialProperties[it,6] = old_div(self.materialProperties_default[it,6],self.SRF)#c_mc + self.materialProperties[it,5] = atan(tan(self.materialProperties_default[it,5])/self.SRF)#phi_mc + self.materialProperties[it,6] = self.materialProperties_default[it,6]/self.SRF#c_mc self.copyInstructions = {'reset_uList':True} else: print("Completed========================SRF = "+repr(self.SRF)+"===============================") @@ -153,8 +148,8 @@ def postStep(self,t,firstStep=False): self.SRF += 0.05 for it in range(self.materialProperties.shape[0]): if it != 7: - self.materialProperties[it,5] = atan(old_div(tan(self.materialProperties_default[it,5]),self.SRF))#phi_mc - self.materialProperties[it,6] = old_div(self.materialProperties_default[it,6],self.SRF)#c_mc + self.materialProperties[it,5] = atan(tan(self.materialProperties_default[it,5])/self.SRF)#phi_mc + self.materialProperties[it,6] = self.materialProperties_default[it,6]/self.SRF#c_mc self.copyInstructions = None print("=========Not Updating Mesh=================") #self.mesh.nodeArray[:,0]+=self.model.u[0].dof @@ -611,14 +606,14 @@ def __init__(self, if 'penalty' in self.ebq_global: for ebN in range(self.mesh.nElementBoundaries_global): for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebq_global['penalty'][ebN,k] = old_div(self.numericalFlux.penalty_constant,(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power)) + self.ebq_global['penalty'][ebN,k] = self.numericalFlux.penalty_constant/(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) #penalty term #cek move to Numerical flux initialization if 'penalty' in self.ebqe: for ebNE in range(self.mesh.nExteriorElementBoundaries_global): ebN = self.mesh.exteriorElementBoundariesArray[ebNE] for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebqe['penalty'][ebNE,k] = old_div(self.numericalFlux.penalty_constant,self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) + self.ebqe['penalty'][ebNE,k] = self.numericalFlux.penalty_constant/self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power logEvent(memory("numericalFlux","OneLevelTransport"),level=4) self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray #use post processing tools to get conservative fluxes, None by default diff --git a/proteus/elastoplastic/__init__.py b/proteus/elastoplastic/__init__.py index 2444933d36..954f14b54b 100644 --- a/proteus/elastoplastic/__init__.py +++ b/proteus/elastoplastic/__init__.py @@ -3,4 +3,4 @@ """ __all__ = ["ElastoPlastic", - "cElastoPlastic"] + "cElastoPlastic"] \ No newline at end of file diff --git a/proteus/fenton/Fourier.cpp b/proteus/fenton/Fourier.cpp index 9acbb9a4a9..2d19d2306e 100644 --- a/proteus/fenton/Fourier.cpp +++ b/proteus/fenton/Fourier.cpp @@ -5,7 +5,7 @@ #include #include #include -#include "ncurses/curses.h" +#include "ncursesw/curses.h" #include #define ANSI #include "Allocation.h" diff --git a/proteus/fenton/Inout.cpp b/proteus/fenton/Inout.cpp index fa915251fa..df9a7ff812 100644 --- a/proteus/fenton/Inout.cpp +++ b/proteus/fenton/Inout.cpp @@ -1,5 +1,5 @@ #include -#include "ncurses/curses.h" +#include "ncursesw/curses.h" #include #include #include diff --git a/proteus/fenton/Subroutines.cpp b/proteus/fenton/Subroutines.cpp index 2970aa9ed1..4e084bc990 100644 --- a/proteus/fenton/Subroutines.cpp +++ b/proteus/fenton/Subroutines.cpp @@ -4,7 +4,7 @@ #include #include #include -#include "ncurses/curses.h" +#include "ncursesw/curses.h" #define iff(x,y) if(strcmp(x,#y)==0) #define pi 3.14159265358979324 diff --git a/proteus/iproteus.py b/proteus/iproteus.py index aee419c064..3053e79927 100755 --- a/proteus/iproteus.py +++ b/proteus/iproteus.py @@ -12,11 +12,6 @@ # \brief A driver for both single and mult-model simulations # # - -from __future__ import print_function -from builtins import zip -from builtins import str -from builtins import range from importlib import reload import os import proteus diff --git a/proteus/mbd/ChBodyAddedMass.cpp b/proteus/mbd/ChBodyAddedMass.cpp index 941cce874e..1ee3df9974 100644 --- a/proteus/mbd/ChBodyAddedMass.cpp +++ b/proteus/mbd/ChBodyAddedMass.cpp @@ -3,24 +3,24 @@ namespace chrono { - // Register into the object factory, to enable run-time dynamic creation and persistence - CH_FACTORY_REGISTER(ChBodyAddedMass) + // Register into the object factory, to enable run-time dynamic creation and persistence + CH_FACTORY_REGISTER(ChBodyAddedMass) - ChBodyAddedMass::ChBodyAddedMass() { - ChBody::variables = variables; - } + ChBodyAddedMass::ChBodyAddedMass() { + ChBody::variables = variables; + } void ChBodyAddedMass::SetMass(double newmass) { - variables.SetBodyMass(newmass); - ChBody::variables.SetBodyMass(newmass); - } + variables.SetBodyMass(newmass); + ChBody::variables.SetBodyMass(newmass); + } void ChBodyAddedMass::SetInertia(const ChMatrix33<>& newXInertia) { variables.SetBodyInertia(newXInertia); ChBody::variables.SetBodyInertia(newXInertia); } - void ChBodyAddedMass::SetInertiaXX(const ChVector<>& iner) { + void ChBodyAddedMass::SetInertiaXX(const ChVector3d& iner) { variables.GetBodyInertia()(0, 0) = iner.x(); variables.GetBodyInertia()(1, 1) = iner.y(); variables.GetBodyInertia()(2, 2) = iner.z(); @@ -28,7 +28,7 @@ namespace chrono { ChBody::SetInertiaXX(iner); } - void ChBodyAddedMass::SetInertiaXY(const ChVector<>& iner) { + void ChBodyAddedMass::SetInertiaXY(const ChVector3d& iner) { variables.GetBodyInertia()(0, 1) = iner.x(); variables.GetBodyInertia()(0, 2) = iner.y(); variables.GetBodyInertia()(1, 2) = iner.z(); @@ -55,81 +55,81 @@ namespace chrono { // return iner; // } - void ChBodyAddedMass::SetMfullmass(ChMatrixDynamic<> Mfullmass_in) { - assert(Mfullmass_in.rows() == variables.Get_ndof()); - assert(Mfullmass_in.cols() == variables.Get_ndof()); - variables.SetMfullmass(Mfullmass_in); - } + void ChBodyAddedMass::SetMfullmass(ChMatrixDynamic<> Mfullmass_in) { + assert(Mfullmass_in.rows() == variables.GetDOF()); + assert(Mfullmass_in.cols() == variables.GetDOF()); + variables.SetMfullmass(Mfullmass_in); + } - // void ChBodyAddedMass::SetInvMfullmass(ChMatrixDynamic<> inv_Mfullmass_in) { - // assert(inv_Mfullmass_in.GetRows() == variables.Get_ndof()); - // assert(inv_Mfullmass_in.GetColumns() == variables.Get_ndof()); - // ChMatrixDynamic<>& Mm = variables.GetInvMfullmass(); - // for (int i = 0; i < 6; i++) { - // for (int j = 0; j < 6; j++) { - // Mm(i, j) = inv_Mfullmass_in(i, j); - // } - // } - // } -//// STATE BOOKKEEPING FUNCTIONS - - - -void ChBodyAddedMass::IntToDescriptor(const unsigned int off_v, // offset in v, R - const ChStateDelta& v, - const ChVectorDynamic<>& R, - const unsigned int off_L, // offset in L, Qc - const ChVectorDynamic<>& L, - const ChVectorDynamic<>& Qc) { - this->variables.Get_qb() = v.segment(off_v, 6); - this->variables.Get_fb() = R.segment(off_v, 6); -} - -void ChBodyAddedMass::IntFromDescriptor(const unsigned int off_v, // offset in v - ChStateDelta& v, - const unsigned int off_L, // offset in L - ChVectorDynamic<>& L) { - v.segment(off_v, 6) = this->variables.Get_qb(); -} - -//// - -void ChBodyAddedMass::InjectVariables(ChSystemDescriptor& mdescriptor) { + // void ChBodyAddedMass::SetInvMfullmass(ChMatrixDynamic<> inv_Mfullmass_in) { + // assert(inv_Mfullmass_in.GetRows() == variables.GetDOF()); + // assert(inv_Mfullmass_in.GetColumns() == variables.GetDOF()); + // ChMatrixDynamic<>& Mm = variables.GetInvMfullmass(); + // for (int i = 0; i < 6; i++) { + // for (int j = 0; j < 6; j++) { + // Mm(i, j) = inv_Mfullmass_in(i, j); + // } + // } + // } + //// STATE BOOKKEEPING FUNCTIONS + + + + void ChBodyAddedMass::IntToDescriptor(const unsigned int off_v, // offset in v, R + const ChStateDelta& v, + const ChVectorDynamic<>& R, + const unsigned int off_L, // offset in L, Qc + const ChVectorDynamic<>& L, + const ChVectorDynamic<>& Qc) { + this->variables.State() = v.segment(off_v, 6); + this->variables.Force() = R.segment(off_v, 6); + } + + void ChBodyAddedMass::IntFromDescriptor(const unsigned int off_v, // offset in v + ChStateDelta& v, + const unsigned int off_L, // offset in L + ChVectorDynamic<>& L) { + v.segment(off_v, 6) = this->variables.State(); + } + + //// + + void ChBodyAddedMass::InjectVariables(ChSystemDescriptor& mdescriptor) { this->variables.SetDisabled(!this->IsActive()); mdescriptor.InsertVariables(&this->variables); -} + } -void ChBodyAddedMass::VariablesFbReset() { - this->variables.Get_fb().setZero(); -} + void ChBodyAddedMass::VariablesFbReset() { + this->variables.Force().setZero(); + } -void ChBodyAddedMass::VariablesFbLoadForces(double factor) { - // add applied forces to 'fb' vector - this->variables.Get_fb().segment(0, 3) += factor * Xforce.eigen(); + void ChBodyAddedMass::VariablesFbLoadForces(double factor) { + // add applied forces to Force vector + this->variables.Force().segment(0, 3) += factor * Xforce.eigen(); - // add applied torques to 'fb' vector, including gyroscopic torque - if (this->GetNoGyroTorque()) - this->variables.Get_fb().segment(3, 3) += factor * Xtorque.eigen(); + // add applied torques to Force vector, including gyroscopic torque + if (this->IsUsingGyroTorque()) + this->variables.Force().segment(3, 3) += factor * Xtorque.eigen(); else - this->variables.Get_fb().segment(3, 3) += factor * (Xtorque - gyro).eigen(); -} + this->variables.Force().segment(3, 3) += factor * (Xtorque - gyro).eigen(); + } -void ChBodyAddedMass::VariablesFbIncrementMq() { - this->variables.Compute_inc_Mb_v(this->variables.Get_fb(), this->variables.Get_qb()); -} + void ChBodyAddedMass::VariablesFbIncrementMq() { + this->variables.AddMassTimesVector(this->variables.Force(), this->variables.State()); + } -void ChBodyAddedMass::VariablesQbLoadSpeed() { - // set current speed in 'qb', it can be used by the solver when working in incremental mode - this->variables.Get_qb().segment(0, 3) = GetCoord_dt().pos.eigen(); - this->variables.Get_qb().segment(3, 3) = GetWvel_loc().eigen(); -} + void ChBodyAddedMass::VariablesQbLoadSpeed() { + // set current speed in State, it can be used by the solver when working in incremental mode + this->variables.State().segment(0, 3) = GetCoordsysDt().pos.eigen(); + this->variables.State().segment(3, 3) = GetAngVelLocal().eigen(); + } -void ChBodyAddedMass::VariablesQbSetSpeed(double step) { - ChCoordsys<> old_coord_dt = this->GetCoord_dt(); + void ChBodyAddedMass::VariablesQbSetSpeed(double step) { + ChCoordsys<> old_coord_dt = this->GetCoordsysDt(); - // from 'qb' vector, sets body speed, and updates auxiliary data - this->SetPos_dt(this->variables.Get_qb().segment(0, 3)); - this->SetWvel_loc(this->variables.Get_qb().segment(3, 3)); + // from State vector, sets body speed, and updates auxiliary data + this->SetPosDt(this->variables.State().segment(0, 3)); + this->SetAngVelLocal(this->variables.State().segment(3, 3)); // apply limits (if in speed clamping mode) to speeds. ClampSpeed(); @@ -139,20 +139,20 @@ void ChBodyAddedMass::VariablesQbSetSpeed(double step) { // Compute accel. by BDF (approximate by differentiation); if (step) { - this->SetPos_dtdt((this->GetCoord_dt().pos - old_coord_dt.pos) / step); - this->SetRot_dtdt((this->GetCoord_dt().rot - old_coord_dt.rot) / step); + this->SetPosDt2((this->GetCoordsysDt().pos - old_coord_dt.pos) / step); + this->SetRotDt2((this->GetCoordsysDt().rot - old_coord_dt.rot) / step); } -} + } -void ChBodyAddedMass::VariablesQbIncrementPosition(double dt_step) { + void ChBodyAddedMass::VariablesQbIncrementPosition(double dt_step) { if (!this->IsActive()) - return; + return; // Updates position with incremental action of speed contained in the - // 'qb' vector: pos' = pos + dt * speed , like in an Eulero step. + // State vector: pos' = pos + dt * speed , like in an Eulero step. - ChVector<> newspeed(variables.Get_qb().segment(0, 3)); - ChVector<> newwel(variables.Get_qb().segment(3, 3)); + ChVector3d newspeed(variables.State().segment(0, 3)); + ChVector3d newwel(variables.State().segment(3, 3)); // ADVANCE POSITION: pos' = pos + dt * vel this->SetPos(this->GetPos() + newspeed * dt_step); @@ -160,40 +160,40 @@ void ChBodyAddedMass::VariablesQbIncrementPosition(double dt_step) { // ADVANCE ROTATION: rot' = [dt*wwel]%rot (use quaternion for delta rotation) ChQuaternion<> mdeltarot; ChQuaternion<> moldrot = this->GetRot(); - ChVector<> newwel_abs = Amatrix * newwel; + ChVector3d newwel_abs = this->GetRotMat() * newwel; double mangle = newwel_abs.Length() * dt_step; newwel_abs.Normalize(); - mdeltarot.Q_from_AngAxis(mangle, newwel_abs); - ChQuaternion<> mnewrot = mdeltarot % moldrot; + mdeltarot.SetFromAngleAxis(mangle, newwel_abs); + ChQuaternion<> mnewrot = mdeltarot * moldrot; this->SetRot(mnewrot); -} + } -void ChBodyAddedMass::IntLoadResidual_F(const unsigned int off, // offset in R residual - ChVectorDynamic<>& R, // result: the R residual, R += c*F - const double c // a scaling factor - ) { + void ChBodyAddedMass::IntLoadResidual_F(const unsigned int off, // offset in R residual + ChVectorDynamic<>& R, // result: the R residual, R += c*F + const double c // a scaling factor + ) { - // add applied forces to 'fb' vector + // add applied forces to Force vector R.segment(off, 3) += c * Xforce.eigen(); - // add applied torques to 'fb' vector, including gyroscopic torque - if (this->GetNoGyroTorque()) - R.segment(off + 3, 3) += c * Xtorque.eigen(); + // add applied torques to Force vector, including gyroscopic torque + if (this->IsUsingGyroTorque()) + R.segment(off + 3, 3) += c * Xtorque.eigen(); else - R.segment(off + 3, 3) += c * (Xtorque - gyro).eigen(); -} - -void ChBodyAddedMass::IntLoadResidual_Mv(const unsigned int off, // offset in R residual - ChVectorDynamic<>& R, // result: the R residual, R += c*M*v - const ChVectorDynamic<>& w, // the w vector - const double c // a scaling factor - ) { - ChMatrixDynamic<> ww = ChMatrixDynamic<>(6, 1); - for (int i=0; i < 6; i++) { - ww(i, 0) = w(off+i); - } - R.segment(off, 6) += variables.GetMfullmass()*ww*c; -} + R.segment(off + 3, 3) += c * (Xtorque - gyro).eigen(); + } + + void ChBodyAddedMass::IntLoadResidual_Mv(const unsigned int off, // offset in R residual + ChVectorDynamic<>& R, // result: the R residual, R += c*M*v + const ChVectorDynamic<>& w, // the w vector + const double c // a scaling factor + ) { + ChMatrixDynamic<> ww = ChMatrixDynamic<>(6, 1); + for (int i=0; i < 6; i++) { + ww(i, 0) = w(off+i); + } + R.segment(off, 6) += variables.GetMfullmass()*ww*c; + } } // end namespace chrono chrono::ChBodyAddedMass * newChBodyAddedMass() diff --git a/proteus/mbd/ChBodyAddedMass.h b/proteus/mbd/ChBodyAddedMass.h index 172fd2901d..dad77ac1ac 100644 --- a/proteus/mbd/ChBodyAddedMass.h +++ b/proteus/mbd/ChBodyAddedMass.h @@ -5,16 +5,16 @@ #include "ChVariablesBodyAddedMass.h" namespace chrono { - class ChBodyAddedMass : public ChBody { - protected: - ChVariablesBodyAddedMass variables; - public: - ChBodyAddedMass(); - virtual ~ChBodyAddedMass() {} + class ChBodyAddedMass : public ChBody { + protected: + ChVariablesBodyAddedMass variables; + public: + ChBodyAddedMass(); + virtual ~ChBodyAddedMass() {} void SetMass(double newmass); void SetInertia(const ChMatrix33<>& iner); - void SetInertiaXX(const ChVector<>& iner); - void SetInertiaXY(const ChVector<>& iner); + void SetInertiaXX(const ChVector3d& iner); + void SetInertiaXY(const ChVector3d& iner); /* ChVector<> GetInertiaXX(); */ /* ChVector<> GetInertiaXY(); */ /* double GetMass() { return variables.GetBodyMass(); }; */ @@ -91,7 +91,7 @@ namespace chrono { /// ChVariables in this object (for further passing it to a solver) virtual void InjectVariables(ChSystemDescriptor& mdescriptor) override; - }; + }; } // end namespace chrono diff --git a/proteus/mbd/ChVariablesBodyAddedMass.cpp b/proteus/mbd/ChVariablesBodyAddedMass.cpp index 162f40fce6..e65f82dc30 100644 --- a/proteus/mbd/ChVariablesBodyAddedMass.cpp +++ b/proteus/mbd/ChVariablesBodyAddedMass.cpp @@ -1,159 +1,159 @@ -// ============================================================================= -// PROJECT CHRONO - http://projectchrono.org -// -// Copyright (c) 2014 projectchrono.org -// All rights reserved. -// -// Use of this source code is governed by a BSD-style license that can be found -// in the LICENSE file at the top level of the distribution and at -// http://projectchrono.org/license-chrono.txt. -// -// ============================================================================= -// Authors: Tristan de Lataillade -// ============================================================================= - -#include "ChVariablesBodyAddedMass.h" - -namespace chrono { - -// Register into the object factory, to enable run-time dynamic creation and persistence -CH_FACTORY_REGISTER(ChVariablesBodyAddedMass) - -ChVariablesBodyAddedMass::ChVariablesBodyAddedMass() : ndof(6) { - Maddedmass = ChMatrixDynamic<>(ndof, ndof); - Maddedmass.setIdentity(); - Mmass = ChMatrixDynamic<>(ndof, ndof); - Mmass.setIdentity(); - Mfullmass = ChMatrixDynamic<>(ndof, ndof); - Mfullmass.setIdentity(); - inv_Mfullmass = ChMatrixDynamic<>(ndof, ndof); - inv_Mfullmass.setIdentity(); -} - -ChVariablesBodyAddedMass& ChVariablesBodyAddedMass::operator=(const ChVariablesBodyAddedMass& other) { - if (&other == this) - return *this; - - // copy parent class data - ChVariablesBodyOwnMass::operator=(other); - - // copy class data - Mmass = other.Mmass; - Maddedmass = other.Maddedmass; - Mfullmass = other.Mfullmass; - inv_Mfullmass = other.inv_Mfullmass; - return *this; -} - -void ChVariablesBodyAddedMass::SetMfullmass(ChMatrixDynamic<>& Mfullmass_in) { - assert(Mfullmass_in.rows() == Get_ndof()); - assert(Mfullmass_in.cols() == Get_ndof()); - GetMfullmass() = Mfullmass_in; - GetInvMfullmass() = Mfullmass_in.inverse(); -} - - // Set the inertia matrix - // void ChVariablesBodyAddedMass::SetBodyInertia(const ChMatrix33<>& minertia) { - // ChVariablesBodyOwnMass::SetBodyInertia(minertia); - // GetLog() << "JUST SET " << ChVariablesBodyOwnMass::GetBodyInertia(); - // GetLog() << "JUST SET 2 " << GetBodyInertia(); - // } - - // // Set the mass associated with translation of body - // void ChVariablesBodyAddedMass::SetBodyMass(const double mmass) { - // ChVariablesBodyOwnMass::SetBodyMass(mmass); - // } -// /// Set the inertia matrix -// void ChVariablesBodyAddedMass::SetBodyInertia(const ChMatrix33<>& minertia) { -// ChVariablesBodyOwnMass::SetBodyInertia(minertia); -// /// Add inertia to mass matrix -// ChMatrix33<>& bodyinertia = ChVariablesBodyOwnMass::GetBodyInertia(); -// for (int i = 0; i < 3; i++) { -// for (int j = 0; j < 3; j++) { -// Mmass(3 + i, 3 + j) = bodyinertia(i, j); -// } -// } -// Mfullmass = Mmass + Maddedmass; -// } - - -// /// Set the mass associated with translation of body -// void ChVariablesBodyAddedMass::SetBodyMass(const double mmass) { -// /// Value of mass as double -// ChVariablesBodyOwnMass::SetBodyMass(mmass); -// /// Value of mass in mass matrix -// Mmass(0, 0) = mmass; -// Mmass(1, 1) = mmass; -// Mmass(2, 2) = mmass; -// /// rebuild full mass matrix -// Mfullmass = Mmass + Maddedmass; -// } - -// /// Set the added mass matrix of the body (6x6) -// void ChVariablesBodyAddedMass::SetBodyAddedMass(ChMatrixDynamic<>& Maddedmass_in) { -// assert(Maddedmass_in.GetRows() == Get_ndof()); -// assert(Maddedmass_in.GetColums() == Get_ndof()); -// Maddedmass.CopyFromMatrix(Maddedmass_in); -// /// rebuild full mass matrix -// Mfullmass = Mmass + Maddedmass; -// } - -// Computes the product of the inverse mass matrix by a -// vector, and set in result: result = [invMb]*vect -void ChVariablesBodyAddedMass::Compute_invMb_v(ChVectorRef result, const ChVectorConstRef vect) const { - assert(vect.size() == Get_ndof()); - assert(result.size() == Get_ndof()); - result = inv_Mfullmass * vect; -} - -// Computes the product of the inverse mass matrix by a -// vector, and increment result: result += [invMb]*vect -void ChVariablesBodyAddedMass::Compute_inc_invMb_v(ChVectorRef result, const ChVectorConstRef vect) const { - assert(vect.size() == Get_ndof()); - assert(result.size() == Get_ndof()); - result += inv_Mfullmass * vect; -} - -// Computes the product of the mass matrix by a -// vector, and set in result: result = [Mb]*vect -void ChVariablesBodyAddedMass::Compute_inc_Mb_v(ChVectorRef result, const ChVectorConstRef vect) const { - assert(vect.size() == Get_ndof()); - assert(result.size() == Get_ndof()); - result += Mfullmass * vect; -} - -// Computes the product of the corresponding block in the -// system matrix (ie. the mass matrix) by 'vect', scale by c_a, and add to 'result'. -// NOTE: the 'vect' and 'result' vectors must already have -// the size of the total variables&constraints in the system; the procedure -// will use the ChVariable offsets (that must be already updated) to know the -// indexes in result and vect. -void ChVariablesBodyAddedMass::MultiplyAndAdd(ChVectorRef result, - const ChVectorConstRef vect, - const double c_a) const { - int off = this->offset; - result.segment(off, 6) += Mfullmass*vect.segment(off, 6)*c_a; -} - -// Add the diagonal of the mass matrix scaled by c_a to 'result'. -// NOTE: the 'result' vector must already have the size of system unknowns, ie -// the size of the total variables&constraints in the system; the procedure -// will use the ChVariable offset (that must be already updated) as index. -void ChVariablesBodyAddedMass::DiagonalAdd(ChVectorRef result, const double c_a) const { - assert(result.size() >= this->offset + Get_ndof()); - for (int i = 0; i < Get_ndof(); i++) { - result(this->offset + i) += c_a * Mfullmass(i, i); - } -} - -// Build the mass matrix (for these variables) scaled by c_a, storing -// it in 'storage' sparse matrix, at given column/row offset. -// Note, most iterative solvers don't need to know mass matrix explicitly. -// Optimized: doesn't fill unneeded elements except mass and 3x3 inertia. -void ChVariablesBodyAddedMass::Build_M(ChSparseMatrix& storage, int insrow, int inscol, const double c_a) { - for (int row = 0; row < Get_ndof(); ++row) - for (int col = 0; col < Get_ndof(); ++col) - storage.SetElement(insrow + row, inscol + col, c_a * Mfullmass(row, col)); -} - -} // end namespace chrono +// ============================================================================= +// PROJECT CHRONO - http://projectchrono.org +// +// Copyright (c) 2014 projectchrono.org +// All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found +// in the LICENSE file at the top level of the distribution and at +// http://projectchrono.org/license-chrono.txt. +// +// ============================================================================= +// Authors: Tristan de Lataillade, Chris Kees +// ============================================================================= + +#include "ChVariablesBodyAddedMass.h" + +namespace chrono { + + // Register into the object factory, to enable run-time dynamic creation and persistence + CH_FACTORY_REGISTER(ChVariablesBodyAddedMass) + + ChVariablesBodyAddedMass::ChVariablesBodyAddedMass() : ndof(6) { + Maddedmass = ChMatrixDynamic<>(ndof, ndof); + Maddedmass.setIdentity(); + Mmass = ChMatrixDynamic<>(ndof, ndof); + Mmass.setIdentity(); + Mfullmass = ChMatrixDynamic<>(ndof, ndof); + Mfullmass.setIdentity(); + inv_Mfullmass = ChMatrixDynamic<>(ndof, ndof); + inv_Mfullmass.setIdentity(); + } + + ChVariablesBodyAddedMass& ChVariablesBodyAddedMass::operator=(const ChVariablesBodyAddedMass& other) { + if (&other == this) + return *this; + + // copy parent class data + ChVariablesBodyOwnMass::operator=(other); + + // copy class data + Mmass = other.Mmass; + Maddedmass = other.Maddedmass; + Mfullmass = other.Mfullmass; + inv_Mfullmass = other.inv_Mfullmass; + return *this; + } + + void ChVariablesBodyAddedMass::SetMfullmass(ChMatrixDynamic<>& Mfullmass_in) { + assert(Mfullmass_in.rows() == GetDOF()); + assert(Mfullmass_in.cols() == GetDOF()); + GetMfullmass() = Mfullmass_in; + GetInvMfullmass() = Mfullmass_in.inverse(); + } + + // Set the inertia matrix + // void ChVariablesBodyAddedMass::SetBodyInertia(const ChMatrix33<>& minertia) { + // ChVariablesBodyOwnMass::SetBodyInertia(minertia); + // GetLog() << "JUST SET " << ChVariablesBodyOwnMass::GetBodyInertia(); + // GetLog() << "JUST SET 2 " << GetBodyInertia(); + // } + + // // Set the mass associated with translation of body + // void ChVariablesBodyAddedMass::SetBodyMass(const double mmass) { + // ChVariablesBodyOwnMass::SetBodyMass(mmass); + // } + // /// Set the inertia matrix + // void ChVariablesBodyAddedMass::SetBodyInertia(const ChMatrix33<>& minertia) { + // ChVariablesBodyOwnMass::SetBodyInertia(minertia); + // /// Add inertia to mass matrix + // ChMatrix33<>& bodyinertia = ChVariablesBodyOwnMass::GetBodyInertia(); + // for (int i = 0; i < 3; i++) { + // for (int j = 0; j < 3; j++) { + // Mmass(3 + i, 3 + j) = bodyinertia(i, j); + // } + // } + // Mfullmass = Mmass + Maddedmass; + // } + + + // /// Set the mass associated with translation of body + // void ChVariablesBodyAddedMass::SetBodyMass(const double mmass) { + // /// Value of mass as double + // ChVariablesBodyOwnMass::SetBodyMass(mmass); + // /// Value of mass in mass matrix + // Mmass(0, 0) = mmass; + // Mmass(1, 1) = mmass; + // Mmass(2, 2) = mmass; + // /// rebuild full mass matrix + // Mfullmass = Mmass + Maddedmass; + // } + + // /// Set the added mass matrix of the body (6x6) + // void ChVariablesBodyAddedMass::SetBodyAddedMass(ChMatrixDynamic<>& Maddedmass_in) { + // assert(Maddedmass_in.GetRows() == GetDOF()); + // assert(Maddedmass_in.GetColums() == GetDOF()); + // Maddedmass.CopyFromMatrix(Maddedmass_in); + // /// rebuild full mass matrix + // Mfullmass = Mmass + Maddedmass; + // } + + // Computes the product of the inverse mass matrix by a + // vector, and set in result: result = [invMb]*vect + void ChVariablesBodyAddedMass::ComputeMassInverseTimesVector(ChVectorRef result, ChVectorConstRef vect) const { + assert(vect.size() == GetDOF()); + assert(result.size() == GetDOF()); + result = inv_Mfullmass * vect; + } + + // Computes the product of the inverse mass matrix by a + // vector, and increment result: result += [invMb]*vect + void ChVariablesBodyAddedMass::Compute_inc_invMb_v(ChVectorRef result, ChVectorConstRef vect) const { + assert(vect.size() == GetDOF()); + assert(result.size() == GetDOF()); + result += inv_Mfullmass * vect; + } + + // Computes the product of the mass matrix by a + // vector, and set in result: result = [Mb]*vect + void ChVariablesBodyAddedMass::AddMassTimesVector(ChVectorRef result, const ChVectorConstRef vect) const { + assert(vect.size() == GetDOF()); + assert(result.size() == GetDOF()); + result += Mfullmass * vect; + } + + // Computes the product of the corresponding block in the + // system matrix (ie. the mass matrix) by 'vect', scale by c_a, and add to 'result'. + // NOTE: the 'vect' and 'result' vectors must already have + // the size of the total variables&constraints in the system; the procedure + // will use the ChVariable offsets (that must be already updated) to know the + // indexes in result and vect. + void ChVariablesBodyAddedMass::AddMassTimesVectorInto(ChVectorRef result, + ChVectorConstRef vect, + const double c_a) const { + int off = this->offset; + result.segment(off, 6) += Mfullmass*vect.segment(off, 6)*c_a; + } + + // Add the diagonal of the mass matrix scaled by c_a to 'result'. + // NOTE: the 'result' vector must already have the size of system unknowns, ie + // the size of the total variables&constraints in the system; the procedure + // will use the ChVariable offset (that must be already updated) as index. + void ChVariablesBodyAddedMass::AddMassDiagonalInto(ChVectorRef result, const double c_a) const { + assert(result.size() >= this->offset + GetDOF()); + for (int i = 0; i < GetDOF(); i++) { + result(this->offset + i) += c_a * Mfullmass(i, i); + } + } + + // Build the mass matrix (for these variables) scaled by c_a, storing + // it in 'storage' sparse matrix, at given column/row offset. + // Note, most iterative solvers don't need to know mass matrix explicitly. + // Optimized: doesn't fill unneeded elements except mass and 3x3 inertia. + void ChVariablesBodyAddedMass::PasteMassInto(ChSparseMatrix& storage, unsigned int insrow, unsigned int inscol, const double c_a) const { + for (int row = 0; row < GetDOF(); ++row) + for (int col = 0; col < GetDOF(); ++col) + storage.SetElement(insrow + row, inscol + col, c_a * Mfullmass(row, col)); + } + +} // end namespace chrono diff --git a/proteus/mbd/ChVariablesBodyAddedMass.h b/proteus/mbd/ChVariablesBodyAddedMass.h index 6774e95785..b01dfc7655 100644 --- a/proteus/mbd/ChVariablesBodyAddedMass.h +++ b/proteus/mbd/ChVariablesBodyAddedMass.h @@ -1,116 +1,121 @@ -// ============================================================================= -// PROJECT CHRONO - http://projectchrono.org -// -// Copyright (c) 2014 projectchrono.org -// All rights reserved. -// -// Use of this source code is governed by a BSD-style license that can be found -// in the LICENSE file at the top level of the distribution and at -// http://projectchrono.org/license-chrono.txt. -// -// ============================================================================= -// Authors: Tristan de Lataillade -// ============================================================================= - -#ifndef CHVARIABLESBODYADDEDMASS_H -#define CHVARIABLESBODYADDEDMASS_H - -#include "chrono/solver/ChVariablesBodyOwnMass.h" - -namespace chrono { - - /// Specialized class for representing a 6-DOF item for a - /// system, that is a 3D rigid body, with mass matrix and - /// associate variables (a 6 element vector, ex.speed) - /// A full 6x6 matrix is used for the mass matrix, but forces - /// still computed using the "mass" variable of ChVariablesBodyOwnMass - - class ChApi ChVariablesBodyAddedMass : public ChVariablesBodyOwnMass { - - private: - int ndof; - /// 6x6 mass matrix (mass and moment of inertia) - ChMatrixDynamic<> Mmass; - /// 6x6 added mass matrix - ChMatrixDynamic<> Maddedmass; - /// 6x6 full matrix (mass + added mass) - ChMatrixDynamic<> Mfullmass; - ChMatrixDynamic<> inv_Mfullmass; - - public: - ChVariablesBodyAddedMass(); - virtual ~ChVariablesBodyAddedMass() {} - - /// Assignment operator: copy from other object - ChVariablesBodyAddedMass& operator=(const ChVariablesBodyAddedMass& other); - - /* /// Access the inertia matrix */ - /* ChMatrix<>& GetMaddedmass() { return Maddedmass; } */ - - /* /// Access the inertia matrix */ - /* ChMatrix<>& GetMmass() { return Mmass; } */ - - /// Set the inertia matrix - void SetMfullmass(ChMatrixDynamic<>& Mfullmass_in); - - /// Access the inertia matrix - ChMatrixDynamic<>& GetMfullmass() { return Mfullmass; } - - /// Access the inverted inertia matrix - ChMatrixDynamic<>& GetInvMfullmass() { return inv_Mfullmass; } - - /* /// Set the inertia matrix */ - /* void SetBodyInertia(const ChMatrix33<>& minertia); */ - - /* /// Set the mass associated with translation of body */ - /* void SetBodyMass(const double mmass); */ - - /* /// Get the mass associated with translation of body */ - /* virtual double GetBodyMass() const override { return ChVariablesBodyOwnMass::mmass; } */ - - /* /// Access the 3x3 inertia matrix */ - /* virtual ChMatrix33<>& GetBodyInertia() override { return ChVariablesBodyOwnInertia::inertia; } */ - - /* /// Set the mass associated with translation of body */ - /* void SetBodyAddedMass(ChMatrixDynamic<>& Maddedmass_in); */ - - /// Computes the product of the inverse mass matrix by a - /// vector, and set in result: result = [invMb]*vect - virtual void Compute_invMb_v(ChVectorRef result, const ChVectorConstRef vect) const override; - - /// Computes the product of the inverse mass matrix by a - /// vector, and increment result: result += [invMb]*vect - virtual void Compute_inc_invMb_v(ChVectorRef result, const ChVectorConstRef vect) const override; - - /// Computes the product of the mass matrix by a - /// vector, and set in result: result = [Mb]*vect - virtual void Compute_inc_Mb_v(ChVectorRef result, const ChVectorConstRef vect) const override; - - /// Computes the product of the corresponding block in the - /// system matrix (ie. the mass matrix) by 'vect', scale by c_a, and add to 'result'. - /// NOTE: the 'vect' and 'result' vectors must already have - /// the size of the total variables&constraints in the system; the procedure - /// will use the ChVariable offsets (that must be already updated) to know the - /// indexes in result and vect. - virtual void MultiplyAndAdd(ChVectorRef result, - const ChVectorConstRef vect, - const double c_a) const override; - - /// Add the diagonal of the mass matrix scaled by c_a, to 'result'. - /// NOTE: the 'result' vector must already have the size of system unknowns, ie - /// the size of the total variables&constraints in the system; the procedure - /// will use the ChVariable offset (that must be already updated) as index. - virtual void DiagonalAdd(ChVectorRef result, const double c_a) const override; - - /// Build the mass matrix (for these variables) scaled by c_a, storing - /// it in 'storage' sparse matrix, at given column/row offset. - /// Note, most iterative solvers don't need to know mass matrix explicitly. - /// Optimized: doesn't fill unneeded elements except mass and 3x3 inertia. - virtual void Build_M(ChSparseMatrix& storage, int insrow, int inscol, const double c_a) override; - -}; - - -} // end namespace chrono - -#endif +// ============================================================================= +// PROJECT CHRONO - http://projectchrono.org +// +// Copyright (c) 2014 projectchrono.org +// All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found +// in the LICENSE file at the top level of the distribution and at +// http://projectchrono.org/license-chrono.txt. +// +// ============================================================================= +// Authors: Tristan de Lataillade, Chris Kees +// ============================================================================= + +#ifndef CHVARIABLESBODYADDEDMASS_H +#define CHVARIABLESBODYADDEDMASS_H + +#include "chrono/solver/ChVariablesBodyOwnMass.h" + +namespace chrono { + + /// Specialized class for representing a 6-DOF item for a + /// system, that is a 3D rigid body, with mass matrix and + /// associate variables (a 6 element vector, ex.speed) + /// A full 6x6 matrix is used for the mass matrix, but forces + /// still computed using the "mass" variable of ChVariablesBodyOwnMass + + class ChApi ChVariablesBodyAddedMass : public ChVariablesBodyOwnMass { + + private: + int ndof; + /// 6x6 mass matrix (mass and moment of inertia) + ChMatrixDynamic<> Mmass; + /// 6x6 added mass matrix + ChMatrixDynamic<> Maddedmass; + /// 6x6 full matrix (mass + added mass) + ChMatrixDynamic<> Mfullmass; + ChMatrixDynamic<> inv_Mfullmass; + + public: + ChVariablesBodyAddedMass(); + virtual ~ChVariablesBodyAddedMass() {} + + /// Assignment operator: copy from other object + ChVariablesBodyAddedMass& operator=(const ChVariablesBodyAddedMass& other); + + /* /// Access the inertia matrix */ + /* ChMatrix<>& GetMaddedmass() { return Maddedmass; } */ + + /* /// Access the inertia matrix */ + /* ChMatrix<>& GetMmass() { return Mmass; } */ + + /// Set the inertia matrix + void SetMfullmass(ChMatrixDynamic<>& Mfullmass_in); + + /// Access the inertia matrix + ChMatrixDynamic<>& GetMfullmass() { return Mfullmass; } + + /// Access the inverted inertia matrix + ChMatrixDynamic<>& GetInvMfullmass() { return inv_Mfullmass; } + + /* /// Set the inertia matrix */ + /* void SetBodyInertia(const ChMatrix33<>& minertia); */ + + /* /// Set the mass associated with translation of body */ + /* void SetBodyMass(const double mmass); */ + + /* /// Get the mass associated with translation of body */ + /* virtual double GetBodyMass() const override { return ChVariablesBodyOwnMass::mmass; } */ + + /* /// Access the 3x3 inertia matrix */ + /* virtual ChMatrix33<>& GetBodyInertia() override { return ChVariablesBodyOwnInertia::inertia; } */ + + /* /// Set the mass associated with translation of body */ + /* void SetBodyAddedMass(ChMatrixDynamic<>& Maddedmass_in); */ + + /// Computes the product of the inverse mass matrix by a + /// vector, and set in result: result = [invMb]*vect + //virtual void Compute_invMb_v(ChVectorRef result, const ChVectorConstRef vect) const override; + virtual void ComputeMassInverseTimesVector(ChVectorRef result, ChVectorConstRef vect) const override; + + /// Computes the product of the inverse mass matrix by a + /// vector, and increment result: result += [invMb]*vect + virtual void Compute_inc_invMb_v(ChVectorRef result, ChVectorConstRef vect) const; + + /// Computes the product of the mass matrix by a + /// vector, and set in result: result = [Mb]*vect + //virtual void Compute_inc_Mb_v(ChVectorRef result, const ChVectorConstRef vect) const override; + virtual void AddMassTimesVector(ChVectorRef results, ChVectorConstRef vect) const override; + + /// Computes the product of the corresponding block in the + /// system matrix (ie. the mass matrix) by 'vect', scale by c_a, and add to 'result'. + /// NOTE: the 'vect' and 'result' vectors must already have + /// the size of the total variables&constraints in the system; the procedure + /// will use the ChVariable offsets (that must be already updated) to know the + /// indexes in result and vect. + //virtual void MultiplyAndAdd(ChVectorRef result, + // const ChVectorConstRef vect, + // const double c_a) const override; + virtual void AddMassTimesVectorInto(ChVectorRef result, ChVectorConstRef vect, const double ca) const override; + + /// Add the diagonal of the mass matrix scaled by c_a, to 'result'. + /// NOTE: the 'result' vector must already have the size of system unknowns, ie + /// the size of the total variables&constraints in the system; the procedure + /// will use the ChVariable offset (that must be already updated) as index. + //virtual void DiagonalAdd(ChVectorRef result, const double c_a) const override; + virtual void AddMassDiagonalInto(ChVectorRef result, const double c_a) const override; + + /// Build the mass matrix (for these variables) scaled by c_a, storing + /// it in 'storage' sparse matrix, at given column/row offset. + /// Note, most iterative solvers don't need to know mass matrix explicitly. + /// Optimized: doesn't fill unneeded elements except mass and 3x3 inertia. + //virtual void Build_M(ChSparseMatrix& storage, int insrow, int inscol, const double c_a) override; + virtual void PasteMassInto(ChSparseMatrix& mat, unsigned int insrow, unsigned int inscol, const double c_a) const override; + + }; + + +} // end namespace chrono + +#endif diff --git a/proteus/mbd/ChronoHeaders.pxd b/proteus/mbd/ChronoHeaders.pxd index 1611fd8686..7aa2140c40 100644 --- a/proteus/mbd/ChronoHeaders.pxd +++ b/proteus/mbd/ChronoHeaders.pxd @@ -14,14 +14,28 @@ cdef extern from "ProtChMoorings.h": # ------- CORE ------- # - cdef cppclass ChVector[double]: + cdef cppclass ChVector3d: double x() double y() double z() - ChVector(double x, + ChVector3d(double x, double y, double z) - ChVector() + ChVector3d() + + cdef cppclass ChVector3i: + int x() + int y() + int z() + ChVector3d(int x, + int y, + int z) + ChVector3i() + + cdef cppclass ChWrenchd: + ChVector3d force + ChVector3d torque + ChWrenchd() cdef cppclass ChQuaternion[double]: double e0() @@ -35,19 +49,19 @@ cdef extern from "ProtChMoorings.h": ChQuaternion() cdef cppclass ChCoordsys[double]: - ChVector pos + ChVector3d pos ChQuaternion rot ChCoordsys() - ChCoordsys(ChVector &mv, + ChCoordsys(ChVector3d &mv, ChQuaternion &mq) - ChCoordsys(ChVector &mv, + ChCoordsys(ChVector3d &mv, double Alpha, - ChVector &mu) + ChVector3d &mu) cdef cppclass ChMatrix33[double]: - ChVector Get_A_Xaxis() - ChVector Get_A_Yaxis() - ChVector Get_A_Zaxis() + ChVector3d GetAxisX() + ChVector3d GetAxisY() + ChVector3d GetAxisZ() # void CopyFromMatrixT(ChMatrix matra) # ChMatrix33() # ChMatrix33(ChQuaternion quat) @@ -58,26 +72,26 @@ cdef extern from "ProtChMoorings.h": const int col) # ChMatrixDynamic operator=(const ChMatrix& matbis) # ChMatrixDynamic operator+(const ChMatrix& matbis) - ChVector Get_A_Xaxis() - ChVector Get_A_Yaxis() - ChVector Get_A_Zaxis() + ChVector3d GetAxisX() + ChVector3d GetAxisY() + ChVector3d GetAxisZ() cdef cppclass ChTriangle: - ChTriangle(const ChVector &mp1, - const ChVector &mp2, - const ChVector &mp3) + ChTriangle(const ChVector3d &mp1, + const ChVector3d &mp2, + const ChVector3d &mp3) cdef cppclass ChTriangleMesh: - void addTriangle(const ChVector &vertex0, - const ChVector &vertex1, - const ChVector &vertex2) + void addTriangle(const ChVector3d &vertex0, + const ChVector3d &vertex1, + const ChVector3d &vertex2) void addTriangle(const ChTriangle &atriangle) cdef cppclass ChTriangleMeshConnected(ChTriangleMesh): ChTriangleMeshConnected() - vector[ChVector[double]]& getCoordsVertices() - vector[ChVector[double]]& getCoordsNormals() - vector[ChVector[int]]& getIndicesVertexes() + vector[ChVector3d]& GetCoordsVertices() + vector[ChVector3d]& GetCoordsNormals() + vector[ChVector3i]& GetIndicesVertexes() void LoadWavefrontMesh(string filename, bool load_normals=True, bool load_uv=False) @@ -86,7 +100,7 @@ cdef extern from "ProtChMoorings.h": bool AddTriangleMesh(shared_ptr[ChTriangleMesh] trimesh, bool is_static, bool is_convex, - const ChVector &pos, + const ChVector3d &pos, const ChMatrix33 &rot, double sphereswept_thickness) void SetEnvelope(double amargin) @@ -95,7 +109,7 @@ cdef extern from "ProtChMoorings.h": void BuildModel() ChQuaternion Q_from_AngAxis(double angle, - const ChVector &axis) + const ChVector3d &axis) # ------- PHYSICS ------- # @@ -114,28 +128,28 @@ cdef extern from "ProtChMoorings.h": ChPhysicsItem() cdef cppclass ChFrame[double]: - void SetPos(const ChVector[double]& mpos) except + - ChVector& GetPos() + void SetPos(const ChVector3d& mpos) except + + ChVector3d& GetPos() ChQuaternion& GetRot() void SetRot(ChQuaternion &rot) except + - void SetPos(ChVector &pos) except + - ChMatrix33& GetA() - ChVector GetRotAxis() + void SetPos(ChVector3d &pos) except + + ChMatrix33& GetRotMat() + ChVector3d GetRotAxis() double GetRotAngle() cdef cppclass ChFrameMoving[double](ChFrame): - ChVector& GetPos_dt() - void SetPos_dt(ChVector &pos_dt) - ChQuaternion& GetRot_dt() - void SetRot_dt(ChQuaternion &mrot_dt) - ChVector& GetPos_dtdt() - void SetPos_dtdt(ChVector &mpos_dtdt) - ChQuaternion& GetRot_dtdt() - void SetRot_dtdt(ChQuaternion &mrot_dtdt) - ChMatrix33 GetA_dt() - ChMatrix33 GetA_dtdt() - ChVector GetWvel_loc() - ChVector GetWacc_loc() + ChVector3d& GetPosDt() + void SetPosDt(ChVector3d &pos_dt) + ChQuaternion& GetRotDt() + void SetRotDt(ChQuaternion &mrot_dt) + ChVector3d& GetPosDt2() + void SetPosDt2(ChVector3d &mpos_dtdt) + ChQuaternion& GetRotDt2() + void SetRotDt2(ChQuaternion &mrot_dtdt) + ChMatrix33 GetRotMatDt() + ChMatrix33 GetRotMatDt2() + ChVector3d GetAngVelLocal() + ChVector3d GetAngAccLocal() cdef cppclass ChBodyFrame(ChFrameMoving): ChBodyFrame() @@ -143,14 +157,14 @@ cdef extern from "ProtChMoorings.h": cdef cppclass ChBody(ChPhysicsItem, ChBodyFrame): ChBody() except + # void SetRot(ChQuaternion &rot) except + - # void SetInertiaXX(ChVector &iner) - # void SetInertiaXY(ChVector &iner) + # void SetInertiaXX(ChVector3d &iner) + # void SetInertiaXY(ChVector3d &iner) # const ChMatrix33& GetInertia() void SetBodyFixed(bool state) except + void SetMaterialSurface(const shared_ptr[ChMaterialSurface] &mnewsurf) except + shared_ptr[ChCollisionModel] GetCollisionModel() - void SetCollide(bool state) - bool GetCollide() + void EnableCollision(bool state) + bool IsCollisionEnabled() # void SetMass(double newmass) # double GetMass() @@ -169,12 +183,12 @@ cdef extern from "ProtChMoorings.h": ChNodeBase() cdef cppclass ChNodeXYZ(ChNodeBase): - void SetPos (const ChVector &mpos) - const ChVector& GetPos() - void SetPos_dt (const ChVector &mposdt) - const ChVector& GetPos_dt() - void SetPos_dtdt (const ChVector &mposdtdt) - const ChVector& GetPos_dtdt() + void SetPos (const ChVector3d &mpos) + const ChVector3d& GetPos() + void SetPosDt (const ChVector3d &mposdt) + const ChVector3d& GetPosDt() + void SetPosDt2 (const ChVector3d &mposdtdt) + const ChVector3d& GetPosDt2() cdef cppclass ChNodeFEAbase(ChNodeBase): ChNodeFEAbase() @@ -189,20 +203,20 @@ cdef extern from "ProtChMoorings.h": ChNodeFEAxyz() double GetMass() void SetMass(double mm) - void SetForce(ChVector mf) - ChVector& GetForce() + void SetForce(ChVector3d mf) + ChVector3d& GetForce() cdef cppclass ChNodeFEAxyzD(ChNodeFEAxyz): - const ChVector& GetD() + const ChVector3d& GetSlope1() cdef cppclass ChNodeFEAxyzDD(ChNodeFEAxyzD): - const ChVector& GetDD() + const ChVector3d& GetSlope2() cdef cppclass ChNodeFEAxyzrot(ChNodeFEAbase, ChBodyFrame): - void SetForce(ChVector mf) - ChVector& GetForce() - void SetTorque(ChVector mf) - ChVector& GetTorque() + void SetForce(ChVector3d mf) + ChVector3d& GetForce() + void SetTorque(ChVector3d mf) + ChVector3d& GetTorque() cdef cppclass ChNodeFEAxyzP(ChNodeFEAbase) @@ -219,19 +233,19 @@ cdef extern from "ProtChMoorings.h": cdef cppclass ChElementBeam(ChElementGeneric): # void EvaluateSectionDisplacement(const double eta, # const ChMatrix &displ, - # ChVector &u_displ, - # ChVector &u_rotaz) + # ChVector3d &u_displ, + # ChVector3d &u_rotaz) # void EvaluateSectionFrame(const double eta, # const ChMatrix &displ, - # ChVector &u_displ, + # ChVector3d &u_displ, # ChQuaternion &rot) # void EvaluateSectionForceTorque(const double eta, # const ChMatrix &displ, - # ChVector &Fforce, - # ChVector &Mtorque) + # ChVector3d &Fforce, + # ChVector3d &Mtorque) # void EvaluateSectionStrain(const double eta, # const ChMatrix &displ, - # ChVector &StrainV) + # ChVector3d &StrainV) double GetMass() double GetRestLength() void SetRestLength(double ml) @@ -285,7 +299,10 @@ cdef extern from "ProtChMoorings.h": cdef cppclass ChMaterialSurface: ChMaterialSurface() except + - cdef cppclass ChMaterialSurfaceSMC(ChMaterialSurface): + cdef cppclass ChContactMaterial: + ChContactMaterial() except + + + cdef cppclass ChContactMaterialSMC(ChContactMaterial): void SetYoungModulus(float val) void SetPoissonRatio(float val) void SetSfriction(float val) @@ -322,7 +339,8 @@ cdef extern from "ProtChMoorings.h": void AddAllNodes(const double point_radius) cdef cppclass ChLinkBase: - ChVector Get_react_force() + ChWrenchd GetReaction1() + ChWrenchd GetReaction2() cdef cppclass ChLink(ChLinkBase) @@ -331,11 +349,11 @@ cdef extern from "ProtChMoorings.h": cdef cppclass ChLinkMateGeneric(ChLinkMate) cdef cppclass ChLinkPointFrame(ChLinkBase): - int Initialize(shared_ptr[ChNodeFEAxyz] node, shared_ptr[ChBodyFrame] body, ChVector* pos) - ChVector GetReactionOnNode() - ChVector GetReactionOnBody() + int Initialize(shared_ptr[ChNodeFEAxyz] node, shared_ptr[ChBodyFrame] body, ChVector3d* pos) + ChVector3d GetReactionOnNode() + ChVector3d GetReactionOnBody() #virtual - #int Initialize(shared_ptr[ChNodeFEAxyz] node, shared_ptr[ChBodyFrame] body, ChVector[double] *pos=0) + #int Initialize(shared_ptr[ChNodeFEAxyz] node, shared_ptr[ChBodyFrame] body, ChVector3d *pos=0) cdef cppclass ChLinkPointPoint(ChLinkBase): #virtual @@ -348,12 +366,12 @@ cdef extern from "ChBodyAddedMass.h": ChBodyAddedMass() except + void SetMass(double newmass) void SetInertia(ChMatrix33& newXInertia) - void SetInertiaXX(ChVector& newXInertia) - void SetInertiaXY(ChVector& newXInertia) + void SetInertiaXX(ChVector3d& newXInertia) + void SetInertiaXY(ChVector3d& newXInertia) double GetMass() const ChMatrix33& GetInertia() - ChVector GetInertiaXX() - ChVector GetInertiaXY() + ChVector3d GetInertiaXX() + ChVector3d GetInertiaXY() void SetMfullmass(ChMatrixDynamic Mfullmass_in) void SetInvMfullmass(ChMatrixDynamic inv_Mfullmass_in) ChBodyAddedMass * newChBodyAddedMass() diff --git a/proteus/mbd/CouplingFSI.pxd b/proteus/mbd/CouplingFSI.pxd index 7f82d53b7d..fa96a77133 100644 --- a/proteus/mbd/CouplingFSI.pxd +++ b/proteus/mbd/CouplingFSI.pxd @@ -21,16 +21,16 @@ cdef extern from "ProtChMoorings.h": ch.ChMesh& mesh vector[shared_ptr[ch.ChNodeFEAxyzD]] nodes vector[shared_ptr[ch.ChNodeFEAxyzrot]] nodesRot - vector[shared_ptr[ch.ChVector]] forces_drag - vector[shared_ptr[ch.ChVector]] forces_addedmass + vector[shared_ptr[ch.ChVector3d]] forces_drag + vector[shared_ptr[ch.ChVector3d]] forces_addedmass double L0 double length int nb_elems bool applyDrag bool applyAddedMass bool applyBuoyancy - vector[ch.ChVector] mvecs - vector[ch.ChVector] mvecs_tangents + vector[ch.ChVector3d] mvecs + vector[ch.ChVector3d] mvecs_tangents void buildNodes() void buildMaterials() void buildElements() @@ -53,9 +53,9 @@ cdef extern from "ProtChMoorings.h": vector[shared_ptr[ch.ChElementBeamEuler]] elemsBeamEuler shared_ptr[ch.ChLinkPointFrame] constraint_back shared_ptr[ch.ChLinkPointFrame] constraint_front - vector[shared_ptr[ch.ChVector]] forces_drag - vector[shared_ptr[ch.ChVector]] forces_addedmass - shared_ptr[ch.ChMaterialSurfaceSMC] contact_material + vector[shared_ptr[ch.ChVector3d]] forces_drag + vector[shared_ptr[ch.ChVector3d]] forces_addedmass + shared_ptr[ch.ChContactMaterialSMC] contact_material void buildNodes() void buildElements() void buildCable() @@ -66,11 +66,11 @@ cdef extern from "ProtChMoorings.h": void updateAddedMassForces() void applyForces() void updateBuoyancyForces() - void setFluidVelocityAtNodes(vector[ch.ChVector] fluid_velocity) - void setFluidAccelerationAtNodes(vector[ch.ChVector] fluid_acceleration) + void setFluidVelocityAtNodes(vector[ch.ChVector3d] fluid_velocity) + void setFluidAccelerationAtNodes(vector[ch.ChVector3d] fluid_acceleration) void setFluidDensityAtNodes(vector[double] dens) - void setContactMaterial(shared_ptr[ch.ChMaterialSurfaceSMC] material) - ch.ChVector getTensionElement(int i, double eta) + void setContactMaterial(shared_ptr[ch.ChContactMaterialSMC] material) + ch.ChVector3d getTensionElement(int i, double eta) cppMultiSegmentedCable * newMoorings(shared_ptr[ch.ChSystem] system, shared_ptr[ch.ChMesh] mesh, vector[double] length, @@ -105,38 +105,38 @@ cdef extern from "ProtChBody.h": cdef cppclass cppRigidBody: shared_ptr[ch.ChBody] body double mass - ch.ChVector pos - ch.ChVector pos_last - ch.ChVector vel - ch.ChVector vel_last - ch.ChVector acc - ch.ChVector acc_last - ch.ChVector angvel - ch.ChVector angvel_last - ch.ChVector angacc - ch.ChVector angacc_last - # ChVector inertia + ch.ChVector3d pos + ch.ChVector3d pos_last + ch.ChVector3d vel + ch.ChVector3d vel_last + ch.ChVector3d acc + ch.ChVector3d acc_last + ch.ChVector3d angvel + ch.ChVector3d angvel_last + ch.ChVector3d angacc + ch.ChVector3d angacc_last + # ChVector3d inertia ch.ChMatrix33 rotm ch.ChMatrix33 rotm_last ch.ChQuaternion rotq ch.ChQuaternion rotq_last - ch.ChVector free_x - ch.ChVector free_r - ch.ChVector F - ch.ChVector F_last - ch.ChVector M - ch.ChVector M_last + ch.ChVector3d free_x + ch.ChVector3d free_r + ch.ChVector3d F + ch.ChVector3d F_last + ch.ChVector3d M + ch.ChVector3d M_last shared_ptr[ch.ChTriangleMeshConnected] trimesh bool has_trimesh - vector[ch.ChVector] trimesh_pos - vector[ch.ChVector] trimesh_pos0 - ch.ChVector pos0_trimesh + vector[ch.ChVector3d] trimesh_pos + vector[ch.ChVector3d] trimesh_pos0 + ch.ChVector3d pos0_trimesh ch.ChQuaternion rotq0_trimesh cppRigidBody(cppSystem* system) void calculate_init() void prestep(double* force, double* torque) void poststep() - ch.ChVector hxyz(double* x, double dt) + ch.ChVector3d hxyz(double* x, double dt) double hx(double* x, double dt) double hy(double* x, double dt) double hz(double* x, double dt) @@ -181,7 +181,7 @@ cdef class ProtChBody: cdef cppRigidBody * thisptr cdef ch.ChQuaternion rotation cdef ch.ChQuaternion rotation_last - cdef vector[ch.ChVector] trimesh_nodes + cdef vector[ch.ChVector3d] trimesh_nodes cdef vector[ch.ChTriangle] trimesh_triangles cdef public: str record_file diff --git a/proteus/mbd/CouplingFSI.pyx b/proteus/mbd/CouplingFSI.pyx index 06873a4e45..f69543e5b7 100644 --- a/proteus/mbd/CouplingFSI.pyx +++ b/proteus/mbd/CouplingFSI.pyx @@ -134,7 +134,7 @@ cdef class ProtChBody: if take_shape_name is True: self.setName(bytes(shape.name,'utf-8')) self.nd = shape.Domain.nd - new_vec = chrono.ChVectorD(shape.barycenter[0], + new_vec = chrono.ChVector3d(shape.barycenter[0], shape.barycenter[1], shape.barycenter[2]) self.ChBody.SetPos(new_vec) @@ -245,13 +245,13 @@ cdef class ProtChBody: def getTriangleMeshInfo(self): # vertices - cdef vector[ch.ChVector[double]] chpos = deref(self.thisptr.trimesh).getCoordsVertices() + cdef vector[ch.ChVector3d] chpos = deref(self.thisptr.trimesh).GetCoordsVertices() cdef double[:,:] pos = np.zeros((chpos.size(),3 )) for i in range(chpos.size()): pos[i, 0] = chpos.at(i).x() pos[i, 1] = chpos.at(i).y() pos[i, 2] = chpos.at(i).z() - cdef vector[ch.ChVector[int]] chel_connect = deref(self.thisptr.trimesh).getIndicesVertexes() + cdef vector[ch.ChVector3i] chel_connect = deref(self.thisptr.trimesh).GetIndicesVertexes() # connection of vertices cdef int[:,:] el_connect = np.zeros((chel_connect.size(), 3), dtype=np.int32) for i in range(chel_connect.size()): @@ -264,7 +264,7 @@ cdef class ProtChBody: double envelope=0.001, double margin=0.0005, bool collide=True): - deref(self.thisptr.body).SetCollide(collide) + deref(self.thisptr.body).EnableCollision(collide) deref(deref(self.thisptr.body).GetCollisionModel()).SetEnvelope(envelope) deref(deref(self.thisptr.body).GetCollisionModel()).SetSafeMargin(margin) @@ -326,7 +326,7 @@ cdef class ProtChBody: cdef np.ndarray d_tra, d_tra_last # translational displacements cdef np.ndarray d_rot, d_rot_last # rotational displacements cdef np.ndarray h_body # displacement from body - cdef ch.ChVector h_body_vec + cdef ch.ChVector3d h_body_vec h = np.zeros(3) if self.predicted is False: self.prediction() @@ -591,11 +591,11 @@ cdef class ProtChBody: # inverse of full mass matrix inv_FM = np.linalg.inv(FM) #set it to chrono variable - chFM = chrono.ChMatrixDynamicD(6, 6) - inv_chFM = chrono.ChMatrixDynamicD(6, 6) + chFM = chrono.ChMatrixDynamicd(6, 6) + inv_chFM = chrono.ChMatrixDynamicd(6, 6) for i in range(6): for j in range(6): - chFM.setitem(i, j, FM[i, j]) + chFM.SetItem(i, j, FM[i, j]) # hack for swig cdef SwigPyObject *swig_obj = chFM.this @@ -607,8 +607,8 @@ cdef class ProtChBody: aa = np.zeros(6) - aa[:3] = pyvec2array(self.ChBody.GetPos_dtdt()) - aa[3:] = pyvec2array(self.ChBody.GetWacc_par()) + aa[:3] = pyvec2array(self.ChBody.GetPosDt2()) + aa[3:] = pyvec2array(self.ChBody.GetAngAccParent()) Aija = np.dot(Aij_global, aa) self.F_Aij = Aija[:3] self.M_Aij = Aija[3:] @@ -677,15 +677,15 @@ cdef class ProtChBody: rot: array_like current rotation (matrix) of body """ - x0 = self.thisptr.rotm.Get_A_Xaxis().x() - x1 = self.thisptr.rotm.Get_A_Xaxis().y() - x2 = self.thisptr.rotm.Get_A_Xaxis().z() - y0 = self.thisptr.rotm.Get_A_Yaxis().x() - y1 = self.thisptr.rotm.Get_A_Yaxis().y() - y2 = self.thisptr.rotm.Get_A_Yaxis().z() - z0 = self.thisptr.rotm.Get_A_Zaxis().x() - z1 = self.thisptr.rotm.Get_A_Zaxis().y() - z2 = self.thisptr.rotm.Get_A_Zaxis().z() + x0 = self.thisptr.rotm.GetAxisX().x() + x1 = self.thisptr.rotm.GetAxisX().y() + x2 = self.thisptr.rotm.GetAxisX().z() + y0 = self.thisptr.rotm.GetAxisY().x() + y1 = self.thisptr.rotm.GetAxisY().y() + y2 = self.thisptr.rotm.GetAxisY().z() + z0 = self.thisptr.rotm.GetAxisZ().x() + z1 = self.thisptr.rotm.GetAxisZ().y() + z2 = self.thisptr.rotm.GetAxisZ().z() rot = np.array([x0, x1, x2], [y0, y1, y2], [z0, z1, z2]) @@ -788,15 +788,15 @@ cdef class ProtChBody: """ if self.prescribed_motion_function is not None: new_x = self.callPrescribedMotion(self.ProtChSystem.model.stepController.t_model_last) - new_vec = chrono.ChVectorD(new_x[0], new_x[1], new_x[2]) + new_vec = chrono.ChVector3d(new_x[0], new_x[1], new_x[2]) self.ChBody.SetPos(new_vec) self.thisptr.poststep() self.getValues() comm = Comm.get().comm.tompi4py() cdef ch.ChQuaternion rotq cdef ch.ChQuaternion rotq_last - cdef ch.ChVector pos - cdef ch.ChVector pos_last + cdef ch.ChVector3d pos + cdef ch.ChVector3d pos_last cdef double e0, e1, e2, e3, e0_last, e1_last, e2_last, e3_last cdef double posx, posy, posz, posx_last, posy_last, posz_last if comm.rank == 0 and self.ProtChSystem.record_values is True: @@ -810,8 +810,8 @@ cdef class ProtChBody: e0_last, e1_last, e2_last, e3_last = self.rotq_last posx, posy, posz = self.position posx_last, posy_last, posz_last = self.position_last - pos = ch.ChVector[double](posx, posy, posz) - pos_last = ch.ChVector[double](posx_last, posy_last, posz_last) + pos = ch.ChVector3d(posx, posy, posz) + pos_last = ch.ChVector3d(posx_last, posy_last, posz_last) rotq = ch.ChQuaternion[double](e0, e1, e2, e3) rotq_last = ch.ChQuaternion[double](e0_last, e1_last, e2_last, e3_last) self.thisptr.rotq = rotq @@ -829,8 +829,8 @@ cdef class ProtChBody: c = self.ProtChSystem.model.levelModelList[-1].coefficients if c.use_ball_as_particle: chpos = self.ChBody.GetPos() - chvel = self.ChBody.GetPos_dt() - chvel_ang = self.ChBody.GetWvel_loc() + chvel = self.ChBody.GetPosDt() + chvel_ang = self.ChBody.GetAngVelLocal() for flag in self.boundaryFlags: c.ball_radius[flag] = self.radiusIBM c.ball_center[flag, 0] = chpos.x @@ -853,7 +853,7 @@ cdef class ProtChBody: return self.sdfIBM(t, relative_x) def setPosition(self, np.ndarray pos): - chvec = chrono.ChVectorD(pos[0], pos[1], pos[2]) + chvec = chrono.ChVector3d(pos[0], pos[1], pos[2]) self.ChBody.SetPos(chvec) def getPosition(self): @@ -867,11 +867,11 @@ cdef class ProtChBody: return self.ChBody.GetMass() def setInertiaXX(self, np.ndarray inertia): - chvec = chrono.ChVectorD(inertia[0], inertia[1], inertia[2]) + chvec = chrono.ChVector3d(inertia[0], inertia[1], inertia[2]) self.ChBody.SetInertiaXX(chvec) def setInertiaXY(self, np.ndarray inertia): - chvec = chrono.ChVectorD(inertia[0], inertia[1], inertia[2]) + chvec = chrono.ChVector3d(inertia[0], inertia[1], inertia[2]) self.ChBody.SetInertiaXY(chvec) def getInertia(self): @@ -879,16 +879,16 @@ cdef class ProtChBody: return iner def getVelocity(self): - chvel = self.ChBody.GetPos_dt() + chvel = self.ChBody.GetPosDt() return pyvec2array(chvel) def setVelocity(self, np.ndarray vel): - chvec = chrono.ChVectorD(vel[0], vel[1], vel[2]) - self.ChBody.SetPos_dt(chvec) + chvec = chrono.ChVector3d(vel[0], vel[1], vel[2]) + self.ChBody.SetPosDt(chvec) def prediction(self): comm = Comm.get().comm.tompi4py() - cdef ch.ChVector h_body_vec + cdef ch.ChVector3d h_body_vec h_body_vec = self.thisptr.hxyz( self.position_last.data, 0.) #print("MY BODY DISP: ", h_body_vec.x(), h_body_vec.y(), h_body_vec.z()) if self.ProtChSystem.model is not None: @@ -916,7 +916,7 @@ cdef class ProtChBody: # +self.ang_velocity[2]**2)*dt_half # self.h_ang_vel_predict = self.ang_velocity # # else: - # # nsteps = max(int(dt_half/self.ProtChSystem.chrono_dt), 1) + # # nsteps = max(int(dt_half/self.ProtChSystem.chronoDt), 1) # # if nsteps < self.ProtChSystem.min_nb_steps: # # nsteps = self.ProtChSystem.min_nb_steps # # h = np.zeros(3) @@ -937,7 +937,7 @@ cdef class ProtChBody: # # else: # # self.h_predict = np.zeros(3) # # print("ADDED: ", self.h_predict, dt_half) - # # print("BODY H:", h_body, self.velocity, self.ChBody.GetPos_dt()) + # # print("BODY H:", h_body, self.velocity, self.ChBody.GetPosDt()) # self.h_predict = h self.predicted = True @@ -961,8 +961,8 @@ cdef class ProtChBody: cdef np.ndarray zeros = np.zeros(3) self.setExternalForces(zeros, zeros) # build collision model - if deref(self.thisptr.body).GetCollide() is True: - deref(deref(self.thisptr.body).GetCollisionModel()).BuildModel() + #if deref(self.thisptr.body).IsCollisionEnabled(): + # deref(deref(self.thisptr.body).GetCollisionModel()).BuildModel() # poststep (record values, etc) self.thisptr.poststep() # get first, store then on initial time step @@ -1111,13 +1111,13 @@ cdef class ProtChBody: self.rotq = pyquat2array(self.ChBody.GetRot()) # self.rotm = mat332array(self.ChBody.GetA()) # acceleration - self.acceleration = pyvec2array(self.ChBody.GetPos_dtdt()) + self.acceleration = pyvec2array(self.ChBody.GetPosDt2()) #velocity - self.velocity = pyvec2array(self.ChBody.GetPos_dt()) + self.velocity = pyvec2array(self.ChBody.GetPosDt()) # angular acceleration - self.ang_acceleration = pyvec2array(self.ChBody.GetWacc_loc()) + self.ang_acceleration = pyvec2array(self.ChBody.GetAngAccLocal()) # angular velocity - self.ang_velocity = pyvec2array(self.ChBody.GetWvel_loc()) + self.ang_velocity = pyvec2array(self.ChBody.GetAngVelLocal()) # norm of angular velocity self.ang_vel_norm = np.sqrt(self.ang_velocity[0]**2 +self.ang_velocity[1]**2 @@ -1488,11 +1488,11 @@ cdef class ProtChSystem: mesh.ProtChSystem = self def setGravitationalAcceleration(self, g): - chvec = chrono.ChVectorD(g[0], g[1], g[2]) - self.ChSystem.Set_G_acc(chvec) + chvec = chrono.ChVector3d(g[0], g[1], g[2]) + self.ChSystem.SetGravitationalAcceleration(chvec) def getGravitationalAcceleration(self): - return pyvec2array(self.ChSystem.Get_G_acc()) + return pyvec2array(self.ChSystem.GetGravitationalAcceleration()) def setCouplingScheme(self, string scheme, string prediction=b'backwardEuler'): assert scheme == b"CSS" or scheme == b"ISS", "Coupling scheme requested unknown" @@ -1512,7 +1512,7 @@ cdef class ProtChSystem: def setMinimumSubsteps(self, int nb): """Sets the minimum nb of chrono substeps per proteus step - if prot_dt=0.001 and ch_dt=0.002, there will be + if protDt=0.001 and chDt=0.002, there will be substeps of chrono instead of just 1. Parameters @@ -2398,8 +2398,8 @@ cdef class ProtChSystem: # cdef ChSystem system = ChSystem() # cdef ChBody bod = ChBody() # cdef ChVector oo = ChVector[double](2.,3.,4.) -# bod.SetPos_dt(oo) -# cdef ChVector& gg = bod.GetPos_dt() +# bod.SetPosDt(oo) +# cdef ChVector& gg = bod.GetPosDt() # print(gg.x, gg.y, gg.z) @@ -2826,9 +2826,9 @@ cdef class ProtChMoorings: """ Get Tension at the back of the cable """ - cdef ch.ChVector T + cdef ch.ChVector3d T if self.thisptr.constraint_back: - T = deref(self.thisptr.constraint_back).Get_react_force() + T = deref(self.thisptr.constraint_back).GetReaction2().force return np.array([T.x(), T.y(), T.z()]) else: return np.zeros(3) @@ -2837,9 +2837,9 @@ cdef class ProtChMoorings: """ Get Tension at the front of the cable """ - cdef ch.ChVector T + cdef ch.ChVector3d T if self.thisptr.constraint_front: - T = deref(self.thisptr.constraint_front).Get_react_force() + T = deref(self.thisptr.constraint_front).GetReaction1().force return np.array([T.x(), T.y(), T.z()]) else: return np.zeros(3) @@ -2973,12 +2973,12 @@ cdef class ProtChMoorings: self.thisptr.attachFrontNodeToBody(body.thisptr.body) def getTensionElement(self, int i=0, eta=0.): - cdef ch.ChVector[double] F + cdef ch.ChVector3d F F = self.thisptr.getTensionElement(i, eta) return np.array([F.x(), F.y(), F.z()]) def getNodesTension(self, eta=0.): - cdef ch.ChVector[double] vec + cdef ch.ChVector3d vec if self.beam_type == b'BeamEuler': T = np.zeros((self.thisptr.nodesRot.size()-1,3 )) else: @@ -3039,7 +3039,7 @@ cdef class ProtChMoorings: """ # self.nodes_positions0 = positions # self.nodes_tangents0 = tangents - cdef ch.ChVector[double] vec + cdef ch.ChVector3d vec if positions is None: for i in range(self.thisptr.cables.size()): deref(self.thisptr.cables[i]).mvecs.clear() @@ -3054,7 +3054,7 @@ cdef class ProtChMoorings: ds = L/(nb_nodes-1) for j in range(nb_nodes): x, y, z = self.nodes_function(L0+ds*j) - vec = ch.ChVector[double](x, y, z) + vec = ch.ChVector3d(x, y, z) deref(self.thisptr.cables[i]).mvecs.push_back(vec) else: for i in range(self.thisptr.cables.size()): @@ -3062,7 +3062,7 @@ cdef class ProtChMoorings: nb_nodes = len(positions[i]) for j in range(len(positions[i])): x, y, z = positions[i][j] - vec = ch.ChVector[double](x, y, z) + vec = ch.ChVector3d(x, y, z) deref(self.thisptr.cables[i]).mvecs.push_back(vec) if tangents is None: for i in range(self.thisptr.cables.size()): @@ -3078,7 +3078,7 @@ cdef class ProtChMoorings: ds = L/(nb_nodes-1) for j in range(nb_nodes): x, y, z = self.nodes_function_tangent(L0+ds*j) - vec = ch.ChVector[double](x, y, z) + vec = ch.ChVector3d(x, y, z) deref(self.thisptr.cables[i]).mvecs_tangents.push_back(vec) else: for i in range(self.thisptr.cables.size()): @@ -3086,7 +3086,7 @@ cdef class ProtChMoorings: nb_nodes = len(tangents[i]) for j in range(len(tangents[i])): x, y, z = tangents[i][j] - vec = ch.ChVector[double](x, y, z) + vec = ch.ChVector3d(x, y, z) deref(self.thisptr.cables[i]).mvecs_tangents.push_back(vec) # self.buildNodes() @@ -3167,13 +3167,13 @@ cdef class ProtChMoorings: if self.beam_type == b'BeamEuler': pos = np.zeros(( self.thisptr.nodesRot.size(),3 )) for i in range(self.thisptr.nodesRot.size()): - vec = deref(self.thisptr.nodesRot[i]).GetPos_dt() + vec = deref(self.thisptr.nodesRot[i]).GetPosDt() pos[i] = [vec.x(), vec.y(), vec.z()] return pos else: pos = np.zeros(( self.thisptr.nodes.size(),3 )) for i in range(self.thisptr.nodes.size()): - vec = deref(self.thisptr.nodes[i]).GetPos_dt() + vec = deref(self.thisptr.nodes[i]).GetPosDt() pos[i] = [vec.x(), vec.y(), vec.z()] return pos @@ -3188,18 +3188,18 @@ cdef class ProtChMoorings: if self.beam_type == b'BeamEuler': pos = np.zeros((self.nodes_nb,3 )) for i in range(self.thisptr.nodesRot.size()): - vec = deref(self.thisptr.nodesRot[i]).GetPos_dtdt() + vec = deref(self.thisptr.nodesRot[i]).GetPosDt2() pos[i] = [vec.x(), vec.y(), vec.z()] return pos else: pos = np.zeros(( self.thisptr.nodes.size(),3 )) for i in range(self.thisptr.nodes.size()): - vec = deref(self.thisptr.nodes[i]).GetPos_dtdt() + vec = deref(self.thisptr.nodes[i]).GetPosDt2() pos[i] = [vec.x(), vec.y(), vec.z()] return pos def getDragForces(self): - cdef ch.ChVector Fd + cdef ch.ChVector3d Fd drag = np.zeros((self.nodes_nb,3 )) for i in range(self.thisptr.forces_drag.size()): Fd = deref(self.thisptr.forces_drag[i]) @@ -3207,7 +3207,7 @@ cdef class ProtChMoorings: return drag def getAddedMassForces(self): - cdef ch.ChVector Fd + cdef ch.ChVector3d Fd drag = np.zeros((self.nodes_nb,3 )) for i in range(self.thisptr.forces_addedmass.size()): Fd = deref(self.thisptr.forces_addedmass[i]) @@ -3228,7 +3228,7 @@ cdef class ProtChMoorings: """ dire = np.zeros(( self.thisptr.nodes.size(),3 )) for i in range(self.thisptr.nodes.size()): - vec = deref(self.thisptr.nodes[i]).GetD() + vec = deref(self.thisptr.nodes[i]).GetSlope1() dire[i] = [vec.x(), vec.y(), vec.z()] return dire @@ -3237,12 +3237,12 @@ cdef class ProtChMoorings: Parameters ---------- - mat: ChMaterialSurfaceSMC + mat: ChContactMaterialSMC Material of cable. """ cdef SwigPyObject *swig_obj = mat.this - cdef shared_ptr[ch.ChMaterialSurfaceSMC]* pt_to_shp = swig_obj.ptr; - cdef shared_ptr[ch.ChMaterialSurfaceSMC] matp = pt_to_shp[0] + cdef shared_ptr[ch.ChContactMaterialSMC]* pt_to_shp = swig_obj.ptr; + cdef shared_ptr[ch.ChContactMaterialSMC] matp = pt_to_shp[0] self.thisptr.setContactMaterial(matp) def setExternalForces(self, fluid_velocity_array=None, fluid_density_array=None, @@ -3260,10 +3260,10 @@ cdef class ProtChMoorings: self.fluid_density_array = fluid_density_array if fluid_acceleration_array is not None: self.fluid_acceleration_array = fluid_acceleration_array - cdef vector[ch.ChVector[double]] fluid_velocity - cdef vector[ch.ChVector[double]] fluid_acceleration - cdef ch.ChVector[double] vel - cdef ch.ChVector[double] acc + cdef vector[ch.ChVector3d] fluid_velocity + cdef vector[ch.ChVector3d] fluid_acceleration + cdef ch.ChVector3d vel + cdef ch.ChVector3d acc cdef vector[double] fluid_density cdef double dens comm = Comm.get().comm.tompi4py() @@ -3323,19 +3323,19 @@ cdef class ProtChMoorings: else: vel_arr[:] = 0 self.fluid_velocity_array[i] = vel_arr - vel = ch.ChVector[double](vel_arr[0], vel_arr[1], vel_arr[2]) + vel = ch.ChVector3d(vel_arr[0], vel_arr[1], vel_arr[2]) if self.fluid_velocity_function is not None and fluid_velocity_array is None: vel_arr = self.fluid_velocity_function(coords, self.ProtChSystem.t) - vel = ch.ChVector[double](vel_arr[0], vel_arr[1], vel_arr[2]) + vel = ch.ChVector3d(vel_arr[0], vel_arr[1], vel_arr[2]) else: - vel = ch.ChVector[double](self.fluid_velocity_array[i][0], self.fluid_velocity_array[i][1], self.fluid_velocity_array[i][2]) + vel = ch.ChVector3d(self.fluid_velocity_array[i][0], self.fluid_velocity_array[i][1], self.fluid_velocity_array[i][2]) fluid_velocity.push_back(vel) self.fluid_acceleration_array[i] = (self.fluid_velocity_array[i]-self.fluid_velocity_array_previous[i])/self.ProtChSystem.proteus_dt # acc = du/dt+u.grad(u) #vel_grad_arr[:] = self.ProtChSystem.getFluidVelocityGradientLocalCoords(xi, el, rank) #acc_arr = (vel_arr-fluid_velocity_array_previous[i])/dt+vel_arr*vel_grad_arr #arr[:self.nd] = self.ProtChSystem.findFluidVelocityAtCoords(coords[:self.nd]) - acc = ch.ChVector[double](self.fluid_acceleration_array[i][0], self.fluid_acceleration_array[i][1], self.fluid_acceleration_array[i][2]) + acc = ch.ChVector3d(self.fluid_acceleration_array[i][0], self.fluid_acceleration_array[i][1], self.fluid_acceleration_array[i][2]) fluid_acceleration.push_back(acc) dens = self.fluid_density_array[i] fluid_density.push_back(dens) @@ -3364,20 +3364,20 @@ cdef class ProtChMoorings: self.thisptr.setFluidDensityAtNodes(fluid_density) def setFluidVelocityAtNodes(self, np.ndarray velocity_array): - cdef vector[ch.ChVector[double]] fluid_velocity - cdef ch.ChVector[double] vel + cdef vector[ch.ChVector3d] fluid_velocity + cdef ch.ChVector3d vel self.fluid_velocity_array = velocity_array for v in velocity_array: - vel = ch.ChVector[double](v[0], v[1], v[2]) + vel = ch.ChVector3d(v[0], v[1], v[2]) fluid_velocity.push_back(vel) self.thisptr.setFluidVelocityAtNodes(fluid_velocity) def setFluidAccelerationAtNodes(self, np.ndarray acceleration_array): - cdef vector[ch.ChVector[double]] fluid_acceleration - cdef ch.ChVector[double] acc + cdef vector[ch.ChVector3d] fluid_acceleration + cdef ch.ChVector3d acc self.fluid_acceleration_array = acceleration_array for a in acceleration_array: - acc = ch.ChVector[double](a[0], a[1], a[2]) + acc = ch.ChVector3d(a[0], a[1], a[2]) fluid_acceleration.push_back(acc) self.thisptr.setFluidAccelerationAtNodes(fluid_acceleration) @@ -3645,14 +3645,14 @@ def pyvec2array(vec): return np.array([vec.x, vec.y, vec.z]) def mat332array(mat): - return np.array([[mat.Get_A_Xaxis().x(), mat.Get_A_Xaxis().y(), mat.Get_A_Xaxis().z()], - [mat.Get_A_Yaxis().x(), mat.Get_A_Yaxis().y(), mat.Get_A_Yaxis().z()], - [mat.Get_A_Zaxis().x(), mat.Get_A_Zaxis().y(), mat.Get_A_Zaxis().z()]]) + return np.array([[mat.GetAxisX().x(), mat.GetAxisX().y(), mat.GetAxisX().z()], + [mat.GetAxisY().x(), mat.GetAxisY().y(), mat.GetAxisY().z()], + [mat.GetAxisZ().x(), mat.GetAxisZ().y(), mat.GetAxisZ().z()]]) def pymat332array(mat): - return np.array([[mat.Get_A_Xaxis().x, mat.Get_A_Xaxis().y, mat.Get_A_Xaxis().z], - [mat.Get_A_Yaxis().x, mat.Get_A_Yaxis().y, mat.Get_A_Yaxis().z], - [mat.Get_A_Zaxis().x, mat.Get_A_Zaxis().y, mat.Get_A_Zaxis().z]]) + return np.array([[mat.GetAxisX().x, mat.GetAxisX().y, mat.GetAxisX().z], + [mat.GetAxisY().x, mat.GetAxisY().y, mat.GetAxisY().z], + [mat.GetAxisZ().x, mat.GetAxisZ().y, mat.GetAxisZ().z]]) def quat2array(quat): return np.array([quat.e0(), quat.e1(), quat.e2(), quat.e3()]) diff --git a/proteus/mbd/ProtChBody.h b/proteus/mbd/ProtChBody.h index f62c2eb458..c066453854 100644 --- a/proteus/mbd/ProtChBody.h +++ b/proteus/mbd/ProtChBody.h @@ -3,19 +3,19 @@ #include "chrono/physics/ChSystemSMC.h" #include "chrono/physics/ChSystem.h" #include "chrono/timestepper/ChTimestepper.h" +#include "chrono/timestepper/ChTimestepperHHT.h" #include "chrono/solver/ChSolverPMINRES.h" -#include "chrono/core/ChTransform.h" +#include "chrono/core/ChFrame.h" #include "chrono/physics/ChLinkTSDA.h" #include "chrono/geometry/ChTriangleMeshConnected.h" #include #include using namespace chrono; -using namespace chrono::collision; using namespace std; class cppSystem { - public: +public: std::shared_ptr systemSMC; std::shared_ptr system; double chrono_dt; @@ -30,34 +30,34 @@ class cppSystem { class cppRigidBody { - public: - ChVector<> free_x; - ChVector<> free_r; - ChVector<> pos; - ChVector<> pos_last; - ChVector<> pos0; - std::vector> trimesh_pos; - std::vector> trimesh_pos_last; - std::vector> trimesh_pos0; - ChVector<> pos0_trimesh; +public: + ChVector3d free_x; + ChVector3d free_r; + ChVector3d pos; + ChVector3d pos_last; + ChVector3d pos0; + std::vector trimesh_pos; + std::vector trimesh_pos_last; + std::vector trimesh_pos0; + ChVector3d pos0_trimesh; ChQuaternion<> rotq0_trimesh; - ChVector<> vel; - ChVector<> vel_last; - ChVector<> acc; - ChVector<> acc_last; - ChVector<> angvel; - ChVector<> angvel_last; - ChVector<> angacc; - ChVector<> angacc_last; + ChVector3d vel; + ChVector3d vel_last; + ChVector3d acc; + ChVector3d acc_last; + ChVector3d angvel; + ChVector3d angvel_last; + ChVector3d angacc; + ChVector3d angacc_last; ChMatrix33 rotm; ChMatrix33 rotm_last; ChQuaternion rotq; ChQuaternion rotq_last; ChQuaternion rotq0; - ChVector<> F; - ChVector<> F_last; - ChVector<> M; - ChVector<> M_last; + ChVector3d F; + ChVector3d F_last; + ChVector3d M; + ChVector3d M_last; std::shared_ptr lock_motion; // lock for prescribed motion double lock_motion_t_max; // max time up to which lock motion is used double mass; @@ -70,7 +70,7 @@ class cppRigidBody { std::shared_ptr body; cppSystem* system; cppRigidBody(cppSystem* system); - ChVector hxyz(double* x, double t); + ChVector3d hxyz(double* x, double t); double hx(double* x, double t); double hy(double* x, double t); double hz(double* x, double t); @@ -96,7 +96,7 @@ class cppRigidBody { std::vector y, std::vector z, std::vector ang, std::vector ang2, std::vector ang3, double t_max); - void getTriangleMeshSDF(ChVector<> pos_node, + void getTriangleMeshSDF(ChVector3d pos_node, double* dist_n); void getTriangleMeshVel(double *x, double dt, @@ -133,29 +133,29 @@ cppSystem::cppSystem() void cppSystem::setTimestepperType(std::string tstype, bool verbose=false) { if (tstype == "HHT") { system->SetTimestepperType(ChTimestepper::Type::HHT); - auto mystepper = std::dynamic_pointer_cast(system->GetTimestepper()); - mystepper->SetAlpha(-0.2); - mystepper->SetMaxiters(10); - mystepper->SetAbsTolerances(1e-6); - mystepper->SetMode(ChTimestepperHHT::POSITION); - mystepper->SetScaling(false); - mystepper->SetVerbose(verbose); - mystepper->SetModifiedNewton(false); - } - else if (tstype == "Euler") { - system->SetTimestepperType(ChTimestepper::Type::EULER_IMPLICIT_LINEARIZED); - } - else if (tstype == "Trapezoidal") { - system->SetTimestepperType(ChTimestepper::Type::TRAPEZOIDAL); - } + auto mystepper = std::dynamic_pointer_cast(system->GetTimestepper()); + mystepper->SetAlpha(-0.2); + mystepper->SetMaxItersSuccess(10); + mystepper->SetAbsTolerances(1e-6); + //mystepper->SetMode(ChTimestepperHHT::POSITION); + //mystepper->SetScaling(false); + mystepper->SetVerbose(verbose); + mystepper->SetModifiedNewton(false); } + else if (tstype == "Euler") { + system->SetTimestepperType(ChTimestepper::Type::EULER_IMPLICIT_LINEARIZED); + } + else if (tstype == "Trapezoidal") { + system->SetTimestepperType(ChTimestepper::Type::TRAPEZOIDAL); + } +} void cppSystem::step(double proteus_dt, int n_substeps=1) { - double dt2 = proteus_dt/(double)n_substeps; - for (int i = 0; i < n_substeps; ++i) { - system->DoStepDynamics(dt2); - } + double dt2 = proteus_dt/(double)n_substeps; + for (int i = 0; i < n_substeps; ++i) { + system->DoStepDynamics(dt2); + } } void cppSystem::addMesh(std::shared_ptr mesh) { @@ -170,70 +170,66 @@ cppRigidBody::cppRigidBody(cppSystem* system): // add body to system /* system->system->AddBody(body); */ // now added externally in cython // basic attributes of body - rotm = body->GetA(); - rotm_last = body->GetA(); + rotm = body->GetRotMat(); + rotm_last = body->GetRotMat(); pos = body->GetPos(); pos_last = body->GetPos(); body->SetMass(mass); - free_x = ChVector<>(1., 1., 1.); - free_r = ChVector<>(1., 1., 1.); + free_x = ChVector3d(1., 1., 1.); + free_r = ChVector3d(1., 1., 1.); lock_motion_t_max = 0.; has_trimesh = false; } void cppSystem::setDirectory(std::string dir) { - directory = dir; + directory = dir; } void cppRigidBody::updateTriangleMeshVisualisationPos() { - /* rotm = body->GetA(); */ + /* rotm = body->GetRotMat(); */ for (int i = 0; i < trimesh_pos.size(); i++) { - ChVector local = ChTransform::TransformParentToLocal(trimesh_pos0[i], - pos0_trimesh, - rotq0_trimesh); - ChVector xNew = ChTransform::TransformLocalToParent(local, - pos, - rotq); + ChVector3d local = ChFrame(pos0_trimesh,rotq0_trimesh).TransformPointParentToLocal(trimesh_pos0[i]); + ChVector3d xNew = ChFrame(pos,rotq).TransformPointLocalToParent(local); trimesh_pos[i].Set(xNew.x(), xNew.y(), xNew.z()); } } -ChVector cppRigidBody::hxyz(double* x, double t) +ChVector3d cppRigidBody::hxyz(double* x, double t) { - /* rotm = body->GetA(); */ - ChVector xx = ChVector(x[0], x[1], x[2]); - ChVector local = ChTransform::TransformParentToLocal(xx, pos_last, rotq_last); - ChVector xNew = ChTransform::TransformLocalToParent(local, pos, rotq); + /* rotm = body->GetRotMat(); */ + ChVector3d xx = ChVector3d(x[0], x[1], x[2]); + ChVector3d local = ChFrame(pos_last, rotq_last).TransformPointParentToLocal(xx); + ChVector3d xNew = ChFrame(pos, rotq).TransformPointLocalToParent(local); return xNew - xx; } void cppSystem::setCollisionEnvelopeMargin(double envelope, double margin) { - collision::ChCollisionModel::SetDefaultSuggestedEnvelope(envelope); - collision::ChCollisionModel::SetDefaultSuggestedMargin(margin); + ChCollisionModel::SetDefaultSuggestedEnvelope(envelope); + ChCollisionModel::SetDefaultSuggestedMargin(margin); } double cppRigidBody::hx(double* x, double t) { - /* rotm = body->GetA(); */ - ChVector local = ChTransform::TransformParentToLocal(ChVector(x[0],x[1],x[2]), pos_last, rotq_last); - ChVector xNew = ChTransform::TransformLocalToParent(local, pos, rotq); + /* rotm = body->GetRotMat(); */ + ChVector3d local = ChFrame(pos_last, rotq_last).TransformPointParentToLocal(ChVector3d(x[0],x[1],x[2])); + ChVector3d xNew = ChFrame(pos, rotq).TransformPointLocalToParent(local); return xNew.x() - x[0]; } double cppRigidBody::hy(double* x, double t) { - /* rotm = body->GetA(); */ - ChVector local = ChTransform::TransformParentToLocal(ChVector(x[0],x[1],x[2]), pos_last, rotq_last); - ChVector xNew = ChTransform::TransformLocalToParent(local, pos, rotq); + /* rotm = body->GetRotMat(); */ + ChVector3d local = ChFrame(pos_last, rotq_last).TransformPointParentToLocal(ChVector3d(x[0],x[1],x[2])); + ChVector3d xNew = ChFrame(pos, rotq).TransformPointLocalToParent(local); return xNew.y() - x[1]; } double cppRigidBody::hz(double* x, double t) { - /* rotm = body->GetA(); */ - ChVector local = ChTransform::TransformParentToLocal(ChVector(x[0],x[1],x[2]), pos_last, rotq_last); - ChVector xNew = ChTransform::TransformLocalToParent(local, pos, rotq); + /* rotm = body->GetRotMat(); */ + ChVector3d local = ChFrame(pos_last, rotq_last).TransformPointParentToLocal(ChVector3d(x[0],x[1],x[2])); + ChVector3d xNew = ChFrame(pos, rotq).TransformPointLocalToParent(local); return xNew.z() - x[2]; } @@ -243,14 +239,14 @@ void cppRigidBody::calculate_init() { if (has_trimesh == true) { trimesh_pos.clear(); trimesh_pos0.clear(); - auto trimesh_coords = trimesh->getCoordsVertices(); + auto trimesh_coords = trimesh->GetCoordsVertices(); for (int i = 0; i < trimesh_coords.size(); i++) { - trimesh_pos0.push_back(ChVector(trimesh_coords[i].x(), - trimesh_coords[i].y(), - trimesh_coords[i].z())); - trimesh_pos.push_back(ChVector(trimesh_coords[i].x(), - trimesh_coords[i].y(), - trimesh_coords[i].z())); + trimesh_pos0.push_back(ChVector3d(trimesh_coords[i].x(), + trimesh_coords[i].y(), + trimesh_coords[i].z())); + trimesh_pos.push_back(ChVector3d(trimesh_coords[i].x(), + trimesh_coords[i].y(), + trimesh_coords[i].z())); } } } @@ -259,57 +255,57 @@ void cppRigidBody::prestep(double* force, double* torque) { /* step to call before running chrono system step */ pos_last = body->GetPos(); - vel_last = body->GetPos_dt(); + vel_last = body->GetPosDt(); if (has_trimesh == true) { - trimesh_pos_last = trimesh->getCoordsVertices(); + trimesh_pos_last = trimesh->GetCoordsVertices(); } - acc_last = body->GetPos_dtdt(); - rotm_last = body->GetA(); + acc_last = body->GetPosDt2(); + rotm_last = body->GetRotMat(); rotq_last = body->GetRot(); - angacc_last = body->GetWacc_loc(); - angvel_last = body->GetWvel_loc(); - F_last = body->Get_accumulated_torque(); - M_last = body->Get_accumulated_torque(); + angacc_last = body->GetAngAccLocal(); + angvel_last = body->GetAngVelLocal(); + F_last = body->GetAccumulatedForce(); + M_last = body->GetAccumulatedTorque(); // apply external forces - body->Empty_forces_accumulators(); + body->EmptyAccumulators(); // calculate opposite force of gravity if free_x is 0 double forceG[3]={0.,0.,0.}; - if (free_x.x() == 0) {forceG[0] = -system->system->Get_G_acc().x()*body->GetMass();} - if (free_x.y() == 0) {forceG[1] = -system->system->Get_G_acc().y()*body->GetMass();} - if (free_x.z() == 0) {forceG[2] = -system->system->Get_G_acc().z()*body->GetMass();} - body->Accumulate_force(ChVector(forceG[0]+force[0]*free_x.x(), - forceG[1]+force[1]*free_x.y(), - forceG[2]+force[2]*free_x.z()), - pos_last, - false); - body->Accumulate_torque(ChVector(torque[0]*free_r.x(), - torque[1]*free_r.y(), - torque[2]*free_r.z()), - false); + if (free_x.x() == 0) {forceG[0] = -system->system->GetGravitationalAcceleration().x()*body->GetMass();} + if (free_x.y() == 0) {forceG[1] = -system->system->GetGravitationalAcceleration().y()*body->GetMass();} + if (free_x.z() == 0) {forceG[2] = -system->system->GetGravitationalAcceleration().z()*body->GetMass();} + body->AccumulateForce(ChVector3d(forceG[0]+force[0]*free_x.x(), + forceG[1]+force[1]*free_x.y(), + forceG[2]+force[2]*free_x.z()), + pos_last, + false); + body->AccumulateTorque(ChVector3d(torque[0]*free_r.x(), + torque[1]*free_r.y(), + torque[2]*free_r.z()), + false); if (spring!=0) { - double spring_length = spring->GetLength(); - if (spring_length < mooring_restlength) { - spring->SetDisabled(true);//SetRestLength(spring_length); - } - else { - spring->SetDisabled(false);//SetRestLength(mooring_restlength); - } - } + double spring_length = spring->GetLength(); + if (spring_length < mooring_restlength) { + spring->SetDisabled(true);//SetRestLength(spring_length); + } + else { + spring->SetDisabled(false);//SetRestLength(mooring_restlength); + } } +} void cppRigidBody::poststep() { pos = body->GetPos(); - vel = body->GetPos_dt(); - acc = body->GetPos_dtdt(); - rotm = body->GetA(); + vel = body->GetPosDt(); + acc = body->GetPosDt2(); + rotm = body->GetRotMat(); rotq = body->GetRot(); - angacc = body->GetWacc_loc(); - angvel = body->GetWvel_loc(); - F = body->Get_accumulated_force(); - M = body->Get_accumulated_torque(); + angacc = body->GetAngAccLocal(); + angvel = body->GetAngVelLocal(); + F = body->GetAccumulatedForce(); + M = body->GetAccumulatedTorque(); if (lock_motion_t_max > 0) { double t = system->system->GetChTime(); if (lock_motion_t_max < t && lock_motion->IsDisabled() == false) { @@ -328,96 +324,95 @@ void cppRigidBody::setPrescribedMotionCustom(std::vector t, double t_max) { auto fixed_body = chrono_types::make_shared(); fixed_body->SetPos(body->GetPos()); - fixed_body->SetBodyFixed(true); + fixed_body->SetFixed(true); system->system->Add(fixed_body); lock_motion = chrono_types::make_shared(); lock_motion_t_max = t_max; - lock_motion->Initialize(body, fixed_body, fixed_body->GetCoord()); + lock_motion->Initialize(body, fixed_body, fixed_body->GetFrameCOMToAbs()); system->system->Add(lock_motion); if (x.size() > 0) { - auto forced_motion = chrono_types::make_shared(); + auto forced_motion = chrono_types::make_shared(); for (int i = 0; i < x.size(); i++) { forced_motion->AddPoint(t[i], x[i]); } std::shared_ptr forced_ptr = forced_motion; - lock_motion->SetMotion_X(forced_ptr); + lock_motion->SetMotionX(forced_ptr); } if (y.size() > 0) { - auto forced_motion = chrono_types::make_shared(); + auto forced_motion = chrono_types::make_shared(); for (int i = 0; i < y.size(); i++) { forced_motion->AddPoint(t[i], y[i]); } std::shared_ptr forced_ptr = forced_motion; - lock_motion->SetMotion_Y(forced_ptr); + lock_motion->SetMotionY(forced_ptr); } if (z.size() > 0) { - auto forced_motion = chrono_types::make_shared(); + auto forced_motion = chrono_types::make_shared(); for (int i = 0; i < z.size(); i++) { forced_motion->AddPoint(t[i], z[i]); } std::shared_ptr forced_ptr = forced_motion; - lock_motion->SetMotion_Z(forced_ptr); + lock_motion->SetMotionZ(forced_ptr); } if (ang.size() > 0) { - auto forced_motion = chrono_types::make_shared(); + auto forced_motion = chrono_types::make_shared(); for (int i = 0; i < ang.size(); i++) { forced_motion->AddPoint(t[i], ang[i]); } std::shared_ptr forced_ptr = forced_motion; - lock_motion->SetMotion_ang(forced_ptr); + lock_motion->SetMotionAng1(forced_ptr); } if (ang2.size() > 0) { - auto forced_motion = chrono_types::make_shared(); + auto forced_motion = chrono_types::make_shared(); for (int i = 0; i < ang2.size(); i++) { forced_motion->AddPoint(t[i], ang2[i]); } std::shared_ptr forced_ptr = forced_motion; - lock_motion->SetMotion_ang2(forced_ptr); + lock_motion->SetMotionAng2(forced_ptr); } if (ang3.size() > 0) { - auto forced_motion = chrono_types::make_shared(); + auto forced_motion = chrono_types::make_shared(); for (int i = 0; i < ang3.size(); i++) { forced_motion->AddPoint(t[i], ang3[i]); } std::shared_ptr forced_ptr = forced_motion; - lock_motion->SetMotion_ang3(forced_ptr); + lock_motion->SetMotionAng3(forced_ptr); } } void cppRigidBody::setPrescribedMotionPoly(double coeff1) { auto fixed_body = chrono_types::make_shared(); fixed_body->SetPos(body->GetPos()); - fixed_body->SetBodyFixed(true); + fixed_body->SetFixed(true); system->system->Add(fixed_body); auto lock = chrono_types::make_shared(); - lock->Initialize(body, fixed_body, fixed_body->GetCoord()); + lock->Initialize(body, fixed_body, fixed_body->GetFrameCOMToAbs()); system->system->Add(lock); - auto forced_motion = chrono_types::make_shared(); - forced_motion->Set_order(1); - forced_motion->Set_coeff(coeff1, 1); + auto forced_motion = chrono_types::make_shared(); + forced_motion->SetCoefficients(std::vector{coeff1}); std::shared_ptr forced_ptr = forced_motion; - lock->SetMotion_X(forced_ptr); + lock->SetMotionX(forced_ptr); } void cppRigidBody::setPrescribedMotionSine(double a, double f) { auto fixed_body = chrono_types::make_shared(); fixed_body->SetPos(body->GetPos()); - fixed_body->SetBodyFixed(true); + fixed_body->SetFixed(true); system->system->Add(fixed_body); auto lock = chrono_types::make_shared(); - lock->Initialize(body, fixed_body, fixed_body->GetCoord()); + lock->Initialize(body, fixed_body, fixed_body->GetFrameCOMToAbs()); system->system->Add(lock); - auto forced_motion = chrono_types::make_shared(); - forced_motion->Set_amp(a); - forced_motion->Set_freq(f); + auto forced_motion = chrono_types::make_shared(); + forced_motion->SetAmplitude(a); + forced_motion->SetFrequency(f); std::shared_ptr forced_ptr = forced_motion; - lock->SetMotion_X(forced_ptr); + lock->SetMotionX(forced_ptr); } void cppRigidBody::setConstraints(double* free_x_in, double* free_r_in){ - free_x = ChVector<>(free_x_in[0], free_x_in[1], free_x_in[2]); - free_r = ChVector<>(free_r_in[0], free_r_in[1], free_r_in[2]); + free_x = ChVector3d(free_x_in[0], free_x_in[1], free_x_in[2]); + free_r = ChVector3d(free_r_in[0], free_r_in[1], free_r_in[2]); } void cppRigidBody::addSpring(double stiffness, @@ -429,14 +424,14 @@ void cppRigidBody::addSpring(double stiffness, mooring_restlength = rest_length; spring = chrono_types::make_shared(); std::shared_ptr anchor_body = chrono_types::make_shared(); - anchor_body->SetPos(ChVector<>(anchor[0], anchor[1], anchor[2])); - anchor_body->SetBodyFixed(true); + anchor_body->SetPos(ChVector3d(anchor[0], anchor[1], anchor[2])); + anchor_body->SetFixed(true); system->system->AddBody(anchor_body); spring->Initialize(body, anchor_body, true, // true for pos relative to bodies - ChVector<>(fairlead[0], fairlead[1], fairlead[2]), - ChVector<>(0.,0.,0.)); + ChVector3d(fairlead[0], fairlead[1], fairlead[2]), + ChVector3d(0.,0.,0.)); spring->SetSpringCoefficient(stiffness); spring->SetDampingCoefficient(damping); system->system->AddLink(spring); @@ -446,12 +441,14 @@ void cppRigidBody::addPrismaticLinkX(double* pris1) { auto mybod2 = chrono_types::make_shared(); mybod2->SetName("PRIS1"); - mybod2->SetPos(ChVector<>(pris1[0], pris1[1], pris1[2])); + mybod2->SetPos(ChVector3d(pris1[0], pris1[1], pris1[2])); mybod2->SetMass(0.00001); - mybod2->SetBodyFixed(true); + mybod2->SetFixed(true); system->system->AddBody(mybod2); auto mylink1 = chrono_types::make_shared(); - auto mycoordsys1 = ChCoordsys<>(mybod2->GetPos(),Q_from_AngAxis(CH_C_PI/2., VECT_Y));//Q_from_AngAxis(CH_C_PI / 2, VECT_X)); + ChQuaternion Q; + Q.SetFromAngleAxis(CH_PI/2., VECT_Y); + auto mycoordsys1 = ChFrame(mybod2->GetPos(), Q);//Q_from_AngAxis(CH_C_PI / 2, VECT_X)); mylink1->Initialize(mybod2, body, mycoordsys1); system->system->AddLink(mylink1); } @@ -470,34 +467,38 @@ void cppRigidBody::addPrismaticLinksWithSpring(double* pris1, system->system->AddBody(fairlead); auto mybod2 = chrono_types::make_shared(); mybod2->SetName("PRIS1"); - mybod2->SetPos(ChVector<>(pris1[0], pris1[1], pris1[2])); + mybod2->SetPos(ChVector3d(pris1[0], pris1[1], pris1[2])); mybod2->SetMass(0.00001); - //mybod2->AddForce(-system->system->Get_G_acc()); - //mybod2->SetBodyFixed(true); + //mybod2->AddForce(-system->system->GetGravitationalAcceleration()); + //mybod2->SetFixed(true); system->system->AddBody(mybod2); auto mybod3 = chrono_types::make_shared(); mybod3->SetName("PRIS2"); - mybod3->SetPos(ChVector<>(pris2[0], pris2[1], pris2[2])); - mybod3->SetBodyFixed(true); + mybod3->SetPos(ChVector3d(pris2[0], pris2[1], pris2[2])); + mybod3->SetFixed(true); system->system->AddBody(mybod3); auto mylink1 = chrono_types::make_shared(); system->system->AddLink(mylink1); - auto mycoordsys1 = ChCoordsys<>(mybod2->GetPos(),Q_from_AngAxis(CH_C_PI/2., VECT_Y));//Q_from_AngAxis(CH_C_PI / 2, VECT_X)); + ChQuaternion QX; + QX.SetFromAngleAxis(CH_PI/2., VECT_Y); + auto mycoordsys1 = ChFrame(mybod2->GetPos(), QX);//Q_from_AngAxis(CH_C_PI / 2, VECT_X)); mylink1->Initialize(fairlead, mybod2, mycoordsys1); auto mylink2 = chrono_types::make_shared(); system->system->AddLink(mylink2); - auto mycoordsys2 = ChCoordsys<>(mybod3->GetPos(),Q_from_AngAxis(CH_C_PI/2., VECT_X));//Q_from_AngAxis(CH_C_PI / 2, VECT_X)); + ChQuaternion QY; + QY.SetFromAngleAxis(CH_PI/2., VECT_X); + auto mycoordsys2 = ChFrame(mybod3->GetPos(), QY);//Q_from_AngAxis(CH_C_PI / 2, VECT_X)); mylink2->Initialize(mybod2, mybod3,mycoordsys2); auto mylink3 = chrono_types::make_shared(); //auto mylink3 = chrono_types::make_shared(); - //mylink3->SetMotion_axis(ChVector<>(0.,1.,0.)); + //mylink3->SetMotion_axis(ChVector3d(0.,1.,0.)); system->system->AddLink(mylink3); - mylink3->Initialize(fairlead, body, false, fairlead->GetCoord(), body->GetCoord()); + mylink3->Initialize(fairlead, body, false, fairlead->GetFrameCOMToAbs(), body->GetFrameCOMToAbs()); @@ -505,8 +506,8 @@ void cppRigidBody::addPrismaticLinksWithSpring(double* pris1, spring->Initialize(fairlead, mybod2, true, // true for pos relative to bodies - ChVector<>(0.,0.,0.), - ChVector<>(0.,0.,0.)); + ChVector3d(0.,0.,0.), + ChVector3d(0.,0.,0.)); spring->SetSpringCoefficient(stiffness); spring->SetDampingCoefficient(damping); spring->SetName("SPRING1"); @@ -514,14 +515,14 @@ void cppRigidBody::addPrismaticLinksWithSpring(double* pris1, } void cppRigidBody::setName(std::string name) { - body->SetNameString(name); + body->SetName(name); } -void cppRigidBody::getTriangleMeshSDF(ChVector<> pos, +void cppRigidBody::getTriangleMeshSDF(ChVector3d pos, double* dist_n) { - auto xxs = trimesh->getCoordsVertices(); - auto nns = trimesh->getCoordsNormals(); - ChVector<> dist_vec; + auto xxs = trimesh->GetCoordsVertices(); + auto nns = trimesh->GetCoordsNormals(); + ChVector3d dist_vec; double min_dist=1e10; double dist; for (int i = 0; i < xxs.size(); i++) { @@ -548,12 +549,12 @@ void cppRigidBody::getTriangleMeshSDF(ChVector<> pos, void cppRigidBody::getTriangleMeshVel(double *x, double dt, double *vel) { - auto xxs = trimesh->getCoordsVertices(); - auto nns = trimesh->getCoordsNormals(); + auto xxs = trimesh->GetCoordsVertices(); + auto nns = trimesh->GetCoordsNormals(); double min_dist = 1e10; - ChVector<> p(x[0], x[1], x[2]); - ChVector<> d_vector(0.0); - ChVector<> ddlast; + ChVector3d p(x[0], x[1], x[2]); + ChVector3d d_vector(0.0); + ChVector3d ddlast; // find closest node int node_closest = -1; for (int i = 0; i < xxs.size(); i++) { @@ -589,7 +590,7 @@ cppRigidBody * newRigidBody(cppSystem* system) void ChLinkLockBodies(std::shared_ptr body1, std::shared_ptr body2, std::shared_ptr system, - ChCoordsys<> coordsys, + ChFrame frame, double limit_X=0., double limit_Y=0., double limit_Z=0., @@ -598,25 +599,25 @@ void ChLinkLockBodies(std::shared_ptr body1, double limit_Rz=0.) { auto mylink = chrono_types::make_shared(); system->AddLink(mylink); - auto chlimit_X = mylink->GetLimit_X(); + auto chlimit_X = mylink->LimitX(); chlimit_X.SetActive(true); chlimit_X.SetMax(limit_X); - auto chlimit_Y = mylink->GetLimit_Y(); + auto chlimit_Y = mylink->LimitY(); chlimit_Y.SetActive(true); chlimit_Y.SetMax(limit_Y); - auto chlimit_Z = mylink->GetLimit_Z(); + auto chlimit_Z = mylink->LimitZ(); chlimit_Z.SetActive(true); chlimit_Z.SetMax(limit_Z); - auto chlimit_Rx = mylink->GetLimit_Rx(); + auto chlimit_Rx = mylink->LimitRx(); chlimit_Rx.SetMax(limit_Rx); chlimit_Rx.SetActive(true); - auto chlimit_Ry = mylink->GetLimit_Ry(); + auto chlimit_Ry = mylink->LimitRy(); chlimit_Ry.SetActive(true); chlimit_Ry.SetMax(limit_Ry); - auto chlimit_Rz = mylink->GetLimit_Rz(); + auto chlimit_Rz = mylink->LimitRz(); chlimit_Rz.SetActive(true); chlimit_Rz.SetMax(limit_Rz); - mylink->Initialize(body1, body2, coordsys); + mylink->Initialize(body1, body2, frame); } struct no_op_delete diff --git a/proteus/mbd/ProtChMoorings.h b/proteus/mbd/ProtChMoorings.h index 3b8afa3722..57a43c9c75 100644 --- a/proteus/mbd/ProtChMoorings.h +++ b/proteus/mbd/ProtChMoorings.h @@ -10,26 +10,25 @@ #include "chrono/physics/ChLoadContainer.h" #include "chrono/physics/ChLinkMate.h" #include "chrono/physics/ChBodyEasy.h" +#include "chrono/physics/ChContactMaterial.h" +#include "chrono/physics/ChContactMaterialSMC.h" #include "chrono/fea/ChElementBeamANCF_3333.h" #include "chrono/fea/ChElementCableANCF.h" #include "chrono/fea/ChElementBeamEuler.h" #include "chrono/fea/ChBeamSection.h" #include "chrono/fea/ChMesh.h" -#include "chrono/fea/ChLinkPointPoint.h" -#include "chrono/fea/ChLinkPointFrame.h" -#include "chrono/fea/ChLinkDirFrame.h" +#include "chrono/fea/ChLinkNodeNode.h" +#include "chrono/fea/ChLinkNodeFrame.h" +#include "chrono/fea/ChLinkNodeSlopeFrame.h" #include "chrono/fea/ChLoadsBeam.h" #include "chrono/fea/ChContactSurfaceNodeCloud.h" #include "chrono/timestepper/ChTimestepper.h" #include "chrono/solver/ChSolverPMINRES.h" -#include "chrono/core/ChTransform.h" //using namespace std; using namespace chrono; -using namespace chrono::fea; -using namespace chrono::collision; -using namespace chrono::geometry; +using namespace fea; // override some functions of ChElement @@ -73,10 +72,10 @@ class ChElementBeamEulermod : public ChElementBeamEuler { ChMatrix33<> A0; auto node0 = GetNodeA(); auto node1 = GetNodeB(); - ChVector<> mXele = node1->GetX0().GetPos() - node0->GetX0().GetPos(); - ChVector<> myele = node0->GetX0().GetA().Get_A_Yaxis(); - A0.Set_A_Xdir(mXele, myele); - q_element_ref_rot = A0.Get_A_quaternion(); + ChVector3d mXele = node1->GetX0().GetPos() - node0->GetX0().GetPos(); + ChVector3d myele = node0->GetX0().GetRotMat().GetAxisY(); + A0.SetFromAxisX(mXele, myele); + q_element_ref_rot = A0.GetQuaternion(); // Compute local stiffness matrix: ComputeStiffnessMatrix(); @@ -85,14 +84,14 @@ class ChElementBeamEulermod : public ChElementBeamEuler { class MyLoaderTriangular : public ChLoaderUdistributed { - public: +public: // Useful: a constructor that also sets ChLoadable - ChVector<> Fa; - ChVector<> Fb; - MyLoaderTriangular(std::shared_ptr mloadable): - ChLoaderUdistributed(mloadable) { - Fa = ChVector<>(0.,0.,0.); - Fb = ChVector<>(0.,0.,0.); + ChVector3d Fa; + ChVector3d Fb; + MyLoaderTriangular(std::shared_ptr mloadable): + ChLoaderUdistributed(mloadable) { + Fa = ChVector3d(0.,0.,0.); + Fb = ChVector3d(0.,0.,0.); }; // Compute F=F(u) // This is the function that you have to implement. It should return the @@ -104,12 +103,12 @@ class MyLoaderTriangular : public ChLoaderUdistributed { ChVectorDynamic<>* state_w ) { double Fy_max = 0.005; - ChVector<> force = Fa*abs(-1+U)/2.+Fb*(1+U)/2.; + ChVector3d force = Fa*abs(-1+U)/2.+Fb*(1+U)/2.; F(0) = force.x(); F(1) = force.y(); F(2) = force.z(); } - void SetF(ChVector<> Fa_in, ChVector<> Fb_in) { + void SetF(ChVector3d Fa_in, ChVector3d Fb_in) { Fa = Fa_in; Fb = Fb_in; } @@ -124,7 +123,7 @@ class MyLoaderTriangular : public ChLoaderUdistributed { class cppCable { - public: +public: std::shared_ptr system; // global system std::shared_ptr mesh; // mesh int nb_elems; // number of nodes along cable @@ -133,10 +132,10 @@ class cppCable { double Cd_normal; // drag coeff in normal direction double Cm_axial; // added mass coeff in axial direction double Cm_normal; // added mass coeff in normal direction - std::vector> mvecs; // vectors (nodes coordinates) - std::vector> mvecs_tangents; // vectors (tangents at nodes coordinates) - std::vector> mvecs_middle; - std::vector> mdirs; // vectors (nodes coordinates) + std::vector mvecs; // vectors (nodes coordinates) + std::vector mvecs_tangents; // vectors (tangents at nodes coordinates) + std::vector mvecs_middle; + std::vector mdirs; // vectors (nodes coordinates) double d, rho, E, length; // diameter, density, Young's modulus, length of cable double A0; // unstretched diameter double L0 = 0; // initial length along cable @@ -155,21 +154,21 @@ class cppCable { std::shared_ptr msection_cable; // cable material std::shared_ptr msection_advanced; // cable material std::vector elems_length; // array of elements - std::vector> fluid_velocity; - std::vector> fluid_acceleration; + std::vector fluid_velocity; + std::vector fluid_acceleration; std::vector fluid_density; std::vector nodes_density; // density of (cable-fluid) at nodes cppCable(std::shared_ptr system, std::shared_ptr mesh, double length, int nb_elems, double d, double rho, double E, double L0, std::string beam_type); // constructor - void setFluidVelocityAtNodes(std::vector> vel); - void setFluidAccelerationAtNodes(std::vector> acc); + void setFluidVelocityAtNodes(std::vector vel); + void setFluidAccelerationAtNodes(std::vector acc); void setFluidDensityAtNodes(std::vector vof); - std::vector>> getNodalPositions(); - std::vector>> forces_drag; - std::vector>> forces_addedmass; + std::vector> getNodalPositions(); + std::vector> forces_drag; + std::vector> forces_addedmass; /* std::vector> elems_loads_distributed; */ - std::vector>> elems_loads_triangular; - std::vector>> elems_loads_volumetric; + std::vector> elems_loads_triangular; + std::vector> elems_loads_volumetric; /* std::vector> elems_loads; */ void buildVectors(); // builds location vectors for the nodes void buildNodes(bool last_node); // builds the nodes for the mesh @@ -192,18 +191,18 @@ class cppCable { }; class cppMultiSegmentedCable { - public: +public: std::shared_ptr system; // global system std::string beam_type; - std::shared_ptr mysurfmaterial; + std::shared_ptr mysurfmaterial; std::shared_ptr mesh; // mesh std::shared_ptr fairleadd; - std::shared_ptr fairlead2; + std::shared_ptr fairlead2; std::vector nb_nodes; // number of nodes along cable std::vector nb_elems; // number of nodes along cable - std::vector> mvecs; // vectors (nodes coordinates) + std::vector mvecs; // vectors (nodes coordinates) std::vector> cables; - std::shared_ptr contact_material; // mesh + std::shared_ptr contact_material; // mesh std::vector d; std::vector rho; std::vector E; @@ -211,15 +210,15 @@ class cppMultiSegmentedCable { std::vector> nodes; // array nodes coordinates and direction std::vector> nodesDD; // array nodes coordinates and direction std::vector> nodesRot; // array nodes coordinates and direction - std::vector> fluid_velocity; - std::vector> fluid_acceleration; + std::vector fluid_velocity; + std::vector fluid_acceleration; std::vector fluid_density; std::vector> elemsCableANCF; // array of elements */ std::vector> elemsBeamEuler; // array of elements */ std::shared_ptr constraint_front; std::shared_ptr constraint_back; - std::vector>> forces_drag; - std::vector>> forces_addedmass; + std::vector> forces_drag; + std::vector> forces_addedmass; std::shared_ptr body_back; std::shared_ptr body_front; int nb_nodes_tot; @@ -235,13 +234,13 @@ class cppMultiSegmentedCable { std::vector rho, std::vector E, std::string beam_type); - void setFluidVelocityAtNodes(std::vector> vel); - void setFluidAccelerationAtNodes(std::vector> vel); + void setFluidVelocityAtNodes(std::vector vel); + void setFluidAccelerationAtNodes(std::vector vel); void setFluidDensityAtNodes(std::vector dens); void updateDragForces(); void updateAddedMassForces(); void applyForces(); - std::vector>> getNodalPositions(); + std::vector> getNodalPositions(); void buildNodes(); void buildElements(); void buildCable(); // builds the multi-segmented cable @@ -249,9 +248,9 @@ class cppMultiSegmentedCable { void attachBackNodeToBody(std::shared_ptr body); void attachFrontNodeToBody(std::shared_ptr body); - void setContactMaterial(std::shared_ptr material); + void setContactMaterial(std::shared_ptr material); void buildNodesCloud(); - ChVector<> getTensionElement(int i, double eta); + ChVector3d getTensionElement(int i, double eta); }; @@ -263,7 +262,7 @@ cppMultiSegmentedCable::cppMultiSegmentedCable(std::shared_ptr system, std::vector rho, std::vector E, std::string beam_type="CableANCF"): -system(system), + system(system), mesh(mesh), length(length), nb_elems(nb_elems), @@ -374,7 +373,7 @@ void cppMultiSegmentedCable::buildCable() { system->Add(con1); } else if (beam_type == "CableANCF") { - auto con1 = chrono_types::make_shared(); + auto con1 = chrono_types::make_shared(); auto nodeA = cables[i]->nodes.front(); auto nodeB = cables[i-1]->nodes.back(); con1->Initialize(nodeA, nodeB); @@ -396,8 +395,8 @@ void cppMultiSegmentedCable::buildCable() { nb_nodes_tot = nodes.size(); } for (int i = 0; i < nb_nodes_tot; ++i) { - fluid_velocity.push_back(ChVector<>(0.,0.,0.)); - fluid_acceleration.push_back(ChVector<>(0.,0.,0.)); + fluid_velocity.push_back(ChVector3d(0.,0.,0.)); + fluid_acceleration.push_back(ChVector3d(0.,0.,0.)); fluid_density.push_back(0.); } setFluidVelocityAtNodes(fluid_velocity); @@ -405,7 +404,7 @@ void cppMultiSegmentedCable::buildCable() { setFluidDensityAtNodes(fluid_density); } -void cppMultiSegmentedCable::setFluidAccelerationAtNodes(std::vector> acc) { +void cppMultiSegmentedCable::setFluidAccelerationAtNodes(std::vector acc) { fluid_acceleration = acc; int node_nb = 0; int node_nb_prev = node_nb; @@ -416,14 +415,14 @@ void cppMultiSegmentedCable::setFluidAccelerationAtNodes(std::vector> else if (beam_type == "CableANCF") { node_nb += cables[i]->nodes.size(); } - std::vector> fluid_acc(fluid_acceleration.begin()+node_nb_prev, + std::vector fluid_acc(fluid_acceleration.begin()+node_nb_prev, fluid_acceleration.begin()+node_nb); cables[i]->setFluidAccelerationAtNodes(fluid_acc); node_nb_prev = node_nb; } } -void cppMultiSegmentedCable::setFluidVelocityAtNodes(std::vector> vel) { +void cppMultiSegmentedCable::setFluidVelocityAtNodes(std::vector vel) { fluid_velocity = vel; int node_nb = 0; int node_nb_prev = node_nb; @@ -434,7 +433,7 @@ void cppMultiSegmentedCable::setFluidVelocityAtNodes(std::vector> vel else if (beam_type == "CableANCF") { node_nb += cables[i]->nodes.size(); } - std::vector> fluid_vel(fluid_velocity.begin()+node_nb_prev, + std::vector fluid_vel(fluid_velocity.begin()+node_nb_prev, fluid_velocity.begin()+node_nb); cables[i]->setFluidVelocityAtNodes(fluid_vel); node_nb_prev = node_nb; @@ -478,10 +477,10 @@ void cppMultiSegmentedCable::applyForces() { }; } -ChVector<> cppMultiSegmentedCable::getTensionElement(int i, const double eta=0.) { +ChVector3d cppMultiSegmentedCable::getTensionElement(int i, const double eta=0.) { - auto force = ChVector<>(); - auto torque = ChVector<>(); + auto force = ChVector3d(); + auto torque = ChVector3d(); if (beam_type == "CableANCF") { elemsCableANCF[i]->EvaluateSectionForceTorque(eta, force, @@ -498,14 +497,14 @@ ChVector<> cppMultiSegmentedCable::getTensionElement(int i, const double eta=0.) return force; } -std::vector>> cppMultiSegmentedCable::getNodalPositions() { - std::vector>> nodal_positions; +std::vector> cppMultiSegmentedCable::getNodalPositions() { + std::vector> nodal_positions; for (int i = 0; i < nodes.size(); ++i) { auto pos = nodes[i]->GetPos(); double x = pos.x(); double y = pos.y(); double z = pos.z(); - auto nodal_position = chrono_types::make_shared>(x, y, z); + auto nodal_position = chrono_types::make_shared(x, y, z); nodal_positions.push_back(nodal_position); } return nodal_positions; @@ -520,7 +519,7 @@ void cppMultiSegmentedCable::attachBackNodeToBody(std::shared_ptr body) constraint_back = constraint; } else { - auto constraint = chrono_types::make_shared(); + auto constraint = chrono_types::make_shared(); constraint->Initialize(nodes.back(), body); system->Add(constraint); body_back = body; @@ -537,7 +536,7 @@ void cppMultiSegmentedCable::attachFrontNodeToBody(std::shared_ptr body) constraint_front = constraint; } else if (beam_type == "CableANCF") { - auto constraint = chrono_types::make_shared(); + auto constraint = chrono_types::make_shared(); constraint->Initialize(nodes.front(), body); system->Add(constraint); body_front = body; @@ -545,7 +544,7 @@ void cppMultiSegmentedCable::attachFrontNodeToBody(std::shared_ptr body) } }; -void cppMultiSegmentedCable::setContactMaterial(std::shared_ptr material) { +void cppMultiSegmentedCable::setContactMaterial(std::shared_ptr material) { contact_material = material; }; @@ -601,13 +600,13 @@ cppCable::cppCable(std::shared_ptr system, // system in which the cabl msection_cable->SetDiameter(d); msection_cable->SetYoungModulus(E); msection_cable->SetDensity(rho); - /* msection_cable->SetI(Iyy); */ - Iyy = msection_cable->GetI(); + /* msection_cable->SetInertia(Iyy); */ + Iyy = msection_cable->GetInertia(); } else if (beam_type == "BeamEuler") { msection_advanced = chrono_types::make_shared(); msection_advanced->SetYoungModulus(E); - msection_advanced->SetGshearModulus(1e-6); + msection_advanced->SetShearModulus(1e-6); msection_advanced->SetDensity(rho); msection_advanced->SetAsCircularSection(d); /* msection_advanced->SetIyy(Iyy); */ @@ -619,7 +618,7 @@ cppCable::cppCable(std::shared_ptr system, // system in which the cabl void cppCable::setIyy(double Iyy_in) { Iyy = Iyy_in; if (beam_type == "CableANCF") { - msection_cable->SetI(Iyy); + msection_cable->SetInertia(Iyy); } else if (beam_type == "BeamEuler") { msection_advanced->SetIyy(Iyy); @@ -637,20 +636,20 @@ void cppCable::buildNodesBeamEuler(bool last_node) { forces_drag.clear(); forces_addedmass.clear(); std::shared_ptr node; - ChVector<> dir; // direction of node - ChVector<> ref = ChVector<>(1.,0.,0.); + ChVector3d dir; // direction of node + ChVector3d ref = ChVector3d(1.,0.,0.); ChQuaternion<> frame_quat; for (int i = 0; i < mvecs.size() - 1; ++i) { dir = mvecs_tangents[i]; dir.Normalize(); double ang = acos(dir^ref); // inner product auto axis = ref%dir; // cross product - frame_quat.Q_from_AngAxis(ang, axis); + frame_quat.SetFromAngleAxis(ang, axis); node = chrono_types::make_shared(ChFrame<>(mvecs[i], - frame_quat)); + frame_quat)); nodesRot.push_back(node); - std::shared_ptr> drag0 = chrono_types::make_shared>(0.,0.,0.); - std::shared_ptr> am0 = chrono_types::make_shared>(0.,0.,0.); + std::shared_ptr drag0 = chrono_types::make_shared(0.,0.,0.); + std::shared_ptr am0 = chrono_types::make_shared(0.,0.,0.); forces_drag.push_back(drag0); forces_addedmass.push_back(am0); } // last node @@ -659,14 +658,14 @@ void cppCable::buildNodesBeamEuler(bool last_node) { dir.Normalize(); double ang = -acos(dir^ref); // inner product auto axis = ref%dir; // cross product - frame_quat.Q_from_AngAxis(ang, axis); + frame_quat.SetFromAngleAxis(ang, axis); node = chrono_types::make_shared(ChFrame<>(mvecs[mvecs.size()-1], - frame_quat)); + frame_quat)); nodesRot.push_back(node); nb_nodes = nodesRot.size(); nb_elems = nb_nodes-1; - std::shared_ptr> drag0 = chrono_types::make_shared>(0.,0.,0.); - std::shared_ptr> am0 = chrono_types::make_shared>(0.,0.,0.); + std::shared_ptr drag0 = chrono_types::make_shared(0.,0.,0.); + std::shared_ptr am0 = chrono_types::make_shared(0.,0.,0.); forces_drag.push_back(drag0); forces_addedmass.push_back(am0); } @@ -681,15 +680,15 @@ void cppCable::buildNodesCableANCF(bool last_node) { forces_drag.clear(); forces_addedmass.clear(); std::shared_ptr node; - ChVector<> dir; // direction of node + ChVector3d dir; // direction of node ChCoordsys<> coordsys; // coordinate system of node for (int i = 0; i < mvecs.size() - 1; ++i) { dir = mvecs_tangents[i]; dir.Normalize(); node = chrono_types::make_shared(mvecs[i], dir); nodes.push_back(node); - std::shared_ptr> drag0 = chrono_types::make_shared>(0.,0.,0.); - std::shared_ptr> am0 = chrono_types::make_shared>(0.,0.,0.); + std::shared_ptr drag0 = chrono_types::make_shared(0.,0.,0.); + std::shared_ptr am0 = chrono_types::make_shared(0.,0.,0.); forces_drag.push_back(drag0); forces_addedmass.push_back(am0); } // last node @@ -700,8 +699,8 @@ void cppCable::buildNodesCableANCF(bool last_node) { nodes.push_back(node); nb_nodes = nodes.size(); nb_elems = nb_nodes-1; - std::shared_ptr> drag0 = chrono_types::make_shared>(0.,0.,0.); - std::shared_ptr> am0 = chrono_types::make_shared>(0.,0.,0.); + std::shared_ptr drag0 = chrono_types::make_shared(0.,0.,0.); + std::shared_ptr am0 = chrono_types::make_shared(0.,0.,0.); forces_drag.push_back(drag0); forces_addedmass.push_back(am0); } @@ -733,9 +732,10 @@ void cppCable::buildElementsCableANCF(bool set_lastnodes) { auto element = chrono_types::make_shared(); auto load_distributed = chrono_types::make_shared(element); auto load = chrono_types::make_shared(element); - std::shared_ptr> loadtri(new ChLoad(element)); - auto load_volumetric = chrono_types::make_shared>(element); - load_volumetric->loader.Set_G_acc(system->Get_G_acc()); + auto gravity = chrono_types::make_shared(element); + gravity->SetGravitationalAcceleration(system->GetGravitationalAcceleration()); + std::shared_ptr loadtri(new ChLoad(gravity)); + auto load_volumetric = chrono_types::make_shared(gravity); /* loadcontainer->Add(load_distributed); */ /* loadcontainer->Add(load); */ loadcontainer->Add(loadtri); // do not forget to add the load to the load container. @@ -770,9 +770,10 @@ void cppCable::buildElementsBeamEuler(bool set_lastnodes) { auto element = chrono_types::make_shared(); auto load_distributed = chrono_types::make_shared(element); auto load = chrono_types::make_shared(element); - std::shared_ptr> loadtri(new ChLoad(element)); - auto load_volumetric = chrono_types::make_shared>(element); - load_volumetric->loader.Set_G_acc(system->Get_G_acc()); + auto gravity = chrono_types::make_shared(element); + gravity->SetGravitationalAcceleration(system->GetGravitationalAcceleration()); + std::shared_ptr loadtri(new ChLoad(gravity)); + auto load_volumetric = chrono_types::make_shared(gravity); /* loadcontainer->Add(load_distributed); */ /* loadcontainer->Add(load); */ loadcontainer->Add(loadtri); // do not forget to add the load to the load container. @@ -835,11 +836,11 @@ void cppCable::buildMeshCableANCF(bool add_lastnode) { } mesh->AddElement(elemsCableANCF[elemsCableANCF.size()-1]); } -void cppCable::setFluidAccelerationAtNodes(std::vector> acc) { +void cppCable::setFluidAccelerationAtNodes(std::vector acc) { fluid_acceleration = acc; } -void cppCable::setFluidVelocityAtNodes(std::vector> vel) { +void cppCable::setFluidVelocityAtNodes(std::vector vel) { fluid_velocity = vel; } @@ -867,32 +868,32 @@ void cppCable::setDragForce() { * setFluidVelocityAtNodes and setFluidDensityAtNodes * must be called before this function */ - ChVector<> u_ch; // velocity from chrono - ChVector<> u_prot; // velocity from proteus - ChVector<> u_rel; // relative velocity of node with surrounding fluid - ChVector<> t_dir; // tangent at node - ChVector<> Fd_a; // axial (tangential) drag force - ChVector<> Fd_n; // normal(transversal) drag force - ChVector<> Fd; // total drag force - ChVector<> Va; - ChVector<> Vn; + ChVector3d u_ch; // velocity from chrono + ChVector3d u_prot; // velocity from proteus + ChVector3d u_rel; // relative velocity of node with surrounding fluid + ChVector3d t_dir; // tangent at node + ChVector3d Fd_a; // axial (tangential) drag force + ChVector3d Fd_n; // normal(transversal) drag force + ChVector3d Fd; // total drag force + ChVector3d Va; + ChVector3d Vn; double rho_f; // clear current drag forces double length_elem = length / (nb_nodes - 1); for (int i = 0; i < nb_nodes; ++i) { if (beam_type == "CableANCF") { - t_dir = nodes[i]->GetD(); - u_ch = nodes[i]->GetPos_dt(); + t_dir = nodes[i]->GetSlope1(); + u_ch = nodes[i]->GetPosDt(); } else if (beam_type == "BeamEuler") { t_dir = nodesRot[i]->GetRot().GetVector(); - u_ch = nodesRot[i]->GetPos_dt(); + u_ch = nodesRot[i]->GetPosDt(); } // get velocity u_prot from proteus // TO CHANGE !! double ux_prot = fluid_velocity[i][0]; double uy_prot = fluid_velocity[i][1]; double uz_prot = fluid_velocity[i][2]; - u_prot = ChVector<>(ux_prot, uy_prot, uz_prot); + u_prot = ChVector3d(ux_prot, uy_prot, uz_prot); u_rel = u_prot - u_ch; // CAREFUL HERE: ChBeamElementANCF, GetD() does not give direction but normal rho_f = fluid_density[i]; @@ -912,33 +913,33 @@ void cppCable::setAddedMassForce() { * setFluidVelocityAtNodes and setFluidDensityAtNodes * must be called before this function */ - ChVector<> a_ch; // acceleration from chrono - ChVector<> a_prot; // acceleration from proteus - ChVector<> a_rel; // relative acceleration of node with surrounding fluid - ChVector<> t_dir; // tangent at node - ChVector<> Fm_a; // axial (tangential) added mass force - ChVector<> Fm_n; // normal(transversal) added mass force - ChVector<> Fm_f; // fluid part added mass force - ChVector<> Fm; // total added mass force - ChVector<> Va; - ChVector<> Vn; + ChVector3d a_ch; // acceleration from chrono + ChVector3d a_prot; // acceleration from proteus + ChVector3d a_rel; // relative acceleration of node with surrounding fluid + ChVector3d t_dir; // tangent at node + ChVector3d Fm_a; // axial (tangential) added mass force + ChVector3d Fm_n; // normal(transversal) added mass force + ChVector3d Fm_f; // fluid part added mass force + ChVector3d Fm; // total added mass force + ChVector3d Va; + ChVector3d Vn; double rho_f; // clear current drag forces double length_elem = length / (nb_nodes - 1); for (int i = 0; i < nb_nodes; ++i) { if (beam_type == "CableANCF") { - t_dir = nodes[i]->GetD(); - a_ch = nodes[i]->GetPos_dtdt(); + t_dir = nodes[i]->GetSlope1(); + a_ch = nodes[i]->GetPosDt2(); } else if (beam_type == "BeamEuler") { t_dir = nodesRot[i]->GetRot().GetVector(); - a_ch = nodesRot[i]->GetPos_dtdt(); + a_ch = nodesRot[i]->GetPosDt2(); } // get velocity u_prot from proteus // TO CHANGE !! double ax_prot = fluid_acceleration[i][0]; double ay_prot = fluid_acceleration[i][1]; double az_prot = fluid_acceleration[i][2]; - a_prot = ChVector<>(ax_prot, ay_prot, az_prot); + a_prot = ChVector3d(ax_prot, ay_prot, az_prot); a_rel = a_prot - a_ch; rho_f = fluid_density[i]; double dot = a_rel^t_dir; @@ -954,8 +955,8 @@ void cppCable::setAddedMassForce() { void cppCable::applyForces() { for (int i = 0; i < nb_nodes-1; ++i) { - ChVector<> Fa = ChVector<>(0.,0.,0.); - ChVector<> Fb = ChVector<>(0.,0.,0.); + ChVector3d Fa = ChVector3d(0.,0.,0.); + ChVector3d Fb = ChVector3d(0.,0.,0.); if (applyDrag == true) { Fa = Fa+*forces_drag[i].get(); Fb = Fb+*forces_drag[i+1].get(); @@ -968,10 +969,10 @@ void cppCable::applyForces() { // buoyancy if (applyBuoyancy == true) { if (mesh->GetAutomaticGravity() == true) { - /* elems_loads_volumetric[i]->loader.Set_G_acc(-fluid_density[i]/rho*system->Get_G_acc()); */ + /* elems_loads_volumetric[i]->loader.SetBodyAppliedForce(-fluid_density[i]/rho*system->GetBodyAppliedForce()); */ } else { - /* elems_loads_volumetric[i]->loader.Set_G_acc((1-fluid_density[i]/rho)*system->Get_G_acc()); */ + /* elems_loads_volumetric[i]->loader.SetBodyAppliedForce((1-fluid_density[i]/rho)*system->GetBodyAppliedForce()); */ } } } @@ -1012,7 +1013,7 @@ void cppAttachNodeToNodeFEAxyzD(cppMultiSegmentedCable* cable1, int node1, cppMultiSegmentedCable* cable2, int node2) { - auto con1 = chrono_types::make_shared(); + auto con1 = chrono_types::make_shared(); auto nodeA = cable1->nodes[node1]; auto nodeB = cable2->nodes[node2]; con1->Initialize(nodeA, nodeB); diff --git a/proteus/mesh.cpp b/proteus/mesh.cpp index 95f701f6cc..aedbd6a405 100644 --- a/proteus/mesh.cpp +++ b/proteus/mesh.cpp @@ -211,8 +211,8 @@ extern "C" t[2][1] = nodeArray[n3*3+1] - nodeArray[n0*3+1]; t[2][2] = nodeArray[n3*3+2] - nodeArray[n0*3+2]; - double det = t[0][0]*(t[1][1]*t[2][2] - t[1][2]*t[2][1]) - - t[0][1]*(t[1][0]*t[2][2] - t[1][2]*t[2][0]) + + double det = t[0][0]*(t[1][1]*t[2][2] - t[1][2]*t[2][1]) - + t[0][1]*(t[1][0]*t[2][2] - t[1][2]*t[2][0]) + t[0][2]*(t[1][0]*t[2][1] - t[1][1]*t[2][0]); if (det < 0) diff --git a/proteus/mprans/AddedMass.py b/proteus/mprans/AddedMass.py index a9b227b72f..0f57f9b74b 100644 --- a/proteus/mprans/AddedMass.py +++ b/proteus/mprans/AddedMass.py @@ -1,8 +1,3 @@ -from __future__ import absolute_import -from __future__ import division -from builtins import str -from builtins import range -from past.utils import old_div import proteus import numpy as np from proteus.Transport import OneLevelTransport @@ -149,7 +144,7 @@ def postStep(self, t, firstStep=False): def evaluate(self, t, c): if c[('u',0)].shape == self.q_rho.shape: - c[('a', 0, 0)][..., 0] = old_div(1.0,self.q_rho) + c[('a', 0, 0)][..., 0] = 1.0/self.q_rho for i in range(1, c[('a', 0, 0)].shape[-1]): c[('a', 0, 0)][..., i] = c[('a', 0, 0)][..., 0] @@ -613,8 +608,7 @@ def __init__(self, for ebN in range(self.mesh.nElementBoundaries_global): for k in range( self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebq_global['penalty'][ebN, k] = old_div(self.numericalFlux.penalty_constant, ( - self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power)) + self.ebq_global['penalty'][ebN, k] = self.numericalFlux.penalty_constant/(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) # penalty term # cek move to Numerical flux initialization if 'penalty' in self.ebqe: @@ -622,8 +616,7 @@ def __init__(self, ebN = self.mesh.exteriorElementBoundariesArray[ebNE] for k in range( self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebqe['penalty'][ebNE, k] = old_div(self.numericalFlux.penalty_constant, \ - self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) + self.ebqe['penalty'][ebNE, k] = self.numericalFlux.penalty_constant/self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power logEvent(memory("numericalFlux", "OneLevelTransport"), level=4) self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray # helper for writing out data storage diff --git a/proteus/mprans/ArchiveBeams.py b/proteus/mprans/ArchiveBeams.py index e9dcf49e92..dcec6523ef 100644 --- a/proteus/mprans/ArchiveBeams.py +++ b/proteus/mprans/ArchiveBeams.py @@ -1,5 +1,3 @@ -from __future__ import print_function -from builtins import range import numpy as np @@ -147,4 +145,4 @@ def Archive_time_step(Beam_x, + '\t\t\n' + '\t\n' + '\n') - f.close() + f.close( diff --git a/proteus/mprans/BodyDynamics.py b/proteus/mprans/BodyDynamics.py index 07dc9b541d..3d28052189 100644 --- a/proteus/mprans/BodyDynamics.py +++ b/proteus/mprans/BodyDynamics.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import range -from past.utils import old_div from math import cos, sin, sqrt, atan2, acos, asin, pi import csv import os @@ -243,7 +240,7 @@ def getAcceleration(self): a: array_like acceleration of current time step """ - a = old_div(self.F, self.mass) + a = self.F/self.mass return a def getAngularAcceleration(self): @@ -251,7 +248,7 @@ def getAngularAcceleration(self): self.inertia = self.getInertia(self.M, self.Shape.barycenter) assert self.inertia != 0, 'Zero inertia: inertia tensor (It)' \ 'was not set correctly!' - self.ang_acc = old_div(self.M[:], self.inertia) + self.ang_acc = self.M[:]/self.inertia else: self.inertia = None self.ang_acc = np.array([0., 0., 0.]) @@ -261,7 +258,7 @@ def getDisplacement(self, dt): # acceleration from force self.acceleration = self.getAcceleration() # substeps for smoother motion between timesteps - dt_sub = old_div(dt, float(self.substeps)) + dt_sub = dt/float(self.substeps) # Forward_Euler if self.scheme == 'Forward_Euler': @@ -282,9 +279,9 @@ def getDisplacement(self, dt): vx0 = self.last_velocity[0] # x-axis velocity vy0 = self.last_velocity[1] # y-axis velocity vz0 = self.last_velocity[2] # z-axis velocity - ax0 = old_div((Fx - Cx * vx0 - Kx * ux0), mass) # x-axis acceleration - ay0 = old_div((Fy - Cy * vy0 - Ky * uy0), mass) # y-axis acceleration - az0 = old_div((Fz - Cz * vz0 - Kz * uz0), mass) # z-axis acceleration + ax0 = (Fx-Cx*vx0-Kx*ux0)/mass # x-axis acceleration + ay0 = (Fy-Cy*vy0-Ky*uy0)/mass # y-axis acceleration + az0 = (Fz-Cz*vz0-Kz*uz0)/mass # z-axis acceleration # solving numerical scheme ux, vx, ax = runge_kutta(u0=ux0, v0=vx0, a0=ax0, dt=dt_sub, substeps=self.substeps, F=Fx, K=Kx, C=Cx, m=mass, velCheck=False) uy, vy, ay = runge_kutta(u0=uy0, v0=vy0, a0=ay0, dt=dt_sub, substeps=self.substeps, F=Fy, K=Ky, C=Cy, m=mass, velCheck=False) @@ -303,7 +300,7 @@ def getDisplacement(self, dt): def getAngularDisplacement(self, dt): # angular acceleration from moment self.ang_acc = self.getAngularAcceleration() - dt_sub = old_div(dt, float(self.substeps)) + dt_sub = dt/float(self.substeps) # Forward_Euler if self.scheme == 'Forward_Euler': @@ -330,7 +327,7 @@ def getAngularDisplacement(self, dt): # initial condition rz0 = atan2(self.last_rotation[0, 1], self.last_rotation[0, 0]) # angular displacement vrz0 = self.last_ang_vel[2] # angular velocity - arz0 = old_div((Mp[2] - Crot * vrz0 - Krot * rz0), inertia) # angular acceleration + arz0 = (Mp[2]-Crot*vrz0-Krot*rz0)/inertia # angular acceleration # solving numerical scheme rz, vrz, arz = runge_kutta(u0=rz0, v0=vrz0, a0=arz0, dt=dt_sub, substeps=self.substeps, F=Mp[2], K=Krot, C=Crot, m=inertia, velCheck=False) @@ -567,7 +564,7 @@ def getInertia(self, vec=(0., 0., 1.), pivot=None): # making unity vector/axis of rotation vec = vx, vy, vz = np.array(vec) length_vec = np.sqrt(vx**2 + vy**2 + vz**2) - vec = old_div(vec, length_vec) + vec = vec/length_vec if self.nd == 2: I = self.It * self.mass elif self.nd == 3: @@ -903,12 +900,12 @@ def getInertia(self, vec=(0., 0., 1.), pivot=None): # making unity vector/axis of rotation vec = vx, vy, vz = np.array(vec) length_vec = np.sqrt(vx**2 + vy**2 + vz**2) - vec = old_div(vec, length_vec) + vec = vec/length_vec if self.Shape.Domain.nd == 2: L, H = self.Shape.dim dx, dy, dz = distance # To calculate It when pivot != barycenter - Ix = float(old_div((H**2), 12.)) + float(dy**2) # To calculate x-component of It when pivot != barycenter - Iy = float(old_div((L**2), 12.)) + float(dx**2) # To calculate y-component of It when pivot != barycenter + Ix = float((H**2)/12.) + float(dy**2) # To calculate x-component of It when pivot != barycenter + Iy = float((L**2)/12.) + float(dx**2) # To calculate y-component of It when pivot != barycenter self.It = Ix + Iy I = self.It * self.mass elif self.Shape.Domain.nd == 3: @@ -1009,13 +1006,13 @@ def friction_module(self, dt): """ nd = self.Shape.Domain.nd substeps = 20 - dt_sub = old_div(dt, float(substeps)) + dt_sub = dt/float(substeps) # movement_functions for friction test cases Fx, Fy, Fz = self.F eps = (10**-30) # to avoid 0/0 mass = self.mass - sign_static = old_div(Fx, (abs(Fx) + eps)) - sign_dynamic = old_div(self.last_velocity[0], (abs(self.last_velocity[0]) + eps)) + sign_static = Fx/(abs(Fx)+eps) + sign_dynamic = self.last_velocity[0]/(abs(self.last_velocity[0])+eps) if nd == 2: g = np.array([0., -9.81, 0.]) Fv = Fy @@ -1054,7 +1051,7 @@ def dynamic_case(self, sign, Fx, Fv, mass, m): # calculation on the vertical direction for frictional force # solving numerical scheme - ay0 = old_div((Fv - Cy * vy0 - Ky * uy0), mass) + ay0 = (Fv-Cy*vy0-Ky*uy0)/mass if self.scheme == 'Runge_Kutta': uy, vy, ay = runge_kutta(u0=uy0, v0=vy0, a0=ay0, dt=dt_sub, substeps=substeps, @@ -1095,7 +1092,7 @@ def dynamic_case(self, sign, Fx, Fv, mass, m): # initial condition acceleration # solving numerical scheme - ax0 = old_div((Fh - Cx * vx0 - Kx * ux0), mass) + ax0 = (Fh-Cx*vx0-Kx*ux0)/mass if self.scheme == 'Runge_Kutta': ux, vx, ax = runge_kutta(u0=ux0, v0=vx0, a0=ax0, dt=dt_sub, substeps=substeps, @@ -1153,7 +1150,7 @@ def overturning_module(self, dt): """ nd = self.Shape.Domain.nd substeps = 20 - dt_sub = old_div(dt, float(substeps)) + dt_sub = dt/float(substeps) #--------------------------------------------------------------- def calculate_rotation(self, floating, h): @@ -1201,7 +1198,7 @@ def calculate_rotation(self, floating, h): # initial condition rz0 = atan2(self.last_rotation[0, 1], self.last_rotation[0, 0]) # angular displacement vrz0 = self.last_ang_vel[2] # angular velocity - arz0 = old_div((Mp[2] - Crot * vrz0 - Krot * rz0), inertia) # angular acceleration + arz0 = (Mp[2]-Crot*vrz0-Krot*rz0)/inertia # angular acceleration # solving numerical scheme if self.scheme == 'Runge_Kutta': @@ -1584,19 +1581,19 @@ def runge_kutta(u0, v0, a0, dt, substeps, F, K, C, m, velCheck): # 2 step u2 = u1 + v1 * dt / 2. v2 = v1 + a1 * dt / 2. - a2 = old_div((F - C * v2 - K * u2), m) + a2 = (F-C*v2-K*u2)/m # 3 step u3 = u1 + v2 * dt / 2. v3 = v1 + a2 * dt / 2. - a3 = old_div((F - C * v3 - K * u3), m) + a3 = (F-C*v3-K*u3)/m # 4 step u4 = u1 + v3 * dt v4 = v1 + a3 * dt - a4 = old_div((F - C * v4 - K * u4), m) + a4 = (F-C*v4-K*u4)/m # calculation - u = u0 + (old_div(dt, 6.)) * (v1 + 2. * v2 + 2. * v3 + v4) - v = v0 + (old_div(dt, 6.)) * (a1 + 2. * a2 + 2. * a3 + a4) - a = old_div((F - C * v - K * u), m) + u = u0 + (dt/6.) * (v1 + 2. * v2 + 2. * v3 + v4) + v = v0 + (dt/6.) * (a1 + 2. * a2 + 2. * a3 + a4) + a = (F-C*v-K*u)/m # velocity check if velCheck == True: # When velocity changes sign, it means that 0-condition is passed @@ -1607,4 +1604,4 @@ def runge_kutta(u0, v0, a0, dt, substeps, F, K, C, m, velCheck): u0 = u v0 = v a0 = a - return u, v, a + return u, v, a \ No newline at end of file diff --git a/proteus/mprans/BoundaryConditions.py b/proteus/mprans/BoundaryConditions.py index b5f23aafc7..55f52834d5 100644 --- a/proteus/mprans/BoundaryConditions.py +++ b/proteus/mprans/BoundaryConditions.py @@ -4,11 +4,6 @@ # cython: wraparound=False # cython: boundscheck=False # cython: initializedcheck=False - -from __future__ import division -from builtins import str -from builtins import range -from past.utils import old_div import cython """ @@ -699,7 +694,7 @@ def ux_dirichlet(x, t, n=None): if phi <= 0.: H = 0.0 elif 0 < phi <= smoothing: - H = smoothedHeaviside(smoothing, phi-smoothing/2.)#smoothedHeaviside(old_div(smoothing, 2.), phi - old_div(smoothing, 2.)) + H = smoothedHeaviside(smoothing, phi-smoothing/2.)#smoothedHeaviside(smoothing/2., phi - smoothing/2.) else: H = 1.0 u = H * Uwind[i] + (1 - H) * U[i] @@ -727,7 +722,7 @@ def inlet_p_advective(x, t, n=None): if phi <= 0.: H = 0.0 elif 0 < phi <= smoothing: - H = smoothedHeaviside(smoothing, phi-smoothing/2.)#smoothedHeaviside(old_div(smoothing, 2.), phi - old_div(smoothing, 2.)) + H = smoothedHeaviside(smoothing, phi-smoothing/2.)#smoothedHeaviside(smoothing/2., phi - smoothing/2.) else: H = 1.0 u = H * Uwind + (1 - H) * U @@ -741,7 +736,7 @@ def inlet_k_dirichlet(x, t, n=None): if phi <= 0.: H = 0.0 elif 0 < phi <= smoothing: - H = smoothedHeaviside(smoothing, phi-smoothing/2.)#smoothedHeaviside(old_div(smoothing, 2.), phi - old_div(smoothing, 2.)) + H = smoothedHeaviside(smoothing, phi-smoothing/2.)#smoothedHeaviside(smoothing/2., phi - smoothing/2.) else: H = 1.0 return H * kInflowAir + (1 - H) * kInflow @@ -751,7 +746,7 @@ def inlet_dissipation_dirichlet(x, t, n=None): if phi <= 0.: H = 0.0 elif 0 < phi <= smoothing: - H = smoothedHeaviside(smoothing, phi-smoothing/2.)#smoothedHeaviside(old_div(smoothing, 2.), phi - old_div(smoothing, 2.)) + H = smoothedHeaviside(smoothing, phi-smoothing/2.)#smoothedHeaviside(smoothing/2., phi - smoothing/2.) else: H = 1.0 return H * dissipationInflowAir + (1 - H) * dissipationInflow @@ -827,7 +822,7 @@ def inlet_k_dirichlet(x, t, n=None): if phi <= 0.: H = 0.0 elif 0 < phi <= smoothing: - H = smoothedHeaviside(old_div(smoothing, 2.), phi - old_div(smoothing, 2.)) + H = smoothedHeaviside(smoothing/2., phi - smoothing/2.) else: H = 1.0 return H * kInflowAir + (1 - H) * kInflow @@ -837,7 +832,7 @@ def inlet_dissipation_dirichlet(x, t, n=None): if phi <= 0.: H = 0.0 elif 0 < phi <= smoothing: - H = smoothedHeaviside(old_div(smoothing, 2.), phi - old_div(smoothing, 2.)) + H = smoothedHeaviside(smoothing/2., phi - smoothing/2.) else: H = 1.0 return H * dissipationInflowAir + (1 - H) * dissipationInflow @@ -881,7 +876,7 @@ def ux_dirichlet(x, t, n=None): if phi <= 0.: H = 0.0 elif 0 < phi <= smoothing: - H = smoothedHeaviside(old_div(smoothing, 2.), phi - old_div(smoothing, 2.)) + H = smoothedHeaviside(smoothing/2., phi - smoothing/2.) else: H = 1.0 return H * Uwind[i] + (1 - H) * U[i] @@ -946,7 +941,7 @@ class instance of a wave from proteus.WaveTools (must be set for def __cinit__(self, zone_type, center, orientation, epsFact_porous, waves=None, shape=None, wind_speed=np.array([0., 0., 0.]), - dragAlpha=old_div(0.5, 1.005e-6), dragBeta=0., porosity=1., vert_axis=None, smoothing=0., + dragAlpha=0.5/1.005e-6, dragBeta=0., porosity=1., vert_axis=None, smoothing=0., vof_water=0., vof_air=1.): self.Shape = shape self.nd = self.Shape.Domain.nd @@ -1161,7 +1156,7 @@ def __cpp_calculate_velocity(self, x, t): waterSpeed = self.WT.u(xx, t) elif 0 < phi <= self.smoothing: # smoothing on half the range of VOF (above wave crest) - H = smoothedHeaviside(old_div(self.smoothing, 2.), phi - old_div(self.smoothing, 2.)) + H = smoothedHeaviside(self.smoothing/2., phi - self.smoothing/2.) # use max velocity of wave for water x_max[0] = x[0] x_max[1] = x[1] @@ -1476,7 +1471,7 @@ def tangentialVelocity(self, x, t, n, uInit=None): # projection of u vector over an ortoganal plane to n self.tanU = self.meanV - self.meanV * (n**2) # tangential unit vector - self.tV = old_div(self.tanU,np.sqrt(np.sum(self.tanU**2))) + self.tV = self.tanU/np.sqrt(np.sum(self.tanU**2)) def getVariables(self, x, t): """ @@ -1496,15 +1491,15 @@ def getVariables(self, x, t): if self.Ystar < 11.225: self.Ustar = self.Ystar self.uDir = (self.utStar*self.Ystar) * self.tV - self.gradU = ( old_div((self.utStar**2), self.nu) ) * self.tV + self.gradU = ( (self.utStar**2)/self.nu ) * self.tV # log-law layer else: # Wall function theory from S.B. Pope, page 442-443 E = np.exp(self.B * self.K) self.Ustar = self.utStar * np.log(E * self.Ystar) / self.K - self.utAbs = self.utStar * np.sqrt(old_div(Up, self.Ustar)) + self.utAbs = self.utStar * np.sqrt(Up/self.Ustar) # Velocity vector and velocity gradient multiplied by the tangential vector unit - self.gradU = (old_div(self.utAbs, (self.K * self.Y))) * self.tV + self.gradU = (self.utAbs/(self.K*self.Y)) * self.tV # Linear approximation for velocity at the wall (using the gradU of the logLaw) self.uDir = self.tanU - (self.gradU * self.Y) @@ -1553,9 +1548,9 @@ def get_dissipation_dirichlet(self, x, t, n): self.getVariables(x, t) d = 0. if self.turbModel == 'ke': - d = old_div((self.utStar**3), (self.K * self.Y)) + d = (self.utStar**3)/(self.K*self.Y) elif self.turbModel == 'kw' and self.kappa > 0.: - d = old_div(np.sqrt(self.kappa), (self.K * self.Y * (self.Cmu**0.25))) + d = np.sqrt(self.kappa)/(self.K*self.Y*(self.Cmu**0.25)) return d def get_u_diffusive(self, x, t, n): @@ -1649,7 +1644,7 @@ def getFluidKappaLocalCoords(self, xi, element, rank): def kappaNearWall(self, xi, element, rank, kInit=None): if kInit is True or self.model is None: self.ut = self.Yplus * self.nu / self.Y - self.kappa = old_div((self.ut**2), np.sqrt(self.Cmu)) + self.kappa = (self.ut**2)/np.sqrt(self.Cmu) else: self.kappa = self.getFluidKappaLocalCoords(xi, element, rank) @@ -1659,4 +1654,4 @@ def getKappa(self, x, t, xi, element, rank): else: kInit = True self.kappaNearWall(xi, element, rank, kInit) - return abs(self.kappa) + return abs(self.kappa) \ No newline at end of file diff --git a/proteus/mprans/CLSVOF.py b/proteus/mprans/CLSVOF.py index 189a228667..d60f11dd4d 100644 --- a/proteus/mprans/CLSVOF.py +++ b/proteus/mprans/CLSVOF.py @@ -1,7 +1,3 @@ -from __future__ import division -from builtins import str -from builtins import range -from past.utils import old_div import proteus from proteus.mprans.cCLSVOF import * import numpy as np @@ -439,7 +435,7 @@ def __init__(self, self.q[('u',0)] = np.zeros((self.mesh.nElements_global,self.nQuadraturePoints_element),'d') self.q[('H(u)',0)] = np.zeros((self.mesh.nElements_global,self.nQuadraturePoints_element),'d') self.q[('mH(u)',0)] = np.zeros((self.mesh.nElements_global,self.nQuadraturePoints_element),'d') - self.q[('dV_u',0)] = (old_div(1.0,self.mesh.nElements_global))*np.ones((self.mesh.nElements_global,self.nQuadraturePoints_element),'d') + self.q[('dV_u',0)] = (1.0/self.mesh.nElements_global)*np.ones((self.mesh.nElements_global,self.nQuadraturePoints_element),'d') self.q[('grad(u)',0)] = np.zeros((self.mesh.nElements_global,self.nQuadraturePoints_element,self.nSpace_global),'d') self.q[('m',0)] = self.q[('u',0)] self.q[('m_last',0)] = np.zeros((self.mesh.nElements_global,self.nQuadraturePoints_element),'d') @@ -550,14 +546,14 @@ def __init__(self, if 'penalty' in self.ebq_global: for ebN in range(self.mesh.nElementBoundaries_global): for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebq_global['penalty'][ebN,k] = old_div(self.numericalFlux.penalty_constant,(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power)) + self.ebq_global['penalty'][ebN,k] = self.numericalFlux.penalty_constant/(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) #penalty term #cek move to Numerical flux initialization if 'penalty' in self.ebqe: for ebNE in range(self.mesh.nExteriorElementBoundaries_global): ebN = self.mesh.exteriorElementBoundariesArray[ebNE] for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebqe['penalty'][ebNE,k] = old_div(self.numericalFlux.penalty_constant,self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) + self.ebqe['penalty'][ebNE,k] = self.numericalFlux.penalty_constant/self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power logEvent(memory("numericalFlux","OneLevelTransport"),level=4) self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray #use post processing tools to get conservative fluxes, None by default @@ -934,8 +930,8 @@ def getMetricsAtETS(self): #ETS=Every Time Step self.global_V0 = globalSum(global_V0) self.global_sV = globalSum(global_sV) self.global_sV0 = globalSum(global_sV0) - self.global_V_err = old_div(np.abs(self.global_V-self.global_V0),self.global_V0) - self.global_sV_err = old_div(np.abs(self.global_sV-self.global_sV0),self.global_sV0) + self.global_V_err = np.abs(self.global_V-self.global_V0)/self.global_V0 + self.global_sV_err = np.abs(self.global_sV-self.global_sV0)/self.global_sV0 # metrics about distance property self.global_D_err = globalSum(global_D_err) # compute global_R and global_sR @@ -992,13 +988,13 @@ def getMetricsAtEOS(self,u_exact): #EOS=End Of Simulation self.global_V0 = globalSum(global_V0) self.global_sV = globalSum(global_sV) self.global_sV0 = globalSum(global_sV0) - self.global_V_err = old_div(np.abs(self.global_V-self.global_V0),self.global_V0) - self.global_sV_err = old_div(np.abs(self.global_sV-self.global_sV0),self.global_sV0) + self.global_V_err = np.abs(self.global_V-self.global_V0)/self.global_V0 + self.global_sV_err = np.abs(self.global_sV-self.global_sV0)/self.global_sV0 # distance property metric self.global_D_err = globalSum(global_D_err) # L2 error on level set self.global_L2_err = globalSum(global_L2_err) - self.global_L2Banded_err = old_div(globalSum(global_L2Banded_err),globalSum(global_area_band)) + self.global_L2Banded_err = globalSum(global_L2Banded_err)/globalSum(global_area_band) self.global_sH_L2_err = globalSum(global_sH_L2_err) ############################################### @@ -1401,4 +1397,4 @@ def calculateSolutionAtQuadrature(self): def calculateAuxiliaryQuantitiesAfterStep(self): pass def updateAfterMeshMotion(self): - pass + pass \ No newline at end of file diff --git a/proteus/mprans/Dissipation.py b/proteus/mprans/Dissipation.py index e69cadc01a..f4e3e85df4 100644 --- a/proteus/mprans/Dissipation.py +++ b/proteus/mprans/Dissipation.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import range -from past.utils import old_div import proteus from proteus.mprans.cDissipation import * from proteus.mprans.cDissipation2D import * @@ -878,16 +875,14 @@ def __init__(self, if 'penalty' in self.ebq_global: for ebN in range(self.mesh.nElementBoundaries_global): for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebq_global['penalty'][ebN, k] = old_div(self.numericalFlux.penalty_constant, \ - (self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power)) + self.ebq_global['penalty'][ebN, k] = self.numericalFlux.penalty_constant/(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) # penalty term # cek move to Numerical flux initialization if 'penalty' in self.ebqe: for ebNE in range(self.mesh.nExteriorElementBoundaries_global): ebN = self.mesh.exteriorElementBoundariesArray[ebNE] for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebqe['penalty'][ebNE, k] = old_div(self.numericalFlux.penalty_constant, \ - self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) + self.ebqe['penalty'][ebNE, k] = self.numericalFlux.penalty_constant/self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power prof.logEvent(prof.memory("numericalFlux", "OneLevelTransport"), level=4) self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray # use post processing tools to get conservative fluxes, None by default diff --git a/proteus/mprans/GN_SW2DCV.py b/proteus/mprans/GN_SW2DCV.py index f613c79218..5361f84035 100644 --- a/proteus/mprans/GN_SW2DCV.py +++ b/proteus/mprans/GN_SW2DCV.py @@ -1,8 +1,3 @@ -from __future__ import print_function -from __future__ import division -from builtins import str -from builtins import range -from past.utils import old_div import proteus from proteus import FemTools from proteus import LinearAlgebraTools as LAT @@ -102,11 +97,11 @@ def choose_dt(self): maxCFL = max(maxCFL, max(adjusted_maxCFL, globalMax(self.edge_based_cfl.max()))) - self.dt = old_div(self.runCFL, maxCFL) + self.dt = self.runCFL/maxCFL if self.dtLast is None: self.dtLast = self.dt - if old_div(self.dt, self.dtLast) > self.dtRatioMax: + if self.dt/self.dtLast > self.dtRatioMax: self.dt = self.dtLast * self.dtRatioMax self.t = self.tLast + self.dt # Ignoring dif. time step levels @@ -153,7 +148,7 @@ def updateStage(self): elif self.lstage == 2: for ci in range(self.nc): self.u_dof_lstage[ci][:] = self.transport.u[ci].dof - self.u_dof_lstage[ci] *= old_div(1., 4.) + self.u_dof_lstage[ci] *= 1./4. self.u_dof_lstage[ci] += 3. / 4. * self.u_dof_last[ci] # update u_dof_old self.transport.h_dof_old[:] = self.u_dof_lstage[0] @@ -166,7 +161,7 @@ def updateStage(self): else: for ci in range(self.nc): self.u_dof_lstage[ci][:] = self.transport.u[ci].dof - self.u_dof_lstage[ci][:] *= old_div(2.0, 3.0) + self.u_dof_lstage[ci][:] *= 2.0/3.0 self.u_dof_lstage[ci][:] += 1.0 / 3.0 * self.u_dof_last[ci] # update solution to u[0].dof self.transport.u[ci].dof[:] = self.u_dof_lstage[ci] @@ -198,7 +193,7 @@ def updateStage(self): else: for ci in range(self.nc): self.u_dof_lstage[ci][:] = self.transport.u[ci].dof - self.u_dof_lstage[ci][:] *= old_div(1., 2.) + self.u_dof_lstage[ci][:] *= 1./2. self.u_dof_lstage[ci][:] += 1. / 2. * self.u_dof_last[ci] # update solution to u[0].dof self.transport.u[ci].dof[:] = self.u_dof_lstage[ci] @@ -680,13 +675,13 @@ def __init__(self, (self.mesh.nElementBoundaries_global, self.nElementBoundaryQuadraturePoints_elementBoundary), 'd') self.ebq_global[('velocityAverage', 0)] = np.zeros((self.mesh.nElementBoundaries_global, self.nElementBoundaryQuadraturePoints_elementBoundary, self.nSpace_global), 'd') - self.q[('dV_u', 0)] = (old_div(1.0, self.mesh.nElements_global)) * \ + self.q[('dV_u', 0)] = (1.0/self.mesh.nElements_global) * \ np.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') - self.q[('dV_u', 1)] = (old_div(1.0, self.mesh.nElements_global)) * \ + self.q[('dV_u', 1)] = (1.0/self.mesh.nElements_global) * \ np.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') - self.q[('dV_u', 2)] = (old_div(1.0, self.mesh.nElements_global)) * \ + self.q[('dV_u', 2)] = (1.0/self.mesh.nElements_global) * \ np.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') self.q['dV'] = self.q[('dV_u', 0)] @@ -961,16 +956,14 @@ def __init__(self, if 'penalty' in self.ebq_global: for ebN in range(self.mesh.nElementBoundaries_global): for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebq_global['penalty'][ebN, k] = old_div(self.numericalFlux.penalty_constant, - (self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power)) + self.ebq_global['penalty'][ebN, k] = self.numericalFlux.penalty_constant/(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) # penalty term # cek move to Numerical flux initialization if 'penalty' in self.ebqe: for ebNE in range(self.mesh.nExteriorElementBoundaries_global): ebN = self.mesh.exteriorElementBoundariesArray[ebNE] for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebqe['penalty'][ebNE, k] = old_div(self.numericalFlux.penalty_constant, - self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) + self.ebqe['penalty'][ebNE, k] = self.numericalFlux.penalty_constant/self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power logEvent(memory("numericalFlux", "OneLevelTransport"), level=4) self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray # use post processing tools to get conservative fluxes, None by default @@ -1338,7 +1331,7 @@ def getCMatrices(self): # fill vector rowptr_cMatrix for i in range(1, rowptr_cMatrix.size): rowptr_cMatrix[i] = rowptr_cMatrix[i - 1] + \ - old_div((rowptr[6 * (i - 1) + 1] - rowptr[6 * (i - 1)]), 6) + (rowptr[6 * (i - 1) + 1] - rowptr[6 * (i - 1)])//6 # fill vector colind_cMatrix i_cMatrix = 0 # ith row of cMatrix @@ -1349,8 +1342,7 @@ def getCMatrices(self): offset_cMatrix = list( range(rowptr_cMatrix[i_cMatrix], rowptr_cMatrix[i_cMatrix + 1])) if (j % 6 == 0): - colind_cMatrix[offset_cMatrix[old_div(j, 6)]] = old_div( - colind[offset], 6) + colind_cMatrix[offset_cMatrix[j//6]] = colind[offset]//6 i_cMatrix += 1 # END OF SPARSITY PATTERN FOR C MATRICES @@ -2355,4 +2347,4 @@ def calculateAuxiliaryQuantitiesAfterStep(self): OneLevelTransport.calculateAuxiliaryQuantitiesAfterStep(self) def getForce(self, cg, forceExtractionFaces, force, moment): - pass + pass \ No newline at end of file diff --git a/proteus/mprans/Kappa.py b/proteus/mprans/Kappa.py index c368e3972b..c54b26884e 100644 --- a/proteus/mprans/Kappa.py +++ b/proteus/mprans/Kappa.py @@ -1,7 +1,3 @@ -from __future__ import print_function -from __future__ import division -from builtins import range -from past.utils import old_div import proteus from proteus.mprans.cKappa import * from proteus.mprans.cKappa2D import * @@ -871,16 +867,14 @@ def __init__(self, if 'penalty' in self.ebq_global: for ebN in range(self.mesh.nElementBoundaries_global): for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebq_global['penalty'][ebN, k] = old_div(self.numericalFlux.penalty_constant, \ - (self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power)) + self.ebq_global['penalty'][ebN, k] = self.numericalFlux.penalty_constant/(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) # penalty term # cek move to Numerical flux initialization if 'penalty' in self.ebqe: for ebNE in range(self.mesh.nExteriorElementBoundaries_global): ebN = self.mesh.exteriorElementBoundariesArray[ebNE] for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebqe['penalty'][ebNE, k] = old_div(self.numericalFlux.penalty_constant, \ - self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) + self.ebqe['penalty'][ebNE, k] = self.numericalFlux.penalty_constant/self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power prof.logEvent(prof.memory("numericalFlux", "OneLevelTransport"), level=4) self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray # use post processing tools to get conservative fluxes, None by default diff --git a/proteus/mprans/MCorr.py b/proteus/mprans/MCorr.py index 7ad48daf0b..db3e5a246b 100644 --- a/proteus/mprans/MCorr.py +++ b/proteus/mprans/MCorr.py @@ -1,7 +1,3 @@ -from __future__ import division -from builtins import zip -from builtins import range -from past.utils import old_div import proteus from proteus import cfemIntegrals, Norms, Quadrature from proteus.Comm import globalSum @@ -569,16 +565,14 @@ def __init__(self, if 'penalty' in self.ebq_global: for ebN in range(self.mesh.nElementBoundaries_global): for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebq_global['penalty'][ebN, k] = old_div(self.numericalFlux.penalty_constant, \ - (self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power)) + self.ebq_global['penalty'][ebN, k] = self.numericalFlux.penalty_constant/(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) # penalty term # cek move to Numerical flux initialization if 'penalty' in self.ebqe: for ebNE in range(self.mesh.nExteriorElementBoundaries_global): ebN = self.mesh.exteriorElementBoundariesArray[ebNE] for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebqe['penalty'][ebNE, k] = old_div(self.numericalFlux.penalty_constant, \ - self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) + self.ebqe['penalty'][ebNE, k] = self.numericalFlux.penalty_constant/self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power logEvent(memory("numericalFlux", "OneLevelTransport"), level=4) self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray # use post processing tools to get conservative fluxes, None by default @@ -1045,12 +1039,12 @@ def globalConstantSolve(self, u, r): logEvent(" Mass Conservation Residual 0 ", level=3, data=R) RNORM_OLD = fabs(R) while ((fabs(R) > self.atol and its < self.maxIts) or its < 1): - U -= old_div(R, (J + 1.0e-8)) + U -= R/(J+1.0e-8) (R, J) = self.globalConstantRJ(u, r, U) lsits = 0 while(fabs(R) > 0.99 * RNORM_OLD and lsits < self.maxLSits): lsits += 1 - U += (0.5)**lsits * (old_div(R, (J + 1.0e-8))) + U += (0.5)**lsits * (R/(J+1.0e-8)) (R, J) = self.globalConstantRJ(u, r, U) its += 1 logEvent(" Mass Conservation Residual " + repr(its)+" ", level=3, data=R) diff --git a/proteus/mprans/MCorr3P.py b/proteus/mprans/MCorr3P.py index c7311d7f3c..5dfb67f9b4 100644 --- a/proteus/mprans/MCorr3P.py +++ b/proteus/mprans/MCorr3P.py @@ -1,8 +1,3 @@ -from __future__ import absolute_import -from __future__ import division -from builtins import zip -from builtins import range -from past.utils import old_div import proteus import numpy from proteus import * @@ -633,8 +628,7 @@ def __init__(self, for ebN in range(self.mesh.nElementBoundaries_global): for k in range( self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebq_global['penalty'][ebN, k] = old_div(self.numericalFlux.penalty_constant, ( - self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power)) + self.ebq_global['penalty'][ebN, k] = self.numericalFlux.penalty_constant/(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) # penalty term # cek move to Numerical flux initialization if 'penalty' in self.ebqe: @@ -642,8 +636,7 @@ def __init__(self, ebN = self.mesh.exteriorElementBoundariesArray[ebNE] for k in range( self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebqe['penalty'][ebNE, k] = old_div(self.numericalFlux.penalty_constant, \ - self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) + self.ebqe['penalty'][ebNE, k] = self.numericalFlux.penalty_constant/self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power log(memory("numericalFlux", "OneLevelTransport"), level=4) self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray # use post processing tools to get conservative fluxes, None by default @@ -1032,12 +1025,12 @@ def globalConstantSolve(self, u, r): log(" Mass Conservation Residual 0 ", level=3, data=R) RNORM_OLD = fabs(R) while ((fabs(R) > self.atol and its < self.maxIts) or its < 1): - U -= old_div(R, (J + 1.0e-8)) + U -= R/(J+1.0e-8) (R, J) = self.globalConstantRJ(u, r, U) lsits = 0 while(fabs(R) > 0.99 * RNORM_OLD and lsits < self.maxLSits): lsits += 1 - U += (0.5)**lsits * (old_div(R, (J + 1.0e-8))) + U += (0.5)**lsits * (R/(J+1.0e-8)) (R, J) = self.globalConstantRJ(u, r, U) its += 1 log(" Mass Conservation Residual " + repr(its)+" ", level=3, data=R) diff --git a/proteus/mprans/MoveMesh.py b/proteus/mprans/MoveMesh.py index 2dd5a25354..487d803a0b 100644 --- a/proteus/mprans/MoveMesh.py +++ b/proteus/mprans/MoveMesh.py @@ -1,7 +1,3 @@ -from __future__ import division -from builtins import str -from builtins import range -from past.utils import old_div import proteus from proteus.mprans.cMoveMesh2D import cMoveMesh2D_base from proteus.mprans.cMoveMesh import cMoveMesh_base @@ -495,16 +491,14 @@ def __init__(self, if 'penalty' in self.ebq_global: for ebN in range(self.mesh.nElementBoundaries_global): for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebq_global['penalty'][ebN, k] = old_div(self.numericalFlux.penalty_constant, \ - (self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power)) + self.ebq_global['penalty'][ebN, k] = self.numericalFlux.penalty_constant/(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) # penalty term # cek move to Numerical flux initialization if 'penalty' in self.ebqe: for ebNE in range(self.mesh.nExteriorElementBoundaries_global): ebN = self.mesh.exteriorElementBoundariesArray[ebNE] for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebqe['penalty'][ebNE, k] = old_div(self.numericalFlux.penalty_constant, \ - self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) + self.ebqe['penalty'][ebNE, k] = self.numericalFlux.penalty_constant/self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power logEvent(memory("numericalFlux", "OneLevelTransport"), level=4) self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray # use post processing tools to get conservative fluxes, None by default diff --git a/proteus/mprans/NCLS.py b/proteus/mprans/NCLS.py index 5584ef1c20..92a5d376da 100644 --- a/proteus/mprans/NCLS.py +++ b/proteus/mprans/NCLS.py @@ -1,7 +1,3 @@ -from __future__ import division -from builtins import str -from builtins import range -from past.utils import old_div import proteus from proteus.mprans.cNCLS import * import numpy as np @@ -102,7 +98,7 @@ def __init__(self, transport, timeOrder=1, runCFL=0.1, integrateInterpolationPoi def choose_dt(self): maxCFL = 1.0e-6 maxCFL = max(maxCFL, globalMax(self.cfl.max())) - self.dt = old_div(self.runCFL, maxCFL) + self.dt = self.runCFL/maxCFL if self.dtLast is None: self.dtLast = self.dt self.t = self.tLast + self.dt @@ -142,7 +138,7 @@ def updateStage(self): logEvent("Second stage of SSP33 method", level=4) for ci in range(self.nc): self.u_dof_stage[ci][self.lstage][:] = self.transport.u[ci].dof - self.u_dof_stage[ci][self.lstage] *= old_div(1., 4.) + self.u_dof_stage[ci][self.lstage] *= 1./4. self.u_dof_stage[ci][self.lstage] += 3. / 4. * self.u_dof_last[ci] # Update u_dof_old self.transport.u_dof_old[:] = self.u_dof_stage[ci][self.lstage] @@ -150,7 +146,7 @@ def updateStage(self): logEvent("Third stage of SSP33 method", level=4) for ci in range(self.nc): self.u_dof_stage[ci][self.lstage][:] = self.transport.u[ci].dof - self.u_dof_stage[ci][self.lstage] *= old_div(2.0, 3.0) + self.u_dof_stage[ci][self.lstage] *= 2.0/3.0 self.u_dof_stage[ci][self.lstage] += 1.0 / 3.0 * self.u_dof_last[ci] # update u_dof_old self.transport.u_dof_old[:] = self.u_dof_last[ci] @@ -167,7 +163,7 @@ def updateStage(self): logEvent("Second stage of SSP22 method", level=4) for ci in range(self.nc): self.u_dof_stage[ci][self.lstage][:] = self.transport.u[ci].dof - self.u_dof_stage[ci][self.lstage][:] *= old_div(1., 2.) + self.u_dof_stage[ci][self.lstage][:] *= 1./2. self.u_dof_stage[ci][self.lstage][:] += 1. / 2. * self.u_dof_last[ci] # update u_dof_old self.transport.u_dof_old[:] = self.u_dof_last[ci] @@ -667,7 +663,7 @@ def __init__(self, # mesh self.q['x'] = np.zeros((self.mesh.nElements_global, self.nQuadraturePoints_element, 3), 'd') self.ebqe['x'] = np.zeros((self.mesh.nExteriorElementBoundaries_global, self.nElementBoundaryQuadraturePoints_elementBoundary, 3), 'd') - self.q[('dV_u', 0)] = (old_div(1.0, self.mesh.nElements_global)) * np.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') + self.q[('dV_u', 0)] = (1.0/self.mesh.nElements_global) * np.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') self.q[('u', 0)] = np.zeros((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') self.q[('grad(u)', 0)] = np.zeros((self.mesh.nElements_global, self.nQuadraturePoints_element, self.nSpace_global), 'd') self.q[('m_last', 0)] = np.zeros((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') @@ -806,16 +802,14 @@ def __init__(self, if 'penalty' in self.ebq_global: for ebN in range(self.mesh.nElementBoundaries_global): for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebq_global['penalty'][ebN, k] = old_div(self.numericalFlux.penalty_constant, \ - (self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power)) + self.ebq_global['penalty'][ebN, k] = self.numericalFlux.penalty_constant/(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) # penalty term # cek move to Numerical flux initialization if 'penalty' in self.ebqe: for ebNE in range(self.mesh.nExteriorElementBoundaries_global): ebN = self.mesh.exteriorElementBoundariesArray[ebNE] for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebqe['penalty'][ebNE, k] = old_div(self.numericalFlux.penalty_constant, \ - self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) + self.ebqe['penalty'][ebNE, k] = self.numericalFlux.penalty_constant/self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power logEvent(memory("numericalFlux", "OneLevelTransport"), level=4) self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray # use post processing tools to get conservative fluxes, None by default diff --git a/proteus/mprans/NCLS3P.py b/proteus/mprans/NCLS3P.py index 0353d9f53c..91161ece9f 100644 --- a/proteus/mprans/NCLS3P.py +++ b/proteus/mprans/NCLS3P.py @@ -1,8 +1,3 @@ -from __future__ import absolute_import -from __future__ import division -from builtins import str -from builtins import range -from past.utils import old_div import proteus import numpy as np from math import fabs @@ -531,7 +526,7 @@ def __init__(self, self.nElementBoundaryQuadraturePoints_elementBoundary, 3), 'd') - self.q[('dV_u', 0)] = (old_div(1.0, self.mesh.nElements_global)) * \ + self.q[('dV_u', 0)] = (1.0/self.mesh.nElements_global) * \ np.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') self.q[('u', 0)] = np.zeros( (self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') @@ -683,8 +678,7 @@ def __init__(self, for ebN in range(self.mesh.nElementBoundaries_global): for k in range( self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebq_global['penalty'][ebN, k] = old_div(self.numericalFlux.penalty_constant, ( - self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power)) + self.ebq_global['penalty'][ebN, k] = self.numericalFlux.penalty_constant/(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) # penalty term # cek move to Numerical flux initialization if 'penalty' in self.ebqe: @@ -692,8 +686,7 @@ def __init__(self, ebN = self.mesh.exteriorElementBoundariesArray[ebNE] for k in range( self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebqe['penalty'][ebNE, k] = old_div(self.numericalFlux.penalty_constant, \ - self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) + self.ebqe['penalty'][ebNE, k] = self.numericalFlux.penalty_constant/self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power log(memory("numericalFlux", "OneLevelTransport"), level=4) self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray # use post processing tools to get conservative fluxes, None by default diff --git a/proteus/mprans/Pres.py b/proteus/mprans/Pres.py index dedcadfac0..48a411b78e 100644 --- a/proteus/mprans/Pres.py +++ b/proteus/mprans/Pres.py @@ -1,7 +1,3 @@ -from __future__ import absolute_import -from __future__ import division -from builtins import range -from past.utils import old_div import proteus import numpy as np from proteus.Transport import OneLevelTransport @@ -174,7 +170,7 @@ def postStep(self, t, firstStep=False): if (firstStep or self.fluidModel.timeIntegration.timeOrder == 1): r = 1 else: - r = old_div(self.fluidModel.timeIntegration.dt, self.fluidModel.timeIntegration.dt_history[0]) + r = self.fluidModel.timeIntegration.dt/self.fluidModel.timeIntegration.dt_history[0] self.model.p_sharp_dof[:] = self.model.u[0].dof + r * self.pressureIncrementModel.u[0].dof self.model.q_p_sharp[:] = self.model.q[('u', 0)] + r * self.pressureIncrementModel.q[('u', 0)] self.model.ebqe_p_sharp[:] = self.model.ebqe[('u', 0)] + r * self.pressureIncrementModel.ebqe[('u', 0)] @@ -575,8 +571,7 @@ def __init__(self, for ebN in range(self.mesh.nElementBoundaries_global): for k in range( self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebq_global['penalty'][ebN, k] = old_div(self.numericalFlux.penalty_constant, ( - self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power)) + self.ebq_global['penalty'][ebN, k] = self.numericalFlux.penalty_constant/(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) # penalty term # cek move to Numerical flux initialization if 'penalty' in self.ebqe: @@ -584,8 +579,7 @@ def __init__(self, ebN = self.mesh.exteriorElementBoundariesArray[ebNE] for k in range( self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebqe['penalty'][ebNE, k] = old_div(self.numericalFlux.penalty_constant, \ - self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) + self.ebqe['penalty'][ebNE, k] = self.numericalFlux.penalty_constant/self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power log(memory("numericalFlux", "OneLevelTransport"), level=4) self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray # strong Dirichlet diff --git a/proteus/mprans/PresInc.h b/proteus/mprans/PresInc.h index ce2c583d5d..904b9bfde6 100644 --- a/proteus/mprans/PresInc.h +++ b/proteus/mprans/PresInc.h @@ -253,7 +253,7 @@ namespace proteus }//i // //save momentum for time history and velocity for subgrid error - //save solution for other models + //save solution for other models // q_a[eN_k] = a; q_u[eN_k] = u; @@ -408,7 +408,7 @@ namespace proteus ebqe_grad_u.data(), offset_u, stride_u, - elementResidual_u, + elementResidual_u, nExteriorElementBoundaries_global, exteriorElementBoundariesArray.data(), elementBoundaryElementsArray.data(), @@ -423,7 +423,7 @@ namespace proteus // for(int i=0;i 0: self.particle_forceHistory.write("%21.16e %21.16e %21.16e\n" % tuple(self.particle_netForces[0, :])) @@ -1542,16 +1539,14 @@ def __init__(self, if 'penalty' in self.ebq_global: for ebN in range(self.mesh.nElementBoundaries_global): for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebq_global['penalty'][ebN, k] = old_div(self.numericalFlux.penalty_constant, \ - (self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power)) + self.ebq_global['penalty'][ebN, k] = self.numericalFlux.penalty_constant/(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) # penalty term # cek move to Numerical flux initialization if 'penalty' in self.ebqe: for ebNE in range(self.mesh.nExteriorElementBoundaries_global): ebN = self.mesh.exteriorElementBoundariesArray[ebNE] for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebqe['penalty'][ebNE, k] = old_div(self.numericalFlux.penalty_constant, \ - self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) + self.ebqe['penalty'][ebNE, k] = self.numericalFlux.penalty_constant/self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power logEvent(memory("numericalFlux", "OneLevelTransport"), level=4) self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray logEvent("setting up post-processing") @@ -1692,6 +1687,7 @@ def getResidual(self, u, r): r : :class:`numpy.ndarray` Stores the calculated residual vector. """ + memory() assert(np.all(np.isfinite(u))) assert(np.all(np.isfinite(r))) # Load the unknowns into the finite element dof @@ -1769,7 +1765,7 @@ def getResidual(self, u, r): self.timeIntegration.t) if self.MOVING_DOMAIN == 1.0: self.u[cj].dof[dofN] += self.mesh.nodeVelocityArray[dofN, cj - 1] - + logEvent(memory("residaul-pre-argdict","RANS"),level=4) argsDict = cArgumentsDict.ArgumentsDict() argsDict["NONCONSERVATIVE_FORM"] = float(self.coefficients.NONCONSERVATIVE_FORM) argsDict["MOMENTUM_SGE"] = float(self.coefficients.MOMENTUM_SGE) @@ -2012,7 +2008,9 @@ def getResidual(self, u, r): argsDict["ball_u"]= self.ball_u argsDict["ball_v"]= self.ball_v argsDict["ball_w"]= self.ball_w + logEvent(memory("ArgumentsDict-post","RANS"),level=4) self.rans2p.calculateResidual(argsDict) + logEvent(memory("calculateResidual","RANS"),level=4) if self.forceStrongConditions: try: for cj in range(len(self.dirichletConditionsForceDOF)): @@ -2110,8 +2108,10 @@ def getResidual(self, u, r): w_I.append({:21.16e}) velocity_I.append({:21.16e}) """.format(*self.errors.flatten().tolist())) + logEvent(memory("calculateResidual-end","RANS"),level=4) def getJacobian(self, jacobian): + memory() cfemIntegrals.zeroJacobian_CSR(self.nNonzerosInJacobian, jacobian) if self.nSpace_global == 2: @@ -2136,7 +2136,7 @@ def getJacobian(self, jacobian): self.csrColumnOffsets_eb[(3, 1)] = self.csrColumnOffsets[(0, 2)] self.csrColumnOffsets_eb[(3, 2)] = self.csrColumnOffsets[(0, 2)] self.csrColumnOffsets_eb[(3, 3)] = self.csrColumnOffsets[(0, 2)] - + logEvent(memory("ArgumentsDict-J","RANS-pre"),level=4) argsDict = cArgumentsDict.ArgumentsDict() argsDict["NONCONSERVATIVE_FORM"] = float(self.coefficients.NONCONSERVATIVE_FORM) argsDict["MOMENTUM_SGE"] = float(self.coefficients.MOMENTUM_SGE) @@ -2375,7 +2375,9 @@ def getJacobian(self, jacobian): argsDict["isActiveDOF_vel"] = self.isActiveDOF_vel argsDict["isActiveElement"] = self.isActiveElement argsDict["isActiveElement_last"] = self.isActiveElement_last + logEvent(memory("ArgumentsDict-J-post","RANS"),level=4) self.rans2p.calculateJacobian(argsDict) + logEvent(memory("calcualteJacobian","RANS"),level=4) assert(np.all(np.isfinite(jacobian.getCSRrepresentation()[2]))) if not self.forceStrongConditions and max(numpy.linalg.norm(self.u[1].dof, numpy.inf), numpy.linalg.norm(self.u[2].dof, numpy.inf), numpy.linalg.norm(self.u[3].dof, numpy.inf)) < 1.0e-8: self.pp_hasConstantNullSpace = True @@ -2425,6 +2427,7 @@ def getJacobian(self, jacobian): logEvent("Jacobian ", level=10, data=jacobian) self.nonlinear_function_jacobian_evaluations += 1 + logEvent(memory("calcualteJacobian-rest","RANS"),level=4) return jacobian def calculateElementQuadrature(self, domainMoved=False): diff --git a/proteus/mprans/RANS2P_IB.py b/proteus/mprans/RANS2P_IB.py index 7f16bf7f71..b34bfeaabf 100644 --- a/proteus/mprans/RANS2P_IB.py +++ b/proteus/mprans/RANS2P_IB.py @@ -1,9 +1,3 @@ -from __future__ import print_function -from __future__ import absolute_import -from __future__ import division -from builtins import str -from builtins import range -from past.utils import old_div import proteus import proteus.mprans.RANS2P as RANS2P from proteus.mprans.cRANS2P_IB import * @@ -230,7 +224,7 @@ def updateBeams(self, t): self.Beam_Solver[I].updateLoads(self.q3[I, :], self.q2[I, :], self.q1[I, :]) for j in range(loadSteps): self.Beam_Solver[I].Phi.flat[:] = 0.0 - self.Beam_Solver[I].updateQs(endLoad=[0.0, 0.0, 0.0], scale=old_div(float(j), float(loadSteps))) + self.Beam_Solver[I].updateQs(endLoad=[0.0, 0.0, 0.0], scale=float(j)/float(loadSteps)) counter = 0 go = True Phi = np.copy(self.Beam_Solver[I].Phi) @@ -302,9 +296,9 @@ def updateBeams(self, t): # self.avgHeight+=self.zv[I,-1] # self.avgDeflection += abs(self.xv[I,-1]-self.xv[I,0]) # self.avgAngle+= math.degrees(math.atan((self.zv[I,-1]-self.zv[I,-2])/(self.xv[I,-1]-self.xv[I,-2])))#self.Beam_Solver[I].Phi[-3] - self.avgHeight = old_div(np.sum(self.zv[:, -1]), float(self.nBeams)) - self.avgDeflection = old_div(np.sum(np.abs(self.xv[:, -1] - self.xv[:, 0])), float(self.nBeams)) - self.avgAngle = old_div(np.sum(np.rad2deg(np.arctan(old_div((self.zv[:, -1] - self.zv[:, -2]), (self.xv[:, -1] - self.xv[:, -2]))))), float(self.nBeams)) + self.avgHeight = np.sum(self.zv[:,-1])/float(self.nBeams) + self.avgDeflection = np.sum(np.abs(self.xv[:,-1]-self.xv[:,0]))/float(self.nBeams) + self.avgAngle = np.sum(np.rad2deg(np.arctan((self.zv[:, -1] - self.zv[:, -2])/(self.xv[:, -1] - self.xv[:, -2]))))/float(self.nBeams) def initializeBeams(self): comm = Comm.get() @@ -676,9 +670,9 @@ def __init__(self, self.q[('mt', 1)] = numpy.zeros((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') self.q[('mt', 2)] = numpy.zeros((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') self.q[('mt', 3)] = numpy.zeros((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') - self.q[('dV_u', 1)] = (old_div(1.0, self.mesh.nElements_global)) * numpy.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') - self.q[('dV_u', 2)] = (old_div(1.0, self.mesh.nElements_global)) * numpy.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') - self.q[('dV_u', 3)] = (old_div(1.0, self.mesh.nElements_global)) * numpy.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') + self.q[('dV_u', 1)] = (1.0/self.mesh.nElements_global) * numpy.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') + self.q[('dV_u', 2)] = (1.0/self.mesh.nElements_global) * numpy.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') + self.q[('dV_u', 3)] = (1.0/self.mesh.nElements_global) * numpy.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') self.q['dV'] = self.q[('dV_u', 1)] self.q[('f', 0)] = numpy.zeros((self.mesh.nElements_global, self.nQuadraturePoints_element, self.nSpace_global), 'd') self.q[('velocity', 0)] = numpy.zeros((self.mesh.nElements_global, self.nQuadraturePoints_element, self.nSpace_global), 'd') @@ -959,16 +953,14 @@ def __init__(self, if 'penalty' in self.ebq_global: for ebN in range(self.mesh.nElementBoundaries_global): for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebq_global['penalty'][ebN, k] = old_div(self.numericalFlux.penalty_constant, \ - (self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power)) + self.ebq_global['penalty'][ebN, k] = self.numericalFlux.penalty_constant/(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) # penalty term # cek move to Numerical flux initialization if 'penalty' in self.ebqe: for ebNE in range(self.mesh.nExteriorElementBoundaries_global): ebN = self.mesh.exteriorElementBoundariesArray[ebNE] for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebqe['penalty'][ebNE, k] = old_div(self.numericalFlux.penalty_constant, \ - self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) + self.ebqe['penalty'][ebNE, k] = self.numericalFlux.penalty_constant/self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power logEvent(memory("numericalFlux", "OneLevelTransport"), level=4) self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray logEvent("setting up post-processing") @@ -1745,5 +1737,5 @@ def beamStep(self): for i in range(3): self.coefficients.vel_avg[i] = globalSum(self.coefficients.vel_avg[i]) - self.coefficients.vel_avg = old_div(self.coefficients.vel_avg, 0.1472) + self.coefficients.vel_avg = self.coefficients.vel_avg/0.1472 self.coefficients.netBeamDrag[0] = globalSum(self.coefficients.netBeamDrag[0]) diff --git a/proteus/mprans/RANS3PF.py b/proteus/mprans/RANS3PF.py index 54fef025e4..d66ae3f8f4 100644 --- a/proteus/mprans/RANS3PF.py +++ b/proteus/mprans/RANS3PF.py @@ -1,9 +1,3 @@ -from __future__ import absolute_import -from __future__ import division -from builtins import zip -from builtins import str -from builtins import range -from past.utils import old_div import proteus from proteus import Profiling import numpy as np @@ -207,7 +201,7 @@ def __init__(self, fContact=0.02, mContact=2.0, nContact=5.0, - angFriction=old_div(pi, 6.0), + angFriction=pi/6.0, nParticles=0, particle_epsFact=3.0, particle_alpha=1000.0, @@ -957,7 +951,7 @@ def preStep(self, t, firstStep=False): if self.model.timeIntegration.timeOrder == 1: r = 1. else: - r = old_div(self.model.timeIntegration.dt, self.model.timeIntegration.dt_history[0]) + r = self.model.timeIntegration.dt/self.model.timeIntegration.dt_history[0] # self.model.uStar_dof[:] = (1+r)*self.model.u[0].dof[:] - r*self.model.u_dof_old[:] self.model.vStar_dof[:] = (1+r)*self.model.u[1].dof[:] - r*self.model.v_dof_old[:] @@ -1954,8 +1948,7 @@ def __init__(self, for ebN in range(self.mesh.nElementBoundaries_global): for k in range( self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebq_global['penalty'][ebN, k] = old_div(self.numericalFlux.penalty_constant, ( - self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power)) + self.ebq_global['penalty'][ebN, k] = self.numericalFlux.penalty_constant/(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) # penalty term # cek move to Numerical flux initialization if 'penalty' in self.ebqe: @@ -1963,8 +1956,7 @@ def __init__(self, ebN = self.mesh.exteriorElementBoundariesArray[ebNE] for k in range( self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebqe['penalty'][ebNE, k] = old_div(self.numericalFlux.penalty_constant, \ - self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) + self.ebqe['penalty'][ebNE, k] = self.numericalFlux.penalty_constant/self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power log(memory("numericalFlux", "OneLevelTransport"), level=4) self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray log("setting up post-processing") diff --git a/proteus/mprans/RANS3PSed.py b/proteus/mprans/RANS3PSed.py index ca6b8b44ec..ed69adacb3 100644 --- a/proteus/mprans/RANS3PSed.py +++ b/proteus/mprans/RANS3PSed.py @@ -1,9 +1,3 @@ -from __future__ import absolute_import -from __future__ import division -import math -from builtins import str -from builtins import range -from past.utils import old_div import proteus from proteus import Profiling import numpy as np @@ -202,7 +196,7 @@ def __init__(self, fContact=0.02, mContact=2.0, nContact=5.0, - angFriction=old_div(math.pi,6.0), + angFriction=math.pi/6.0, vos_function=None, staticSediment=False, vos_limiter = 0.05, @@ -706,7 +700,7 @@ def preStep(self, t, firstStep=False): if self.model.timeIntegration.timeOrder == 1: r = 1. else: - r = old_div(self.model.timeIntegration.dt,self.model.timeIntegration.dt_history[0]) + r = self.model.timeIntegration.dt/self.model.timeIntegration.dt_history[0] self.model.q[('velocityStar',0)][:] = (1+r)*self.model.q[('velocity',0)] - r*self.model.q[('velocityOld',0)] self.model.q[('velocityOld',0)][:] = self.model.q[('velocity',0)] self.model.dt_last = self.model.timeIntegration.dt @@ -1460,8 +1454,7 @@ def __init__(self, for ebN in range(self.mesh.nElementBoundaries_global): for k in range( self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebq_global['penalty'][ebN, k] = old_div(self.numericalFlux.penalty_constant, ( - self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power)) + self.ebq_global['penalty'][ebN, k] = self.numericalFlux.penalty_constant/(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) # penalty term # cek move to Numerical flux initialization if 'penalty' in self.ebqe: @@ -1469,8 +1462,7 @@ def __init__(self, ebN = self.mesh.exteriorElementBoundariesArray[ebNE] for k in range( self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebqe['penalty'][ebNE, k] = old_div(self.numericalFlux.penalty_constant, \ - self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) + self.ebqe['penalty'][ebNE, k] = self.numericalFlux.penalty_constant/\self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power log(memory("numericalFlux", "OneLevelTransport"), level=4) self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray log("setting up post-processing") @@ -2321,4 +2313,4 @@ def calculateAuxiliaryQuantitiesAfterStep(self): OneLevelTransport.calculateAuxiliaryQuantitiesAfterStep(self) def updateAfterMeshMotion(self): - pass + pass \ No newline at end of file diff --git a/proteus/mprans/RDLS.py b/proteus/mprans/RDLS.py index ad8e126326..851f8f85d9 100644 --- a/proteus/mprans/RDLS.py +++ b/proteus/mprans/RDLS.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import range -from past.utils import old_div import proteus from proteus import TimeIntegration from proteus.mprans.cRDLS import * @@ -109,7 +106,7 @@ def updateSubstep(self): m.timeIntegration.choose_dt() self.dt_model = self.start_ratio * self.model.levelModelList[0].timeIntegration.dt res = self.model.solver.solverList[-1].norm_r0 - ssError = old_div(res, (self.res0 * self.rtol + self.atol)) + ssError = res/(self.res0*self.rtol+self.atol) for m in self.model.levelModelList: m.updateTimeHistory(self.t_model) m.timeIntegration.updateTimeHistory() @@ -125,7 +122,7 @@ def updateSubstep(self): # physical time step self.t_model = self.substeps[0] self.substeps.append(self.substeps[0]) - logEvent("Osher-PsiTC iteration %d dt = %12.5e |res| = %12.5e %g " % (self.nSteps, self.dt_model, res, (old_div(res, self.res0)) * 100.0), level=1) + logEvent("Osher-PsiTC iteration %d dt = %12.5e |res| = %12.5e %g " % (self.nSteps, self.dt_model, res, (res/self.res0) * 100.0), level=1) elif self.nSteps >= self.nStepsMax: logEvent("Osher-PsiTC DID NOT Converge |res| = %12.5e but quitting anyway" % (res,)) logEvent("Osher-PsiTC tolerance %12.5e " % (self.res0 * self.rtol + self.atol,)) @@ -814,16 +811,14 @@ def __init__(self, if 'penalty' in self.ebq_global: for ebN in range(self.mesh.nElementBoundaries_global): for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebq_global['penalty'][ebN, k] = old_div(self.numericalFlux.penalty_constant, \ - (self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power)) + self.ebq_global['penalty'][ebN, k] = self.numericalFlux.penalty_constant/(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) # penalty term # cek move to Numerical flux initialization if 'penalty' in self.ebqe: for ebNE in range(self.mesh.nExteriorElementBoundaries_global): ebN = self.mesh.exteriorElementBoundariesArray[ebNE] for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebqe['penalty'][ebNE, k] = old_div(self.numericalFlux.penalty_constant, \ - self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) + self.ebqe['penalty'][ebNE, k] = self.numericalFlux.penalty_constant/self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power logEvent(memory("numericalFlux", "OneLevelTransport"), level=4) self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray # use post processing tools to get conservative fluxes, None by default diff --git a/proteus/mprans/SW2D.py b/proteus/mprans/SW2D.py index 3689622dce..fda0004986 100644 --- a/proteus/mprans/SW2D.py +++ b/proteus/mprans/SW2D.py @@ -1,8 +1,3 @@ -from __future__ import print_function -from __future__ import division -from builtins import str -from builtins import range -from past.utils import old_div import proteus from proteus.mprans.cSW2D import * from proteus.Comm import globalMax @@ -562,16 +557,14 @@ def __init__(self, if 'penalty' in self.ebq_global: for ebN in range(self.mesh.nElementBoundaries_global): for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebq_global['penalty'][ebN, k] = old_div(self.numericalFlux.penalty_constant, \ - (self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power)) + self.ebq_global['penalty'][ebN, k] = self.numericalFlux.penalty_constant/(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) # penalty term # cek move to Numerical flux initialization if 'penalty' in self.ebqe: for ebNE in range(self.mesh.nExteriorElementBoundaries_global): ebN = self.mesh.exteriorElementBoundariesArray[ebNE] for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebqe['penalty'][ebNE, k] = old_div(self.numericalFlux.penalty_constant, \ - self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) + self.ebqe['penalty'][ebNE, k] = self.numericalFlux.penalty_constant/self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power logEvent(memory("numericalFlux", "OneLevelTransport"), level=4) self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray # use post processing tools to get conservative fluxes, None by default diff --git a/proteus/mprans/SW2DCV.py b/proteus/mprans/SW2DCV.py index be3aea28a6..5f30ab9d14 100644 --- a/proteus/mprans/SW2DCV.py +++ b/proteus/mprans/SW2DCV.py @@ -1,8 +1,3 @@ -from __future__ import print_function -from __future__ import division -from builtins import str -from builtins import range -from past.utils import old_div import proteus from proteus import FemTools from proteus import LinearAlgebraTools as LAT @@ -99,11 +94,11 @@ def choose_dt(self): maxCFL = max(maxCFL, max(adjusted_maxCFL, globalMax(self.edge_based_cfl.max()))) - self.dt = old_div(self.runCFL, maxCFL) + self.dt = self.runCFL/maxCFL if self.dtLast is None: self.dtLast = self.dt - if old_div(self.dt, self.dtLast) > self.dtRatioMax: + if self.dt/self.dtLast > self.dtRatioMax: self.dt = self.dtLast * self.dtRatioMax self.t = self.tLast + self.dt # Ignoring dif. time step levels @@ -146,7 +141,7 @@ def updateStage(self): elif self.lstage == 2: for ci in range(self.nc): self.u_dof_lstage[ci][:] = self.transport.u[ci].dof - self.u_dof_lstage[ci] *= old_div(1., 4.) + self.u_dof_lstage[ci] *= 1./4. self.u_dof_lstage[ci] += 3. / 4. * self.u_dof_last[ci] # update u_dof_old self.transport.h_dof_old[:] = self.u_dof_lstage[0] @@ -156,7 +151,7 @@ def updateStage(self): else: for ci in range(self.nc): self.u_dof_lstage[ci][:] = self.transport.u[ci].dof - self.u_dof_lstage[ci][:] *= old_div(2.0, 3.0) + self.u_dof_lstage[ci][:] *= 2.0/3.0 self.u_dof_lstage[ci][:] += 1.0 / 3.0 * self.u_dof_last[ci] # update solution to u[0].dof self.transport.u[ci].dof[:] = self.u_dof_lstage[ci] @@ -177,7 +172,7 @@ def updateStage(self): else: for ci in range(self.nc): self.u_dof_lstage[ci][:] = self.transport.u[ci].dof - self.u_dof_lstage[ci][:] *= old_div(1., 2.) + self.u_dof_lstage[ci][:] *= 1./2. self.u_dof_lstage[ci][:] += 1. / 2. * self.u_dof_last[ci] # update solution to u[0].dof self.transport.u[ci].dof[:] = self.u_dof_lstage[ci] @@ -582,9 +577,9 @@ def __init__(self, self.ebq_global[('totalFlux', 0)] = np.zeros((self.mesh.nElementBoundaries_global, self.nElementBoundaryQuadraturePoints_elementBoundary), 'd') self.ebq_global[('velocityAverage', 0)] = np.zeros((self.mesh.nElementBoundaries_global, self.nElementBoundaryQuadraturePoints_elementBoundary, self.nSpace_global), 'd') - self.q[('dV_u', 0)] = (old_div(1.0, self.mesh.nElements_global)) * np.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') - self.q[('dV_u', 1)] = (old_div(1.0, self.mesh.nElements_global)) * np.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') - self.q[('dV_u', 2)] = (old_div(1.0, self.mesh.nElements_global)) * np.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') + self.q[('dV_u', 0)] = (1.0/self.mesh.nElements_global) * np.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') + self.q[('dV_u', 1)] = (1.0/self.mesh.nElements_global) * np.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') + self.q[('dV_u', 2)] = (1.0/self.mesh.nElements_global) * np.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') self.q['dV'] = self.q[('dV_u',0)] self.q[('u', 0)] = np.zeros((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') self.q[('u', 1)] = np.zeros((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') @@ -770,16 +765,14 @@ def __init__(self, if 'penalty' in self.ebq_global: for ebN in range(self.mesh.nElementBoundaries_global): for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebq_global['penalty'][ebN, k] = old_div(self.numericalFlux.penalty_constant, - (self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power)) + self.ebq_global['penalty'][ebN, k] = self.numericalFlux.penalty_constant/(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) # penalty term # cek move to Numerical flux initialization if 'penalty' in self.ebqe: for ebNE in range(self.mesh.nExteriorElementBoundaries_global): ebN = self.mesh.exteriorElementBoundariesArray[ebNE] for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebqe['penalty'][ebNE, k] = old_div(self.numericalFlux.penalty_constant, - self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) + self.ebqe['penalty'][ebNE, k] = self.numericalFlux.penalty_constant/self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power logEvent(memory("numericalFlux", "OneLevelTransport"), level=4) self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray # use post processing tools to get conservative fluxes, None by default @@ -986,7 +979,7 @@ def getCMatrices(self): colind_cMatrix = np.zeros(nnz_cMatrix, 'i') # fill vector rowptr_cMatrix for i in range(1, rowptr_cMatrix.size): - rowptr_cMatrix[i] = rowptr_cMatrix[i - 1] + old_div((rowptr[3 * (i - 1) + 1] - rowptr[3 * (i - 1)]), 3) + rowptr_cMatrix[i] = rowptr_cMatrix[i - 1] + (rowptr[3 * (i - 1) + 1] - rowptr[3 * (i - 1)])//3 # = rowptr_cMatrix[i-1] + 1/3*(Number of columns of Jacobian's row 3*(i-1)=0, 3, 6, 9, 12, ... 3*(i-1), ..., 3*n-3) # fill vector colind_cMatrix @@ -997,7 +990,7 @@ def getCMatrices(self): for j, offset in enumerate(range(rowptr[i], rowptr[i + 1])): offset_cMatrix = list(range(rowptr_cMatrix[i_cMatrix], rowptr_cMatrix[i_cMatrix + 1])) if (j % 3 == 0): - colind_cMatrix[offset_cMatrix[old_div(j, 3)]] = old_div(colind[offset], 3) + colind_cMatrix[offset_cMatrix[j//3]] = colind[offset]//3 i_cMatrix += 1 # END OF SPARSITY PATTERN FOR C MATRICES @@ -1798,4 +1791,4 @@ def calculateAuxiliaryQuantitiesAfterStep(self): OneLevelTransport.calculateAuxiliaryQuantitiesAfterStep(self) def getForce(self, cg, forceExtractionFaces, force, moment): - pass + pass \ No newline at end of file diff --git a/proteus/mprans/SpatialTools.py b/proteus/mprans/SpatialTools.py index 0f675166ec..e3aa65c9c6 100644 --- a/proteus/mprans/SpatialTools.py +++ b/proteus/mprans/SpatialTools.py @@ -21,12 +21,6 @@ st.assembleDomain(domain) """ -from __future__ import division - -#from builtins import str -from builtins import str -from builtins import range -from past.utils import old_div from math import cos, sin, sqrt, atan2, acos, asin from itertools import compress import csv @@ -374,9 +368,9 @@ def _CuboidsetInertiaTensor(self): (!) should not be used manually """ L, W, H = self.dim - self.It = [[old_div((W**2. + H**2.), 12.), 0, 0], - [0, old_div((L**2. + H**2.), 12.), 0], - [0, 0, old_div((W**2. + L**2.), 12.)]] + self.It = [[(W**2.+H**2.)/12., 0, 0], + [0, (L**2.+H**2.)/12., 0], + [0, 0, (W**2.+L**2.)/12.]] Cuboid._setInertiaTensor = _CuboidsetInertiaTensor @@ -388,7 +382,7 @@ def _RectanglesetInertiaTensor(self): (!) should not be used manually """ L, H = self.dim - self.It = old_div((L**2 + H**2), 12) + self.It = (L**2+H**2)/12 Rectangle._setInertiaTensor = _RectanglesetInertiaTensor @@ -419,7 +413,7 @@ def __init__(self, domain, dim=(0., 0., 0.), coords=None): self.__class__.count += 1 self.name = "tank3d" + repr(self.__class__.count) if coords is None: - self.coords = old_div(np.array(dim), 2.) + self.coords = np.array(dim)/2. self.from_0 = True else: self.coords = coords @@ -502,7 +496,7 @@ def setDimensions(self, dim): L, W, H = dim self.dim = dim if self.from_0 is True: - x, y, z = old_div(L, 2.), old_div(W, 2.), old_div(H, 2.) + x, y, z = L/2., W/2., H/2. else: x, y, z = self.coords self.coords = [x, y, z] @@ -526,7 +520,7 @@ def setDimensions(self, dim): segmentFlags = [] volumes = [[[0, 1]]] facetFlags = [bt['z-'], bt['z+']] - regions = [[old_div((x0 + x1), 2.), old_div((y0 + y1), 2.), old_div((z0 + z1), 2.)]] + regions = [[(x0+x1)/2., (y0+y1)/2., (z0+z1)/2.]] regionFlags = [1] self.regionIndice = {'tank': 0} v_i = 8 # index of next vector to add @@ -556,7 +550,7 @@ def setDimensions(self, dim): facets += [[[v0, v1, v3, v2]]] facetFlags += [bt['y-']] volumes[0][0] += [f_i] - regions += [[old_div((x0 + x1), 2.), old_div((y0 + (ymin)), 2.), old_div((z0 + z1), 2.)]] + regions += [[(x0+x1)/2., (y0+(ymin))/2., (z0+z1)/2.]] self.regionIndice['y-'] = r_i regionFlags += [r_i + 1] facets += [[[0, 1, v1, v0]], @@ -614,7 +608,7 @@ def setDimensions(self, dim): facets += [[[v0, v1, v3, v2]]] facetFlags += [bt['x+']] volumes[0][0] += [f_i] - regions += [[old_div((x1 + (xmax)), 2.), old_div((y0 + y1), 2.), old_div((z0 + z1), 2.)]] + regions += [[(x1+(xmax))/2., (y0+y1)/2., (z0+z1)/2.]] self.regionIndice['x+'] = r_i regionFlags += [r_i + 1] facets += [[[1, 2, v1, v0]], @@ -672,7 +666,7 @@ def setDimensions(self, dim): facets += [[[v0, v1, v3, v2]]] volumes[0][0] += [f_i] facetFlags += [bt['y+']] - regions += [[old_div((x0 + x1), 2.), old_div((y1 + (ymax)), 2.), old_div((z0 + z1), 2.)]] + regions += [[(x0+x1)/2., (y1+(ymax))/2., (z0+z1)/2.]] self.regionIndice['y+'] = r_i regionFlags += [r_i + 1] facets += [[[2, 3, v1, v0]], @@ -745,7 +739,7 @@ def setDimensions(self, dim): v3 = v_i + 1 facets += [[[v0, v1, v3, v2]]] facetFlags += [bt['x-']] - regions += [[old_div((x0 + (xmin)), 2.), old_div((y0 + y1), 2.), old_div((z0 + z1), 2.)]] + regions += [[(x0+(xmin))/2., (y0+y1)/2., (z0+z1)/2.]] self.regionIndice['x-'] = r_i regionFlags += [r_i + 1] facets += [[[0, 3, v1, v0]], @@ -829,7 +823,7 @@ def setAbsorptionZones(self, dragAlpha, allSponge=False, self._attachAuxiliaryVariable('RelaxZones') ind = self.regionIndice[key] flag = self.regionFlags[ind] - epsFact_porous = old_div(self.spongeLayers[key], 2.) + epsFact_porous = self.spongeLayers[key]/2. center = np.array(self.coords) zeros_to_append = 3 - len(center) if zeros_to_append: @@ -902,32 +896,32 @@ def setGenerationZones(self, dragAlpha, smoothing, waves=None, self._attachAuxiliaryVariable('RelaxZones') ind = self.regionIndice[key] flag = self.regionFlags[ind] - epsFact_porous = old_div(self.spongeLayers[key], 2.) + epsFact_porous = self.spongeLayers[key]/2. center = np.array(self.coords) zeros_to_append = 3 - len(center) if zeros_to_append: for i in range(zeros_to_append): center = np.append(center, [0]) if key == 'x-': - center[0] += -0.5 * self.dim[0] - old_div(sl['x-'], 2.) + center[0] += -0.5 * self.dim[0] - sl['x-']/2. orientation = np.array([1., 0., 0.]) self.BC['x-'].setUnsteadyTwoPhaseVelocityInlet(wave=waves, wind_speed=wind_speed, smoothing=smoothing) elif key == 'x+': - center[0] += +0.5 * self.dim[0] + old_div(sl['x+'], 2.) + center[0] += +0.5 * self.dim[0] + sl['x+']/2. orientation = np.array([-1., 0., 0.]) self.BC['x+'].setUnsteadyTwoPhaseVelocityInlet(wave=waves, wind_speed=wind_speed, smoothing=smoothing) elif key == 'y-': - center[1] += -0.5 * self.dim[1] - old_div(sl['y-'], 2.) + center[1] += -0.5 * self.dim[1] - sl['y-']/2. orientation = np.array([0., 1., 0.]) self.BC['y-'].setUnsteadyTwoPhaseVelocityInlet(wave=waves, wind_speed=wind_speed, smoothing=smoothing) elif key == 'y+': - center[1] += +0.5 * self.dim[1] + old_div(sl['y+'], 2.) + center[1] += +0.5 * self.dim[1] + sl['y+']/2. orientation = np.array([0., -1., 0.]) self.BC['y+'].setUnsteadyTwoPhaseVelocityInlet(wave=waves, wind_speed=wind_speed, @@ -964,7 +958,7 @@ class Tank2D(ShapeRANS): def __init__(self, domain, dim, coords=None): super(Tank2D, self).__init__(domain, nd=2) if coords is None: - self.coords = old_div(np.array(dim), 2.) + self.coords = np.array(dim)/2. self.from_0 = True else: self.coords = coords @@ -1181,7 +1175,7 @@ def setAbsorptionZones(self, dragAlpha, x_n=False, x_p=False, 0.]) ind = self.regionIndice['x-'] flag = self.regionFlags[ind] - epsFact_porous = old_div(self.spongeLayers['x-'], 2.) + epsFact_porous = self.spongeLayers['x-']/2. orientation = np.array([1., 0.]) self.zones[flag] = bc.RelaxationZone(shape=self, zone_type='absorption', @@ -1199,7 +1193,7 @@ def setAbsorptionZones(self, dragAlpha, x_n=False, x_p=False, 0.]) ind = self.regionIndice['x+'] flag = self.regionFlags[ind] - epsFact_porous = old_div(self.spongeLayers['x+'], 2.) + epsFact_porous = self.spongeLayers['x+']/2. orientation = np.array([-1., 0.]) self.zones[flag] = bc.RelaxationZone(shape=self, zone_type='absorption', @@ -1250,7 +1244,7 @@ def setGenerationZones(self, dragAlpha, smoothing, 0.]) ind = self.regionIndice['x-'] flag = self.regionFlags[ind] - epsFact_porous = old_div(self.spongeLayers['x-'], 2.) + epsFact_porous = self.spongeLayers['x-']/2. orientation = np.array([1., 0.]) self.zones[flag] = bc.RelaxationZone(shape=self, zone_type='generation', @@ -1272,7 +1266,7 @@ def setGenerationZones(self, dragAlpha, smoothing, 0.]) ind = self.regionIndice['x+'] flag = self.regionFlags[ind] - epsFact_porous = old_div(self.spongeLayers['x+'], 2.) + epsFact_porous = self.spongeLayers['x+']/2. orientation = np.array([-1., 0.]) self.zones[flag] = bc.RelaxationZone(shape=self, zone_type='generation', @@ -1923,7 +1917,7 @@ def setAbsorptionZones(self, dragAlpha, x_n=False, x_p=False, sponge_half_height_x0, 0.]) ind = self.regionIndice['x-'] flag = self.regionFlags[ind] - epsFact_porous = old_div(self.spongeLayers['x-'], 2.) + epsFact_porous = self.spongeLayers['x-']/2. orientation = np.array([1., 0.]) self.zones[flag] = bc.RelaxationZone(shape=self, zone_type='absorption', @@ -1940,7 +1934,7 @@ def setAbsorptionZones(self, dragAlpha, x_n=False, x_p=False, sponge_half_height_x1, 0.]) ind = self.regionIndice['x+'] flag = self.regionFlags[ind] - epsFact_porous = old_div(self.spongeLayers['x+'], 2.) + epsFact_porous = self.spongeLayers['x+']/2. orientation = np.array([-1., 0.]) self.zones[flag] = bc.RelaxationZone(shape=self, zone_type='absorption', @@ -1995,7 +1989,7 @@ def setGenerationZones(self, dragAlpha, smoothing, waves=None, sponge_half_height_x0, 0.]) ind = self.regionIndice['x-'] flag = self.regionFlags[ind] - epsFact_porous = old_div(self.spongeLayers['x-'], 2.) + epsFact_porous = self.spongeLayers['x-']/2. orientation = np.array([1., 0.]) self.zones[flag] = bc.RelaxationZone(shape=self, zone_type='generation', @@ -2017,7 +2011,7 @@ def setGenerationZones(self, dragAlpha, smoothing, waves=None, sponge_half_height_x1, 0.]) ind = self.regionIndice['x+'] flag = self.regionFlags[ind] - epsFact_porous = old_div(self.spongeLayers['x+'], 2.) + epsFact_porous = self.spongeLayers['x+']/2. orientation = np.array([-1., 0.]) self.zones[flag] = bc.RelaxationZone(shape=self, zone_type='generation', @@ -2172,4 +2166,4 @@ def assembleAuxiliaryVariables(domain): def get_unit_vector(vector): - return old_div(np.array(vector), np.linalg.norm(vector)) + return np.array(vector)/np.linalg.norm(vector) \ No newline at end of file diff --git a/proteus/mprans/TADR.py b/proteus/mprans/TADR.py index a3f958047e..8289c95ff1 100644 --- a/proteus/mprans/TADR.py +++ b/proteus/mprans/TADR.py @@ -2,10 +2,6 @@ """ An optimized volume-of-fluid transport module """ -from __future__ import absolute_import -from __future__ import division -from builtins import range -from past.utils import old_div import numpy as np from math import fabs import proteus @@ -133,7 +129,7 @@ def __init__(self, transport, timeOrder=1, runCFL=0.1, integrateInterpolationPoi def choose_dt(self): maxCFL = 1.0e-6 maxCFL = max(maxCFL, globalMax(self.cfl.max())) - self.dt = old_div(self.runCFL, maxCFL) + self.dt = self.runCFL/maxCFL if self.dtLast is None: self.dtLast = self.dt self.t = self.tLast + self.dt @@ -762,7 +758,7 @@ def __init__(self, self.q['x'] = np.zeros((self.mesh.nElements_global, self.nQuadraturePoints_element, 3), 'd') self.ebqe['x'] = np.zeros((self.mesh.nExteriorElementBoundaries_global, self.nElementBoundaryQuadraturePoints_elementBoundary, 3), 'd') self.q[('u', 0)] = np.zeros((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') - self.q[('dV_u', 0)] = (old_div(1.0, self.mesh.nElements_global)) * np.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') + self.q[('dV_u', 0)] = (1.0/self.mesh.nElements_global) * np.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') self.q[('grad(u)', 0)] = np.zeros((self.mesh.nElements_global, self.nQuadraturePoints_element, self.nSpace_global), 'd') self.q[('m_last', 0)] = np.zeros((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') self.q[('mt', 0)] = np.zeros((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') @@ -851,16 +847,14 @@ def __init__(self, if 'penalty' in self.ebq_global: for ebN in range(self.mesh.nElementBoundaries_global): for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebq_global['penalty'][ebN, k] = old_div(self.numericalFlux.penalty_constant, \ - (self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power)) + self.ebq_global['penalty'][ebN, k] = self.numericalFlux.penalty_constant/(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) # penalty term # cek move to Numerical flux initialization if 'penalty' in self.ebqe: for ebNE in range(self.mesh.nExteriorElementBoundaries_global): ebN = self.mesh.exteriorElementBoundariesArray[ebNE] for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebqe['penalty'][ebNE, k] = old_div(self.numericalFlux.penalty_constant, \ - self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) + self.ebqe['penalty'][ebNE, k] = self.numericalFlux.penalty_constant/self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power logEvent(memory("numericalFlux", "OneLevelTransport"), level=4) self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray # use post processing tools to get conservative fluxes, None by default diff --git a/proteus/mprans/VOF.py b/proteus/mprans/VOF.py index 59d15d9bbc..c21e8402f0 100644 --- a/proteus/mprans/VOF.py +++ b/proteus/mprans/VOF.py @@ -2,10 +2,6 @@ """ An optimized volume-of-fluid transport module """ -from __future__ import absolute_import -from __future__ import division -from builtins import range -from past.utils import old_div import numpy as np from math import fabs import proteus @@ -133,7 +129,7 @@ def __init__(self, transport, timeOrder=1, runCFL=0.1, integrateInterpolationPoi def choose_dt(self): maxCFL = 1.0e-6 maxCFL = max(maxCFL, globalMax(self.cfl.max())) - self.dt = old_div(self.runCFL, maxCFL) + self.dt = self.runCFL/maxCFL if self.dtLast is None: self.dtLast = self.dt self.t = self.tLast + self.dt @@ -761,7 +757,7 @@ def __init__(self, self.q['x'] = np.zeros((self.mesh.nElements_global, self.nQuadraturePoints_element, 3), 'd') self.ebqe['x'] = np.zeros((self.mesh.nExteriorElementBoundaries_global, self.nElementBoundaryQuadraturePoints_elementBoundary, 3), 'd') self.q[('u', 0)] = np.zeros((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') - self.q[('dV_u', 0)] = (old_div(1.0, self.mesh.nElements_global)) * np.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') + self.q[('dV_u', 0)] = (1.0/self.mesh.nElements_global) * np.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') self.q[('grad(u)', 0)] = np.zeros((self.mesh.nElements_global, self.nQuadraturePoints_element, self.nSpace_global), 'd') self.q[('m_last', 0)] = np.zeros((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') self.q[('mt', 0)] = np.zeros((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') @@ -850,16 +846,14 @@ def __init__(self, if 'penalty' in self.ebq_global: for ebN in range(self.mesh.nElementBoundaries_global): for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebq_global['penalty'][ebN, k] = old_div(self.numericalFlux.penalty_constant, \ - (self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power)) + self.ebq_global['penalty'][ebN, k] = self.numericalFlux.penalty_constant/(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) # penalty term # cek move to Numerical flux initialization if 'penalty' in self.ebqe: for ebNE in range(self.mesh.nExteriorElementBoundaries_global): ebN = self.mesh.exteriorElementBoundariesArray[ebNE] for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebqe['penalty'][ebNE, k] = old_div(self.numericalFlux.penalty_constant, \ - self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) + self.ebqe['penalty'][ebNE, k] = self.numericalFlux.penalty_constant/self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power logEvent(memory("numericalFlux", "OneLevelTransport"), level=4) self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray # use post processing tools to get conservative fluxes, None by default diff --git a/proteus/mprans/VOF3P.py b/proteus/mprans/VOF3P.py index 5c3e3fe38a..4561f5ed52 100644 --- a/proteus/mprans/VOF3P.py +++ b/proteus/mprans/VOF3P.py @@ -2,10 +2,6 @@ """ An optimized volume-of-fluid transport module """ -from __future__ import absolute_import -from __future__ import division -from builtins import range -from past.utils import old_div import numpy as np from math import fabs import proteus @@ -129,7 +125,7 @@ def __init__(self, transport, timeOrder=1, runCFL=0.1, integrateInterpolationPoi def choose_dt(self): maxCFL = 1.0e-6 maxCFL = max(maxCFL, globalMax(self.cfl.max())) - self.dt = old_div(self.runCFL, maxCFL) + self.dt = self.runCFL/maxCFL if self.dtLast is None: self.dtLast = self.dt self.t = self.tLast + self.dt @@ -741,7 +737,7 @@ def __init__(self, self.q['x'] = np.zeros((self.mesh.nElements_global, self.nQuadraturePoints_element, 3), 'd') self.ebqe['x'] = np.zeros((self.mesh.nExteriorElementBoundaries_global, self.nElementBoundaryQuadraturePoints_elementBoundary, 3), 'd') self.q[('u', 0)] = np.zeros((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') - self.q[('dV_u', 0)] = (old_div(1.0, self.mesh.nElements_global)) * np.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') + self.q[('dV_u', 0)] = (1.0/self.mesh.nElements_global) * np.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') self.q[('grad(u)', 0)] = np.zeros((self.mesh.nElements_global, self.nQuadraturePoints_element, self.nSpace_global), 'd') self.q[('m', 0)] = self.q[('u', 0)] self.q[('m_last', 0)] = np.zeros((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') @@ -830,16 +826,14 @@ def __init__(self, if 'penalty' in self.ebq_global: for ebN in range(self.mesh.nElementBoundaries_global): for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebq_global['penalty'][ebN, k] = old_div(self.numericalFlux.penalty_constant, \ - (self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power)) + self.ebq_global['penalty'][ebN, k] = self.numericalFlux.penalty_constant/(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) # penalty term # cek move to Numerical flux initialization if 'penalty' in self.ebqe: for ebNE in range(self.mesh.nExteriorElementBoundaries_global): ebN = self.mesh.exteriorElementBoundariesArray[ebNE] for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebqe['penalty'][ebNE, k] = old_div(self.numericalFlux.penalty_constant, \ - self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) + self.ebqe['penalty'][ebNE, k] = self.numericalFlux.penalty_constant/self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power logEvent(memory("numericalFlux", "OneLevelTransport"), level=4) self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray # use post processing tools to get conservative fluxes, None by default diff --git a/proteus/mprans/VOS3P.py b/proteus/mprans/VOS3P.py index 2befb05795..4603203444 100644 --- a/proteus/mprans/VOS3P.py +++ b/proteus/mprans/VOS3P.py @@ -2,10 +2,6 @@ """ An optimized volume-of-fluid transport module """ -from __future__ import absolute_import -from __future__ import division -from builtins import range -from past.utils import old_div import numpy as np from math import fabs import proteus @@ -134,7 +130,7 @@ def __init__(self, transport, timeOrder=1, runCFL=0.1, integrateInterpolationPoi def choose_dt(self): maxCFL = 1.0e-6 maxCFL = max(maxCFL, globalMax(self.cfl.max())) - self.dt = old_div(self.runCFL, maxCFL) + self.dt = self.runCFL/maxCFL if self.dtLast is None: self.dtLast = self.dt self.t = self.tLast + self.dt @@ -174,7 +170,7 @@ def updateStage(self): logEvent("Second stage of SSP33 method", level=4) for ci in range(self.nc): self.u_dof_stage[ci][self.lstage][:] = self.transport.u[ci].dof - self.u_dof_stage[ci][self.lstage] *= old_div(1., 4.) + self.u_dof_stage[ci][self.lstage] *= 1./4. self.u_dof_stage[ci][self.lstage] += 3. / 4. * self.u_dof_last[ci] # Update u_dof_old self.transport.u_dof_old[:] = self.u_dof_stage[ci][self.lstage] @@ -182,7 +178,7 @@ def updateStage(self): logEvent("Third stage of SSP33 method", level=4) for ci in range(self.nc): self.u_dof_stage[ci][self.lstage][:] = self.transport.u[ci].dof - self.u_dof_stage[ci][self.lstage] *= old_div(2.0, 3.0) + self.u_dof_stage[ci][self.lstage] *= 2.0/3.0 self.u_dof_stage[ci][self.lstage] += 1.0 / 3.0 * self.u_dof_last[ci] # update u_dof_old self.transport.u_dof_old[:] = self.u_dof_last[ci] @@ -199,7 +195,7 @@ def updateStage(self): logEvent("Second stage of SSP22 method", level=4) for ci in range(self.nc): self.u_dof_stage[ci][self.lstage][:] = self.transport.u[ci].dof - self.u_dof_stage[ci][self.lstage][:] *= old_div(1., 2.) + self.u_dof_stage[ci][self.lstage][:] *= 1./2. self.u_dof_stage[ci][self.lstage][:] += 1. / 2. * self.u_dof_last[ci] # update u_dof_old self.transport.u_dof_old[:] = self.u_dof_last[ci] @@ -873,7 +869,7 @@ def __init__(self, 'd') self.q[('u', 0)] = np.zeros( (self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') - self.q[('dV_u', 0)] = (old_div(1.0, self.mesh.nElements_global)) * \ + self.q[('dV_u', 0)] = (1.0/self.mesh.nElements_global) * \ np.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') self.q[ ('grad(u)', @@ -1095,8 +1091,7 @@ def __init__(self, for ebN in range(self.mesh.nElementBoundaries_global): for k in range( self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebq_global['penalty'][ebN, k] = old_div(self.numericalFlux.penalty_constant, ( - self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power)) + self.ebq_global['penalty'][ebN, k] = self.numericalFlux.penalty_constant/(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) # penalty term # cek move to Numerical flux initialization if 'penalty' in self.ebqe: @@ -1104,8 +1099,7 @@ def __init__(self, ebN = self.mesh.exteriorElementBoundariesArray[ebNE] for k in range( self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebqe['penalty'][ebNE, k] = old_div(self.numericalFlux.penalty_constant, \ - self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) + self.ebqe['penalty'][ebNE, k] = self.numericalFlux.penalty_constant/\self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power logEvent(memory("numericalFlux", "OneLevelTransport"), level=4) self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray # use post processing tools to get conservative fluxes, None by default @@ -1789,4 +1783,4 @@ def calculateAuxiliaryQuantitiesAfterStep(self): pass def updateAfterMeshMotion(self): - pass + pass \ No newline at end of file diff --git a/proteus/mprans/beamFEM.py b/proteus/mprans/beamFEM.py index d87ab8f0e7..b760e143a6 100644 --- a/proteus/mprans/beamFEM.py +++ b/proteus/mprans/beamFEM.py @@ -1,7 +1,3 @@ -from __future__ import division -from builtins import range -from builtins import object -from past.utils import old_div import numpy as np #import scipy as sp #import matplotlib.pyplot as plt @@ -47,11 +43,11 @@ def initializePhi(self): def GaussQuad(self): if self.quadOrder == 2: self.w = (1.0, 1.0) - self.zeta = (old_div(-1.0, 3.0**.5), old_div(1.0, 3.0**0.5)) + self.zeta = (-1.0/3.0**.5, 1.0/3.0**0.5) #self.quadSpacing = (self.zeta[0]+1.0, self.zeta[1]-self.zeta[0], 1.0-self.zeta[1]) elif self.quadOrder == 3: - self.w = (old_div(5.0, 9.0), old_div(8.0, 9.0), old_div(5.0, 9.0)) - self.zeta = (-(old_div(3.0, 5.0))**.5, 0.0, (old_div(3.0, 5.0))**0.5) + self.w = (5.0/9.0, 8.0/9.0, 5.0/9.0) + self.zeta = (-(3.0/5.0)**.5, 0.0, (3.0/5.0)**0.5) #self.quadSpacing = (self.zeta[0]+1.0, self.zeta[1]-self.zeta[0], self.zeta[2]-self.zeta[1],1.0-self.zeta[2]) def initializeCoords(self): @@ -322,4 +318,4 @@ def getCoords_at_Quad(self): y_quad[self.quadOrder * i + j] += np.dot(self.v[j], y_el) z_quad[self.quadOrder * i + j] += np.dot(self.v[j], z_el) weights = np.array(self.w) - return x_quad[:], y_quad[:], z_quad[:] + return x_quad[:], y_quad[:], z_quad[:] \ No newline at end of file diff --git a/proteus/mprans/cMoveMeshMonitor.pyx b/proteus/mprans/cMoveMeshMonitor.pyx index dac847158b..709fda8396 100644 --- a/proteus/mprans/cMoveMeshMonitor.pyx +++ b/proteus/mprans/cMoveMeshMonitor.pyx @@ -325,7 +325,7 @@ cdef class cCoefficients: cdef double[:] coords = np.zeros(3) cdef int b_i, b_i_global cdef double[:] bound_bar - cdef int[:] result + cdef int[3] result cdef int[:] result2 cdef bool found cdef double array_size_local = 0 @@ -427,7 +427,7 @@ cdef class cCoefficients: coords[ndi] += dphi[ndi]*dt*fixed_dir[ndi] xx[node, ndi] = coords[ndi] else: # find node that moved already (search) - result = findN(coords=coords, + findN(coords=coords, nodeArray=nodeArray, nodeStarOffsets=nodeStarOffsets, nodeStarArray=nodeStarArray, @@ -453,7 +453,8 @@ cdef class cCoefficients: elementBoundaryOffsets_subdomain_owned=elementBoundaryOffsets_subdomain_owned, nodeMaterialTypes=nodeMaterialTypes, elementNodesArray=elementNodesArray, - nNel=nNel) + nNel=nNel, + result_out = result) nearestN = result[0] typeN = result[1] new_rank = result[2] @@ -634,7 +635,7 @@ cdef class cCoefficients: fixed_dir[1] = coords_2doArray[iN, 13] fixed_dir[2] = coords_2doArray[iN, 14] if solFound_2doArray[iN] == 0: - result = findN(coords=coords, + findN(coords=coords, nodeArray=nodeArray, nodeStarOffsets=nodeStarOffsets, nodeStarArray=nodeStarArray, @@ -660,7 +661,8 @@ cdef class cCoefficients: elementBoundaryOffsets_subdomain_owned=elementBoundaryOffsets_subdomain_owned, nodeMaterialTypes=nodeMaterialTypes, elementNodesArray=elementNodesArray, - nNel=nNel) + nNel=nNel, + result_out=result) nearestN = result[0] typeN = result[1] new_rank = result[2] @@ -1629,7 +1631,7 @@ cdef tuple checkOwnedVariable(int variable_nb_local, # return tofind_2do -cdef int[:] findN(double[:] coords, +cdef void findN(double[:] coords, double[:,:] nodeArray, int[:] nodeStarOffsets, int[:] nodeStarArray, @@ -1655,9 +1657,9 @@ cdef int[:] findN(double[:] coords, int[:] elementBoundaryOffsets_subdomain_owned, int[:,:] elementNodesArray, int[:] nodeMaterialTypes, - int nNel): + int nNel, + int[3] result_out): cdef int[:] result_in - cdef int[3] result_out cdef double[:] starting_coords = np.zeros(3) cdef int rank = my_rank # rank of owning processor cdef bool stop = False @@ -1753,7 +1755,6 @@ cdef int[:] findN(double[:] coords, result_out[0] = nearestN result_out[1] = typeN result_out[2] = rank - return result_out # def mpicomm(dict_2rank, ): # comm = Comm.get().comm.tompi4py() diff --git a/proteus/partitioning.cpp b/proteus/partitioning.cpp index efc3e38cbe..5aa3ced2b3 100644 --- a/proteus/partitioning.cpp +++ b/proteus/partitioning.cpp @@ -1684,7 +1684,7 @@ int partitionNodesFromTetgenFiles(const MPI_Comm& PROTEUS_COMM_WORLD, const char weights_subdomain, &petscAdjacency);CHKERRABORT(PROTEUS_COMM_WORLD, ierr); //const double max_rss_gb(0.75*3.25);//half max mem per core on topaz - const double max_rss_gb(3.75); + const double max_rss_gb(10.0); ierr = enforceMemoryLimit(PROTEUS_COMM_WORLD, rank, max_rss_gb,"Done allocating MPIAdj");CHKERRABORT(PROTEUS_COMM_WORLD, ierr); MatPartitioning petscPartition; ierr = MatPartitioningCreate(PROTEUS_COMM_WORLD,&petscPartition);CHKERRABORT(PROTEUS_COMM_WORLD, ierr); @@ -3178,7 +3178,7 @@ int partitionNodesFromTriangleFiles(const MPI_Comm& PROTEUS_COMM_WORLD, const ch weights_subdomain, &petscAdjacency);CHKERRABORT(PROTEUS_COMM_WORLD, ierr); //const double max_rss_gb(0.75*3.25);//half max mem per core on topaz - const double max_rss_gb(3.75); + const double max_rss_gb(10.0); ierr = enforceMemoryLimit(PROTEUS_COMM_WORLD, rank, max_rss_gb,"Done allocating MPIAdj");CHKERRABORT(PROTEUS_COMM_WORLD, ierr); MatPartitioning petscPartition; ierr = MatPartitioningCreate(PROTEUS_COMM_WORLD,&petscPartition);CHKERRABORT(PROTEUS_COMM_WORLD, ierr); diff --git a/proteus/richards/Richards.h b/proteus/richards/Richards.h index 1adaaefeef..497ba6c03b 100644 --- a/proteus/richards/Richards.h +++ b/proteus/richards/Richards.h @@ -32,12 +32,15 @@ namespace proteus } namespace proteus + { class Richards_base { //The base class defining the interface public: - virtual ~Richards_base(){} + virtual ~Richards_base(){ + double anb_seepage_flux =1e-16; + } virtual void calculateResidual(arguments_dict& args)=0; virtual void calculateJacobian(arguments_dict& args)=0; virtual void invert(arguments_dict& args)=0; @@ -113,6 +116,7 @@ namespace proteus psiC = -u; m_vg = 1.0 - 1.0 / n_vg; thetaS = thetaR + thetaSR; + //std::cout<< "Thetas"< 0.0) { pcBar = alpha * psiC; @@ -172,7 +176,7 @@ namespace proteus } } } - + inline void evaluateInverseCoefficients(const int rowptr[nSpace], const int colind[nnz], @@ -183,7 +187,7 @@ namespace proteus const double n_vg, const double thetaR, const double thetaSR, - const double KWs[nnz], + const double KWs[nnz], double& u, const double& m, const double& dm, @@ -191,7 +195,7 @@ namespace proteus const double df[nSpace], const double a[nnz], const double da[nnz]) - { + { double psiC, pcBar,pcBar_n, sBar, @@ -222,7 +226,6 @@ namespace proteus <<"psiC "<& csrRowIndeces_DofLoops, + const xt::pyarray& csrColumnOffsets_DofLoops, + const xt::pyarray& uLow, + const xt::pyarray& dt_times_fH_minus_fL, + double dt, + double mi +) { + double Pposi = 0.0, Pnegi = 0.0; + double mini = 0.0, maxi = 1.0; + int ij = csrRowIndeces_DofLoops(i); // assuming using xtensor array + + for (int offset = csrRowIndeces_DofLoops(i); offset < csrRowIndeces_DofLoops(i + 1); ++offset) { + int j = csrColumnOffsets_DofLoops(offset); + // Compute P vectors + Pposi += dt_times_fH_minus_fL(offset) * (dt_times_fH_minus_fL(offset) > 0 ? 1.0 : 0.0); + Pnegi += dt_times_fH_minus_fL(offset) * (dt_times_fH_minus_fL(offset) < 0 ? 1.0 : 0.0); + } + + double Qposi = mi * (maxi - uLow(i)); + double Qnegi = mi * (mini - uLow(i)); + double Rposi = (Pposi == 0.0) ? 1.0 : std::fmin(1.0, Qposi / Pposi); + double Rnegi = (Pnegi == 0.0) ? 1.0 : std::fmin(1.0, Qnegi / Pnegi); + + double ith_limited_flux_correction = 0.0; + for (int offset = csrRowIndeces_DofLoops(i); offset < csrRowIndeces_DofLoops(i + 1); ++offset) { + int j = csrColumnOffsets_DofLoops(offset); + double Lij = dt_times_fH_minus_fL(offset) > 0 ? std::fmin(Rposi, uLow(j)) : std::fmin(Rnegi, uLow(j)); + ith_limited_flux_correction += Lij * dt_times_fH_minus_fL(offset); + } + + if (std::isnan(ith_limited_flux_correction)) { + ith_limited_flux_correction = 0.0; + } + + return ith_limited_flux_correction; +} + + + void calculateResidual(arguments_dict& args) { xt::pyarray& mesh_trial_ref = args.array("mesh_trial_ref"); @@ -501,11 +562,26 @@ namespace proteus xt::pyarray& quantDOFs = args.array("quantDOFs"); xt::pyarray& sLow = args.array("sLow"); xt::pyarray& sn = args.array("sn"); - + assert(a_rowptr.data()[nSpace] == nnz); assert(a_rowptr.data()[nSpace] == nSpace); //cek should this be read in? double Ct_sge = 4.0; + //For flux Calculation + //double anb_seepage_flux=0.0; + //anb_seepage_flux = args["anb_seepage_flux"]; + //double anb_seepage_flux = args.scalar("anb_seepage_flux"); + //anb_seepage_flux=0.0; + + xt::pyarray& anb_seepage_flux_n = args.array("anb_seepage_flux_n"); + + + //double anb_seepage_flux=0.0; + double & anb_seepage_flux (args.scalar("anb_seepage_flux")) ; + //double anb_seepage_flux = args.scalar("anb_seepage_flux_n"); + + //double anb_seepage_flux=0.0; + anb_seepage_flux=0.0; //loop over elements to compute volume integrals and load them into element and global residual // @@ -648,8 +724,6 @@ namespace proteus /* // */ /* //calculate shock capturing diffusion */ /* // */ - - /* ck.calculateNumericalDiffusion(shockCapturingDiffusion,elementDiameter[eN],pdeResidual_u,grad_u,numDiff0); */ /* //ck.calculateNumericalDiffusion(shockCapturingDiffusion,G,pdeResidual_u,grad_u_old,numDiff1); */ /* ck.calculateNumericalDiffusion(shockCapturingDiffusion,sc_uref, sc_alpha,G,G_dd_G,pdeResidual_u,grad_u,numDiff1); */ @@ -718,6 +792,7 @@ namespace proteus da_ext[nnz], as_ext[nnz], flux_ext=0.0, + //anb_seepage_flux=0.0, // for flux calculation bc_u_ext=0.0, bc_grad_u_ext[nSpace], bc_m_ext=0.0, @@ -852,17 +927,32 @@ namespace proteus ebqe_penalty_ext.data()[ebNE_kb],// penalty, flux_ext); ebqe_flux.data()[ebNE_kb] = flux_ext; - ebqe_u.data()[ebNE_kb] = u_ext; + + anb_seepage_flux= seepagefluxcalculator(anb_seepage_flux, + isSeepageFace.data()[ebNE], + dS, + flux_ext); + //std::cout<<"The seepage flux is "<0) + { + std::cout<<"The seepage flux is "<0 ? Rposi : Rpos[j]); + Lij = (Fluxij>0 ? Rposi : Rpos[j]); // compute limited flux ith_Limiter_times_FluxCorrectionMatrix += Lij*Fluxij; - + // update limited flux limitedFlux.data()[ij] = Lij*Fluxij; - + //update FluxMatrix - FluxMatrix.data()[ij] = Fluxij; - + FluxMatrix.data()[ij] = Fluxij; + //update ij ij+=1; } @@ -1575,7 +1669,7 @@ namespace proteus double Qnegi = mi*(mini-solLim.data()[i]); // compute R vectors // Rpos[i] = ((Pposi==0) ? 1. : fmin(1.0,Qposi/Pposi)); - Rneg[i] = ((Pnegi==0) ? 1. : fmin(1.0,Qnegi/Pnegi)); + Rneg[i] = ((Pnegi==0) ? 1. : fmin(1.0,Qnegi/Pnegi)); } // COMPUTE LIMITERS // @@ -1623,6 +1717,7 @@ namespace proteus xt::pyarray& mesh_grad_trial_trace_ref = args.array("mesh_grad_trial_trace_ref"); xt::pyarray& dS_ref = args.array("dS_ref"); xt::pyarray& u_trial_trace_ref = args.array("u_trial_trace_ref"); + xt::pyarray& u_grad_trial_trace_ref = args.array("u_grad_trial_trace_ref"); xt::pyarray& u_test_trace_ref = args.array("u_test_trace_ref"); xt::pyarray& u_grad_test_trace_ref = args.array("u_grad_test_trace_ref"); @@ -1717,6 +1812,18 @@ namespace proteus xt::pyarray& quantDOFs = args.array("quantDOFs"); xt::pyarray& sLow = args.array("sLow"); xt::pyarray& sn = args.array("sn"); + + xt::pyarray& anb_seepage_flux_n = args.array("anb_seepage_flux_n"); + + + //double anb_seepage_flux=0.0; + double & anb_seepage_flux (args.scalar("anb_seepage_flux")) ; + //double anb_seepage_flux = args.scalar("anb_seepage_flux_n"); + + //double anb_seepage_flux=0.0; + anb_seepage_flux=0.0; + + double Rpos[numDOFs], Rneg[numDOFs]; //double FluxCorrectionMatrix[NNZ]; // NOTE: This function follows a different (but equivalent) implementation of the smoothness based indicator than NCLS.h @@ -1727,6 +1834,8 @@ namespace proteus std::valarray u_free_dof(numDOFs); std::valarray u_free_dof_old(numDOFs); std::valarray ML2(numDOFs); + + for(int eN=0;eN= 0 && isFluxBoundary_u[ebNE_kb] != 1 ) //outflow. This is handled via the transport matrices. Then flux_ext=0 and dflux_ext!=0 */ - /* { */ - /* dflux_ext = flow; */ - /* flux_ext = 0; */ - /* // save external u */ - /* ebqe_u[ebNE_kb] = u_ext; */ - /* } */ - /* else // inflow. This is handled via the boundary integral. Then flux_ext!=0 and dflux_ext=0 */ - /* { */ - /* dflux_ext = 0; */ - /* // save external u */ - /* ebqe_u[ebNE_kb] = isDOFBoundary_u[ebNE_kb]*ebqe_bc_u_ext[ebNE_kb]+(1-isDOFBoundary_u[ebNE_kb])*u_ext; */ - /* if (isDOFBoundary_u[ebNE_kb] == 1) */ - /* flux_ext = ebqe_bc_u_ext[ebNE_kb]*flow; */ - /* else if (isFluxBoundary_u[ebNE_kb] == 1) */ - /* flux_ext = ebqe_bc_flux_u_ext[ebNE_kb]; */ - /* else */ - /* { */ - /* std::cout<<"warning: VOF open boundary with no external trace, setting to zero for inflow"<0) + // { + // std::cout<<"The seepage flux is "<("anb_seepage_flux_n"); + // //anb_seepage_flux_n=0.0; + + // //anb_seepage_flux_n= anb_seepage_flux; + + + + // //if (isSeepageFace) + // //{ + // // anb_seepage_flux+= dS* flux_ext; + // // std::cout<<"The seepage flux is "<0){ + // // std::cout<<"The seepage flux is "<= 0 && isFluxBoundary_u[ebNE_kb] != 1 ) //outflow. This is handled via the transport matrices. Then flux_ext=0 and dflux_ext!=0 + // // { + // // dflux_ext = flow; + // // flux_ext = 0; + // // // save external u + // // ebqe_u[ebNE_kb] = u_ext; + // // } + // //else // inflow. This is handled via the boundary integral. Then flux_ext!=0 and dflux_ext=0 + // //{ + // //dflux_ext = 0; + // // save external u + // //ebqe_u[ebNE_kb] = isDOFBoundary_u[ebNE_kb]*ebqe_bc_u_ext[ebNE_kb]+(1-isDOFBoundary_u[ebNE_kb])*u_ext; + // //if (isDOFBoundary_u[ebNE_kb] == 1) + // // flux_ext = ebqe_bc_u_ext[ebNE_kb]*flow; + // //else if (isFluxBoundary_u[ebNE_kb] == 1) + // //flux_ext = ebqe_bc_flux_u_ext[ebNE_kb]; + // // flux_ext = ebqe_bc_u_ext[ebNE_kb]; + // //else + // // { + // // std::cout<<"warning: VOF open boundary with no external trace, setting to zero for inflow"< mMax) - { - std::cout<<"mass out of bounds "< mMax) + { + std::cout<<"mass out of bounds "< 1.0 || Rposi < 0.0) + //if (Rposi > 1.0 || Rposi < 0.0) //std::cout << "Rposi: " << Rposi << std::endl; - //if (Rnegi > 1.0 || Rnegi < 0.0) - //std::cout << "Rnegi: " << Rnegi << std::endl; - + //if (Rnegi > 1.0 || Rnegi < 0.0) + //std::cout << "Rnegi: " << Rnegi << std::endl; + // LOOP OVER THE SPARSITY PATTERN (j-LOOP)// // for (int offset=csrRowIndeces_DofLoops.data()[i]; // offset& a_rowptr = args.array("a_rowptr"); @@ -2926,6 +3202,8 @@ namespace proteus }//computeMassMatrix };//Richards + + inline Richards_base* newRichards(int nSpaceIn, int nQuadraturePoints_elementIn, int nDOF_mesh_trial_elementIn, @@ -2936,11 +3214,11 @@ namespace proteus { if (nSpaceIn == 1) return proteus::chooseAndAllocateDiscretization1D(nSpaceIn, - nQuadraturePoints_elementIn, - nDOF_mesh_trial_elementIn, - nDOF_trial_elementIn, - nDOF_test_elementIn, - nQuadraturePoints_elementBoundaryIn, + nQuadraturePoints_elementIn, + nDOF_mesh_trial_elementIn, + nDOF_trial_elementIn, + nDOF_test_elementIn, + nQuadraturePoints_elementBoundaryIn, CompKernelFlag); else if (nSpaceIn == 2) return proteus::chooseAndAllocateDiscretization2D(nSpaceIn, @@ -2962,5 +3240,5 @@ namespace proteus CompKernelFlag); } } -}//proteus -#endif +};//proteus +#endif \ No newline at end of file diff --git a/proteus/richards/Richards.py b/proteus/richards/Richards.py index 841fcd0884..a36d0a6fc9 100644 --- a/proteus/richards/Richards.py +++ b/proteus/richards/Richards.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import range -from past.utils import old_div import proteus from .cRichards import * import numpy as np @@ -12,6 +9,8 @@ from proteus.LinearAlgebraTools import SparseMat from proteus import TimeIntegration from proteus.NonlinearSolvers import ExplicitLumpedMassMatrixForRichards +from proteus.NonlinearSolvers import Newton + class ThetaScheme(TimeIntegration.BackwardEuler): def __init__(self,transport,integrateInterpolationPoints=False): @@ -51,6 +50,8 @@ def __init__(self, transport, timeOrder=1, runCFL=0.1, integrateInterpolationPoi self.u_dof_stage[ci] = [] for k in range(self.nStages + 1): self.u_dof_stage[ci].append(transport.u[ci].dof.copy()) + #print() + # def set_dt(self, DTSET): # self.dt = DTSET # don't update t @@ -58,11 +59,13 @@ def choose_dt(self): comm = Comm.get() maxCFL = 1.0e-6 maxCFL = max(maxCFL, comm.globalMax(self.cfl.max())) - self.dt = old_div(self.runCFL, maxCFL) + self.dt = self.runCFL/maxCFL if self.dtLast is None: self.dtLast = self.dt self.t = self.tLast + self.dt self.substeps = [self.t for i in range(self.nStages)] # Manuel is ignoring different time step levels for now + + def initialize_dt(self, t0, tOut, q): """ @@ -98,7 +101,7 @@ def updateStage(self): logEvent("Second stage of SSP33 method", level=4) for ci in range(self.nc): self.u_dof_stage[ci][self.lstage][:] = self.transport.u[ci].dof - self.u_dof_stage[ci][self.lstage] *= old_div(1., 4.) + self.u_dof_stage[ci][self.lstage] *= 1./4. self.u_dof_stage[ci][self.lstage] += 3. / 4. * self.u_dof_last[ci] # Update u_dof_old self.transport.u_dof_old[:] = self.u_dof_stage[ci][self.lstage] @@ -106,7 +109,7 @@ def updateStage(self): logEvent("Third stage of SSP33 method", level=4) for ci in range(self.nc): self.u_dof_stage[ci][self.lstage][:] = self.transport.u[ci].dof - self.u_dof_stage[ci][self.lstage] *= old_div(2.0, 3.0) + self.u_dof_stage[ci][self.lstage] *= 2.0/3.0 self.u_dof_stage[ci][self.lstage] += 1.0 / 3.0 * self.u_dof_last[ci] # update u_dof_old self.transport.u_dof_old[:] = self.u_dof_last[ci] @@ -123,7 +126,7 @@ def updateStage(self): logEvent("Second stage of SSP22 method", level=4) for ci in range(self.nc): self.u_dof_stage[ci][self.lstage][:] = self.transport.u[ci].dof - self.u_dof_stage[ci][self.lstage][:] *= old_div(1., 2.) + self.u_dof_stage[ci][self.lstage][:] *= 1./2. self.u_dof_stage[ci][self.lstage][:] += 1. / 2. * self.u_dof_last[ci] # update u_dof_old self.transport.u_dof_old[:] = self.u_dof_last[ci] @@ -134,6 +137,7 @@ def updateStage(self): for ci in range(self.nc): self.u_dof_stage[ci][self.lstage][:] = self.transport.u[ci].dof[:] self.transport.u_dof_old[:] = self.transport.u[ci].dof + def initializeTimeHistory(self, resetFromDOF=True): """ @@ -199,6 +203,8 @@ def setFromOptions(self, nOptions): setattr(self, flag, val) if flag == 'timeOrder': self.resetOrder(self.timeOrder) + + class Coefficients(proteus.TransportCoefficients.TC_base): """ @@ -223,8 +229,7 @@ def __init__(self, ENTROPY_TYPE=2, # logarithmic LUMPED_MASS_MATRIX=False, MONOLITHIC=True, - FCT=False, - forceStrongBoundaryConditions=False, + FCT=True, num_fct_iter=1, # FOR ENTROPY VISCOSITY cE=1.0, @@ -233,7 +238,9 @@ def __init__(self, # FOR ARTIFICIAL COMPRESSION cK=1.0, # OUTPUT quantDOFs - outputQuantDOFs=False): + outputQuantDOFs=False, ): + self.anb_seepage_flux= 0.00 + #self.anb_seepage_flux_n =0.0 variableNames=['pressure_head'] nc=1 mass={0:{0:'nonlinear'}} @@ -294,7 +301,7 @@ def __init__(self, self.uL = uL self.uR = uR self.cK = cK - self.forceStrongConditions = forceStrongBoundaryConditions + self.forceStrongConditions = True self.cE = cE self.outputQuantDOFs = outputQuantDOFs TC_base.__init__(self, @@ -320,12 +327,15 @@ def initializeMesh(self,mesh): #mwf missing ebNE-->ebN? ebN = mesh.exteriorElementBoundariesArray[ebNE] #print "eb flag",mesh.elementBoundaryMaterialTypes[ebN] + #print self.getSeepageFace(mesh.elementBoundaryMaterialTypes[ebN]) self.isSeepageFace[ebNE] = self.getSeepageFace(mesh.elementBoundaryMaterialTypes[ebN]) - #print self.isSeepageFace + #print (self.isSeepageFace) def initializeElementQuadrature(self,t,cq): self.materialTypes_q = self.elementMaterialTypes self.q_shape = cq[('u',0)].shape + #self.anb_seepage_flux= anb_seepage_flux + #print("The seepage is ", anb_seepage_flux) # cq['Ks'] = np.zeros(self.q_shape,'d') # for k in range(self.q_shape[1]): # cq['Ks'][:,k] = self.Ksw_types[self.elementMaterialTypes,0] @@ -342,6 +352,8 @@ def initializeGlobalExteriorElementBoundaryQuadrature(self,t,cebqe): self.ebqe_shape = cebqe[('u',0)].shape self.ebqe[('vol_frac',0)] = np.zeros(self.ebqe_shape,'d') # + + def evaluate(self,t,c): if c[('u',0)].shape == self.q_shape: materialTypes = self.materialTypes_q @@ -402,11 +414,13 @@ def evaluate(self,t,c): np.isnan(c[('dm',0,0)]).any()): import pdb pdb.set_trace() - -# #mwf debug -# if c[('u',0)].shape == self.q_shape: -# c[('visPerm',0)]=c[('a',0,0)][:,:,0,0] - + + def postStep(self, t, firstStep=False): + # #anb_seepage_flux_n[:]= self.anb_seepage_flux + with open('seepage_stab_0', "a") as f: + # f.write("\n Time"+ ",\t" +"Seepage\n") + f.write(repr(t)+ ",\t")# +repr(np.sum(self.LevelModel.anb_seepage_flux_n))) + class LevelModel(proteus.Transport.OneLevelTransport): nCalls=0 def __init__(self, @@ -538,6 +552,7 @@ def __init__(self, for I in self.coefficients.elementIntegralKeys: if I in elementQuadrature: elementQuadratureDict[I] = elementQuadrature[I] + else: elementQuadratureDict[I] = elementQuadrature['default'] else: @@ -557,6 +572,7 @@ def __init__(self, if elemQuadIsDict: if ('numDiff',ci,ci) in elementQuadrature: elementQuadratureDict[('numDiff',ci,ci)] = elementQuadrature[('numDiff',ci,ci)] + else: elementQuadratureDict[('numDiff',ci,ci)] = elementQuadrature['default'] else: @@ -631,7 +647,7 @@ def __init__(self, self.edge_based_cfl = np.zeros(self.u[0].dof.shape)+100 #mesh #self.q['x'] = np.zeros((self.mesh.nElements_global,self.nQuadraturePoints_element,3),'d') - self.q[('dV_u', 0)] = (old_div(1.0, self.mesh.nElements_global)) * np.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') + self.q[('dV_u', 0)] = (1.0/self.mesh.nElements_global) * np.ones((self.mesh.nElements_global, self.nQuadraturePoints_element), 'd') self.ebqe['x'] = np.zeros((self.mesh.nExteriorElementBoundaries_global,self.nElementBoundaryQuadraturePoints_elementBoundary,3),'d') self.q[('u',0)] = np.zeros((self.mesh.nElements_global,self.nQuadraturePoints_element),'d') self.q[('grad(u)',0)] = np.zeros((self.mesh.nElements_global,self.nQuadraturePoints_element,self.nSpace_global),'d') @@ -716,6 +732,17 @@ def __init__(self, assert cond, "Use lumped mass matrix just with: STABILIZATION_TYPE=2 (smoothness based stab.)" cond = 'levelNonlinearSolver' in dir(options) and options.levelNonlinearSolver == ExplicitLumpedMassMatrixForRichards assert cond, "Use levelNonlinearSolver=ExplicitLumpedMassMatrixForRichards when the mass matrix is lumped" + + ################################################################# + ####################ARNOB_FCT_EDIT############################### + ################################################################# + if not self.coefficients.LUMPED_MASS_MATRIX and self.coefficients.STABILIZATION_TYPE == 2: + cond = 'levelNonlinearSolver' in dir(options) and options.levelNonlinearSolver == Newton + + + + + if self.coefficients.FCT == True: cond = self.coefficients.STABILIZATION_TYPE > 0, "Use FCT just with STABILIZATION_TYPE>0; i.e., edge based stabilization" # END OF ASSERTS @@ -739,6 +766,7 @@ def __init__(self, self.sLow = np.zeros(self.u[0].dof.shape, 'd') self.sHigh = np.zeros(self.u[0].dof.shape, 'd') self.sn = np.zeros(self.u[0].dof.shape, 'd') + self.anb_seepage_flux_n = np.zeros(self.u[0].dof.shape, 'd') comm = Comm.get() self.comm=comm if comm.size() > 1: @@ -749,6 +777,8 @@ def __init__(self, self.stride = [self.nc for ci in range(self.nc)] # logEvent(memory("stride+offset","OneLevelTransport"),level=4) + + if numericalFluxType != None: if options is None or options.periodicDirichletConditions is None: self.numericalFlux = numericalFluxType(self, @@ -768,14 +798,14 @@ def __init__(self, if 'penalty' in self.ebq_global: for ebN in range(self.mesh.nElementBoundaries_global): for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebq_global['penalty'][ebN,k] = old_div(self.numericalFlux.penalty_constant,(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power)) + self.ebq_global['penalty'][ebN,k] = self.numericalFlux.penalty_constant/(self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) #penalty term #cek move to Numerical flux initialization if 'penalty' in self.ebqe: for ebNE in range(self.mesh.nExteriorElementBoundaries_global): ebN = self.mesh.exteriorElementBoundariesArray[ebNE] for k in range(self.nElementBoundaryQuadraturePoints_elementBoundary): - self.ebqe['penalty'][ebNE,k] = old_div(self.numericalFlux.penalty_constant,self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power) + self.ebqe['penalty'][ebNE,k] = self.numericalFlux.penalty_constant/self.mesh.elementBoundaryDiametersArray[ebN]**self.numericalFlux.penalty_power logEvent(memory("numericalFlux","OneLevelTransport"),level=4) self.elementEffectiveDiametersArray = self.mesh.elementInnerDiametersArray #use post processing tools to get conservative fluxes, None by default @@ -821,7 +851,7 @@ def __init__(self, self.MOVING_DOMAIN=0.0 if self.mesh.nodeVelocityArray is None: self.mesh.nodeVelocityArray = np.zeros(self.mesh.nodeArray.shape,'d') - self.forceStrongConditions=self.coefficients.forceStrongConditions + self.forceStrongConditions=False self.dirichletConditionsForceDOF = {} if self.forceStrongConditions: for cj in range(self.nc): @@ -860,6 +890,7 @@ def FCTStep(self): argsDict["max_s_bc"] = np.ones_like(self.min_s_bc)*self.coefficients.rho*(self.coefficients.thetaR_types[0] + self.coefficients.thetaSR_types[0]) #cek hack argsDict["LUMPED_MASS_MATRIX"] = self.coefficients.LUMPED_MASS_MATRIX argsDict["MONOLITHIC"] =0#cek hack self.coefficients.MONOLITHIC + argsDict["anb_seepage_flux_n"]= self.anb_seepage_flux_n #pdb.set_trace() self.richards.FCTStep(argsDict) @@ -1163,8 +1194,8 @@ def getResidual(self,u,r): # self.ebqe[('diffusiveFlux_bc',0)][t[0],t[1]] = g(self.ebqe[('x')][t[0],t[1]],self.timeIntegration.t) # self.ebqe[('diffusiveFlux_bc_flag',0)][t[0],t[1]] = 1 #self.shockCapturing.lag=True + self.bc_mask = np.ones_like(self.u[0].dof) if self.forceStrongConditions: - self.bc_mask = np.ones_like(self.u[0].dof) for cj in range(len(self.dirichletConditionsForceDOF)): for dofN,g in list(self.dirichletConditionsForceDOF[cj].DOFBoundaryConditionsDict.items()): self.u[cj].dof[dofN] = g(self.dirichletConditionsForceDOF[cj].DOFBoundaryPointDict[dofN],self.timeIntegration.t) @@ -1177,8 +1208,7 @@ def getResidual(self,u,r): pass argsDict = cArgumentsDict.ArgumentsDict() - if self.forceStrongConditions: - argsDict["bc_mask"] = self.bc_mask + argsDict["bc_mask"] = self.bc_mask argsDict["dt"] = self.timeIntegration.dt argsDict["Theta"] = 1.0 argsDict["mesh_trial_ref"] = self.u[0].femSpace.elementMaps.psi @@ -1292,12 +1322,36 @@ def getResidual(self,u,r): argsDict["quantDOFs"] = self.quantDOFs argsDict["sLow"] = self.sLow argsDict["sn"] = self.sn + argsDict["anb_seepage_flux_n"]= self.anb_seepage_flux_n +###################################################################################### + argsDict["pn"] = self.u[0].dof + argsDict["solH"] = self.sHigh + + rowptr, colind, MassMatrix = self.MC_global.getCSRrepresentation() + argsDict["MassMatrix"] = MassMatrix + argsDict["solH"] = self.sHigh + +###################################################################################### + argsDict["anb_seepage_flux"] = self.coefficients.anb_seepage_flux + #print(anb_seepage_flux) + #argsDict["anb_seepage_flux_n"] = self.coefficients.anb_seepage_flux_n + #if np.sum(anb_seepage_flux_n)>0: + + #logEvent("Hi, this is Arnob", self.anb_seepage_flux_n[0]) + #print("Seepage Flux from Python file", np.sum(self.anb_seepage_flux_n)) + seepage_text_variable= np.sum(self.anb_seepage_flux_n) + + with open('seepage_stab_0',"a" ) as f: + #f.write("\n Time"+ ",\t" +"Seepage\n") + #f.write(repr(self.coefficients.t)+ ",\t" +repr(seepage_text_variable), "\n") + f.write(repr(seepage_text_variable)+ "\n") if (self.coefficients.STABILIZATION_TYPE == 0): # SUPG self.calculateResidual = self.richards.calculateResidual self.calculateJacobian = self.richards.calculateJacobian else: self.calculateResidual = self.richards.calculateResidual_entropy_viscosity self.calculateJacobian = self.richards.calculateMassMatrix + if self.delta_x_ij is None: self.delta_x_ij = -np.ones((self.nNonzerosInJacobian*3,),'d') self.calculateResidual(argsDict) @@ -1316,6 +1370,8 @@ def getResidual(self,u,r): if self.globalResidualDummy is None: self.globalResidualDummy = np.zeros(r.shape,'d') + + def invert(self,u,r): #u=s #r=p @@ -1468,6 +1524,10 @@ def invert(self,u,r): argsDict["quantDOFs"] = self.quantDOFs argsDict["sLow"] = self.sLow argsDict["sn"] = self.sn + #Arnob trying to print flux + argsDict["anb_seepage_flux"] = self.coefficients.anb_seepage_flux + + self.richards.invert(argsDict) # self.timeIntegration.dt, # self.u[0].femSpace.elementMaps.psi, @@ -1591,6 +1651,10 @@ def invert(self,u,r): #self.nonlinear_function_evaluations += 1 #if self.globalResidualDummy is None: # self.globalResidualDummy = numpy.zeros(r.shape,'d') + def postStep(self, t, firstStep=False): + with open('seepage_flux_nnnn', "a") as f: + f.write("\n Time"+ ",\t" +"Seepage\n") + f.write(repr(t)+ ",\t" +repr(self.coefficients.anb_seepage_flux)) def getJacobian(self,jacobian): if (self.coefficients.STABILIZATION_TYPE == 0): # SUPG cfemIntegrals.zeroJacobian_CSR(self.nNonzerosInJacobian, @@ -1666,6 +1730,8 @@ def getJacobian(self,jacobian): argsDict["ebqe_bc_flux_ext"] = self.ebqe[('advectiveFlux_bc',0)] argsDict["csrColumnOffsets_eb_u_u"] = self.csrColumnOffsets_eb[(0,0)] argsDict["LUMPED_MASS_MATRIX"] = self.coefficients.LUMPED_MASS_MATRIX + argsDict["anb_seepage_flux"] = self.coefficients.anb_seepage_flux + self.calculateJacobian(argsDict) if self.forceStrongConditions: for dofN in list(self.dirichletConditionsForceDOF[0].DOFBoundaryConditionsDict.keys()): @@ -1737,9 +1803,27 @@ def calculateExteriorElementBoundaryQuadrature(self): getDiffusiveFluxBoundaryConditions=self.diffusiveFluxBoundaryConditionsSetterDictDict[cj])) for cj in list(self.advectiveFluxBoundaryConditionsSetterDict.keys())]) self.coefficients.initializeGlobalExteriorElementBoundaryQuadrature(self.timeIntegration.t,self.ebqe) + #argsDict = cArgumentsDict.ArgumentsDict() + #argsDict["anb_seepage_flux"] = self.coefficients.anb_seepage_flux + #print("Hi", self.coefficients.anb_seepage_flux) + + #print("The seepage is ", anb_seepage_flux) def estimate_mt(self): pass def calculateSolutionAtQuadrature(self): pass def calculateAuxiliaryQuantitiesAfterStep(self): pass + def postStep(self, t, firstStep=False): + with open('seepage_flux_nnnnk', "a") as f: + f.write("\n Time"+ ",\t" +"Seepage\n") + f.write(repr(t)+ ",\t" +repr(self.coefficients.anb_seepage_flux)) + + + +#argsDict["anb_seepage_flux"] = self.coefficients.anb_seepage_flux +#anb_seepage_flux= self.coefficients.anb_seepage_flux +#print("Hi",anb_seepage_flux) + + +#print("Hello from the python file", self.coefficients.anb_seepage_flux) diff --git a/proteus/richards/__init__.py b/proteus/richards/__init__.py index c45e66de51..3cc15110bf 100644 --- a/proteus/richards/__init__.py +++ b/proteus/richards/__init__.py @@ -3,4 +3,4 @@ """ __all__ = ["Richards", - "cRichards"] + "cRichards"] \ No newline at end of file diff --git a/proteus/test_utils/TestTools.py b/proteus/test_utils/TestTools.py index fb5dfa4706..c504d1d474 100644 --- a/proteus/test_utils/TestTools.py +++ b/proteus/test_utils/TestTools.py @@ -1,12 +1,4 @@ """ Helper functions commonly used in tests. """ -from __future__ import print_function -from __future__ import division - -from builtins import zip -from builtins import str -from builtins import range -from builtins import object -from past.utils import old_div import os import sys import csv @@ -298,7 +290,7 @@ def _init_ipython_plot(self, if plot_relative == True: max_term = max(data_set) for i,term in enumerate(data_set): - data_set[i] = old_div(data_set[i], max_term) + data_set[i] = data_set[i]/max_term plt.plot(data_set) plt.yscale("log") plt.legend(legend_lst) diff --git a/proteus/test_utils/__init__.py b/proteus/test_utils/__init__.py index 98a290747a..18ef600f25 100644 --- a/proteus/test_utils/__init__.py +++ b/proteus/test_utils/__init__.py @@ -3,4 +3,4 @@ """ __all__ = ["utils", - "TestTools"] + "TestTools"] \ No newline at end of file diff --git a/proteus/test_utils/util.py b/proteus/test_utils/util.py index 4d7ea808fe..d9a45cec3e 100644 --- a/proteus/test_utils/util.py +++ b/proteus/test_utils/util.py @@ -17,4 +17,4 @@ def silent_rm(filename): try: os.remove(filename) except OSError: - pass + pass \ No newline at end of file diff --git a/proteus/tests/AddedMass/Aij_sol2D.csv b/proteus/tests/AddedMass/Aij_sol2D.csv deleted file mode 100644 index f6d7865152..0000000000 --- a/proteus/tests/AddedMass/Aij_sol2D.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b59a6c69ce229c85262404631e0babfe4c25ff788a2163432ed89c68db44b6cb -size 902 diff --git a/proteus/tests/AddedMass/Aij_sol3D.csv b/proteus/tests/AddedMass/Aij_sol3D.csv deleted file mode 100644 index 452e34e178..0000000000 --- a/proteus/tests/AddedMass/Aij_sol3D.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ac9933c970cc8c743bfd3bb06033972c1e7ef20554f65feb81c183eba2922f25 -size 917 diff --git a/proteus/tests/MeshAdaptPUMI/test_parallelMeshLoad.py b/proteus/tests/MeshAdaptPUMI/test_parallelMeshLoad.py deleted file mode 100644 index 6d382e8478..0000000000 --- a/proteus/tests/MeshAdaptPUMI/test_parallelMeshLoad.py +++ /dev/null @@ -1,57 +0,0 @@ -from ctypes import * -from proteus import MeshTools -from proteus import cmeshTools -from proteus import Domain -from proteus.MeshAdaptPUMI import MeshAdapt -from proteus import Comm -import os -from petsc4py import PETSc -import pytest - -#Run these tests with `mpirun -n 2 py.test --boxed test_parallelMeshLoad.py` - -@pytest.mark.skip(reason="need to run in parallel,also files are too large") -def test_3DparallelLoadPUMI(verbose=0): - """Test to load 3D parallel PUMI model and mesh""" - comm = Comm.init() - eq(comm.size(),2) - testDir=os.path.dirname(os.path.abspath(__file__)) - domain = Domain.PUMIDomain() - Model=testDir+ '/Prism.dmg' - Mesh=testDir + '/Prism.smb' - domain.PUMIMesh=MeshAdaptPUMI.MeshAdaptPUMI() - domain.PUMIMesh.loadModelAndMesh(bytes(Model,'utf-8'), bytes(Mesh,'utf-8')) - mesh = MeshTools.TetrahedralMesh() - mesh.cmesh = cmeshTools.CMesh() - mesh.convertFromPUMI(domain.PUMIMesh, domain.faceList, domain.regList,parallel = comm.size() > 1, dim = domain.nd) - eq(mesh.nElements_global,8148) - eq(mesh.nNodes_global,1880) - eq(mesh.nEdges_global,11001) - eq(mesh.nElementBoundaries_global,17270) - #Ideally, we can assert whether each rank gets the proper number of mesh entities/ - #With the present setup, that information doesn't seem accessible - #if(comm.rank()==0): - # eq(mesh.nElements_owned,4074) - # eq(mesh.nNodes_owned,994) - # eq(mesh.nEdges_owned,8729) - # eq(mesh.nElementBoundaries_owned,5648) - -@pytest.mark.skip(reason="need to run in parallel") -def test_2DparallelLoadPUMI(verbose=0): - """Test to load 2D parallel PUMI model and mesh""" - comm = Comm.init() - eq(comm.size(),2) - testDir=os.path.dirname(os.path.abspath(__file__)) - domain = Domain.PUMIDomain(dim=2) - Model=testDir+ '/Rectangle.dmg' - Mesh=testDir + '/Rectangle.smb' - domain.PUMIMesh=MeshAdaptPUMI.MeshAdaptPUMI() - domain.PUMIMesh.loadModelAndMesh(bytes(Model,'utf-8'), bytes(Mesh,'utf-8')) - mesh = MeshTools.TriangularMesh() - mesh.cmesh = cmeshTools.CMesh() - mesh.convertFromPUMI(domain,domain.PUMIMesh, domain.faceList, domain.regList,parallel = comm.size() > 1, dim = domain.nd) - assert mesh.nElements_global == 8 - assert mesh.nNodes_global == 10 - assert mesh.nEdges_global == 17 - assert mesh.nElementBoundaries_global == 17 - diff --git a/proteus/tests/TADR/comparison_files/tadr_level_0_EV1_u_t2.csv b/proteus/tests/TADR/comparison_files/tadr_level_0_EV1_u_t2.csv deleted file mode 100644 index 24e8dc815a..0000000000 --- a/proteus/tests/TADR/comparison_files/tadr_level_0_EV1_u_t2.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:3b0a4f16dcb5e9d0529ab4ba7585a1325d3a8e58c27311532799ae94bf68f1d6 -size 449 diff --git a/proteus/tests/TADR/comparison_files/tadr_level_0_EV2_u_t2.csv b/proteus/tests/TADR/comparison_files/tadr_level_0_EV2_u_t2.csv deleted file mode 100644 index 36e2ab3cb3..0000000000 --- a/proteus/tests/TADR/comparison_files/tadr_level_0_EV2_u_t2.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:3b44436a37a058c5e25ee31c471df35ca36c611a03c786313fc720549d7b2833 -size 444 diff --git a/proteus/tests/TADR/comparison_files/tadr_level_0_SUPG_u_t2.csv b/proteus/tests/TADR/comparison_files/tadr_level_0_SUPG_u_t2.csv deleted file mode 100644 index 042b5680da..0000000000 --- a/proteus/tests/TADR/comparison_files/tadr_level_0_SUPG_u_t2.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:27b08076a947c5ba5f50c2d993eaf8fdd9fd7c6171166298a8ad49809e776659 -size 445 diff --git a/proteus/tests/TADR/comparison_files/tadr_level_0_SmoothnessBased_u_t2.csv b/proteus/tests/TADR/comparison_files/tadr_level_0_SmoothnessBased_u_t2.csv deleted file mode 100644 index 4b7b78e121..0000000000 --- a/proteus/tests/TADR/comparison_files/tadr_level_0_SmoothnessBased_u_t2.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2f536bd5a5ffc4bcb784d5612e5897bed6b6e005ba0789472ee6ba659b6fb698 -size 447 diff --git a/proteus/tests/TADR/comparison_files/tadr_level_0_TaylorGalerkin_u_t2.csv b/proteus/tests/TADR/comparison_files/tadr_level_0_TaylorGalerkin_u_t2.csv deleted file mode 100644 index e169a893a3..0000000000 --- a/proteus/tests/TADR/comparison_files/tadr_level_0_TaylorGalerkin_u_t2.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f0d9801a4c5eb10f49a28c6d6ffc24ca60b8ee0f6eee5f5e4689526162921144 -size 439 diff --git a/proteus/tests/TADR/comparison_files/tadr_level_0_stab4_u_t2.csv b/proteus/tests/TADR/comparison_files/tadr_level_0_stab4_u_t2.csv deleted file mode 100644 index 9e37b88c26..0000000000 --- a/proteus/tests/TADR/comparison_files/tadr_level_0_stab4_u_t2.csv +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:93b6a48bbef6dc73326cd4f143f6c5b14ffff73d876be224a025758443f269bc -size 439 diff --git a/proteus/tests/ci/hexMesh_3x3.mesh b/proteus/tests/ci/hexMesh_3x3.mesh deleted file mode 100644 index 0573e29a51..0000000000 --- a/proteus/tests/ci/hexMesh_3x3.mesh +++ /dev/null @@ -1,93 +0,0 @@ -HEX -64 27 --3.000000000000000000e+00 -3.000000000000000000e+00 -3.000000000000000000e+00 --1.000000000000000000e+00 -3.000000000000000000e+00 -3.000000000000000000e+00 -1.000000000000000000e+00 -3.000000000000000000e+00 -3.000000000000000000e+00 -3.000000000000000000e+00 -3.000000000000000000e+00 -3.000000000000000000e+00 --3.000000000000000000e+00 -1.000000000000000000e+00 -3.000000000000000000e+00 --1.000000000000000000e+00 -1.000000000000000000e+00 -3.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 -3.000000000000000000e+00 -3.000000000000000000e+00 -1.000000000000000000e+00 -3.000000000000000000e+00 --3.000000000000000000e+00 1.000000000000000000e+00 -3.000000000000000000e+00 --1.000000000000000000e+00 1.000000000000000000e+00 -3.000000000000000000e+00 -1.000000000000000000e+00 1.000000000000000000e+00 -3.000000000000000000e+00 -3.000000000000000000e+00 1.000000000000000000e+00 -3.000000000000000000e+00 --3.000000000000000000e+00 3.000000000000000000e+00 -3.000000000000000000e+00 --1.000000000000000000e+00 3.000000000000000000e+00 -3.000000000000000000e+00 -1.000000000000000000e+00 3.000000000000000000e+00 -3.000000000000000000e+00 -3.000000000000000000e+00 3.000000000000000000e+00 -3.000000000000000000e+00 --3.000000000000000000e+00 -3.000000000000000000e+00 -1.000000000000000000e+00 --1.000000000000000000e+00 -3.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 -3.000000000000000000e+00 -1.000000000000000000e+00 -3.000000000000000000e+00 -3.000000000000000000e+00 -1.000000000000000000e+00 --3.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 --1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 -3.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 --3.000000000000000000e+00 1.000000000000000000e+00 -1.000000000000000000e+00 --1.000000000000000000e+00 1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 1.000000000000000000e+00 -1.000000000000000000e+00 -3.000000000000000000e+00 1.000000000000000000e+00 -1.000000000000000000e+00 --3.000000000000000000e+00 3.000000000000000000e+00 -1.000000000000000000e+00 --1.000000000000000000e+00 3.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 3.000000000000000000e+00 -1.000000000000000000e+00 -3.000000000000000000e+00 3.000000000000000000e+00 -1.000000000000000000e+00 --3.000000000000000000e+00 -3.000000000000000000e+00 1.000000000000000000e+00 --1.000000000000000000e+00 -3.000000000000000000e+00 1.000000000000000000e+00 -1.000000000000000000e+00 -3.000000000000000000e+00 1.000000000000000000e+00 -3.000000000000000000e+00 -3.000000000000000000e+00 1.000000000000000000e+00 --3.000000000000000000e+00 -1.000000000000000000e+00 1.000000000000000000e+00 --1.000000000000000000e+00 -1.000000000000000000e+00 1.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 1.000000000000000000e+00 -3.000000000000000000e+00 -1.000000000000000000e+00 1.000000000000000000e+00 --3.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 --1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 -1.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 -3.000000000000000000e+00 1.000000000000000000e+00 1.000000000000000000e+00 --3.000000000000000000e+00 3.000000000000000000e+00 1.000000000000000000e+00 --1.000000000000000000e+00 3.000000000000000000e+00 1.000000000000000000e+00 -1.000000000000000000e+00 3.000000000000000000e+00 1.000000000000000000e+00 -3.000000000000000000e+00 3.000000000000000000e+00 1.000000000000000000e+00 --3.000000000000000000e+00 -3.000000000000000000e+00 3.000000000000000000e+00 --1.000000000000000000e+00 -3.000000000000000000e+00 3.000000000000000000e+00 -1.000000000000000000e+00 -3.000000000000000000e+00 3.000000000000000000e+00 -3.000000000000000000e+00 -3.000000000000000000e+00 3.000000000000000000e+00 --3.000000000000000000e+00 -1.000000000000000000e+00 3.000000000000000000e+00 --1.000000000000000000e+00 -1.000000000000000000e+00 3.000000000000000000e+00 -1.000000000000000000e+00 -1.000000000000000000e+00 3.000000000000000000e+00 -3.000000000000000000e+00 -1.000000000000000000e+00 3.000000000000000000e+00 --3.000000000000000000e+00 1.000000000000000000e+00 3.000000000000000000e+00 --1.000000000000000000e+00 1.000000000000000000e+00 3.000000000000000000e+00 -1.000000000000000000e+00 1.000000000000000000e+00 3.000000000000000000e+00 -3.000000000000000000e+00 1.000000000000000000e+00 3.000000000000000000e+00 --3.000000000000000000e+00 3.000000000000000000e+00 3.000000000000000000e+00 --1.000000000000000000e+00 3.000000000000000000e+00 3.000000000000000000e+00 -1.000000000000000000e+00 3.000000000000000000e+00 3.000000000000000000e+00 -3.000000000000000000e+00 3.000000000000000000e+00 3.000000000000000000e+00 -1 17 21 5 0 16 20 4 0 -2 18 22 6 1 17 21 5 0 -6 7 23 22 2 3 19 18 0 -5 21 25 9 4 20 24 8 0 -6 22 26 10 5 21 25 9 0 -10 11 27 26 6 7 23 22 0 -9 25 29 13 8 24 28 12 0 -10 26 30 14 9 25 29 13 0 -26 30 31 27 10 14 15 11 0 -17 33 37 21 16 32 36 20 0 -18 34 38 22 17 33 37 21 0 -22 23 39 38 18 19 35 34 0 -21 37 41 25 20 36 40 24 0 -22 38 42 26 21 37 41 25 0 -26 27 43 42 22 23 39 38 0 -25 41 45 29 24 40 44 28 0 -26 42 46 30 25 41 45 29 0 -42 46 47 43 26 30 31 27 0 -33 49 53 37 32 48 52 36 0 -34 50 54 38 33 49 53 37 0 -38 39 55 54 34 35 51 50 0 -37 53 57 41 36 52 56 40 0 -38 54 58 42 37 53 57 41 0 -42 43 59 58 38 39 55 54 0 -41 57 61 45 40 56 60 44 0 -42 58 62 46 41 57 61 45 0 -43 59 63 47 42 58 62 46 0 diff --git a/proteus/tests/cylinder2D/conforming_rans3p/cylinder_so.py b/proteus/tests/cylinder2D/conforming_rans3p/cylinder_so.py deleted file mode 100644 index 70bc73eac0..0000000000 --- a/proteus/tests/cylinder2D/conforming_rans3p/cylinder_so.py +++ /dev/null @@ -1,99 +0,0 @@ -import proteus.default_so -from importlib import reload -reload(proteus.default_so) -from proteus.default_so import * -try: - from . import cylinder -except: - import cylinder -reload(cylinder) - -from proteus.SplitOperator import Sequential_FixedStep_Simple, defaultSystem - -if cylinder.sedimentDynamics: - pnList = [("vos_p", "vos_n"),#0 - ("vof_p", "vof_n"),#1 - ("ls_p", "ls_n"),#2 - ("redist_p", "redist_n"),#3 - ("ls_consrv_p", "ls_consrv_n"),#4 - ("threep_navier_stokes_sed_p", "threep_navier_stokes_sed_n"),#5 - ("twp_navier_stokes_p", "twp_navier_stokes_n"),#6 - ("pressureincrement_p", "pressureincrement_n"),#7 - ("pressure_p", "pressure_n"),#8 - ("pressureInitial_p", "pressureInitial_n")]#9 - cylinder.VOS_model=0 - cylinder.VOF_model=1 - cylinder.LS_model=2 - cylinder.RD_model=3 - cylinder.MCORR_model=4 - cylinder.SED_model=5 - cylinder.V_model=6 - cylinder.PINC_model=7 - cylinder.PRESSURE_model=8 - cylinder.PINIT_model=9 -else: -# pnList = [("vof_p", "vof_n"),#0 -# ("ls_p", "ls_n"),#1 -# ("redist_p", "redist_n"),#2 -# ("ls_consrv_p", "ls_consrv_n"),#3 -# ("twp_navier_stokes_p", "twp_navier_stokes_n"),#4 -# ("pressureincrement_p", "pressureincrement_n"),#5 -# ("pressure_p", "pressure_n"),#6 -# ("pressureInitial_p", "pressureInitial_n")]#7 -# cylinder.VOS_model=None -# cylinder.SED_model=None -# cylinder.VOF_model=0 -# cylinder.LS_model=1 -# cylinder.RD_model=2 -# cylinder.MCORR_model=3 -# cylinder.V_model=4 -# cylinder.PINC_model=5 -# cylinder.PRESSURE_model=6 -# cylinder.PINIT_model=7 - pnList = [("twp_navier_stokes_p", "twp_navier_stokes_n"),#0 - ("pressureincrement_p", "pressureincrement_n"),#1 - ("pressure_p", "pressure_n"),#2 - ("pressureInitial_p", "pressureInitial_n")]#3 - - cylinder.VOF_model=None - cylinder.VOS_model=None - cylinder.SED_model=None - cylinder.V_model=0 - cylinder.PINC_model=1 - cylinder.PRESSURE_model=2 - cylinder.PINIT_model=3 - -# if cylinder.useRANS > 0: -# pnList.append(("kappa_p", -# "kappa_n")) -# pnList.append(("dissipation_p", -# "dissipation_n")) -name = "cylinder" -soname=name -#modelSpinUpList = [cylinder.VOF_model, cylinder.LS_model, cylinder.V_model, cylinder.PINIT_model] -modelSpinUpList = [cylinder.PINIT_model] - -class Sequential_MinAdaptiveModelStepPS(Sequential_MinAdaptiveModelStep): - def __init__(self,modelList,system=defaultSystem,stepExact=True): - Sequential_MinAdaptiveModelStep.__init__(self,modelList,system,stepExact) - self.modelList = modelList[:len(pnList)-1] - -class Sequential_MinAdaptiveModelStepPS(Sequential_FixedStep): - def __init__(self,modelList,system=defaultSystem,stepExact=True): - Sequential_FixedStep.__init__(self,modelList,system,stepExact) - self.modelList = modelList[:len(pnList)-1] - -dt_system_fixed = cylinder.dt_fixed -systemStepControllerType = Sequential_MinAdaptiveModelStepPS - -needEBQ_GLOBAL = False -needEBQ = False - -systemStepExact=False - -tnList = cylinder.tnList - - - -info = open("TimeList.txt","w") -#archiveFlag = ArchiveFlags.EVERY_SEQUENCE_STEP diff --git a/proteus/tests/cylinder2D/ibm_method/cylinder_so.py b/proteus/tests/cylinder2D/ibm_method/cylinder_so.py deleted file mode 100644 index a130a1af96..0000000000 --- a/proteus/tests/cylinder2D/ibm_method/cylinder_so.py +++ /dev/null @@ -1,103 +0,0 @@ -from __future__ import absolute_import -import proteus.default_so -from importlib import reload -reload(proteus.default_so) -from proteus.default_so import * -try: - from . import cylinder -except: - import cylinder -reload(cylinder) - -from proteus.SplitOperator import Sequential_FixedStep_Simple, defaultSystem - -if cylinder.sedimentDynamics: - pnList = [("vos_p", "vos_n"),#0 - ("vof_p", "vof_n"),#1 - ("ls_p", "ls_n"),#2 - ("redist_p", "redist_n"),#3 - ("ls_consrv_p", "ls_consrv_n"),#4 - ("threep_navier_stokes_sed_p", "threep_navier_stokes_sed_n"),#5 - ("twp_navier_stokes_p", "twp_navier_stokes_n"),#6 - ("pressureincrement_p", "pressureincrement_n"),#7 - ("pressure_p", "pressure_n"),#8 - ("pressureInitial_p", "pressureInitial_n")]#9 - cylinder.VOS_model=0 - cylinder.VOF_model=1 - cylinder.LS_model=2 - cylinder.RD_model=3 - cylinder.MCORR_model=4 - cylinder.SED_model=5 - cylinder.V_model=6 - cylinder.PINC_model=7 - cylinder.PRESSURE_model=8 - cylinder.PINIT_model=9 -else: -# pnList = [("vof_p", "vof_n"),#0 -# ("ls_p", "ls_n"),#1 -# ("redist_p", "redist_n"),#2 -# ("ls_consrv_p", "ls_consrv_n"),#3 -# ("twp_navier_stokes_p", "twp_navier_stokes_n"),#4 -# ("pressureincrement_p", "pressureincrement_n"),#5 -# ("pressure_p", "pressure_n"),#6 -# ("pressureInitial_p", "pressureInitial_n")]#7 -# cylinder.VOS_model=None -# cylinder.SED_model=None -# cylinder.VOF_model=0 -# cylinder.LS_model=1 -# cylinder.RD_model=2 -# cylinder.MCORR_model=3 -# cylinder.V_model=4 -# cylinder.PINC_model=5 -# cylinder.PRESSURE_model=6 -# cylinder.PINIT_model=7 - - pnList = [("twp_navier_stokes_p", "twp_navier_stokes_n"),#0 - ("pressureincrement_p", "pressureincrement_n"),#1 - ("pressure_p", "pressure_n"),#2 - ("pressureInitial_p", "pressureInitial_n")]#3 - - cylinder.VOF_model=None - cylinder.VOS_model=None - cylinder.SED_model=None - cylinder.V_model=0 - cylinder.PINC_model=1 - cylinder.PRESSURE_model=2 - cylinder.PINIT_model=3 - -if cylinder.useRANS > 0: - pnList.append(("kappa_p", - "kappa_n")) - pnList.append(("dissipation_p", - "dissipation_n")) -name = "cylinder" -soname=name -#modelSpinUpList = [cylinder.VOF_model, cylinder.LS_model, cylinder.V_model, cylinder.PINIT_model] -modelSpinUpList = [cylinder.PINIT_model] - -# class Sequential_MinAdaptiveModelStepPS(Sequential_MinAdaptiveModelStep): -# def __init__(self,modelList,system=defaultSystem,stepExact=True): -# Sequential_MinAdaptiveModelStep.__init__(self,modelList,system,stepExact) -# self.modelList = modelList[:len(pnList)-1] - - -class Sequential_MinAdaptiveModelStepPS(Sequential_FixedStep): - def __init__(self,modelList,system=defaultSystem,stepExact=True): - Sequential_FixedStep.__init__(self,modelList,system,stepExact) - self.modelList = modelList[:len(pnList)-1] - -dt_system_fixed = cylinder.dt_fixed -systemStepControllerType = Sequential_MinAdaptiveModelStepPS - -# systemStepControllerType = Sequential_FixedStep #Sequential_FixedStep_Simple # uses time steps in so.tnList -# dt_system_fixed = 0.01; -systemStepExact=False - - -needEBQ_GLOBAL = False -needEBQ = False - -# tnList = [0.0,cylinder.dt_init]+[i*cylinder.dt_fixed for i in range(1,cylinder.nDTout+1)] -tnList = cylinder.tnList -info = open("TimeList.txt","w") -#archiveFlag = ArchiveFlags.EVERY_SEQUENCE_STEP diff --git a/proteus/tests/cylinder2D/sbm_3Dmesh/__init__.py b/proteus/tests/cylinder2D/sbm_3Dmesh/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/proteus/tests/cylinder2D/sbm_method/__init__.py b/proteus/tests/cylinder2D/sbm_method/__init__.py deleted file mode 100644 index 8c74671af9..0000000000 --- a/proteus/tests/cylinder2D/sbm_method/__init__.py +++ /dev/null @@ -1,76 +0,0 @@ -""" -Modules for computing numerical solutions of differential equations -""" - -try: - import pkg_resources - pkg_resources.declare_namespace(__name__) -except ImportError: - import pkgutil - __path__ = pkgutil.extend_path(__path__, __name__) - -__version__ = '1.4.2' - -__all__ = ["Archiver", - "Domain", - "InputTranslators", - "SplitOperator", - "StepControl", - "NumericalSolution", - "Comm", - "AnalyticalSolutions", - "TransportCoefficients", - "TwophaseDarcyCoefficients", - "DiagUtils", - "EGeometry", - "ErrorEstimators", - "FemTools", - "LatexReport", - "LinearAlgebraTools", - "LinearSolvers", - "MeshTools", - "NonlinearSolvers", - "Norms", - "NumericalFlux", - "PostProcessingTools", - "Profiling", - "Quadrature", - "RefUtils", - "ShockCapturing", - "SimTools", - "SubgridError", - "SubsurfaceTransportCoefficients", - "StupidHeap", - "TimeIntegration", - "Transport", - "TriangleTools", - "UnstructuredFMMandFSWsolvers", - "Viewers", - "AuxiliaryVariables", - "deim_utils", - "default_p", - "default_n", - "default_s", - "default_so", - "InputTranslators", - "cfemIntegrals", - "cshockCapturing", - "csmoothers", - "csubgridError", - "ctimeIntegration", - "ctransportCoefficients", - "clapack", - "superluWrappers", - "triangleWrappers", - "testStuff", - "testStuffImpl", - "cmeshTools", - "cnumericalFlux", - "cfmmfsw", - "cTwophaseDarcyCoefficients", - "ADR", - "deim_utils", - "WaveTools", - "Context", - "BoundaryConditions", - "SpatialTools"] diff --git a/proteus/tests/elliptic_redist/RDLS/__init__.py b/proteus/tests/elliptic_redist/RDLS/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/proteus/tests/elliptic_redist/RDLS3P/__init__.py b/proteus/tests/elliptic_redist/RDLS3P/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/proteus/tests/elliptic_redist/__init__.py b/proteus/tests/elliptic_redist/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/proteus/tests/griffiths_lane_6/__init__.py b/proteus/tests/griffiths_lane_6/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/proteus/tests/levelset/__init__.py b/proteus/tests/levelset/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/proteus/tests/levelset/rotation/__init__.py b/proteus/tests/levelset/rotation/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/proteus/tests/levelset/vortex/__init__.py b/proteus/tests/levelset/vortex/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/proteus/tests/levelset/vortex2D/__init__.py b/proteus/tests/levelset/vortex2D/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/proteus/tests/linalgebra_tests/__init__.py b/proteus/tests/linalgebra_tests/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/proteus/tests/matrix_constructor/__init__.py b/proteus/tests/matrix_constructor/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/proteus/tests/matrix_constructor/import_modules/__init__.py b/proteus/tests/matrix_constructor/import_modules/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/proteus/tests/mesh_tests/__init__.py b/proteus/tests/mesh_tests/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/proteus/tests/mesh_tests/import_modules/__init__.py b/proteus/tests/mesh_tests/import_modules/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/proteus/tests/periodic/__init__.py b/proteus/tests/periodic/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/proteus/tests/periodic/comparison_files/__init__.py b/proteus/tests/periodic/comparison_files/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/proteus/tests/periodic/petsc/__init__.py b/proteus/tests/periodic/petsc/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/proteus/tests/periodic/petsc/petsc.options.schur.selfp_petsc.superlu b/proteus/tests/periodic/petsc/petsc.options.schur.selfp_petsc.superlu deleted file mode 100644 index 7cd8242c47..0000000000 --- a/proteus/tests/periodic/petsc/petsc.options.schur.selfp_petsc.superlu +++ /dev/null @@ -1,40 +0,0 @@ -# use a Schur Complement for the first set of solves - -#set petsc ksp object and preconditioner -#-log_view --rans2p_ksp_type gmres --rans2p_ksp_gmres_modifiedgramschmidt 1 --rans2p_ksp_gmres_restart 500 -#-rans2p_ksp_pc_side right - -# pc options --rans2p_pc_fieldsplit_type schur --rans2p_pc_fieldsplit_schur_fact_type upper --rans2p_pc_fieldsplit_schur_precondition selfp - -# pressure block options --rans2p_fieldsplit_pressure_ksp_type preonly # This should always be turned on -#-rans2p_fieldsplit_pressure_ksp_monitor_true_residual -#-rans2p_fieldsplit_pressure_ksp_max_it 1 --rans2p_fieldsplit_pressure_pc_type hypre --rans2p_fieldsplit_pressure_pc_hypre_type boomeramg --rans2p_fieldsplit_pressure_pc_constant_null_space 1 -#-rans2p_fieldsplit_pressure_pc_hypre_boomeramg_coarsen_type PMIS -#-rans2p_fieldsplit_pressure_pc_hypre_boomeramg_interp_type classical -#-rans2p_fieldsplit_pressure_pc_factor_mat_solver_type superlu_dist - -# direct solver for velocity block - ksp options --rans2p_fieldsplit_velocity_ksp_type preonly --rans2p_fieldsplit_velocity_pc_type lu --rans2p_fieldsplit_velocity_pc_factor_mat_solver_type superlu_dist -#-fieldsplit_velocity_ksp_view -#-fieldsplit_velocity_ksp_monitor_true_residual -#-fieldsplit_velocity_ksp_converged_reason - --ncls_ksp_type preonly -ncls_pc_type lu -ncls_pc_factor_mat_solver_type superlu_dist --vof_ksp_type preonly -vof_pc_type lu -vof_pc_factor_mat_solver_type superlu_dist --rdls_ksp_type preonly -rdls_pc_type lu -rdls_pc_factor_mat_solver_type superlu_dist --mcorr_ksp_type preonly -mcorr_pc_type lu -mcorr_pc_factor_mat_solver_type superlu_dist --kappa_ksp_type preonly -kappa_pc_type lu -kappa_pc_factor_mat_solver_type superlu_dist --dissipation_ksp_type preonly -dissipation_pc_type lu -dissipation_pc_factor_mat_solver_type superlu_dist --mesh_ksp_type preonly -mesh_pc_type lu -mesh_pc_factor_mat_solver_type superlu_dist \ No newline at end of file diff --git a/proteus/tests/poisson_2d/__init__.py b/proteus/tests/poisson_2d/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/proteus/tests/post_processing/__init__.py b/proteus/tests/post_processing/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/proteus/tests/post_processing/import_modules/__init__.py b/proteus/tests/post_processing/import_modules/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/proteus/tests/single_phase_gw/__init__.py b/proteus/tests/single_phase_gw/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/proteus/tests/solver_tests/__init__.py b/proteus/tests/solver_tests/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/proteus/tests/solver_tests/import_modules/__init__.py b/proteus/tests/solver_tests/import_modules/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/proteus/tests/surface_tension/__init__.py b/proteus/tests/surface_tension/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/__init__.py b/proteus/tests/surface_tension/rising_bubble_rans3p/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/proteus/tests/wave_tests/__init__.py b/proteus/tests/wave_tests/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/pyproject.toml b/pyproject.toml index 8cff2542b8..26ecdf30aa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,3 @@ [build-system] -requires = ["setuptools>=61.0","cython==3.0.0","pybind11==2.11.1","numpy==1.25.1"]#"h5py","numpy","scipy","pybind11","swig"]#"petsc4py","mpi4py", +requires = ["setuptools>=61.0","cython==3.0.0","pybind11==2.11.1","numpy==1.25.1","mpi4py"]#"h5py","numpy","scipy","pybind11","swig"]#"petsc4py","mpi4py", build-backend = "setuptools.build_meta" diff --git a/scripts/H5toXMF.py b/scripts/H5toXMF.py index 78ea4af13b..0e5e42a3ac 100644 --- a/scripts/H5toXMF.py +++ b/scripts/H5toXMF.py @@ -1,11 +1,6 @@ -from __future__ import print_function - - #import numpy #import os #from xml.etree.ElementTree import * -from builtins import str -from builtins import range import tables #from Xdmf import * diff --git a/scripts/KueperFrindGenPoly.py b/scripts/KueperFrindGenPoly.py index 35604a145a..0a8e196ce8 100644 --- a/scripts/KueperFrindGenPoly.py +++ b/scripts/KueperFrindGenPoly.py @@ -1,9 +1,6 @@ #!/usr/bin/env python -from __future__ import division -from builtins import range -from past.utils import old_div nBlocks = 22 -blockLeft = [0.0, old_div(0.7,3.0), 0.0, 0.0, 0.05, 0.1, 0.2, 0.5, 0.6, 0.2, 0.45, 0.65, 0.25, 0.1, 0.05, 0.1, 0.5, 0.1, 0.2, 0.35, 0.1, 0.35] +blockLeft = [0.0, 0.7/3.0, 0.0, 0.0, 0.05, 0.1, 0.2, 0.5, 0.6, 0.2, 0.45, 0.65, 0.25, 0.1, 0.05, 0.1, 0.5, 0.1, 0.2, 0.35, 0.1, 0.35] blockRight = [0.7, 2.0*0.7/3.0,0.7, 0.05, 0.1, 0.2, 0.45, 0.65, 0.65, 0.5, 0.5, 0.7, 0.35, 0.6, 0.65, 0.2, 0.6, 0.25, 0.5, 0.6, 0.6, 0.6] blockFront = [0.0, 0.45, 0.0, 0.05, 0.05, 0.05, 0.1, 0.05, 0.15, 0.05, 0.1, 0.05, 0.2, 0.3, 0.4, 0.35, 0.35, 0.2, 0.35, 0.2, 0.15, 0.25] blockBack = [0.5, 0.5, 0.05, 0.5 , 0.4, 0.15, 0.15, 0.15, 0.4, 0.1, 0.15, 0.5, 0.3, 0.35, 0.5, 0.4, 0.4, 0.3, 0.4, 0.25, 0.2, 0.3] diff --git a/scripts/UTEPblock.py b/scripts/UTEPblock.py index 0bfc6e3d38..65cab2373c 100644 --- a/scripts/UTEPblock.py +++ b/scripts/UTEPblock.py @@ -1,13 +1,10 @@ #!/usr/bin/env python -from __future__ import division -from builtins import range -from past.utils import old_div import numpy Lx=1.0; Ly=1.0; nx=128; ny=128; #nx=16; ny=16; -dx=old_div(Lx,nx); dy = old_div(Ly,ny) +dx=Lx/nx; dy = Ly/ny vertices = [] for j in range(ny+1): diff --git a/scripts/adh2ensight.py b/scripts/adh2ensight.py index aaa9c623b1..6d9d72217d 100755 --- a/scripts/adh2ensight.py +++ b/scripts/adh2ensight.py @@ -1,7 +1,4 @@ #! /usr/bin/env python -from __future__ import print_function -from builtins import zip -from builtins import range from numpy import * import proteus from proteus.MeshTools import * diff --git a/scripts/clearh5.py b/scripts/clearh5.py index 7de825a427..264e853491 100755 --- a/scripts/clearh5.py +++ b/scripts/clearh5.py @@ -1,7 +1,4 @@ #!/usr/bin/env python - -from builtins import str -from builtins import range import numpy import os from xml.etree.ElementTree import * diff --git a/scripts/cobras_saj_embankment.py b/scripts/cobras_saj_embankment.py index 6394cd6aec..68b069a200 100644 --- a/scripts/cobras_saj_embankment.py +++ b/scripts/cobras_saj_embankment.py @@ -1,5 +1,4 @@ #! /usr/bin/env python -from builtins import range import math diff --git a/scripts/cobras_wave_flume_1.py b/scripts/cobras_wave_flume_1.py index 88ff34334e..cad28d08fd 100644 --- a/scripts/cobras_wave_flume_1.py +++ b/scripts/cobras_wave_flume_1.py @@ -130,4 +130,4 @@ poly.write("#regions \n") for i,reg in enumerate(porous_regions.keys()): poly.write('%d %12.5e %12.5e %d #%s \n' % (i+1,porous_regions[reg][0]+xshift,porous_regions[reg][1]+yshift,porous_regions[reg][2],reg)) -poly.close() +poly.close() \ No newline at end of file diff --git a/scripts/extractSolution.py b/scripts/extractSolution.py index b6bc2bb7b5..1f426bd6db 100644 --- a/scripts/extractSolution.py +++ b/scripts/extractSolution.py @@ -1,8 +1,4 @@ #!/usr/bin/env python - -from __future__ import print_function -from builtins import str -from builtins import range import tables import os import sys diff --git a/scripts/extractWaterline.py b/scripts/extractWaterline.py index b69f425026..fb26e2a55a 100755 --- a/scripts/extractWaterline.py +++ b/scripts/extractWaterline.py @@ -1,9 +1,4 @@ #!/usr/bin/env python - -from __future__ import division -from builtins import str -from builtins import range -from past.utils import old_div from numpy import * @@ -13,7 +8,7 @@ def interpolate(master,slave1,slave2): x = master[0] - alpha = old_div((x-slave1[0]),(slave2[0]-slave1[0])) + alpha = (x-slave1[0])/(slave2[0]-slave1[0]) y = 0.5*(abs(master[1]) + abs((1.0-alpha)*slave1[1] + alpha*slave2[1]) ) z = 0.5*(master[2] + (1.0-alpha)*slave1[2] + alpha*slave2[2] ) diff --git a/scripts/fixLongInt.py b/scripts/fixLongInt.py index b88306af14..5a95806bf6 100755 --- a/scripts/fixLongInt.py +++ b/scripts/fixLongInt.py @@ -9,4 +9,4 @@ "PyArray_INT") fh = open(f,'w') fh.write(fstr) - fh.close() + fh.close() \ No newline at end of file diff --git a/scripts/fixNames.py b/scripts/fixNames.py index fb727d2411..2996efcb70 100644 --- a/scripts/fixNames.py +++ b/scripts/fixNames.py @@ -15,4 +15,4 @@ #nstart=nf.find('n.py') #nf = nf[:dstart]+nf[dstart+3:nstart]+'2d'+nf[nstart:] #print nf - system('svn mv '+f+' '+nf) + system('svn mv '+f+' '+nf) \ No newline at end of file diff --git a/scripts/fixNumericalFlux.py b/scripts/fixNumericalFlux.py index 3b6ccf5edc..4b2903203f 100755 --- a/scripts/fixNumericalFlux.py +++ b/scripts/fixNumericalFlux.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -from __future__ import print_function import glob files = glob.glob('*.py') print(files) diff --git a/scripts/fixNumpy.py b/scripts/fixNumpy.py index 1df1c96dc9..d789255392 100755 --- a/scripts/fixNumpy.py +++ b/scripts/fixNumpy.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -from __future__ import print_function import glob files = glob.glob('*.py') print(files) diff --git a/scripts/fixNumpyAsNumpy.py b/scripts/fixNumpyAsNumpy.py index a85a9188a5..38d9e82ccb 100755 --- a/scripts/fixNumpyAsNumpy.py +++ b/scripts/fixNumpyAsNumpy.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -from __future__ import print_function import glob files = glob.glob('*.py') print(files) diff --git a/scripts/fixNumpyImport.py b/scripts/fixNumpyImport.py index b918d1cead..304ca41d61 100755 --- a/scripts/fixNumpyImport.py +++ b/scripts/fixNumpyImport.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -from __future__ import print_function import glob files = glob.glob('*.py') print(files) diff --git a/scripts/fixNumpyInclude.py b/scripts/fixNumpyInclude.py index e6d5977191..428559bb84 100644 --- a/scripts/fixNumpyInclude.py +++ b/scripts/fixNumpyInclude.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -from __future__ import print_function import glob files = glob.glob('*.c') + glob.glob('*.cpp') + glob.glob('*.h') print(files) diff --git a/scripts/fixRavel.py b/scripts/fixRavel.py index 7acb2dbf7d..bcde2e071f 100755 --- a/scripts/fixRavel.py +++ b/scripts/fixRavel.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -from __future__ import print_function import glob files = glob.glob('*.py') print(files) diff --git a/scripts/fixTypeCodes.py b/scripts/fixTypeCodes.py index 7a5d905421..8c9a2bfa34 100755 --- a/scripts/fixTypeCodes.py +++ b/scripts/fixTypeCodes.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -from __future__ import print_function import glob files = glob.glob('*.py') print(files) diff --git a/scripts/fixWith.py b/scripts/fixWith.py index ec98b6422b..ec5dc5ced1 100755 --- a/scripts/fixWith.py +++ b/scripts/fixWith.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -from __future__ import print_function import glob files = glob.glob('*.py') print(files) diff --git a/scripts/fix_n.py b/scripts/fix_n.py index a1ab86ef4b..6a765eeef4 100644 --- a/scripts/fix_n.py +++ b/scripts/fix_n.py @@ -19,4 +19,4 @@ line = line[:start]+'ladr'+line[start+6:]+'\n' #stdout.write(line) nf.write(line) - nf.close() + nf.close() \ No newline at end of file diff --git a/scripts/gatherArchives.py b/scripts/gatherArchives.py index 0ae53c325e..4924d6879b 100755 --- a/scripts/gatherArchives.py +++ b/scripts/gatherArchives.py @@ -1,11 +1,4 @@ #!/usr/bin/env python - -from __future__ import print_function -from __future__ import division -from builtins import zip -from builtins import str -from builtins import range -from past.utils import old_div import numpy import os from xml.etree.ElementTree import * @@ -130,7 +123,7 @@ def gatherSplitTimeStepXDMFfilesOpt(size,filename,dataDir='.',addname="_all",nSt if nStepsOnly != None: nSteps = nStepsOnly print("nSteps",nSteps) - stepsToGather=[i*stride for i in range(old_div(nSteps,stride))] + stepsToGather=[i*stride for i in range(nSteps//stride)] for tn in stepsToGather: fAll = open(os.path.join(dataDir,filename+"_t"+str(tn) + addname+str(size)+".xmf"),"w") fAll.write(r""" @@ -230,4 +223,4 @@ def gatherSplitTimeStepXDMFfilesOpt(size,filename,dataDir='.',addname="_all",nSt elif opts.splitTimeSteps: gatherSplitTimeStepXDMFfilesOpt(opts.size,opts.filebase,opts.dataDir,opts.append,opts.nStepsOnly,opts.mStride) else: - gatherXDMFfilesOpt(opts.size,opts.filebase,opts.dataDir,opts.append,opts.nStepsOnly,opts.mStride) + gatherXDMFfilesOpt(opts.size,opts.filebase,opts.dataDir,opts.append,opts.nStepsOnly,opts.mStride) \ No newline at end of file diff --git a/scripts/gatherTimes b/scripts/gatherTimes index 7d1ff6f1aa..34b052b4d2 100755 --- a/scripts/gatherTimes +++ b/scripts/gatherTimes @@ -1,7 +1,4 @@ #!/usr/bin/env python - -from builtins import str -from builtins import range import numpy import os from xml.etree.ElementTree import * diff --git a/scripts/gen3Dfiles.py b/scripts/gen3Dfiles.py index c6b3804ef3..79971a9b76 100755 --- a/scripts/gen3Dfiles.py +++ b/scripts/gen3Dfiles.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -from __future__ import print_function from glob import glob from os import system from sys import stdout,argv diff --git a/scripts/genMesh.py b/scripts/genMesh.py index f0a246f9d9..f6bf5d00f2 100755 --- a/scripts/genMesh.py +++ b/scripts/genMesh.py @@ -1,6 +1,4 @@ #! /usr/bin/env python -from __future__ import print_function -from builtins import range import proteus from proteus.MeshTools import * ## \ingroup scripts diff --git a/scripts/genProto.py b/scripts/genProto.py index 4e887da226..8cc828ea63 100755 --- a/scripts/genProto.py +++ b/scripts/genProto.py @@ -33,4 +33,4 @@ new_contents = contents.replace('const const','const') hf.write(new_contents) hf.close() -os.system('indent %s' % (fileRoot+'.h',)) +os.system('indent %s' % (fileRoot+'.h',)) \ No newline at end of file diff --git a/scripts/gen_eqp.py b/scripts/gen_eqp.py index 441820d700..b22e670bc5 100644 --- a/scripts/gen_eqp.py +++ b/scripts/gen_eqp.py @@ -117,4 +117,4 @@ f.write("""}//equivalent_polynomials #endif """) -f.close() +f.close() \ No newline at end of file diff --git a/scripts/gen_eqp_quad.py b/scripts/gen_eqp_quad.py index 8c4363a744..3c273ef293 100644 --- a/scripts/gen_eqp_quad.py +++ b/scripts/gen_eqp_quad.py @@ -126,4 +126,4 @@ def simplify(expression): f.write("""}//equivalent_polynomials #endif """) -f.close() +f.close() \ No newline at end of file diff --git a/scripts/intSliceFromBin.py b/scripts/intSliceFromBin.py index b69ca71ee1..461eaef32f 100755 --- a/scripts/intSliceFromBin.py +++ b/scripts/intSliceFromBin.py @@ -1,9 +1,4 @@ -from __future__ import division -## Automatically adapted for numpy.oldnumeric Apr 14, 2008 by -c - #!/usr/bin/env python -from builtins import range -from past.utils import old_div import numpy as numpy #path to input file #nx=300; ny=300; @@ -61,7 +56,7 @@ #set up funcs to build R,G,and B arrays from the gray scale 0,1,2 data then use merge('RGB') to build color image #experiment with writing to a file that triangle can mesh -L=(1.0,1.0); dx=old_div(L[0],nx); dy=old_div(L[1],ny); +L=(1.0,1.0); dx=L[0]/nx; dy=L[1]/ny; base=1 # #generate segments that connect different colors and record these? diff --git a/scripts/makeOsherAnimation.py b/scripts/makeOsherAnimation.py index fccd5e4603..f347fcdf9b 100644 --- a/scripts/makeOsherAnimation.py +++ b/scripts/makeOsherAnimation.py @@ -1,9 +1,3 @@ -from __future__ import print_function -from __future__ import division -## Automatically adapted for numpy.oldnumeric Apr 14, 2008 by -c - -from builtins import str -from past.utils import old_div import sys import os import Gnuplot @@ -23,7 +17,7 @@ while (i <= totalNumberOfIndex): - time = T_start + i*( old_div((T_stop-T_start),totalNumberOfIndex) ) + time = T_start + i*( (T_stop-T_start)/totalNumberOfIndex ) g = Gnuplot.Gnuplot(debug=1) g('set style data lines') @@ -34,7 +28,7 @@ PlotTitle = "S_e vs x at time: " + str(time) g.title(PlotTitle) g('set term postscript eps enhanced color solid') - Fraction = old_div(float(time),float(T_stop)) + FudgeFactor + Fraction = float(time)/float(T_stop) + FudgeFactor outFile = 'set output \"' + str('Se') + 'plotFraction' + str(Fraction) + 'MakeAnimations.eps\"' g(outFile) Plot = 'plot \'' + str(datFile) + '\' index ' + str(i) + ' title \"\"' diff --git a/scripts/marinExtractHeight.py b/scripts/marinExtractHeight.py index da0ccb70c0..418ae391fe 100755 --- a/scripts/marinExtractHeight.py +++ b/scripts/marinExtractHeight.py @@ -1,11 +1,4 @@ #! /usr/bin/env pvpython - -# for use with pvpython versions at least 4.4 -from __future__ import print_function -from __future__ import division -from builtins import str -from builtins import range -from past.utils import old_div from paraview import servermanager from paraview.simple import * from optparse import OptionParser diff --git a/scripts/marinExtractPressure.py b/scripts/marinExtractPressure.py index 5969a46c47..3dfc224d39 100755 --- a/scripts/marinExtractPressure.py +++ b/scripts/marinExtractPressure.py @@ -1,7 +1,4 @@ #! /usr/bin/env pvpython - -# for use with pvpython versions at least 4.4 -from builtins import str from paraview import servermanager from paraview.simple import * from optparse import OptionParser diff --git a/scripts/parun b/scripts/parun index d9574ef5bc..b260b64db6 100755 --- a/scripts/parun +++ b/scripts/parun @@ -12,11 +12,6 @@ # \brief A driver for both single and mult-model simulations # # - -from __future__ import print_function -from builtins import zip -from builtins import str -from builtins import range import os import proteus @@ -26,7 +21,7 @@ from warnings import * import optparse import sys -usage = "usage: %prog [options] main.py [soModule.py] [pModule.py nModule.py]" +usage = "usage: %prog [options] [main.py] [soModule.py] [pModule.py nModule.py]" parser = optparse.OptionParser(usage=usage) parser.add_option("-I", "--inspect", help="Inspect namespace at 't0','user_step'", diff --git a/scripts/petsc_config_linux.sh b/scripts/petsc_config_linux.sh new file mode 100755 index 0000000000..879f9d81db --- /dev/null +++ b/scripts/petsc_config_linux.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +./configure --prefix=${HOME}/proteus/petsc-dev --CC=/usr/bin/gcc --CXX=/usr/bin/g++ --FC=/usr/bin/gfortran --download-openmpi --download-openmpi-configure-arguments="--with-cuda" --with-numpy --with-petsc4py --download-mpi4py --with-cuda-dir=/usr/local/cuda-12.5 --with-cuda --download-superlu --download-superlu_dist --download-mumps --download-eigen --download-ctetgen --download-tetgen --download-gmsh --download-hdf5 --download-hdf5-configure-arguments="--enable-parallel" --download-hypre --download-libceed --download-metis --download-parmetis --download-opencascade --download-suitesparse --download-scalapack --download-szlib --download-zlib --with-python-exec=/usr/bin/python --download-triangle --download-yaml --download-zoltan --with-debugging=0 \ No newline at end of file diff --git a/scripts/petsc_config_linux_conda_seq.sh b/scripts/petsc_config_linux_conda_seq.sh new file mode 100755 index 0000000000..3fbe7ee050 --- /dev/null +++ b/scripts/petsc_config_linux_conda_seq.sh @@ -0,0 +1,2 @@ +#!/bin/bash +PETSC_DIR=${PWD} PETSC_ARCH=arch-linux-conda-seq-opt ./configure --prefix=${CONDA_PREFIX} --CC=$CC --CFLAGS="$CFLAGS" --CXX=$CXX --CXXFLAGS="$CXXFLAGS" --FC=$FC --FFLAGS="$FFLAGS" --F77=$F77 --F90=$F90 --CPP=$CPP --CPPFLAGS="$CPPFLAGS" --LDFLAGS="$LDFLAGS" --RANLIB=$RANLIB --AR=$AR --download-openmpi --download-openmpi --with-openblas --with-openblas-dir=${CONDA_PREFIX} --with-openmp --download-superlu --download-superlu_dist --download-mumps --download-eigen --download-ctetgen --download-tetgen --download-gmsh --download-hdf5 --download-hdf5-configure-arguments="--enable-parallel" --download-hypre --download-libceed --download-metis --download-parmetis --download-opencascade --download-suitesparse --download-scalapack --download-szlib --download-zlib --download-triangle --download-yaml --download-zoltan --download-kokkos --with-debugging=0 diff --git a/scripts/petsc_config_linux_distro_cuda.sh b/scripts/petsc_config_linux_distro_cuda.sh new file mode 100755 index 0000000000..a619cd9101 --- /dev/null +++ b/scripts/petsc_config_linux_distro_cuda.sh @@ -0,0 +1,2 @@ +#!/bin/bash +PETSC_DIR=${PWD} PETSC_ARCH=arch-linux-cuda-opt ./configure --prefix=${HOME}/petsc-venv --CC=/usr/bin/gcc --CXX=/usr/bin/g++ --FC=/usr/bin/gfortran --download-openmpi --download-openmpi-configure-arguments="--with-cuda=/usr/local/cuda-12.5" --with-cuda --with-cuda-dir=/usr/local/cuda-12.5 --download-superlu --download-superlu_dist --download-mumps --download-eigen --download-ctetgen --download-tetgen --download-gmsh --download-hdf5 --download-hdf5-configure-arguments="--enable-parallel" --download-hypre --download-libceed --download-metis --download-parmetis --download-opencascade --download-suitesparse --download-scalapack --download-szlib --download-zlib --download-triangle --download-yaml --download-zoltan --with-debugging=0 diff --git a/scripts/petsc_config_osx_conda.sh b/scripts/petsc_config_osx_conda.sh new file mode 100755 index 0000000000..363a7c2a7d --- /dev/null +++ b/scripts/petsc_config_osx_conda.sh @@ -0,0 +1,2 @@ +#!/bin/bash +./configure PETSC_ARCH=arch-darwin-conda-c-opt --prefix=${CONDA_PREFIX} --CC=${CC_FOR_BUILD} --with-cxx-dialect="c++17" --CXX=${CXX_FOR_BUILD} --FC=${FC_FOR_BUILD} --download-mpich --with-numpy --with-petsc4py --download-superlu --download-superlu_dist --download-mumps --download-eigen --download-ctetgen --download-tetgen --download-gmsh --download-hdf5 --download-hdf5-configure-arguments="--enable-parallel" --download-hypre --download-metis --download-parmetis --download-opencascade --download-suitesparse --download-scalapack --download-szlib --download-zlib --with-python-exec=${HOME}/proteus/petsc-dev/bin/python --download-triangle --download-yaml --download-zoltan --download-mpi4py --download-openblas --download-openblas-use-pthreads --with-pthread --download-kokkos --download-kokkos-kernels --with-debugging=0 diff --git a/scripts/petsc_config_osx_noconda.sh b/scripts/petsc_config_osx_noconda.sh new file mode 100755 index 0000000000..7f9050cde1 --- /dev/null +++ b/scripts/petsc_config_osx_noconda.sh @@ -0,0 +1,2 @@ +#!/bin/bash +./configure PETSC_ARCH=arch-darwin-noconda-c-opt --prefix=${HOME}/petsc-dev --CC=clang COPTFLAGS="-O2" --CXX=clang++ --with-cxx-dialect="c++17" CXXOPTFLAGS="-O2" --FC=/usr/local/bin/gfortran FOPTFLAGS="-O2" --download-mpich --with-numpy --with-petsc4py --download-superlu --download-superlu_dist --download-mumps --download-eigen --download-ctetgen --download-tetgen --download-gmsh --download-hdf5 --download-hdf5-configure-arguments="--enable-parallel" --download-hypre --download-metis --download-parmetis --download-opencascade --download-suitesparse --download-scalapack --download-szlib --download-zlib --with-python-exec=${HOME}/proteus/petsc-dev/bin/python --download-triangle --download-yaml --download-zoltan --download-mpi4py --download-openblas --download-openblas-use-pthreads --with-pthread --download-kokkos --download-kokkos-kernels --with-debugging=0 diff --git a/scripts/pome_gen_poly.py b/scripts/pome_gen_poly.py index 21e77a5cb2..51c8173e94 100755 --- a/scripts/pome_gen_poly.py +++ b/scripts/pome_gen_poly.py @@ -1,6 +1,3 @@ -from __future__ import print_function -from builtins import zip -from builtins import range import math n_domain_vertices = 100 domain_vertices =[(0.75*math.sin(2.0*math.pi*float(n)/float(n_domain_vertices))+0.5,0.75*math.cos(2.0*math.pi*float(n)/float(n_domain_vertices))+0.5) for n in range(n_domain_vertices)] diff --git a/scripts/povgen.py b/scripts/povgen.py index 928b4798a5..b541afbc87 100755 --- a/scripts/povgen.py +++ b/scripts/povgen.py @@ -2,7 +2,6 @@ """ A script for generating povray frames of zero level set """ -from builtins import range import argparse import tables import numpy as np diff --git a/scripts/ppmatlab.py b/scripts/ppmatlab.py index aa756acd81..b7f3dae2bd 100644 --- a/scripts/ppmatlab.py +++ b/scripts/ppmatlab.py @@ -1,7 +1,5 @@ ## Automatically adapted for numpy.oldnumeric Apr 14, 2008 by -c - -from builtins import range def writeMeshMatlabFormat(mesh,meshFileBase): """ build array data structures for matlab finite element mesh representation diff --git a/scripts/pyadhDat2Gif.py b/scripts/pyadhDat2Gif.py index ae0fb1281b..291d852996 100644 --- a/scripts/pyadhDat2Gif.py +++ b/scripts/pyadhDat2Gif.py @@ -1,5 +1,3 @@ -from __future__ import print_function -from __future__ import division ## Automatically adapted for numpy.oldnumeric Apr 14, 2008 by -c #! /usr/bin/env python @@ -22,8 +20,6 @@ #John Chrispell, Summer 07 #modified by cek -from builtins import str -from past.utils import old_div import sys import os import Gnuplot @@ -119,7 +115,7 @@ PlotTitle = "Time: " + str(time) g.title(PlotTitle) g('set term postscript eps enhanced color solid') - Fraction = old_div(float(time),float(FinalTime)) + FudgeFactor + Fraction = float(time)/float(FinalTime) + FudgeFactor outFile = 'set output \"' + str(Variable) + 'plotFraction' + str(Fraction) + 'MakeAnimations.eps\"' g(outFile) Plot = 'plot \'' + str(datFile) + '\' index ' + str(i) + ' title \"\"' diff --git a/scripts/pyadhGui.py b/scripts/pyadhGui.py index ccbf9d613f..0905a24b8c 100755 --- a/scripts/pyadhGui.py +++ b/scripts/pyadhGui.py @@ -12,14 +12,6 @@ # \brief driver for single model simulations # # -from __future__ import print_function -from __future__ import division -from future import standard_library -standard_library.install_aliases() -from builtins import str -from builtins import input -from builtins import range -from past.utils import old_div import os import sys import socket @@ -657,7 +649,7 @@ def runProblem(pName,p,n,opts,simFlags=None): ctemp=mlTransport.modelList[-1].coefficients.allocateDummyCoefficients(c=mlTransport.modelList[-1].q) mlTransport.modelList[-1].coefficients.plotCoefficientFunctions(mlTransport.modelList[-1].T,ctemp) timeValues = [tn] - dt = old_div(p.T,n.nDTout) + dt = p.T/n.nDTout #mwf debug print("""proteusRun T=%g nDTout= %d dt=%g """ % (p.T,n.nDTout,dt)) failedFlag=False diff --git a/scripts/pyadhRun.py b/scripts/pyadhRun.py index a4c4fce673..c4c8a0f7c0 100755 --- a/scripts/pyadhRun.py +++ b/scripts/pyadhRun.py @@ -12,14 +12,6 @@ # \brief driver for single model simulations # # -from __future__ import print_function -from __future__ import division -from future import standard_library -standard_library.install_aliases() -from builtins import str -from builtins import input -from builtins import range -from past.utils import old_div import os import sys import socket @@ -700,7 +692,7 @@ def runProblem(pName,p,n,opts,simFlags=None): ctemp=mlTransport.modelList[-1].coefficients.allocateDummyCoefficients(c=mlTransport.modelList[-1].q) mlTransport.modelList[-1].coefficients.plotCoefficientFunctions(mlTransport.modelList[-1].T,ctemp) timeValues = [tn] - dt = old_div(p.T,n.nDTout) + dt = p.T/n.nDTout #mwf debug print("""proteusRun T=%g nDTout= %d dt=%g """ % (p.T,n.nDTout,dt)) failedFlag=False diff --git a/scripts/pyadhRunSSO.py b/scripts/pyadhRunSSO.py index ae18577aa2..080f0d09f5 100755 --- a/scripts/pyadhRunSSO.py +++ b/scripts/pyadhRunSSO.py @@ -1,13 +1,4 @@ -from __future__ import print_function -## Automatically adapted for numpy.oldnumeric Apr 14, 2008 by -c - #! /usr/bin/env python -from future import standard_library -standard_library.install_aliases() -from builtins import str -from builtins import input -from builtins import zip -from builtins import range import os ## need to insert more comments diff --git a/scripts/pyadhRunSSONew.py b/scripts/pyadhRunSSONew.py index dda0d99368..950615001b 100755 --- a/scripts/pyadhRunSSONew.py +++ b/scripts/pyadhRunSSONew.py @@ -1,14 +1,4 @@ #!/usr/bin/env python - -from __future__ import print_function -from __future__ import division -from future import standard_library -standard_library.install_aliases() -from builtins import str -from builtins import input -from builtins import zip -from builtins import range -from past.utils import old_div import os import sys import socket @@ -638,7 +628,7 @@ def runProblems(pNameAll,pNameList,pList,nList,opts,simFlagsList=None): timeValues = [tnList[opts.masterModel]] failedFlag=False mM = mList[opts.masterModel] - dt = old_div(pList[opts.masterModel].T,nList[opts.masterModel].nDTout) + dt = pList[opts.masterModel].T/nList[opts.masterModel].nDTout dtInit=1.0e-5 print("master T",pList[opts.masterModel].T) print("master nDTout",nList[opts.masterModel].nDTout) diff --git a/scripts/pyadhRunSSONew2.py b/scripts/pyadhRunSSONew2.py index cb7a2f4fa4..37562c8d85 100755 --- a/scripts/pyadhRunSSONew2.py +++ b/scripts/pyadhRunSSONew2.py @@ -1,15 +1,4 @@ -from __future__ import print_function -from __future__ import division -## Automatically adapted for numpy.oldnumeric Apr 14, 2008 by -c - #! /usr/bin/env python -from future import standard_library -standard_library.install_aliases() -from builtins import str -from builtins import input -from builtins import zip -from builtins import range -from past.utils import old_div import os import sys import pickle @@ -523,7 +512,7 @@ def runProblems(pNameAll,pNameList,pList,nList,opts,simFlagsList=None): timeValues = [tnList[opts.masterModel]] failedFlag=False mM = mList[opts.masterModel] - dt = old_div(pList[opts.masterModel].T,nList[opts.masterModel].nDTout) + dt = pList[opts.masterModel].T/nList[opts.masterModel].nDTout print("dt",dt) firstStep=True for n,ti,tn in zip(nList,timeIntegratorList,tnList): diff --git a/scripts/readFun.py b/scripts/readFun.py index 95308dadcc..135d0d29d0 100755 --- a/scripts/readFun.py +++ b/scripts/readFun.py @@ -1,6 +1,4 @@ #! /usr/bin/env python -from __future__ import print_function -from builtins import range from numpy import * import proteus from proteus.MeshTools import * diff --git a/scripts/readFunDump.py b/scripts/readFunDump.py index 0a6efb3468..856442855f 100755 --- a/scripts/readFunDump.py +++ b/scripts/readFunDump.py @@ -1,6 +1,4 @@ #! /usr/bin/env python -from __future__ import print_function -from builtins import range from numpy import * import proteus from proteus.MeshTools import * diff --git a/scripts/readFunLite.py b/scripts/readFunLite.py index 30d1073248..3b0e67eb63 100755 --- a/scripts/readFunLite.py +++ b/scripts/readFunLite.py @@ -1,6 +1,4 @@ #! /usr/bin/env python -from __future__ import print_function -from builtins import range from numpy import * import proteus from proteus.MeshTools import * diff --git a/scripts/readMesh.py b/scripts/readMesh.py index 5bf5956df8..3711e9cee3 100755 --- a/scripts/readMesh.py +++ b/scripts/readMesh.py @@ -1,6 +1,4 @@ #! /usr/bin/env python -from __future__ import print_function -from builtins import input import proteus from proteus.MeshTools import * diff --git a/scripts/removeNumpyHeader.py b/scripts/removeNumpyHeader.py index 1f7ee84481..cae00c6257 100755 --- a/scripts/removeNumpyHeader.py +++ b/scripts/removeNumpyHeader.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -from __future__ import print_function import glob files = glob.glob('*.py') print(files) diff --git a/scripts/renameFiles.py b/scripts/renameFiles.py index 34c4b02389..a2452878b7 100755 --- a/scripts/renameFiles.py +++ b/scripts/renameFiles.py @@ -31,4 +31,4 @@ line = 'from '+newName+'_p import *\n' #stdout.write(line) nf.write(line) -nf.close() +nf.close() \ No newline at end of file diff --git a/scripts/replacePYADH.py b/scripts/replacePYADH.py index 0370124b7d..95db087e18 100755 --- a/scripts/replacePYADH.py +++ b/scripts/replacePYADH.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -from __future__ import print_function import glob files = glob.glob('*.py') + glob.glob('*.cpp') + glob.glob('*.c') + glob.glob('*.h') + glob.glob('*.pxd') print(files) diff --git a/scripts/runAll.py b/scripts/runAll.py index f71c5d93e6..1565e93c66 100755 --- a/scripts/runAll.py +++ b/scripts/runAll.py @@ -1,5 +1,4 @@ #! /usr/bin/env python -from __future__ import print_function import sys import os import glob diff --git a/scripts/runSWEs.py b/scripts/runSWEs.py index e6d3fb7e29..bb2b19012c 100755 --- a/scripts/runSWEs.py +++ b/scripts/runSWEs.py @@ -62,4 +62,4 @@ " -v " + opts.fileName + context_opts + - dataDir) + dataDir) \ No newline at end of file diff --git a/scripts/testCBPT.py b/scripts/testCBPT.py index a4579c5226..987bc96eab 100644 --- a/scripts/testCBPT.py +++ b/scripts/testCBPT.py @@ -1,10 +1,4 @@ #! /usr/bin/env python - -from __future__ import print_function -from __future__ import division -from builtins import input -from builtins import range -from past.utils import old_div from proteus import * import numpy def generateTrajectories(mesh,v,x_source,t_0,t_f): @@ -14,8 +8,8 @@ def generateTrajectories(mesh,v,x_source,t_0,t_f): x_0 = x_traj[-1]; t_0 = t_traj[-1]; e_0 = e_traj[-1] x_1 = mesh.nodeArray[mesh.elementNodesArray[e_0,1],0] x_12 = 0.5*(x_0+x_1) - t_12= t_0 + old_div((x_12-x_0),v) #include midpoint to test search alg - t_1 = t_0 + old_div((x_1-x_0),v) + t_12= t_0 + (x_12-x_0)/v #include midpoint to test search alg + t_1 = t_0 + (x_1-x_0)/v e_12= e_0 e_1 = mesh.elementNeighborsArray[e_0,0] if e_1 == -1: e_1 = e_0 @@ -64,7 +58,7 @@ def test_onesource(nx=11,Lx=1.0,ndt=20,q=1.0,theta=1.0,timeflag=0,testflag=0,plo mesh.generateEdgeMeshFromRectangularGrid(nx,Lx) #assume uniform porosity and velocity to make tracking simple - v = old_div(q,theta); + v = q/theta; #source located at inflow, track over [t_0,t_f] with one particle x_source = 0.0; t_0 = 0.0; t_f=1.0; n_p = 1; @@ -98,7 +92,7 @@ def test_onesource(nx=11,Lx=1.0,ndt=20,q=1.0,theta=1.0,timeflag=0,testflag=0,plo ct.fill(0.0) accumulateSourceContribution(tau,traj_offsets,x_traj,t_traj,e_traj,massSource_t,massSource_m,decay,retardation,particleFlags,ct) ct /= aqueousVolume - caq = old_div(ct,retardation[:,0]) + caq = ct/retardation[:,0] if plotSolution: ax = pylab.plot(xc,caq,'r*-',xc,ct,'bo-',hold=False); pylab.legend(('c_aq','c_t')); pylab.title('tau= %s ' % tau) if wait4plot: diff --git a/scripts/update_n.py b/scripts/update_n.py index c56d3521b1..7e86a59155 100755 --- a/scripts/update_n.py +++ b/scripts/update_n.py @@ -32,4 +32,4 @@ nf.write(line) else: nf.write(line) - nf.close() + nf.close() \ No newline at end of file diff --git a/scripts/update_p.py b/scripts/update_p.py index e17a1fff73..6f98d486d8 100755 --- a/scripts/update_p.py +++ b/scripts/update_p.py @@ -19,4 +19,4 @@ pass else: pf.write(line) -pf.close() +pf.close() \ No newline at end of file diff --git a/scripts/utepRes2text.py b/scripts/utepRes2text.py index b8a3afa6cd..db93a3b974 100755 --- a/scripts/utepRes2text.py +++ b/scripts/utepRes2text.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -from __future__ import print_function def printFinalSolutionToFile(resFileName,outputFileName, key='u_dof',component=0,meshLevel=0,verbose=0): """ diff --git a/scripts/weir_gen_poly.py b/scripts/weir_gen_poly.py index 81c0bf4782..df16549f0e 100755 --- a/scripts/weir_gen_poly.py +++ b/scripts/weir_gen_poly.py @@ -1,5 +1,3 @@ -from builtins import zip -from builtins import range import math vertices = [ ('bottom_left' , (0.0,0.0)), ('weir_bottom_left' , (0.8 + 1.5 + 6.66,0.0)), diff --git a/setup.py b/setup.py index b14e655d7d..4416461774 100644 --- a/setup.py +++ b/setup.py @@ -55,6 +55,7 @@ def get_xtensor_include(): return [str(get_pybind_include()), str(get_pybind_include(user=True)), str(get_numpy_include()), + os.path.join(prefix, 'include'), os.path.join(sys.prefix, 'include'), os.path.join(sys.prefix, 'Library', 'include'), 'proteus', @@ -110,10 +111,10 @@ def __str__(self): language='c++', include_dirs=[numpy.get_include(),'include', 'proteus','proteus/MeshAdaptPUMI']+ - PROTEUS_SCOREC_INCLUDE_DIRS+PROTEUS_MPI_INCLUDE_DIRS, - library_dirs=PROTEUS_SCOREC_LIB_DIRS+PROTEUS_MPI_LIB_DIRS, - libraries=PROTEUS_SCOREC_LIBS+PROTEUS_MPI_LIBS, - extra_compile_args=PROTEUS_SCOREC_EXTRA_COMPILE_ARGS+PROTEUS_EXTRA_COMPILE_ARGS+PROTEUS_OPT, + PROTEUS_SCOREC_INCLUDE_DIRS, + library_dirs=PROTEUS_SCOREC_LIB_DIRS, + libraries=PROTEUS_SCOREC_LIBS, + extra_compile_args=['-std=c++17']+PROTEUS_SCOREC_EXTRA_COMPILE_ARGS+PROTEUS_EXTRA_COMPILE_ARGS+PROTEUS_OPT, extra_link_args=PROTEUS_SCOREC_EXTRA_LINK_ARGS+PROTEUS_EXTRA_LINK_ARGS), Extension( 'mprans.cArgumentsDict', @@ -297,7 +298,7 @@ def __str__(self): libraries=['ChronoEngine', 'stdc++', 'm'], - extra_compile_args=PROTEUS_CHRONO_CXX_FLAGS+PROTEUS_OPT, + extra_compile_args=["-std=c++17"]+PROTEUS_CHRONO_CXX_FLAGS+PROTEUS_OPT, extra_link_args=PROTEUS_EXTRA_LINK_ARGS), Extension("WaveTools", sources=['proteus/WaveTools.py'], @@ -601,7 +602,7 @@ def __str__(self): language="c++", library_dirs=PROTEUS_PETSC_LIB_DIRS+PROTEUS_MPI_LIB_DIRS+PROTEUS_HDF5_LIB_DIRS, libraries=['hdf5','stdc++','m']+PROTEUS_PETSC_LIBS+PROTEUS_MPI_LIBS+PROTEUS_HDF5_LIBS, - extra_compile_args=PROTEUS_EXTRA_COMPILE_ARGS + PROTEUS_PETSC_EXTRA_COMPILE_ARGS+PROTEUS_OPT, + extra_compile_args=['-std=c++17']+PROTEUS_EXTRA_COMPILE_ARGS + PROTEUS_PETSC_EXTRA_COMPILE_ARGS+PROTEUS_OPT, extra_link_args=PROTEUS_EXTRA_LINK_ARGS + PROTEUS_PETSC_EXTRA_LINK_ARGS, ), # Extension("flcbdfWrappers",["proteus/flcbdfWrappers.pyx"], @@ -796,7 +797,7 @@ def __str__(self): def setup_given_extensions(extensions): setup(name='proteus', - version='1.8.2.dev0', + version='1.8.3', classifiers=[ 'Development Status :: 4 - Beta', 'Environment :: Console', @@ -825,64 +826,13 @@ def setup_given_extensions(extensions): 'proteus.mbd', 'proteus.test_utils', 'proteus.config', - 'proteus.tests', - 'proteus.tests.ci', - 'proteus.tests.griffiths_lane_6', - 'proteus.tests.levelset', - 'proteus.tests.linalgebra_tests', - 'proteus.tests.LS_with_edgeBased_EV', - 'proteus.tests.LS_with_edgeBased_EV.VOF', - 'proteus.tests.LS_with_edgeBased_EV.NCLS', - 'proteus.tests.BernsteinPolynomials', - 'proteus.tests.BernsteinPolynomials.poisson_eqn', - 'proteus.tests.elliptic_redist', - 'proteus.tests.elliptic_redist.RDLS', - 'proteus.tests.elliptic_redist.RDLS3P', - 'proteus.tests.surface_tension', - 'proteus.tests.surface_tension.rising_bubble_rans3p', - 'proteus.tests.CLSVOF', - 'proteus.tests.CLSVOF.disc_ICs', - 'proteus.tests.CLSVOF.with_RANS2P', - 'proteus.tests.CLSVOF.with_RANS3PF', - 'proteus.tests.CLSVOF.pure_level_set', 'proteus.TwoPhaseFlow', 'proteus.TwoPhaseFlow.utils', - 'proteus.tests.TwoPhaseFlow', - 'proteus.tests.matrix_constructor', - 'proteus.tests.matrix_constructor.import_modules', 'proteus.SWFlow', 'proteus.SWFlow.utils', - 'proteus.tests.SWFlow', + 'proteus.SWFlow.models', 'proteus.MeshAdaptPUMI', 'proteus.MeshAdaptPUMI', - 'proteus.tests.MeshAdaptPUMI', - 'proteus.tests.MeshAdaptPUMI.gauge_compare.dambreak_Colagrossi_2D', - 'proteus.tests.mesh_tests', - 'proteus.tests.mesh_tests.import_modules', - 'proteus.tests.periodic', - 'proteus.tests.periodic.petsc', - 'proteus.tests.periodic.comparison_files', - 'proteus.tests.poisson_2d', - 'proteus.tests.post_processing', - 'proteus.tests.post_processing.import_modules', - 'proteus.tests.ProjScheme_with_EV', - 'proteus.tests.single_phase_gw', - 'proteus.tests.solver_tests', - 'proteus.tests.solver_tests.import_modules', - 'proteus.tests.solver_tests.comparison_files', - 'proteus.tests.cylinder2D', - 'proteus.tests.cylinder2D.conforming_rans2p', - 'proteus.tests.cylinder2D.conforming_rans3p', - 'proteus.tests.cylinder2D.ibm_method', - 'proteus.tests.cylinder2D.ibm_rans2p', - 'proteus.tests.cylinder2D.ibm_rans2p_3D', - 'proteus.tests.cylinder2D.sbm_method', - 'proteus.tests.cylinder2D.sbm_3Dmesh', - 'proteus.tests.HotStart_3P', - 'proteus.tests.AddedMass', - 'proteus.tests.FSI', - 'proteus.tests.MoveMeshMonitor', - 'proteus.tests.wave_tests', ], cmdclass = {'build_ext':custom_build_ext}, ext_package='proteus', @@ -894,91 +844,6 @@ def setup_given_extensions(extensions): 'proteus/ModelFactory.h', 'proteus/CompKernel.h' ]), - (os.path.join(proteus_install_path,'tests'), - ['proteus/tests/hex_cube_3x3.xmf', - 'proteus/tests/hex_cube_3x3.h5', - 'proteus/tests/sparse_mat_ex.mtx']), - (os.path.join(proteus_install_path,'tests','linalgebra_tests'), - ['proteus/tests/linalgebra_tests/sparse_mat_1.txt', - 'proteus/tests/linalgebra_tests/jac.bin']), - (os.path.join(proteus_install_path,'tests','griffiths_lane_6'), - []), - (os.path.join(proteus_install_path,'tests','levelset'), - []), - (os.path.join(proteus_install_path,'tests','ci','comparison_files'), - []), - (os.path.join(proteus_install_path,'tests','LS_with_edgeBased_EV','VOF','comparison_files'), - []), - (os.path.join(proteus_install_path,'tests','LS_with_edgeBased_EV','NCLS','comparison_files'), - []), - (os.path.join(proteus_install_path,'tests','BernsteinPolynomials','poisson_eqn','comparison_files'), - []), - (os.path.join(proteus_install_path,'tests','surface_tension','rising_bubble_rans3p','comparison_files'), - []), - (os.path.join(proteus_install_path,'tests','CLSVOF','disc_ICs','comparison_files'), - []), - (os.path.join(proteus_install_path,'tests','CLSVOF','pure_level_set','comparison_files'), - []), - (os.path.join(proteus_install_path,'tests','CLSVOF','with_RANS2P','comparison_files'), - []), - (os.path.join(proteus_install_path,'tests','CLSVOF','with_RANS3PF','comparison_files'), - []), - (os.path.join(proteus_install_path,'tests','TwoPhaseFlow','comparison_files'), - []), - (os.path.join(proteus_install_path,'tests','solver_tests','import_modules'), - []), - (os.path.join(proteus_install_path,'tests','mesh_tests','comparison_files'), - []), - (os.path.join(proteus_install_path,'tests','solver_tests_slow','comparison_files'), - []), - (os.path.join(proteus_install_path,'tests','matrix_constructor','comparison_files'), - []), - (os.path.join(proteus_install_path,'tests','periodic','petsc'), - []), - (os.path.join(proteus_install_path,'tests','periodic','comparison_files'), - []), - (os.path.join(proteus_install_path,'tests','post_processing','import_modules'), - []), - (os.path.join(proteus_install_path,'tests','post_processing','comparison_files'), - []), - (os.path.join(proteus_install_path,'tests','matrix_constructor','comparison_files'), - []), - (os.path.join(proteus_install_path,'tests','solver_tests_slow','comparison_files'), - []), - (os.path.join(proteus_install_path,'tests','solver_tests_slow','import_modules'), - []), - (os.path.join(proteus_install_path,'tests','solver_tests_mprans','comparison_files'), - []), - (os.path.join(proteus_install_path,'tests','MeshAdaptPUMI'), - []), - (os.path.join(proteus_install_path,'tests','MeshAdaptPUMI','gauge_compare','dambreak_Colagrossi_2D'), - []), - (os.path.join(proteus_install_path,'tests','poisson_2d'), - []), - (os.path.join(proteus_install_path,'tests','cylinder2D','conforming_rans3p','comparison_files'), - []), - (os.path.join(proteus_install_path,'tests','cylinder2D','ibm_method','comparison_files'), - []), - (os.path.join(proteus_install_path,'tests','cylinder2D','ibm_rans2p','comparison_files'), - []), - (os.path.join(proteus_install_path,'tests','cylinder2D','ibm_rans2p_3D','comparison_files'), - []), - (os.path.join(proteus_install_path,'tests','cylinder2D','sbm_method','comparison_files'), - []), - (os.path.join(proteus_install_path,'tests','cylinder2D','sbm_3Dmesh','comparison_files'), - []), - (os.path.join(proteus_install_path,'tests','cylinder2D','conforming_rans2p','comparison_files'), - []), - (os.path.join(proteus_install_path,'tests','HotStart_3P','comparison_files'), - []), - (os.path.join(proteus_install_path,'tests','AddedMass'), - []), - (os.path.join(proteus_install_path,'tests','FSI'), - []), - (os.path.join(proteus_install_path,'tests','MoveMeshMonitor'), - []), - (os.path.join(proteus_install_path,'tests','wave_tests'), - []) ], scripts = ['scripts/parun','scripts/gf2poly','scripts/gatherArchives.py','scripts/qtm','scripts/waves2xmf','scripts/povgen.py', 'scripts/velocity2xmf','scripts/run_script_garnet','scripts/run_script_diamond', @@ -1008,6 +873,9 @@ def setup_extensions_in_parallel(): logger.setLevel(logging.INFO) if "build_ext" in sys.argv: - setup_extensions_in_parallel() + try: + setup_extensions_in_parallel() + except: + setup_extensions_in_sequential() else: setup_extensions_in_sequential() diff --git a/stack b/stack deleted file mode 160000 index 7c82edb4ff..0000000000 --- a/stack +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7c82edb4ff5758e49f3299db6d62228ebad7be24 diff --git a/test/AddedMass/Aij_sol2D.csv b/test/AddedMass/Aij_sol2D.csv new file mode 100644 index 0000000000..581a4e84ca --- /dev/null +++ b/test/AddedMass/Aij_sol2D.csv @@ -0,0 +1,6 @@ +5.467542077319114924e+02,-1.419614648057176964e-09,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,2.839954049704829231e-09 +-3.874305321005522273e-09,5.465139680917136502e+02,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,5.684341886091141245e-14 +0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00 +0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00 +0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00 +0.000000000000000000e+00,-7.105427357601001859e-15,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,-1.033975765691284594e-25 diff --git a/test/AddedMass/Aij_sol3D.csv b/test/AddedMass/Aij_sol3D.csv new file mode 100644 index 0000000000..e32e76a349 --- /dev/null +++ b/test/AddedMass/Aij_sol3D.csv @@ -0,0 +1,6 @@ +6.544361935142883624e+01,-2.241016241603305481e+00,-2.241833606579757276e+00,-1.239316205214891149e-09,-2.373458565643541433e-12,-3.200673420328204878e-11 +-2.241016242128150981e+00,6.436291615610259953e+01,3.065701275669860948e-01,8.016799076434229005e-10,1.575383294343393220e-10,3.306741572697658243e-11 +-2.241833607201783263e+00,3.065701271639438286e-01,6.436387559974440364e+01,-2.546111469793239322e-14,-1.254834275923355161e-14,-6.095809447045743566e-15 +3.108624468950438313e-15,-1.598721155460225418e-14,-3.885780586188047891e-15,-2.584939414228211484e-25,-2.524354896707237777e-26,-8.077935669463160887e-27 +1.065814103640150279e-14,6.716849298982197070e-15,-1.421085471520200372e-14,1.292469707114105742e-26,3.231174267785264355e-27,-2.019483917365790222e-28 +0.000000000000000000e+00,9.769962616701377556e-15,-4.773959005888173124e-15,5.169878828456422968e-26,3.877409121342317226e-26,1.615587133892632177e-27 diff --git a/proteus/tests/AddedMass/__init__.py b/test/AddedMass/__init__.py similarity index 100% rename from proteus/tests/AddedMass/__init__.py rename to test/AddedMass/__init__.py diff --git a/proteus/tests/AddedMass/addedmass2D.py b/test/AddedMass/addedmass2D.py similarity index 89% rename from proteus/tests/AddedMass/addedmass2D.py rename to test/AddedMass/addedmass2D.py index 003bd881a4..57488ef6b9 100644 --- a/proteus/tests/AddedMass/addedmass2D.py +++ b/test/AddedMass/addedmass2D.py @@ -1,13 +1,10 @@ -from __future__ import print_function -from __future__ import division -from past.utils import old_div import numpy as np from proteus import Domain from proteus.mprans import SpatialTools as st from proteus.mbd import CouplingFSI as fsi +import pychrono as chrono from proteus.TwoPhaseFlow import TwoPhaseFlowProblem as tpf from proteus.TwoPhaseFlow.utils import Parameters -import pychrono as chrono import os rho_0 = 1000. @@ -25,11 +22,10 @@ tank_dim = [5.,5.] tank = st.Tank2D(domain, dim=tank_dim) -rect = st.Rectangle(domain, dim=[1.,1.], coords=[old_div(tank_dim[0],2.), old_div(tank_dim[1],2.)]) +rect = st.Rectangle(domain, dim=[1.,1.], coords=[tank_dim[0]/2., tank_dim[1]/2.]) rect.setHoles(holes=np.array([rect.coords])) domain.MeshOptions.he = he - # BOUNDARY CONDITIONS tank.BC['x+'].setNoSlip() @@ -45,11 +41,11 @@ # CHRONO system = fsi.ProtChSystem() -system.ChSystem.Set_G_acc(chrono.ChVectorD(g[0], g[1], 0.)) +system.ChSystem.SetGravitationalAcceleration(chrono.ChVector3d(g[0], g[1], 0.)) body = fsi.ProtChBody(system=system) body.attachShape(rect) body.ChBody.SetMass(500.) -body.ChBody.SetBodyFixed(True) # fixing body +body.ChBody.SetFixed(True) # fixing body # OTHER PARAMS st.assembleDomain(domain) @@ -98,9 +94,7 @@ def uOfXT(self,x,t): myTpFlowProblem.SystemNumerics.cfl = 0.4 myTpFlowProblem.SystemNumerics.useSuperlu=False - myTpFlowProblem.SystemPhysics.movingDomain = False - params = myTpFlowProblem.SystemPhysics # PHYSICAL PARAMETERS @@ -120,8 +114,8 @@ def uOfXT(self,x,t): myTpFlowProblem.SystemPhysics.modelDict['flow'].p.initialConditions['v']=AtRest() myTpFlowProblem.SystemPhysics.modelDict['addedMass'].p.initialConditions['addedMass']=AtRest() -m['flow'].p.coefficients.NONCONSERVATIVE_FORM=0.0 -m['flow'].p.coefficients.useVF=1.0 +m['flow'].p.coefficients.useVF = 1.0 +m['flow'].p.coefficients.NONCONSERVATIVE_FORM = 0.0 # auxiliary variables m['flow'].auxiliaryVariables += [system] @@ -138,6 +132,8 @@ def uOfXT(self,x,t): flags_rigidbody = np.zeros(max_flag+1, dtype='int32') for s in system.subcomponents: if type(s) is fsi.ProtChBody: - for flag in body.boundaryFlags: + for flag in s.boundaryFlags: flags_rigidbody[flag] = 1 m['addedMass'].p.coefficients.flags_rigidbody = flags_rigidbody +m['addedMass'].n.linTolFac=0.0 +m['addedMass'].n.l_atol_res=1.0e-10 diff --git a/proteus/tests/AddedMass/addedmass3D.py b/test/AddedMass/addedmass3D.py similarity index 90% rename from proteus/tests/AddedMass/addedmass3D.py rename to test/AddedMass/addedmass3D.py index ad616e58d6..3cfd57890a 100644 --- a/proteus/tests/AddedMass/addedmass3D.py +++ b/test/AddedMass/addedmass3D.py @@ -1,6 +1,3 @@ -from __future__ import print_function -from __future__ import division -from past.utils import old_div import numpy as np from proteus import Domain from proteus.mprans import SpatialTools as st @@ -25,9 +22,9 @@ nd=3 tank_dim = [5.,5.,5.] tank = st.Tank3D(domain, dim=tank_dim) -rect = st.Cuboid(domain, dim=[1.,1.,1.], coords=[old_div(tank_dim[0],2.), - old_div(tank_dim[1],2.), - old_div(tank_dim[2],2.)]) +rect = st.Cuboid(domain, dim=[1.,1.,1.], coords=[tank_dim[0]/2., + tank_dim[1]/2., + tank_dim[2]/2.]) rect.setHoles(holes=np.array([rect.coords])) domain.MeshOptions.he = he @@ -50,11 +47,11 @@ # CHRONO system = fsi.ProtChSystem() -system.ChSystem.Set_G_acc(chrono.ChVectorD(g[0], g[1], 0.)) +system.ChSystem.SetGravitationalAcceleration(chrono.ChVector3d(g[0], g[1], g[2])) body = fsi.ProtChBody(system=system) body.attachShape(rect) body.ChBody.SetMass(500.) -body.ChBody.SetBodyFixed(True) # fixing body +body.ChBody.SetFixed(True) # fixing body # OTHER PARAMS st.assembleDomain(domain) @@ -86,7 +83,6 @@ def __init__(self): def uOfXT(self,x,t): return 0.0 - # _ _ _ # | \ | |_ _ _ __ ___ ___ _ __(_) ___ ___ # | \| | | | | '_ ` _ \ / _ \ '__| |/ __/ __| @@ -105,7 +101,6 @@ def uOfXT(self,x,t): myTpFlowProblem.SystemPhysics.setDefaults() myTpFlowProblem.SystemNumerics.cfl = 0.4 - myTpFlowProblem.SystemNumerics.useSuperlu=False myTpFlowProblem.SystemPhysics.movingDomain = False @@ -150,4 +145,5 @@ def uOfXT(self,x,t): for flag in s.boundaryFlags: flags_rigidbody[flag] = 1 m['addedMass'].p.coefficients.flags_rigidbody = flags_rigidbody - +m['addedMass'].n.linTolFac=0.0 +m['addedMass'].n.l_atol_res=1.0e-10 diff --git a/proteus/tests/AddedMass/mesh2D.1.neigh b/test/AddedMass/mesh2D.1.neigh similarity index 100% rename from proteus/tests/AddedMass/mesh2D.1.neigh rename to test/AddedMass/mesh2D.1.neigh diff --git a/proteus/tests/AddedMass/mesh2D.1.poly b/test/AddedMass/mesh2D.1.poly similarity index 100% rename from proteus/tests/AddedMass/mesh2D.1.poly rename to test/AddedMass/mesh2D.1.poly diff --git a/proteus/tests/AddedMass/mesh2D.edge b/test/AddedMass/mesh2D.edge similarity index 100% rename from proteus/tests/AddedMass/mesh2D.edge rename to test/AddedMass/mesh2D.edge diff --git a/proteus/tests/AddedMass/mesh2D.ele b/test/AddedMass/mesh2D.ele similarity index 100% rename from proteus/tests/AddedMass/mesh2D.ele rename to test/AddedMass/mesh2D.ele diff --git a/proteus/tests/AddedMass/mesh2D.node b/test/AddedMass/mesh2D.node similarity index 100% rename from proteus/tests/AddedMass/mesh2D.node rename to test/AddedMass/mesh2D.node diff --git a/proteus/tests/AddedMass/mesh2D.poly b/test/AddedMass/mesh2D.poly similarity index 100% rename from proteus/tests/AddedMass/mesh2D.poly rename to test/AddedMass/mesh2D.poly diff --git a/proteus/tests/AddedMass/mesh3D.edge b/test/AddedMass/mesh3D.edge similarity index 100% rename from proteus/tests/AddedMass/mesh3D.edge rename to test/AddedMass/mesh3D.edge diff --git a/proteus/tests/AddedMass/mesh3D.ele b/test/AddedMass/mesh3D.ele similarity index 100% rename from proteus/tests/AddedMass/mesh3D.ele rename to test/AddedMass/mesh3D.ele diff --git a/proteus/tests/AddedMass/mesh3D.face b/test/AddedMass/mesh3D.face similarity index 100% rename from proteus/tests/AddedMass/mesh3D.face rename to test/AddedMass/mesh3D.face diff --git a/proteus/tests/AddedMass/mesh3D.neigh b/test/AddedMass/mesh3D.neigh similarity index 100% rename from proteus/tests/AddedMass/mesh3D.neigh rename to test/AddedMass/mesh3D.neigh diff --git a/proteus/tests/AddedMass/mesh3D.node b/test/AddedMass/mesh3D.node similarity index 100% rename from proteus/tests/AddedMass/mesh3D.node rename to test/AddedMass/mesh3D.node diff --git a/proteus/tests/AddedMass/mesh3D.poly b/test/AddedMass/mesh3D.poly similarity index 100% rename from proteus/tests/AddedMass/mesh3D.poly rename to test/AddedMass/mesh3D.poly diff --git a/proteus/tests/AddedMass/petsc.options.superlu_dist b/test/AddedMass/petsc.options.superlu_dist similarity index 73% rename from proteus/tests/AddedMass/petsc.options.superlu_dist rename to test/AddedMass/petsc.options.superlu_dist index 0267d2c759..e21c2a67f0 100644 --- a/proteus/tests/AddedMass/petsc.options.superlu_dist +++ b/test/AddedMass/petsc.options.superlu_dist @@ -1,9 +1,9 @@ --rans2p_ksp_type preonly -rans2p_pc_type lu -rans2p_pc_factor_mat_solver_type superlu_dist --ncls_ksp_type preonly -ncls_pc_type lu -ncls_pc_factor_mat_solver_type superlu_dist --vof_ksp_type preonly -vof_pc_type lu -vof_pc_factor_mat_solver_type superlu_dist --rdls_ksp_type preonly -rdls_pc_type lu -rdls_pc_factor_mat_solver_type superlu_dist --mcorr_ksp_type preonly -mcorr_pc_type lu -mcorr_pc_factor_mat_solver_type superlu_dist --kappa_ksp_type preonly -kappa_pc_type lu -kappa_pc_factor_mat_solver_type superlu_dist --dissipation_ksp_type preonly -dissipation_pc_type lu -dissipation_pc_factor_mat_solver_type superlu_dist --mesh_ksp_type preonly -mesh_pc_type lu -mesh_pc_factor_mat_solver_type superlu_dist +-rans2p_ksp_type preonly -rans2p_pc_type lu -rans2p_pc_factor_mat_solver_type superlu +-ncls_ksp_type preonly -ncls_pc_type lu -ncls_pc_factor_mat_solver_type superlu +-vof_ksp_type preonly -vof_pc_type lu -vof_pc_factor_mat_solver_type superlu +-rdls_ksp_type preonly -rdls_pc_type lu -rdls_pc_factor_mat_solver_type superlu +-mcorr_ksp_type preonly -mcorr_pc_type lu -mcorr_pc_factor_mat_solver_type superlu +-kappa_ksp_type preonly -kappa_pc_type lu -kappa_pc_factor_mat_solver_type superlu +-dissipation_ksp_type preonly -dissipation_pc_type lu -dissipation_pc_factor_mat_solver_type superlu +-mesh_ksp_type preonly -mesh_pc_type lu -mesh_pc_factor_mat_solver_type superlu -am_ksp_type cg -am_pc_type gamg -am_mg_coarse_ksp_type preonly -am_mg_coarse_pc_type svd diff --git a/proteus/tests/AddedMass/test_addedmass2D.py b/test/AddedMass/test_addedmass2D.py similarity index 93% rename from proteus/tests/AddedMass/test_addedmass2D.py rename to test/AddedMass/test_addedmass2D.py index b1d218d457..61376bd763 100644 --- a/proteus/tests/AddedMass/test_addedmass2D.py +++ b/test/AddedMass/test_addedmass2D.py @@ -1,7 +1,4 @@ #!/usr/bin/env python -from __future__ import print_function -from __future__ import absolute_import -from builtins import range import os from proteus.iproteus import * import unittest @@ -83,9 +80,9 @@ def test_AddedMass_2D(self): ns.calculateSolution('addedmass2D') Aij = am2D.body.Aij - #np.savetxt('Aij_sol2D.csv', Aij, delimiter=',') + np.savetxt('Aij_sol2D.csv', Aij, delimiter=',') Aij_sol = np.genfromtxt(os.path.join(modulepath, 'Aij_sol2D.csv'), delimiter=',') - npt.assert_almost_equal(Aij, Aij_sol, decimal=5) + npt.assert_allclose(Aij, Aij_sol, atol=1.0e-8, rtol=0.0) self.teardown_method(self) if __name__ == "__main__": diff --git a/proteus/tests/AddedMass/test_addedmass3D.py b/test/AddedMass/test_addedmass3D.py similarity index 89% rename from proteus/tests/AddedMass/test_addedmass3D.py rename to test/AddedMass/test_addedmass3D.py index 6f3e522b0e..97ea5ef5ae 100644 --- a/proteus/tests/AddedMass/test_addedmass3D.py +++ b/test/AddedMass/test_addedmass3D.py @@ -1,7 +1,4 @@ #!/usr/bin/env python -from __future__ import print_function -from __future__ import absolute_import -from builtins import range import os from proteus.iproteus import * import unittest @@ -34,11 +31,11 @@ def teardown_method(self, method): 'addedmass2D_so.log' 'addedmass3D_so.log' ] - #for file in FileList: - # if os.path.isfile(file): - # os.remove(file) - # else: - # pass + for file in FileList: + if os.path.isfile(file): + os.remove(file) + else: + pass def test_AddedMass_3D(self): from proteus import defaults @@ -85,9 +82,9 @@ def test_AddedMass_3D(self): ns.calculateSolution('addedmass3D') Aij = am3D.body.Aij - #np.savetxt('Aij_sol3D.csv', Aij, delimiter=',') + np.savetxt('Aij_sol3D.csv', Aij, delimiter=',') Aij_sol = np.genfromtxt(os.path.join(modulepath, 'Aij_sol3D.csv'), delimiter=',') - npt.assert_almost_equal(Aij, Aij_sol, decimal=5) + npt.assert_allclose(Aij, Aij_sol, atol=1.0e-8, rtol=0.0) self.teardown_method(self) if __name__ == "__main__": diff --git a/proteus/tests/BernsteinPolynomials/plot_basis/plotFEBasisOnCube.py b/test/BernsteinPolynomials/plot_basis/plotFEBasisOnCube.py similarity index 86% rename from proteus/tests/BernsteinPolynomials/plot_basis/plotFEBasisOnCube.py rename to test/BernsteinPolynomials/plot_basis/plotFEBasisOnCube.py index 6a5070d67c..783036bd2e 100644 --- a/proteus/tests/BernsteinPolynomials/plot_basis/plotFEBasisOnCube.py +++ b/test/BernsteinPolynomials/plot_basis/plotFEBasisOnCube.py @@ -1,7 +1,3 @@ -from __future__ import division -from builtins import str -from builtins import range -from past.utils import old_div import proteus from proteus.FemTools import QuadraticOnSimplexWithNodalBasis from proteus.FemTools import LagrangeOnCubeWithNodalBasis @@ -19,8 +15,8 @@ import numpy as np npts = 40 -x = np.arange(-1, 1., old_div(1.,(npts-1))) -y = np.arange(-1, 1., old_div(1.,(npts-1))) +x = np.arange(-1, 1., 1./(npts-1)) +y = np.arange(-1, 1., 1./(npts-1)) xi,yi = np.meshgrid(x,y) zi = xi.copy() zi[:]=0.0 diff --git a/proteus/tests/BernsteinPolynomials/plot_basis/plotFEBasisOnTriangle.py b/test/BernsteinPolynomials/plot_basis/plotFEBasisOnTriangle.py similarity index 87% rename from proteus/tests/BernsteinPolynomials/plot_basis/plotFEBasisOnTriangle.py rename to test/BernsteinPolynomials/plot_basis/plotFEBasisOnTriangle.py index c085bcc7b2..e648f3b605 100644 --- a/proteus/tests/BernsteinPolynomials/plot_basis/plotFEBasisOnTriangle.py +++ b/test/BernsteinPolynomials/plot_basis/plotFEBasisOnTriangle.py @@ -1,7 +1,3 @@ -from __future__ import division -from builtins import str -from builtins import range -from past.utils import old_div import proteus from proteus.FemTools import QuadraticOnSimplexWithNodalBasis from proteus.FemTools import LagrangeOnCubeWithNodalBasis @@ -19,8 +15,8 @@ import numpy as np npts = 40 -x = np.arange(0, 1., old_div(1.,(npts-1))) -y = np.arange(0, 1., old_div(1.,(npts-1))) +x = np.arange(0, 1., 1./(npts-1)) +y = np.arange(0, 1., 1./(npts-1)) xi,yi = np.meshgrid(x,y) zi = xi.copy() zi[:]=0.0 diff --git a/proteus/tests/BernsteinPolynomials/poisson_eqn/L2_batch.py b/test/BernsteinPolynomials/poisson_eqn/L2_batch.py similarity index 99% rename from proteus/tests/BernsteinPolynomials/poisson_eqn/L2_batch.py rename to test/BernsteinPolynomials/poisson_eqn/L2_batch.py index 1a2eb2a46d..8275433186 100644 --- a/proteus/tests/BernsteinPolynomials/poisson_eqn/L2_batch.py +++ b/test/BernsteinPolynomials/poisson_eqn/L2_batch.py @@ -15,4 +15,4 @@ # start -quit +quit \ No newline at end of file diff --git a/proteus/tests/BernsteinPolynomials/__init__.py b/test/BernsteinPolynomials/poisson_eqn/__init__.py similarity index 100% rename from proteus/tests/BernsteinPolynomials/__init__.py rename to test/BernsteinPolynomials/poisson_eqn/__init__.py diff --git a/proteus/tests/BernsteinPolynomials/poisson_eqn/clean.sh b/test/BernsteinPolynomials/poisson_eqn/clean.sh similarity index 100% rename from proteus/tests/BernsteinPolynomials/poisson_eqn/clean.sh rename to test/BernsteinPolynomials/poisson_eqn/clean.sh diff --git a/proteus/tests/BernsteinPolynomials/poisson_eqn/comparison_files/comparison_2D_poisson_hex_degree2_u0_t1.csv b/test/BernsteinPolynomials/poisson_eqn/comparison_files/comparison_2D_poisson_hex_degree2_u0_t1.csv similarity index 100% rename from proteus/tests/BernsteinPolynomials/poisson_eqn/comparison_files/comparison_2D_poisson_hex_degree2_u0_t1.csv rename to test/BernsteinPolynomials/poisson_eqn/comparison_files/comparison_2D_poisson_hex_degree2_u0_t1.csv diff --git a/proteus/tests/BernsteinPolynomials/poisson_eqn/comparison_files/comparison_2D_poisson_simplex_degree2_u0_t1.csv b/test/BernsteinPolynomials/poisson_eqn/comparison_files/comparison_2D_poisson_simplex_degree2_u0_t1.csv similarity index 100% rename from proteus/tests/BernsteinPolynomials/poisson_eqn/comparison_files/comparison_2D_poisson_simplex_degree2_u0_t1.csv rename to test/BernsteinPolynomials/poisson_eqn/comparison_files/comparison_2D_poisson_simplex_degree2_u0_t1.csv diff --git a/proteus/tests/BernsteinPolynomials/poisson_eqn/comparison_files/comparison_3D_poisson_hex_degree2_u0_t1.csv b/test/BernsteinPolynomials/poisson_eqn/comparison_files/comparison_3D_poisson_hex_degree2_u0_t1.csv similarity index 100% rename from proteus/tests/BernsteinPolynomials/poisson_eqn/comparison_files/comparison_3D_poisson_hex_degree2_u0_t1.csv rename to test/BernsteinPolynomials/poisson_eqn/comparison_files/comparison_3D_poisson_hex_degree2_u0_t1.csv diff --git a/proteus/tests/BernsteinPolynomials/poisson_eqn/comparison_files/comparison_3D_poisson_simplex_degree2_u0_t1.csv b/test/BernsteinPolynomials/poisson_eqn/comparison_files/comparison_3D_poisson_simplex_degree2_u0_t1.csv similarity index 100% rename from proteus/tests/BernsteinPolynomials/poisson_eqn/comparison_files/comparison_3D_poisson_simplex_degree2_u0_t1.csv rename to test/BernsteinPolynomials/poisson_eqn/comparison_files/comparison_3D_poisson_simplex_degree2_u0_t1.csv diff --git a/proteus/tests/BernsteinPolynomials/poisson_eqn/parameters_for_poisson.py b/test/BernsteinPolynomials/poisson_eqn/parameters_for_poisson.py similarity index 99% rename from proteus/tests/BernsteinPolynomials/poisson_eqn/parameters_for_poisson.py rename to test/BernsteinPolynomials/poisson_eqn/parameters_for_poisson.py index ca5ade5bad..9ad4025613 100644 --- a/proteus/tests/BernsteinPolynomials/poisson_eqn/parameters_for_poisson.py +++ b/test/BernsteinPolynomials/poisson_eqn/parameters_for_poisson.py @@ -12,4 +12,3 @@ ("unstructured",False,"Use unstructured triangular mesh"), ("genMesh", False, "Generate a new mesh?") ],mutable=True) - diff --git a/proteus/tests/BernsteinPolynomials/poisson_eqn/poisson_n.py b/test/BernsteinPolynomials/poisson_eqn/poisson_n.py similarity index 96% rename from proteus/tests/BernsteinPolynomials/poisson_eqn/poisson_n.py rename to test/BernsteinPolynomials/poisson_eqn/poisson_n.py index cf3a54baca..031a78732c 100644 --- a/proteus/tests/BernsteinPolynomials/poisson_eqn/poisson_n.py +++ b/test/BernsteinPolynomials/poisson_eqn/poisson_n.py @@ -1,5 +1,3 @@ -from __future__ import print_function -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/BernsteinPolynomials/poisson_eqn/poisson_p.py b/test/BernsteinPolynomials/poisson_eqn/poisson_p.py similarity index 94% rename from proteus/tests/BernsteinPolynomials/poisson_eqn/poisson_p.py rename to test/BernsteinPolynomials/poisson_eqn/poisson_p.py index 9c89b5857c..d6d270fdc5 100644 --- a/proteus/tests/BernsteinPolynomials/poisson_eqn/poisson_p.py +++ b/test/BernsteinPolynomials/poisson_eqn/poisson_p.py @@ -1,7 +1,3 @@ -from __future__ import absolute_import -from __future__ import division -from builtins import object -from past.utils import old_div from proteus import * from proteus.default_p import * import os @@ -19,14 +15,14 @@ # DOMAIN # ########## nn=(2**ct.refinement)*10+1 -he=old_div(1.0,(nn-1.0)) +he=1.0/(nn-1.0) if (nd==2): box=Domain.RectangularDomain(L=(1.0,1.0), x=(0.0,0.0), name="box"); else: nn=5 - he=old_div(1.0,(nn-1.0)) + he=1.0/(nn-1.0) box=Domain.RectangularDomain(L=(1.0,1.0,1.0), x=(0.0,0.0,0.0), name="box"); diff --git a/proteus/tests/BernsteinPolynomials/poisson_eqn/run_convergence.sh b/test/BernsteinPolynomials/poisson_eqn/run_convergence.sh similarity index 100% rename from proteus/tests/BernsteinPolynomials/poisson_eqn/run_convergence.sh rename to test/BernsteinPolynomials/poisson_eqn/run_convergence.sh diff --git a/proteus/tests/BernsteinPolynomials/poisson_eqn/test_bernstein.py b/test/BernsteinPolynomials/poisson_eqn/test_bernstein.py similarity index 74% rename from proteus/tests/BernsteinPolynomials/poisson_eqn/test_bernstein.py rename to test/BernsteinPolynomials/poisson_eqn/test_bernstein.py index fd5da35648..e1422cf667 100644 --- a/proteus/tests/BernsteinPolynomials/poisson_eqn/test_bernstein.py +++ b/test/BernsteinPolynomials/poisson_eqn/test_bernstein.py @@ -2,7 +2,6 @@ """ Test module for Berstein basis FE """ -from builtins import object from proteus.iproteus import * from proteus import Comm comm = Comm.get() @@ -10,11 +9,9 @@ Profiling.verbose=True import os import numpy as np -import tables +import h5py import pytest -from . import (parameters_for_poisson, - poisson_p, - poisson_n) +from . import (parameters_for_poisson, poisson_p, poisson_n) class TestBernstein(object): @@ -61,18 +58,18 @@ def test_2D_hex(self): ns.calculateSolution('poisson') # COMPARE VS SAVED FILES # #expected_path = 'comparison_files/'+self.so.name+'.h5' - #expected = tables.open_file(os.path.join(self._scriptdir,expected_path)) - #actual = tables.open_file(self.so.name+'.h5','r') + #expected = h5py.File(os.path.join(self._scriptdir,expected_path)) + #actual = h5py.File(self.so.name+'.h5','r') #assert np.allclose(expected.root.u0_t1, - # actual.root.u0_t1, + # actual['u0_t1'], # atol=1e-10) #expected.close() - actual = tables.open_file(self.so.name+'.h5','r') + actual = h5py.File(self.so.name+'.h5','r') expected_path = 'comparison_files/' + 'comparison_' + self.so.name + '_u0_t1.csv' #write comparison file - #np.array(actual.root.u0_t1).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.u0_t1).flatten(),decimal=10) + #np.array(actual['u0_t1']).tofile(os.path.join(self._scriptdir, expected_path),sep=",") + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['u0_t1']).flatten(),decimal=10) actual.close() def test_2D_simplex(self): @@ -95,16 +92,16 @@ def test_2D_simplex(self): ns.calculateSolution('poisson') # COMPARE VS SAVED FILES # #expected_path = 'comparison_files/'+self.so.name+'.h5' - #expected = tables.open_file(os.path.join(self._scriptdir,expected_path)) - #actual = tables.open_file(self.so.name+'.h5','r') + #expected = h5py.File(os.path.join(self._scriptdir,expected_path)) + #actual = h5py.File(self.so.name+'.h5','r') #assert np.allclose(expected.root.u0_t1, - # actual.root.u0_t1, + # actual['u0_t1'], # atol=1e-10) - actual = tables.open_file(self.so.name+'.h5','r') + actual = h5py.File(self.so.name+'.h5','r') expected_path = 'comparison_files/' + 'comparison_' + self.so.name + '_u0_t1.csv' #write comparison file - #np.array(actual.root.u0_t1).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.u0_t1).flatten(),decimal=10) + #np.array(actual['u0_t1']).tofile(os.path.join(self._scriptdir, expected_path),sep=",") + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['u0_t1']).flatten(),decimal=10) actual.close() def test_3D_hex(self): @@ -127,16 +124,16 @@ def test_3D_hex(self): ns.calculateSolution('poisson') # COMPARE VS SAVED FILES # #expected_path = 'comparison_files/'+self.so.name+'.h5' - #expected = tables.open_file(os.path.join(self._scriptdir,expected_path)) - #actual = tables.open_file(self.so.name+'.h5','r') + #expected = h5py.File(os.path.join(self._scriptdir,expected_path)) + #actual = h5py.File(self.so.name+'.h5','r') #assert np.allclose(expected.root.u0_t1, - # actual.root.u0_t1, + # actual['u0_t1'], # atol=1e-10) - actual = tables.open_file(self.so.name+'.h5','r') + actual = h5py.File(self.so.name+'.h5','r') expected_path = 'comparison_files/' + 'comparison_' + self.so.name + '_u0_t1.csv' #write comparison file - #np.array(actual.root.u0_t1).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.u0_t1).flatten(),decimal=10) + #np.array(actual['u0_t1']).tofile(os.path.join(self._scriptdir, expected_path),sep=",") + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['u0_t1']).flatten(),decimal=10) actual.close() def test_3D_simplex(self): @@ -158,14 +155,14 @@ def test_3D_simplex(self): ns.calculateSolution('poisson') # COMPARE VS SAVED FILES # #expected_path = 'comparison_files/'+self.so.name+'.h5' - #expected = tables.open_file(os.path.join(self._scriptdir,expected_path)) - #actual = tables.open_file(self.so.name+'.h5','r') + #expected = h5py.File(os.path.join(self._scriptdir,expected_path)) + #actual = h5py.File(self.so.name+'.h5','r') #assert np.allclose(expected.root.u0_t1, - # actual.root.u0_t1, + # actual['u0_t1'], # atol=1e-10) - actual = tables.open_file(self.so.name+'.h5','r') + actual = h5py.File(self.so.name+'.h5','r') expected_path = 'comparison_files/' + 'comparison_' + self.so.name + '_u0_t1.csv' #write comparison file - #np.array(actual.root.u0_t1).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.u0_t1).flatten(),decimal=10) + #np.array(actual['u0_t1']).tofile(os.path.join(self._scriptdir, expected_path),sep=",") + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['u0_t1']).flatten(),decimal=10) actual.close() diff --git a/proteus/tests/CLSVOF/disc_ICs/L2_batch.py b/test/CLSVOF/disc_ICs/L2_batch.py similarity index 99% rename from proteus/tests/CLSVOF/disc_ICs/L2_batch.py rename to test/CLSVOF/disc_ICs/L2_batch.py index 626bb7473f..33383b0785 100644 --- a/proteus/tests/CLSVOF/disc_ICs/L2_batch.py +++ b/test/CLSVOF/disc_ICs/L2_batch.py @@ -18,4 +18,4 @@ # start -quit +quit \ No newline at end of file diff --git a/proteus/tests/BernsteinPolynomials/poisson_eqn/__init__.py b/test/CLSVOF/disc_ICs/__init__.py similarity index 100% rename from proteus/tests/BernsteinPolynomials/poisson_eqn/__init__.py rename to test/CLSVOF/disc_ICs/__init__.py diff --git a/proteus/tests/CLSVOF/disc_ICs/clean.sh b/test/CLSVOF/disc_ICs/clean.sh similarity index 100% rename from proteus/tests/CLSVOF/disc_ICs/clean.sh rename to test/CLSVOF/disc_ICs/clean.sh diff --git a/proteus/tests/CLSVOF/disc_ICs/clsvof.py b/test/CLSVOF/disc_ICs/clsvof.py similarity index 94% rename from proteus/tests/CLSVOF/disc_ICs/clsvof.py rename to test/CLSVOF/disc_ICs/clsvof.py index 138289d098..b6f0b7126c 100644 --- a/proteus/tests/CLSVOF/disc_ICs/clsvof.py +++ b/test/CLSVOF/disc_ICs/clsvof.py @@ -1,6 +1,3 @@ -from __future__ import absolute_import -from __future__ import division -from past.utils import old_div from proteus import Domain from proteus import Norms from proteus import Profiling @@ -58,7 +55,7 @@ nnz=1 L=[1.0,1.0] # definition of he -he=old_div(1.0,(nnx-1.0)) +he=1.0/(nnx-1.0) clsvof_nl_atol_res = 1.0e-10#max(1.0e-10, 0.01 * he ** 2) unstructured=unstructured #True for tetgen, false for tet or hex from rectangular grid diff --git a/proteus/tests/CLSVOF/disc_ICs/clsvof_n.py b/test/CLSVOF/disc_ICs/clsvof_n.py similarity index 94% rename from proteus/tests/CLSVOF/disc_ICs/clsvof_n.py rename to test/CLSVOF/disc_ICs/clsvof_n.py index b2a68ac50f..ae53ea449d 100644 --- a/proteus/tests/CLSVOF/disc_ICs/clsvof_n.py +++ b/test/CLSVOF/disc_ICs/clsvof_n.py @@ -1,6 +1,3 @@ -from __future__ import print_function -from __future__ import absolute_import -from builtins import range from proteus import * from proteus.default_n import * try: @@ -70,4 +67,3 @@ tnList=[0.,1E-6] - diff --git a/proteus/tests/CLSVOF/disc_ICs/clsvof_p.py b/test/CLSVOF/disc_ICs/clsvof_p.py similarity index 97% rename from proteus/tests/CLSVOF/disc_ICs/clsvof_p.py rename to test/CLSVOF/disc_ICs/clsvof_p.py index 88ee9c8c7d..525a13e36c 100644 --- a/proteus/tests/CLSVOF/disc_ICs/clsvof_p.py +++ b/test/CLSVOF/disc_ICs/clsvof_p.py @@ -1,7 +1,3 @@ -from __future__ import absolute_import -from builtins import zip -from builtins import range -from builtins import object from proteus import * from proteus.default_p import * from proteus.ctransportCoefficients import smoothedHeaviside diff --git a/proteus/tests/CLSVOF/disc_ICs/comparison_files/comparison_test_case_1_u_t1.csv b/test/CLSVOF/disc_ICs/comparison_files/comparison_test_case_1_u_t1.csv similarity index 100% rename from proteus/tests/CLSVOF/disc_ICs/comparison_files/comparison_test_case_1_u_t1.csv rename to test/CLSVOF/disc_ICs/comparison_files/comparison_test_case_1_u_t1.csv diff --git a/proteus/tests/CLSVOF/disc_ICs/comparison_files/comparison_test_case_2_u_t1.csv b/test/CLSVOF/disc_ICs/comparison_files/comparison_test_case_2_u_t1.csv similarity index 100% rename from proteus/tests/CLSVOF/disc_ICs/comparison_files/comparison_test_case_2_u_t1.csv rename to test/CLSVOF/disc_ICs/comparison_files/comparison_test_case_2_u_t1.csv diff --git a/proteus/tests/CLSVOF/disc_ICs/parameters.py b/test/CLSVOF/disc_ICs/parameters.py similarity index 86% rename from proteus/tests/CLSVOF/disc_ICs/parameters.py rename to test/CLSVOF/disc_ICs/parameters.py index 237d912e29..edc014fcec 100644 --- a/proteus/tests/CLSVOF/disc_ICs/parameters.py +++ b/test/CLSVOF/disc_ICs/parameters.py @@ -2,4 +2,4 @@ ct=Context.Options([ ("test_case",1,"1: circle, 2: zalesak disk") -],mutable=True) +],mutable=True) \ No newline at end of file diff --git a/proteus/tests/CLSVOF/disc_ICs/test_CLSVOF_discICs.py b/test/CLSVOF/disc_ICs/test_CLSVOF_discICs.py similarity index 80% rename from proteus/tests/CLSVOF/disc_ICs/test_CLSVOF_discICs.py rename to test/CLSVOF/disc_ICs/test_CLSVOF_discICs.py index 2b1b3f3149..89878015c1 100644 --- a/proteus/tests/CLSVOF/disc_ICs/test_CLSVOF_discICs.py +++ b/test/CLSVOF/disc_ICs/test_CLSVOF_discICs.py @@ -2,8 +2,6 @@ """ Test module for testing disc ICs for CLSVOF """ -from builtins import range -from builtins import object from proteus.iproteus import * from proteus import Comm comm = Comm.get() @@ -11,7 +9,7 @@ Profiling.verbose=True import os import numpy as np -import tables +import h5py import pytest from proteus import default_so from . import (parameters, @@ -67,18 +65,12 @@ def run_test(self,clsvof_p,clsvof_n,name): def compare_files(self,path,name, write=False): # COMPARE VS SAVED FILES # - #expected_path = path+'/'+name+'.h5' - #expected = tables.open_file(os.path.join(self._scriptdir,expected_path)) - #actual = tables.open_file(name+'.h5','r') - #assert np.allclose(expected.root.u_t1,actual.root.u_t1,atol=1e-10) - #expected.close() - - actual = tables.open_file(name+'.h5','r') + actual = h5py.File(name+'.h5','r') expected_path = 'comparison_files/' + 'comparison_' + name + '_u_t1.csv' #write comparison file if write: - np.array(actual.root.u_t1).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.u_t1).flatten(),decimal=10) + np.array(actual['u_t1']).tofile(os.path.join(self._scriptdir, expected_path),sep=",") + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['u_t1']).flatten(),decimal=10) actual.close() def test_case_1(self): diff --git a/proteus/tests/CLSVOF/__init__.py b/test/CLSVOF/pure_level_set/__init__.py similarity index 100% rename from proteus/tests/CLSVOF/__init__.py rename to test/CLSVOF/pure_level_set/__init__.py diff --git a/proteus/tests/CLSVOF/pure_level_set/clean.sh b/test/CLSVOF/pure_level_set/clean.sh similarity index 100% rename from proteus/tests/CLSVOF/pure_level_set/clean.sh rename to test/CLSVOF/pure_level_set/clean.sh diff --git a/proteus/tests/CLSVOF/pure_level_set/clsvof.py b/test/CLSVOF/pure_level_set/clsvof.py similarity index 94% rename from proteus/tests/CLSVOF/pure_level_set/clsvof.py rename to test/CLSVOF/pure_level_set/clsvof.py index 8f64411991..43d324fce6 100644 --- a/proteus/tests/CLSVOF/pure_level_set/clsvof.py +++ b/test/CLSVOF/pure_level_set/clsvof.py @@ -1,6 +1,3 @@ -from __future__ import absolute_import -from __future__ import division -from past.utils import old_div from proteus import Domain from proteus import Norms from proteus import Profiling @@ -89,13 +86,13 @@ else: if ct.test_case==3: nn=nnx=nny=int((2**refinement)*refinementMultiplier+1) - nnz=int(old_div((nnx-1),2)+1) + nnz=int((nnx-1)//2+1) L=[1.0,1.0,0.5] else: nn=nnx=nny=nnz=int((2**refinement)*refinementMultiplier+1) L=[1.0,1.0,1.0] # definition of he -he=old_div(1.0,(nnx-1.0)) +he=1.0/(nnx-1.0) clsvof_nl_atol_res = max(1.0e-10, 0.01 * he ** 2) unstructured=unstructured #True for tetgen, false for tet or hex from rectangular grid diff --git a/proteus/tests/CLSVOF/pure_level_set/clsvof_n.py b/test/CLSVOF/pure_level_set/clsvof_n.py similarity index 95% rename from proteus/tests/CLSVOF/pure_level_set/clsvof_n.py rename to test/CLSVOF/pure_level_set/clsvof_n.py index 781cf72ae9..be981cae1c 100644 --- a/proteus/tests/CLSVOF/pure_level_set/clsvof_n.py +++ b/test/CLSVOF/pure_level_set/clsvof_n.py @@ -1,6 +1,3 @@ -from __future__ import print_function -from __future__ import absolute_import -from builtins import range from proteus import * from proteus.default_n import * try: @@ -73,4 +70,3 @@ levelLinearSolver = LU tnList=[0.,1E-6]+[float(n)*T/float(nDTout) for n in range(1,nDTout+1)] - diff --git a/proteus/tests/CLSVOF/pure_level_set/clsvof_p.py b/test/CLSVOF/pure_level_set/clsvof_p.py similarity index 97% rename from proteus/tests/CLSVOF/pure_level_set/clsvof_p.py rename to test/CLSVOF/pure_level_set/clsvof_p.py index 5790919288..b729374b21 100644 --- a/proteus/tests/CLSVOF/pure_level_set/clsvof_p.py +++ b/test/CLSVOF/pure_level_set/clsvof_p.py @@ -1,7 +1,3 @@ -from __future__ import absolute_import -from builtins import zip -from builtins import range -from builtins import object from proteus import * from proteus.default_p import * from proteus.ctransportCoefficients import smoothedHeaviside diff --git a/proteus/tests/CLSVOF/pure_level_set/comparison_files/comparison_clsvof_test_case_1_u_t2.csv b/test/CLSVOF/pure_level_set/comparison_files/comparison_clsvof_test_case_1_u_t2.csv similarity index 100% rename from proteus/tests/CLSVOF/pure_level_set/comparison_files/comparison_clsvof_test_case_1_u_t2.csv rename to test/CLSVOF/pure_level_set/comparison_files/comparison_clsvof_test_case_1_u_t2.csv diff --git a/proteus/tests/CLSVOF/pure_level_set/comparison_files/comparison_clsvof_test_case_2_u_t2.csv b/test/CLSVOF/pure_level_set/comparison_files/comparison_clsvof_test_case_2_u_t2.csv similarity index 100% rename from proteus/tests/CLSVOF/pure_level_set/comparison_files/comparison_clsvof_test_case_2_u_t2.csv rename to test/CLSVOF/pure_level_set/comparison_files/comparison_clsvof_test_case_2_u_t2.csv diff --git a/proteus/tests/CLSVOF/pure_level_set/comparison_files/comparison_clsvof_test_case_3_u_t2.csv b/test/CLSVOF/pure_level_set/comparison_files/comparison_clsvof_test_case_3_u_t2.csv similarity index 100% rename from proteus/tests/CLSVOF/pure_level_set/comparison_files/comparison_clsvof_test_case_3_u_t2.csv rename to test/CLSVOF/pure_level_set/comparison_files/comparison_clsvof_test_case_3_u_t2.csv diff --git a/proteus/tests/CLSVOF/pure_level_set/comparison_files/comparison_clsvof_test_case_4_u_t2.csv b/test/CLSVOF/pure_level_set/comparison_files/comparison_clsvof_test_case_4_u_t2.csv similarity index 100% rename from proteus/tests/CLSVOF/pure_level_set/comparison_files/comparison_clsvof_test_case_4_u_t2.csv rename to test/CLSVOF/pure_level_set/comparison_files/comparison_clsvof_test_case_4_u_t2.csv diff --git a/proteus/tests/CLSVOF/pure_level_set/mesh_3.ele b/test/CLSVOF/pure_level_set/mesh_3.ele similarity index 100% rename from proteus/tests/CLSVOF/pure_level_set/mesh_3.ele rename to test/CLSVOF/pure_level_set/mesh_3.ele diff --git a/proteus/tests/CLSVOF/pure_level_set/mesh_3.face b/test/CLSVOF/pure_level_set/mesh_3.face similarity index 100% rename from proteus/tests/CLSVOF/pure_level_set/mesh_3.face rename to test/CLSVOF/pure_level_set/mesh_3.face diff --git a/proteus/tests/CLSVOF/pure_level_set/mesh_3.node b/test/CLSVOF/pure_level_set/mesh_3.node similarity index 100% rename from proteus/tests/CLSVOF/pure_level_set/mesh_3.node rename to test/CLSVOF/pure_level_set/mesh_3.node diff --git a/proteus/tests/CLSVOF/pure_level_set/mesh_4.ele b/test/CLSVOF/pure_level_set/mesh_4.ele similarity index 100% rename from proteus/tests/CLSVOF/pure_level_set/mesh_4.ele rename to test/CLSVOF/pure_level_set/mesh_4.ele diff --git a/proteus/tests/CLSVOF/pure_level_set/mesh_4.face b/test/CLSVOF/pure_level_set/mesh_4.face similarity index 100% rename from proteus/tests/CLSVOF/pure_level_set/mesh_4.face rename to test/CLSVOF/pure_level_set/mesh_4.face diff --git a/proteus/tests/CLSVOF/pure_level_set/mesh_4.node b/test/CLSVOF/pure_level_set/mesh_4.node similarity index 100% rename from proteus/tests/CLSVOF/pure_level_set/mesh_4.node rename to test/CLSVOF/pure_level_set/mesh_4.node diff --git a/proteus/tests/CLSVOF/pure_level_set/parameters.py b/test/CLSVOF/pure_level_set/parameters.py similarity index 90% rename from proteus/tests/CLSVOF/pure_level_set/parameters.py rename to test/CLSVOF/pure_level_set/parameters.py index 6458d9f498..02f10303b7 100644 --- a/proteus/tests/CLSVOF/pure_level_set/parameters.py +++ b/test/CLSVOF/pure_level_set/parameters.py @@ -2,4 +2,4 @@ ct=Context.Options([ ("test_case",1,"1: 2D periodic vortex, 2: 2D solid rotation, 3: 3D solid rotation, 4: 3D LeVeque test") -],mutable=True) +],mutable=True) \ No newline at end of file diff --git a/proteus/tests/CLSVOF/pure_level_set/petsc.options.asm b/test/CLSVOF/pure_level_set/petsc.options.asm similarity index 100% rename from proteus/tests/CLSVOF/pure_level_set/petsc.options.asm rename to test/CLSVOF/pure_level_set/petsc.options.asm diff --git a/proteus/tests/CLSVOF/pure_level_set/petsc.options.superlu_dist b/test/CLSVOF/pure_level_set/petsc.options.superlu_dist similarity index 100% rename from proteus/tests/CLSVOF/pure_level_set/petsc.options.superlu_dist rename to test/CLSVOF/pure_level_set/petsc.options.superlu_dist diff --git a/proteus/tests/CLSVOF/pure_level_set/test_clsvof.py b/test/CLSVOF/pure_level_set/test_clsvof.py similarity index 74% rename from proteus/tests/CLSVOF/pure_level_set/test_clsvof.py rename to test/CLSVOF/pure_level_set/test_clsvof.py index 5897dc7008..2e4d00ccee 100644 --- a/proteus/tests/CLSVOF/pure_level_set/test_clsvof.py +++ b/test/CLSVOF/pure_level_set/test_clsvof.py @@ -2,8 +2,6 @@ """ Test module for CLSVOF """ -from builtins import range -from builtins import object from proteus.iproteus import * from proteus import Comm comm = Comm.get() @@ -11,7 +9,7 @@ Profiling.verbose=True import os import numpy as np -import tables +import h5py import pytest from proteus import default_so from . import (parameters, @@ -44,17 +42,11 @@ def teardown_method(self,method): def compare_files(self,path,name): # COMPARE VS SAVED FILES # - #expected_path = path+'/'+name+'.h5' - #expected = tables.open_file(os.path.join(self._scriptdir,expected_path)) - #actual = tables.open_file(name+'.h5','r') - #assert np.allclose(expected.root.u_t1,actual.root.u_t1,atol=1e-10) - #expected.close() - - actual = tables.open_file(name+'.h5','r') + actual = h5py.File(name+'.h5','r') expected_path = 'comparison_files/' + 'comparison_' + name + '_u_t2.csv' #write comparison file #np.array(actual.root.u_t2).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.u_t2).flatten(),decimal=10) + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['u_t2']).flatten(),decimal=10) actual.close() def test_case_1(self): @@ -84,14 +76,7 @@ def test_case_1(self): opts) ns.calculateSolution('test_case_1') # COMPARE VS SAVED FILES # - self.compare_files('comparison_files',self.so.name) - #expected_path = 'comparison_files/clsvof_test_case_1.h5' - #expected = tables.open_file(os.path.join(self._scriptdir,expected_path)) - #actual = tables.open_file('clsvof_test_case_1.h5','r') - #assert np.allclose(expected.root.u_t2,actual.root.u_t2,atol=1e-10) - #expected.close() - #actual.close() def test_case_2(self): # Set parameters for this test @@ -121,13 +106,7 @@ def test_case_2(self): ns.calculateSolution('test_case_2') # COMPARE VS SAVED FILES # self.compare_files('comparison_files',self.so.name) - #expected_path = 'comparison_files/clsvof_test_case_2.h5' - #expected = tables.open_file(os.path.join(self._scriptdir,expected_path)) - #actual = tables.open_file('clsvof_test_case_2.h5','r') - #assert np.allclose(expected.root.u_t2,actual.root.u_t2,atol=1e-10) - #expected.close() - #actual.close() - + def test_case_3(self): # Set parameters for this test parameters.ct.test_case=3 @@ -156,12 +135,6 @@ def test_case_3(self): ns.calculateSolution('test_case_3') # COMPARE VS SAVED FILES # self.compare_files('comparison_files',self.so.name) - #expected_path = 'comparison_files/clsvof_test_case_3.h5' - #expected = tables.open_file(os.path.join(self._scriptdir,expected_path)) - #actual = tables.open_file('clsvof_test_case_3.h5','r') - #assert np.allclose(expected.root.u_t2,actual.root.u_t2,atol=1e-10) - #expected.close() - #actual.close() def test_case_4(self): # Set parameters for this test @@ -191,9 +164,4 @@ def test_case_4(self): ns.calculateSolution('test_case_4') # COMPARE VS SAVED FILES # self.compare_files('comparison_files',self.so.name) - #expected_path = 'comparison_files/clsvof_test_case_4.h5' - #expected = tables.open_file(os.path.join(self._scriptdir,expected_path)) - #actual = tables.open_file('clsvof_test_case_4.h5','r') - #assert np.allclose(expected.root.u_t2,actual.root.u_t2,atol=1e-10) - #expected.close() - #actual.close() + diff --git a/proteus/tests/CLSVOF/disc_ICs/__init__.py b/test/CLSVOF/with_RANS2P/__init__.py similarity index 100% rename from proteus/tests/CLSVOF/disc_ICs/__init__.py rename to test/CLSVOF/with_RANS2P/__init__.py diff --git a/proteus/tests/CLSVOF/with_RANS2P/clean.sh b/test/CLSVOF/with_RANS2P/clean.sh similarity index 100% rename from proteus/tests/CLSVOF/with_RANS2P/clean.sh rename to test/CLSVOF/with_RANS2P/clean.sh diff --git a/proteus/tests/CLSVOF/with_RANS2P/clsvof_n.py b/test/CLSVOF/with_RANS2P/clsvof_n.py similarity index 95% rename from proteus/tests/CLSVOF/with_RANS2P/clsvof_n.py rename to test/CLSVOF/with_RANS2P/clsvof_n.py index 65ffe3ce24..103f49f360 100644 --- a/proteus/tests/CLSVOF/with_RANS2P/clsvof_n.py +++ b/test/CLSVOF/with_RANS2P/clsvof_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * from .clsvof_p import * @@ -39,4 +38,3 @@ linear_solver_options_prefix = 'clsvof_' linearSolverConvergenceTest = 'r-true' - diff --git a/proteus/tests/CLSVOF/with_RANS2P/clsvof_p.py b/test/CLSVOF/with_RANS2P/clsvof_p.py similarity index 94% rename from proteus/tests/CLSVOF/with_RANS2P/clsvof_p.py rename to test/CLSVOF/with_RANS2P/clsvof_p.py index 6569adae2c..10ba44215c 100644 --- a/proteus/tests/CLSVOF/with_RANS2P/clsvof_p.py +++ b/test/CLSVOF/with_RANS2P/clsvof_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * from proteus.ctransportCoefficients import smoothedHeaviside @@ -34,4 +32,3 @@ def uOfXT(self,x,t): advectiveFluxBoundaryConditions = {0: lambda x, flag: domain.bc[flag].vof_advective.init_cython()} diffusiveFluxBoundaryConditions = {0:{}} - diff --git a/proteus/tests/CLSVOF/with_RANS2P/ls_consrv_n.py b/test/CLSVOF/with_RANS2P/ls_consrv_n.py similarity index 97% rename from proteus/tests/CLSVOF/with_RANS2P/ls_consrv_n.py rename to test/CLSVOF/with_RANS2P/ls_consrv_n.py index 7ec72a8ba1..f7ba5b13b7 100644 --- a/proteus/tests/CLSVOF/with_RANS2P/ls_consrv_n.py +++ b/test/CLSVOF/with_RANS2P/ls_consrv_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus.default_n import * from proteus import (StepControl, TimeIntegration, diff --git a/proteus/tests/CLSVOF/with_RANS2P/ls_consrv_p.py b/test/CLSVOF/with_RANS2P/ls_consrv_p.py similarity index 93% rename from proteus/tests/CLSVOF/with_RANS2P/ls_consrv_p.py rename to test/CLSVOF/with_RANS2P/ls_consrv_p.py index 20b64c53ce..b6a0d7ea54 100644 --- a/proteus/tests/CLSVOF/with_RANS2P/ls_consrv_p.py +++ b/test/CLSVOF/with_RANS2P/ls_consrv_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus.default_p import * from proteus.mprans import MCorr from .multiphase import * @@ -29,4 +27,3 @@ def uOfXT(self,X,t): - diff --git a/proteus/tests/CLSVOF/with_RANS2P/ls_n.py b/test/CLSVOF/with_RANS2P/ls_n.py similarity index 98% rename from proteus/tests/CLSVOF/with_RANS2P/ls_n.py rename to test/CLSVOF/with_RANS2P/ls_n.py index 7bc719b7f6..2b9a3b51ca 100644 --- a/proteus/tests/CLSVOF/with_RANS2P/ls_n.py +++ b/test/CLSVOF/with_RANS2P/ls_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus.default_n import * from . import ls_p as physics from proteus import (StepControl, diff --git a/proteus/tests/CLSVOF/with_RANS2P/ls_p.py b/test/CLSVOF/with_RANS2P/ls_p.py similarity index 93% rename from proteus/tests/CLSVOF/with_RANS2P/ls_p.py rename to test/CLSVOF/with_RANS2P/ls_p.py index a09d98cc96..b3b59afdbb 100644 --- a/proteus/tests/CLSVOF/with_RANS2P/ls_p.py +++ b/test/CLSVOF/with_RANS2P/ls_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus.default_p import * from proteus.mprans import NCLS from .multiphase import * diff --git a/proteus/tests/CLSVOF/with_RANS2P/multiphase.py b/test/CLSVOF/with_RANS2P/multiphase.py similarity index 96% rename from proteus/tests/CLSVOF/with_RANS2P/multiphase.py rename to test/CLSVOF/with_RANS2P/multiphase.py index 0c7d26341d..4124a3830e 100644 --- a/proteus/tests/CLSVOF/with_RANS2P/multiphase.py +++ b/test/CLSVOF/with_RANS2P/multiphase.py @@ -1,9 +1,6 @@ """ Multiphase Water Test """ -from __future__ import division -from builtins import str -from past.utils import old_div import numpy as np from math import sqrt from proteus import (Domain, Context, @@ -134,7 +131,7 @@ dt_fixed = 0.01 dt_init = min(0.1 * dt_fixed, 0.001) runCFL = 0.33 -nDTout = int(round(old_div(T, dt_fixed))) +nDTout = int(round(T/dt_fixed)) # ----- DOMAIN ----- # @@ -162,10 +159,10 @@ # ----- MESH CONSTRUCTION ----- # -he = old_div(tank_dim[0], float(4 * refinement - 1)) +he = tank_dim[0]/float(4*refinement-1) domain.MeshOptions.he = he st.assembleDomain(domain) -triangleOptions = "VApq30Dena%8.8f" % (old_div((he ** 2), 2.0),) +triangleOptions = "VApq30Dena%8.8f" % ((he**2)/2.0,) # ----- STRONG DIRICHLET ----- # diff --git a/proteus/tests/CLSVOF/with_RANS2P/multiphase_so.py b/test/CLSVOF/with_RANS2P/multiphase_so.py similarity index 93% rename from proteus/tests/CLSVOF/with_RANS2P/multiphase_so.py rename to test/CLSVOF/with_RANS2P/multiphase_so.py index 92e2a62187..12da020ed2 100644 --- a/proteus/tests/CLSVOF/with_RANS2P/multiphase_so.py +++ b/test/CLSVOF/with_RANS2P/multiphase_so.py @@ -1,8 +1,6 @@ """ Split operator module for multiphase: CLSVOF with RANS2P """ -from __future__ import absolute_import -from builtins import range import os from proteus.default_so import * from . import multiphase @@ -32,4 +30,3 @@ info = open("TimeList.txt","w") - diff --git a/proteus/tests/CLSVOF/with_RANS2P/redist_n.py b/test/CLSVOF/with_RANS2P/redist_n.py similarity index 98% rename from proteus/tests/CLSVOF/with_RANS2P/redist_n.py rename to test/CLSVOF/with_RANS2P/redist_n.py index 143c47caa5..d4d4ea2839 100644 --- a/proteus/tests/CLSVOF/with_RANS2P/redist_n.py +++ b/test/CLSVOF/with_RANS2P/redist_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus.default_n import * from proteus import (StepControl, TimeIntegration, diff --git a/proteus/tests/CLSVOF/with_RANS2P/redist_p.py b/test/CLSVOF/with_RANS2P/redist_p.py similarity index 93% rename from proteus/tests/CLSVOF/with_RANS2P/redist_p.py rename to test/CLSVOF/with_RANS2P/redist_p.py index 0fef842065..22e808cc97 100644 --- a/proteus/tests/CLSVOF/with_RANS2P/redist_p.py +++ b/test/CLSVOF/with_RANS2P/redist_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus.default_p import * from proteus.mprans import RDLS from .multiphase import * diff --git a/proteus/tests/CLSVOF/with_RANS2P/test_clsvof_with_rans2p.py b/test/CLSVOF/with_RANS2P/test_clsvof_with_rans2p.py similarity index 89% rename from proteus/tests/CLSVOF/with_RANS2P/test_clsvof_with_rans2p.py rename to test/CLSVOF/with_RANS2P/test_clsvof_with_rans2p.py index dea99fed24..6650fd65f1 100644 --- a/proteus/tests/CLSVOF/with_RANS2P/test_clsvof_with_rans2p.py +++ b/test/CLSVOF/with_RANS2P/test_clsvof_with_rans2p.py @@ -2,8 +2,6 @@ """ Test module for clsvof with rans2p """ -from builtins import range -from builtins import object from proteus.iproteus import * from proteus import Comm comm = Comm.get() @@ -11,7 +9,7 @@ Profiling.verbose=True import os import numpy as np -import tables +import h5py import pytest from proteus import default_so from . import (multiphase_so, multiphase, @@ -83,9 +81,8 @@ def test_2D_multiphase(self): ns.calculateSolution('2D_falling_bubble') # COMPARE VS SAVED FILES # expected_path = 'comparison_files/multiphase_2D_falling_bubble.h5' - expected = tables.open_file(os.path.join(self._scriptdir,expected_path)) - actual = tables.open_file('multiphase_2D_falling_bubble.h5','r') - assert np.allclose(expected.root.phi_t2,actual.root.phi_t2,atol=1e-10) + expected= h5py.File(os.path.join(self._scriptdir,expected_path)) + actual = h5py.File('multiphase_2D_falling_bubble.h5','r') + assert np.allclose(expected['phi_t2'],actual['phi_t2'],atol=1e-10) expected.close() actual.close() - diff --git a/proteus/tests/CLSVOF/with_RANS2P/twp_navier_stokes_n.py b/test/CLSVOF/with_RANS2P/twp_navier_stokes_n.py similarity index 98% rename from proteus/tests/CLSVOF/with_RANS2P/twp_navier_stokes_n.py rename to test/CLSVOF/with_RANS2P/twp_navier_stokes_n.py index b170183bab..54574d4ddf 100644 --- a/proteus/tests/CLSVOF/with_RANS2P/twp_navier_stokes_n.py +++ b/test/CLSVOF/with_RANS2P/twp_navier_stokes_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import (StepControl, TimeIntegration, NonlinearSolvers, diff --git a/proteus/tests/CLSVOF/with_RANS2P/twp_navier_stokes_p.py b/test/CLSVOF/with_RANS2P/twp_navier_stokes_p.py similarity index 97% rename from proteus/tests/CLSVOF/with_RANS2P/twp_navier_stokes_p.py rename to test/CLSVOF/with_RANS2P/twp_navier_stokes_p.py index 0a31d71f2f..eeda55f3af 100644 --- a/proteus/tests/CLSVOF/with_RANS2P/twp_navier_stokes_p.py +++ b/test/CLSVOF/with_RANS2P/twp_navier_stokes_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus.default_p import * from proteus.mprans import RANS2P from .multiphase import * diff --git a/proteus/tests/CLSVOF/with_RANS2P/vof_n.py b/test/CLSVOF/with_RANS2P/vof_n.py similarity index 98% rename from proteus/tests/CLSVOF/with_RANS2P/vof_n.py rename to test/CLSVOF/with_RANS2P/vof_n.py index 6c40a65f65..1df966a3dd 100644 --- a/proteus/tests/CLSVOF/with_RANS2P/vof_n.py +++ b/test/CLSVOF/with_RANS2P/vof_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus.default_n import * from proteus import (StepControl, TimeIntegration, diff --git a/proteus/tests/CLSVOF/with_RANS2P/vof_p.py b/test/CLSVOF/with_RANS2P/vof_p.py similarity index 94% rename from proteus/tests/CLSVOF/with_RANS2P/vof_p.py rename to test/CLSVOF/with_RANS2P/vof_p.py index 604125888b..515e2b0d90 100644 --- a/proteus/tests/CLSVOF/with_RANS2P/vof_p.py +++ b/test/CLSVOF/with_RANS2P/vof_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus.default_p import * from proteus.ctransportCoefficients import smoothedHeaviside from proteus.mprans import VOF diff --git a/proteus/tests/CLSVOF/pure_level_set/__init__.py b/test/CLSVOF/with_RANS3PF/__init__.py similarity index 100% rename from proteus/tests/CLSVOF/pure_level_set/__init__.py rename to test/CLSVOF/with_RANS3PF/__init__.py diff --git a/proteus/tests/CLSVOF/with_RANS3PF/clean.sh b/test/CLSVOF/with_RANS3PF/clean.sh similarity index 100% rename from proteus/tests/CLSVOF/with_RANS3PF/clean.sh rename to test/CLSVOF/with_RANS3PF/clean.sh diff --git a/proteus/tests/CLSVOF/with_RANS3PF/clsvof_n.py b/test/CLSVOF/with_RANS3PF/clsvof_n.py similarity index 96% rename from proteus/tests/CLSVOF/with_RANS3PF/clsvof_n.py rename to test/CLSVOF/with_RANS3PF/clsvof_n.py index f78519af56..a077cc5561 100644 --- a/proteus/tests/CLSVOF/with_RANS3PF/clsvof_n.py +++ b/test/CLSVOF/with_RANS3PF/clsvof_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: @@ -42,4 +41,3 @@ linear_solver_options_prefix = 'clsvof_' linearSolverConvergenceTest = 'r-true' - diff --git a/proteus/tests/CLSVOF/with_RANS3PF/clsvof_p.py b/test/CLSVOF/with_RANS3PF/clsvof_p.py similarity index 95% rename from proteus/tests/CLSVOF/with_RANS3PF/clsvof_p.py rename to test/CLSVOF/with_RANS3PF/clsvof_p.py index a0ed519a6f..6172693ec1 100644 --- a/proteus/tests/CLSVOF/with_RANS3PF/clsvof_p.py +++ b/test/CLSVOF/with_RANS3PF/clsvof_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * from proteus.ctransportCoefficients import smoothedHeaviside diff --git a/proteus/tests/CLSVOF/with_RANS3PF/comparison_files/comparison_2D_phi_t2.csv b/test/CLSVOF/with_RANS3PF/comparison_files/comparison_2D_phi_t2.csv similarity index 100% rename from proteus/tests/CLSVOF/with_RANS3PF/comparison_files/comparison_2D_phi_t2.csv rename to test/CLSVOF/with_RANS3PF/comparison_files/comparison_2D_phi_t2.csv diff --git a/proteus/tests/CLSVOF/with_RANS3PF/comparison_files/comparison_3D_phi_t2.csv b/test/CLSVOF/with_RANS3PF/comparison_files/comparison_3D_phi_t2.csv similarity index 100% rename from proteus/tests/CLSVOF/with_RANS3PF/comparison_files/comparison_3D_phi_t2.csv rename to test/CLSVOF/with_RANS3PF/comparison_files/comparison_3D_phi_t2.csv diff --git a/proteus/tests/CLSVOF/with_RANS3PF/ls_consrv_n.py b/test/CLSVOF/with_RANS3PF/ls_consrv_n.py similarity index 96% rename from proteus/tests/CLSVOF/with_RANS3PF/ls_consrv_n.py rename to test/CLSVOF/with_RANS3PF/ls_consrv_n.py index 48d8981014..3582014bea 100644 --- a/proteus/tests/CLSVOF/with_RANS3PF/ls_consrv_n.py +++ b/test/CLSVOF/with_RANS3PF/ls_consrv_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from .multiphase import * from .ls_consrv_p import * diff --git a/proteus/tests/CLSVOF/with_RANS3PF/ls_consrv_p.py b/test/CLSVOF/with_RANS3PF/ls_consrv_p.py similarity index 94% rename from proteus/tests/CLSVOF/with_RANS3PF/ls_consrv_p.py rename to test/CLSVOF/with_RANS3PF/ls_consrv_p.py index afce49171d..976060a6ad 100644 --- a/proteus/tests/CLSVOF/with_RANS3PF/ls_consrv_p.py +++ b/test/CLSVOF/with_RANS3PF/ls_consrv_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * from .multiphase import * diff --git a/proteus/tests/CLSVOF/with_RANS3PF/ls_n.py b/test/CLSVOF/with_RANS3PF/ls_n.py similarity index 97% rename from proteus/tests/CLSVOF/with_RANS3PF/ls_n.py rename to test/CLSVOF/with_RANS3PF/ls_n.py index e493bfaac3..06a2641aad 100644 --- a/proteus/tests/CLSVOF/with_RANS3PF/ls_n.py +++ b/test/CLSVOF/with_RANS3PF/ls_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from .ls_p import * diff --git a/proteus/tests/CLSVOF/with_RANS3PF/ls_p.py b/test/CLSVOF/with_RANS3PF/ls_p.py similarity index 94% rename from proteus/tests/CLSVOF/with_RANS3PF/ls_p.py rename to test/CLSVOF/with_RANS3PF/ls_p.py index cafdb34cf4..c29c8b1d10 100644 --- a/proteus/tests/CLSVOF/with_RANS3PF/ls_p.py +++ b/test/CLSVOF/with_RANS3PF/ls_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * from .multiphase import * diff --git a/proteus/tests/CLSVOF/with_RANS3PF/mesh2D.1.neigh b/test/CLSVOF/with_RANS3PF/mesh2D.1.neigh similarity index 100% rename from proteus/tests/CLSVOF/with_RANS3PF/mesh2D.1.neigh rename to test/CLSVOF/with_RANS3PF/mesh2D.1.neigh diff --git a/proteus/tests/CLSVOF/with_RANS3PF/mesh2D.1.poly b/test/CLSVOF/with_RANS3PF/mesh2D.1.poly similarity index 100% rename from proteus/tests/CLSVOF/with_RANS3PF/mesh2D.1.poly rename to test/CLSVOF/with_RANS3PF/mesh2D.1.poly diff --git a/proteus/tests/CLSVOF/with_RANS3PF/mesh2D.asy b/test/CLSVOF/with_RANS3PF/mesh2D.asy similarity index 100% rename from proteus/tests/CLSVOF/with_RANS3PF/mesh2D.asy rename to test/CLSVOF/with_RANS3PF/mesh2D.asy diff --git a/proteus/tests/CLSVOF/with_RANS3PF/mesh2D.edge b/test/CLSVOF/with_RANS3PF/mesh2D.edge similarity index 100% rename from proteus/tests/CLSVOF/with_RANS3PF/mesh2D.edge rename to test/CLSVOF/with_RANS3PF/mesh2D.edge diff --git a/proteus/tests/CLSVOF/with_RANS3PF/mesh2D.ele b/test/CLSVOF/with_RANS3PF/mesh2D.ele similarity index 100% rename from proteus/tests/CLSVOF/with_RANS3PF/mesh2D.ele rename to test/CLSVOF/with_RANS3PF/mesh2D.ele diff --git a/proteus/tests/CLSVOF/with_RANS3PF/mesh2D.node b/test/CLSVOF/with_RANS3PF/mesh2D.node similarity index 100% rename from proteus/tests/CLSVOF/with_RANS3PF/mesh2D.node rename to test/CLSVOF/with_RANS3PF/mesh2D.node diff --git a/proteus/tests/CLSVOF/with_RANS3PF/mesh2D.ply b/test/CLSVOF/with_RANS3PF/mesh2D.ply similarity index 100% rename from proteus/tests/CLSVOF/with_RANS3PF/mesh2D.ply rename to test/CLSVOF/with_RANS3PF/mesh2D.ply diff --git a/proteus/tests/CLSVOF/with_RANS3PF/mesh2D.poly b/test/CLSVOF/with_RANS3PF/mesh2D.poly similarity index 100% rename from proteus/tests/CLSVOF/with_RANS3PF/mesh2D.poly rename to test/CLSVOF/with_RANS3PF/mesh2D.poly diff --git a/proteus/tests/CLSVOF/with_RANS3PF/mesh3D.asy b/test/CLSVOF/with_RANS3PF/mesh3D.asy similarity index 100% rename from proteus/tests/CLSVOF/with_RANS3PF/mesh3D.asy rename to test/CLSVOF/with_RANS3PF/mesh3D.asy diff --git a/proteus/tests/CLSVOF/with_RANS3PF/mesh3D.edge b/test/CLSVOF/with_RANS3PF/mesh3D.edge similarity index 100% rename from proteus/tests/CLSVOF/with_RANS3PF/mesh3D.edge rename to test/CLSVOF/with_RANS3PF/mesh3D.edge diff --git a/proteus/tests/CLSVOF/with_RANS3PF/mesh3D.ele b/test/CLSVOF/with_RANS3PF/mesh3D.ele similarity index 100% rename from proteus/tests/CLSVOF/with_RANS3PF/mesh3D.ele rename to test/CLSVOF/with_RANS3PF/mesh3D.ele diff --git a/proteus/tests/CLSVOF/with_RANS3PF/mesh3D.face b/test/CLSVOF/with_RANS3PF/mesh3D.face similarity index 100% rename from proteus/tests/CLSVOF/with_RANS3PF/mesh3D.face rename to test/CLSVOF/with_RANS3PF/mesh3D.face diff --git a/proteus/tests/CLSVOF/with_RANS3PF/mesh3D.neigh b/test/CLSVOF/with_RANS3PF/mesh3D.neigh similarity index 100% rename from proteus/tests/CLSVOF/with_RANS3PF/mesh3D.neigh rename to test/CLSVOF/with_RANS3PF/mesh3D.neigh diff --git a/proteus/tests/CLSVOF/with_RANS3PF/mesh3D.node b/test/CLSVOF/with_RANS3PF/mesh3D.node similarity index 100% rename from proteus/tests/CLSVOF/with_RANS3PF/mesh3D.node rename to test/CLSVOF/with_RANS3PF/mesh3D.node diff --git a/proteus/tests/CLSVOF/with_RANS3PF/mesh3D.ply b/test/CLSVOF/with_RANS3PF/mesh3D.ply similarity index 100% rename from proteus/tests/CLSVOF/with_RANS3PF/mesh3D.ply rename to test/CLSVOF/with_RANS3PF/mesh3D.ply diff --git a/proteus/tests/CLSVOF/with_RANS3PF/mesh3D.poly b/test/CLSVOF/with_RANS3PF/mesh3D.poly similarity index 100% rename from proteus/tests/CLSVOF/with_RANS3PF/mesh3D.poly rename to test/CLSVOF/with_RANS3PF/mesh3D.poly diff --git a/proteus/tests/CLSVOF/with_RANS3PF/mesh3D_boundaryLegend.asy b/test/CLSVOF/with_RANS3PF/mesh3D_boundaryLegend.asy similarity index 100% rename from proteus/tests/CLSVOF/with_RANS3PF/mesh3D_boundaryLegend.asy rename to test/CLSVOF/with_RANS3PF/mesh3D_boundaryLegend.asy diff --git a/proteus/tests/CLSVOF/with_RANS3PF/multiphase.py b/test/CLSVOF/with_RANS3PF/multiphase.py similarity index 96% rename from proteus/tests/CLSVOF/with_RANS3PF/multiphase.py rename to test/CLSVOF/with_RANS3PF/multiphase.py index 19422e5c89..14d64db0a4 100644 --- a/proteus/tests/CLSVOF/with_RANS3PF/multiphase.py +++ b/test/CLSVOF/with_RANS3PF/multiphase.py @@ -1,7 +1,3 @@ -from __future__ import print_function -from __future__ import absolute_import -from __future__ import division -from past.utils import old_div from math import * import proteus.MeshTools from proteus import Domain @@ -134,13 +130,13 @@ # Domain and mesh if ct.test_case==1: #2D L = (1.0 , 2.0) - #he = old_div(L[0],float(4*Refinement-1)) + #he = L[0]/float(4*Refinement-1) he = 0.25 #he*=0.5 #he*=0.5 elif ct.test_case==2: #3D L = (1.0, 1.0, 2.0) - he = 0.5#old_div(L[0],float(4*Refinement-1)) + he = 0.5#L[0]/float(4*Refinement-1) weak_bc_penalty_constant = 1.0E6 nLevels = 1 @@ -158,13 +154,13 @@ if nd==2: nny = 2*nnx else: - nnx = int(old_div((nnx - 1),2)) + 1 + nnx = (nnx - 1)//2 + 1 nny = nnx nnz = 2*nnx triangleFlag=1 domain = Domain.RectangularDomain(L) domain.boundaryTags = boundaryTags - he = old_div(L[0],(nnx - 1)) + he = L[0]/(nnx-1) else: if nd==2: vertices = [[0.0, 0.0], #0 @@ -235,14 +231,14 @@ #domain.writePLY("mesh2D") #domain.writeAsymptote("mesh2D") domain.polyfile=os.path.dirname(os.path.abspath(__file__))+"/"+"mesh2D" - domain.MeshOptions.triangleOptions = "VApq30Dena%8.8f" % (old_div((he ** 2), 2.0),) + domain.MeshOptions.triangleOptions = "VApq30Dena%8.8f" % ((he**2)/2.0,) #triangleOptions = "VApen" else: #domain.writePoly("mesh3D") #domain.writePLY("mesh3D") #domain.writeAsymptote("mesh3D") domain.polyfile=os.path.dirname(os.path.abspath(__file__))+"/"+"mesh3D" - domain.MeshOptions.triangleOptions="VApq1.4q12feena%21.16e" % (old_div((he**3),6.0),) + domain.MeshOptions.triangleOptions="VApq1.4q12feena%21.16e" % ((he**3)/6.0,) #triangleOptions="VApfeena0.002" logEvent("""Mesh generated using: tetgen -%s %s""" % (triangleOptions, domain.polyfile + ".poly")) @@ -345,7 +341,7 @@ dt_fixed = 0.01 dt_init = min(0.1*dt_fixed,0.001) runCFL=0.33 -nDTout = int(round(old_div(T,dt_fixed))) +nDTout = int(round(T/dt_fixed)) ########################################## # Signed Distance # diff --git a/proteus/tests/CLSVOF/with_RANS3PF/multiphase_so.py b/test/CLSVOF/with_RANS3PF/multiphase_so.py similarity index 97% rename from proteus/tests/CLSVOF/with_RANS3PF/multiphase_so.py rename to test/CLSVOF/with_RANS3PF/multiphase_so.py index 41b0860f25..8aebe09ff7 100644 --- a/proteus/tests/CLSVOF/with_RANS3PF/multiphase_so.py +++ b/test/CLSVOF/with_RANS3PF/multiphase_so.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import range from proteus.default_so import * try: from . import multiphase diff --git a/proteus/tests/CLSVOF/with_RANS3PF/parameters.py b/test/CLSVOF/with_RANS3PF/parameters.py similarity index 87% rename from proteus/tests/CLSVOF/with_RANS3PF/parameters.py rename to test/CLSVOF/with_RANS3PF/parameters.py index e7e0511f6a..1c32cac1fc 100644 --- a/proteus/tests/CLSVOF/with_RANS3PF/parameters.py +++ b/test/CLSVOF/with_RANS3PF/parameters.py @@ -2,4 +2,4 @@ ct=Context.Options([ ("test_case",1,"1: 2D falling bubble. 2: 3D falling bubble") -],mutable=True) +],mutable=True) \ No newline at end of file diff --git a/proteus/tests/CLSVOF/with_RANS3PF/pressureInitial_n.py b/test/CLSVOF/with_RANS3PF/pressureInitial_n.py similarity index 96% rename from proteus/tests/CLSVOF/with_RANS3PF/pressureInitial_n.py rename to test/CLSVOF/with_RANS3PF/pressureInitial_n.py index ee1905b761..b0eca90540 100644 --- a/proteus/tests/CLSVOF/with_RANS3PF/pressureInitial_n.py +++ b/test/CLSVOF/with_RANS3PF/pressureInitial_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/CLSVOF/with_RANS3PF/pressureInitial_p.py b/test/CLSVOF/with_RANS3PF/pressureInitial_p.py similarity index 94% rename from proteus/tests/CLSVOF/with_RANS3PF/pressureInitial_p.py rename to test/CLSVOF/with_RANS3PF/pressureInitial_p.py index d6943dc1a7..2e13649a28 100644 --- a/proteus/tests/CLSVOF/with_RANS3PF/pressureInitial_p.py +++ b/test/CLSVOF/with_RANS3PF/pressureInitial_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from math import * from proteus import * from proteus.default_p import * diff --git a/proteus/tests/CLSVOF/with_RANS3PF/pressure_n.py b/test/CLSVOF/with_RANS3PF/pressure_n.py similarity index 96% rename from proteus/tests/CLSVOF/with_RANS3PF/pressure_n.py rename to test/CLSVOF/with_RANS3PF/pressure_n.py index 67a4c72f5b..e1b561f1d1 100644 --- a/proteus/tests/CLSVOF/with_RANS3PF/pressure_n.py +++ b/test/CLSVOF/with_RANS3PF/pressure_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/CLSVOF/with_RANS3PF/pressure_p.py b/test/CLSVOF/with_RANS3PF/pressure_p.py similarity index 93% rename from proteus/tests/CLSVOF/with_RANS3PF/pressure_p.py rename to test/CLSVOF/with_RANS3PF/pressure_p.py index 7f002b95ce..e40efc0b39 100644 --- a/proteus/tests/CLSVOF/with_RANS3PF/pressure_p.py +++ b/test/CLSVOF/with_RANS3PF/pressure_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from math import * from proteus import * from proteus.default_p import * diff --git a/proteus/tests/CLSVOF/with_RANS3PF/pressureincrement_n.py b/test/CLSVOF/with_RANS3PF/pressureincrement_n.py similarity index 96% rename from proteus/tests/CLSVOF/with_RANS3PF/pressureincrement_n.py rename to test/CLSVOF/with_RANS3PF/pressureincrement_n.py index 31b7ed3d3a..f49829e951 100644 --- a/proteus/tests/CLSVOF/with_RANS3PF/pressureincrement_n.py +++ b/test/CLSVOF/with_RANS3PF/pressureincrement_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/CLSVOF/with_RANS3PF/pressureincrement_p.py b/test/CLSVOF/with_RANS3PF/pressureincrement_p.py similarity index 95% rename from proteus/tests/CLSVOF/with_RANS3PF/pressureincrement_p.py rename to test/CLSVOF/with_RANS3PF/pressureincrement_p.py index 62e40c8613..218e9aee0c 100644 --- a/proteus/tests/CLSVOF/with_RANS3PF/pressureincrement_p.py +++ b/test/CLSVOF/with_RANS3PF/pressureincrement_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from math import * from proteus import * from proteus.default_p import * diff --git a/proteus/tests/CLSVOF/with_RANS3PF/redist_n.py b/test/CLSVOF/with_RANS3PF/redist_n.py similarity index 97% rename from proteus/tests/CLSVOF/with_RANS3PF/redist_n.py rename to test/CLSVOF/with_RANS3PF/redist_n.py index a4a0e55296..64437e08f3 100644 --- a/proteus/tests/CLSVOF/with_RANS3PF/redist_n.py +++ b/test/CLSVOF/with_RANS3PF/redist_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from .redist_p import * from .multiphase import * diff --git a/proteus/tests/CLSVOF/with_RANS3PF/redist_p.py b/test/CLSVOF/with_RANS3PF/redist_p.py similarity index 93% rename from proteus/tests/CLSVOF/with_RANS3PF/redist_p.py rename to test/CLSVOF/with_RANS3PF/redist_p.py index 6cbc41a923..cf1dae5757 100644 --- a/proteus/tests/CLSVOF/with_RANS3PF/redist_p.py +++ b/test/CLSVOF/with_RANS3PF/redist_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * from math import * diff --git a/proteus/tests/CLSVOF/with_RANS3PF/test_clsvof_with_rans3pf.py b/test/CLSVOF/with_RANS3PF/test_clsvof_with_rans3pf.py similarity index 92% rename from proteus/tests/CLSVOF/with_RANS3PF/test_clsvof_with_rans3pf.py rename to test/CLSVOF/with_RANS3PF/test_clsvof_with_rans3pf.py index 49063fb72b..78a6f4c8b9 100644 --- a/proteus/tests/CLSVOF/with_RANS3PF/test_clsvof_with_rans3pf.py +++ b/test/CLSVOF/with_RANS3PF/test_clsvof_with_rans3pf.py @@ -2,15 +2,13 @@ """ Test module for CLSVOF with RANS3PF """ -from builtins import range -from builtins import object from proteus.iproteus import * from proteus import Comm comm = Comm.get() Profiling.logLevel=7 Profiling.verbose=True import numpy as np -import tables +import h5py import pytest from proteus import default_so from . import (parameters, @@ -105,11 +103,12 @@ def test_2D_falling_bubble(self): assert 0, "Calculate solution failed" # COMPARE VS SAVED FILES # - actual = tables.open_file('multiphase_2D_falling_bubble.h5','r') + actual = h5py.File('multiphase_2D_falling_bubble.h5','r') + expected_path = 'comparison_files/' + 'comparison_2D_phi_t2.csv' #write comparison file #np.array(actual.root.phi_t2).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.phi_t2),decimal=10) + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['phi_t2']),decimal=10) actual.close() def test_3D_falling_bubble(self): @@ -142,11 +141,10 @@ def test_3D_falling_bubble(self): opts) ns.calculateSolution('3D_falling_bubble') # COMPARE VS SAVED FILES # - actual = tables.open_file('multiphase_3D_falling_bubble.h5','r') + actual = h5py.File('multiphase_3D_falling_bubble.h5','r') expected_path = 'comparison_files/' + 'comparison_3D_phi_t2.csv' #write comparison file #np.array(actual.root.phi_t2).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.phi_t2),decimal=10) + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['phi_t2']),decimal=10) actual.close() - diff --git a/proteus/tests/CLSVOF/with_RANS3PF/twp_navier_stokes_n.py b/test/CLSVOF/with_RANS3PF/twp_navier_stokes_n.py similarity index 98% rename from proteus/tests/CLSVOF/with_RANS3PF/twp_navier_stokes_n.py rename to test/CLSVOF/with_RANS3PF/twp_navier_stokes_n.py index d230c28947..4f19a18424 100644 --- a/proteus/tests/CLSVOF/with_RANS3PF/twp_navier_stokes_n.py +++ b/test/CLSVOF/with_RANS3PF/twp_navier_stokes_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * try: from .twp_navier_stokes_p import * diff --git a/proteus/tests/CLSVOF/with_RANS3PF/twp_navier_stokes_p.py b/test/CLSVOF/with_RANS3PF/twp_navier_stokes_p.py similarity index 98% rename from proteus/tests/CLSVOF/with_RANS3PF/twp_navier_stokes_p.py rename to test/CLSVOF/with_RANS3PF/twp_navier_stokes_p.py index 47452ef449..3df9d4177f 100644 --- a/proteus/tests/CLSVOF/with_RANS3PF/twp_navier_stokes_p.py +++ b/test/CLSVOF/with_RANS3PF/twp_navier_stokes_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * try: diff --git a/proteus/tests/CLSVOF/with_RANS3PF/vof_n.py b/test/CLSVOF/with_RANS3PF/vof_n.py similarity index 97% rename from proteus/tests/CLSVOF/with_RANS3PF/vof_n.py rename to test/CLSVOF/with_RANS3PF/vof_n.py index 85f90f7de1..3b6fe9379a 100644 --- a/proteus/tests/CLSVOF/with_RANS3PF/vof_n.py +++ b/test/CLSVOF/with_RANS3PF/vof_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from .multiphase import * from .vof_p import * diff --git a/proteus/tests/CLSVOF/with_RANS3PF/vof_p.py b/test/CLSVOF/with_RANS3PF/vof_p.py similarity index 95% rename from proteus/tests/CLSVOF/with_RANS3PF/vof_p.py rename to test/CLSVOF/with_RANS3PF/vof_p.py index c4f2503646..c5005ee8e2 100644 --- a/proteus/tests/CLSVOF/with_RANS3PF/vof_p.py +++ b/test/CLSVOF/with_RANS3PF/vof_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * from proteus.ctransportCoefficients import smoothedHeaviside diff --git a/proteus/tests/CLSVOF/with_RANS2P/__init__.py b/test/FSI/__init__.py similarity index 100% rename from proteus/tests/CLSVOF/with_RANS2P/__init__.py rename to test/FSI/__init__.py diff --git a/proteus/tests/FSI/fallingCylinder.py b/test/FSI/fallingCylinder.py similarity index 99% rename from proteus/tests/FSI/fallingCylinder.py rename to test/FSI/fallingCylinder.py index ea1d378c22..88ab624f98 100644 --- a/proteus/tests/FSI/fallingCylinder.py +++ b/test/FSI/fallingCylinder.py @@ -244,4 +244,3 @@ def uOfXT(self, x, t): m['flow'].p.coefficients.use_ball_as_particle = opts.use_ball_as_particle m['flow'].p.coefficients.nParticles = 1 m['flow'].n.conservativeFlux=None - diff --git a/proteus/tests/FSI/floatingCube.py b/test/FSI/floatingCube.py similarity index 98% rename from proteus/tests/FSI/floatingCube.py rename to test/FSI/floatingCube.py index 1359bdd73b..2396be57ec 100755 --- a/proteus/tests/FSI/floatingCube.py +++ b/test/FSI/floatingCube.py @@ -123,7 +123,7 @@ def uOfXT(self, x, t): # System g = np.array([0., 0., -9.81]) system = fsi.ProtChSystem() -system.ChSystem.Set_G_acc(pychrono.ChVectorD(g[0], g[1], g[2])) +system.ChSystem.SetGravitationalAcceleration(pychrono.ChVector3d(g[0], g[1], g[2])) system.setTimeStep(1e-5) #system.setCouplingScheme("CSS", prediction="backwardEuler") # Body @@ -132,9 +132,9 @@ def uOfXT(self, x, t): #body.Aij_factor = 1/width chbod = body.ChBody x, y, z = caisson.barycenter -pos = pychrono.ChVectorD(x, y, z) +pos = pychrono.ChVector3d(x, y, z) mass = (2.*radius)**3*rho_0*rhor -inertia = pychrono.ChVectorD(1., 1., 1.) +inertia = pychrono.ChVector3d(1., 1., 1.) chbod.SetPos(pos) chbod.SetMass(mass) chbod.SetInertiaXX(inertia) @@ -233,4 +233,3 @@ def uOfXT(self, x, t): for i in s.boundaryFlags: flags_rigidbody[i] = 1 m['addedMass'].p.coefficients.flags_rigidbody = flags_rigidbody - diff --git a/proteus/tests/FSI/floatingCylinder.py b/test/FSI/floatingCylinder.py similarity index 98% rename from proteus/tests/FSI/floatingCylinder.py rename to test/FSI/floatingCylinder.py index 46cf13cd6a..f31dc6dd29 100755 --- a/proteus/tests/FSI/floatingCylinder.py +++ b/test/FSI/floatingCylinder.py @@ -128,7 +128,7 @@ def uOfXT(self, x, t): # System g = np.array([0., -9.81, 0.]) system = fsi.ProtChSystem() -system.ChSystem.Set_G_acc(pychrono.ChVectorD(g[0], g[1], g[2])) +system.ChSystem.SetGravitationalAcceleration(pychrono.ChVector3d(g[0], g[1], g[2])) system.setTimeStep(1e-5) #system.setCouplingScheme("CSS", prediction="backwardEuler") # Body @@ -137,9 +137,9 @@ def uOfXT(self, x, t): #body.Aij_factor = 1/width chbod = body.ChBody x, y, z = caisson.barycenter -pos = pychrono.ChVectorD(x, y, z) +pos = pychrono.ChVector3d(x, y, z) mass = (2.*radius)**2*rho_0*rhor -inertia = pychrono.ChVectorD(1., 1., 1.) +inertia = pychrono.ChVector3d(1., 1., 1.) chbod.SetPos(pos) chbod.SetMass(mass) chbod.SetInertiaXX(inertia) @@ -236,4 +236,3 @@ def uOfXT(self, x, t): for i in s.boundaryFlags: flags_rigidbody[i] = 1 m['addedMass'].p.coefficients.flags_rigidbody = flags_rigidbody - diff --git a/proteus/tests/FSI/meshFallingCylinder.1.neigh b/test/FSI/meshFallingCylinder.1.neigh similarity index 100% rename from proteus/tests/FSI/meshFallingCylinder.1.neigh rename to test/FSI/meshFallingCylinder.1.neigh diff --git a/proteus/tests/FSI/meshFallingCylinder.1.poly b/test/FSI/meshFallingCylinder.1.poly similarity index 100% rename from proteus/tests/FSI/meshFallingCylinder.1.poly rename to test/FSI/meshFallingCylinder.1.poly diff --git a/proteus/tests/FSI/meshFallingCylinder.edge b/test/FSI/meshFallingCylinder.edge similarity index 100% rename from proteus/tests/FSI/meshFallingCylinder.edge rename to test/FSI/meshFallingCylinder.edge diff --git a/proteus/tests/FSI/meshFallingCylinder.ele b/test/FSI/meshFallingCylinder.ele similarity index 100% rename from proteus/tests/FSI/meshFallingCylinder.ele rename to test/FSI/meshFallingCylinder.ele diff --git a/proteus/tests/FSI/meshFallingCylinder.node b/test/FSI/meshFallingCylinder.node similarity index 100% rename from proteus/tests/FSI/meshFallingCylinder.node rename to test/FSI/meshFallingCylinder.node diff --git a/proteus/tests/FSI/meshFallingCylinder.poly b/test/FSI/meshFallingCylinder.poly similarity index 100% rename from proteus/tests/FSI/meshFallingCylinder.poly rename to test/FSI/meshFallingCylinder.poly diff --git a/proteus/tests/FSI/meshFloatingCube.edge b/test/FSI/meshFloatingCube.edge similarity index 100% rename from proteus/tests/FSI/meshFloatingCube.edge rename to test/FSI/meshFloatingCube.edge diff --git a/proteus/tests/FSI/meshFloatingCube.ele b/test/FSI/meshFloatingCube.ele similarity index 100% rename from proteus/tests/FSI/meshFloatingCube.ele rename to test/FSI/meshFloatingCube.ele diff --git a/proteus/tests/FSI/meshFloatingCube.face b/test/FSI/meshFloatingCube.face similarity index 100% rename from proteus/tests/FSI/meshFloatingCube.face rename to test/FSI/meshFloatingCube.face diff --git a/proteus/tests/FSI/meshFloatingCube.neigh b/test/FSI/meshFloatingCube.neigh similarity index 100% rename from proteus/tests/FSI/meshFloatingCube.neigh rename to test/FSI/meshFloatingCube.neigh diff --git a/proteus/tests/FSI/meshFloatingCube.node b/test/FSI/meshFloatingCube.node similarity index 100% rename from proteus/tests/FSI/meshFloatingCube.node rename to test/FSI/meshFloatingCube.node diff --git a/proteus/tests/FSI/meshFloatingCube.poly b/test/FSI/meshFloatingCube.poly similarity index 100% rename from proteus/tests/FSI/meshFloatingCube.poly rename to test/FSI/meshFloatingCube.poly diff --git a/proteus/tests/FSI/meshFloatingCylinder.1.neigh b/test/FSI/meshFloatingCylinder.1.neigh similarity index 100% rename from proteus/tests/FSI/meshFloatingCylinder.1.neigh rename to test/FSI/meshFloatingCylinder.1.neigh diff --git a/proteus/tests/FSI/meshFloatingCylinder.1.poly b/test/FSI/meshFloatingCylinder.1.poly similarity index 100% rename from proteus/tests/FSI/meshFloatingCylinder.1.poly rename to test/FSI/meshFloatingCylinder.1.poly diff --git a/proteus/tests/FSI/meshFloatingCylinder.edge b/test/FSI/meshFloatingCylinder.edge similarity index 100% rename from proteus/tests/FSI/meshFloatingCylinder.edge rename to test/FSI/meshFloatingCylinder.edge diff --git a/proteus/tests/FSI/meshFloatingCylinder.ele b/test/FSI/meshFloatingCylinder.ele similarity index 100% rename from proteus/tests/FSI/meshFloatingCylinder.ele rename to test/FSI/meshFloatingCylinder.ele diff --git a/proteus/tests/FSI/meshFloatingCylinder.node b/test/FSI/meshFloatingCylinder.node similarity index 100% rename from proteus/tests/FSI/meshFloatingCylinder.node rename to test/FSI/meshFloatingCylinder.node diff --git a/proteus/tests/FSI/meshFloatingCylinder.poly b/test/FSI/meshFloatingCylinder.poly similarity index 100% rename from proteus/tests/FSI/meshFloatingCylinder.poly rename to test/FSI/meshFloatingCylinder.poly diff --git a/proteus/tests/FSI/petsc.options.superlu_dist b/test/FSI/petsc.options.superlu_dist similarity index 70% rename from proteus/tests/FSI/petsc.options.superlu_dist rename to test/FSI/petsc.options.superlu_dist index 40530d19fc..a2ffe6b968 100644 --- a/proteus/tests/FSI/petsc.options.superlu_dist +++ b/test/FSI/petsc.options.superlu_dist @@ -1,9 +1,9 @@ --rans2p_ksp_type preonly -rans2p_pc_type lu -rans2p_pc_factor_mat_solver_package superlu_dist --ncls_ksp_type preonly -ncls_pc_type lu -ncls_pc_factor_mat_solver_package superlu_dist --vof_ksp_type preonly -vof_pc_type lu -vof_pc_factor_mat_solver_package superlu_dist --rdls_ksp_type preonly -rdls_pc_type lu -rdls_pc_factor_mat_solver_package superlu_dist --mcorr_ksp_type preonly -mcorr_pc_type lu -mcorr_pc_factor_mat_solver_package superlu_dist --kappa_ksp_type preonly -kappa_pc_type lu -kappa_pc_factor_mat_solver_package superlu_dist --dissipation_ksp_type preonly -dissipation_pc_type lu -dissipation_pc_factor_mat_solver_package superlu_dist --mesh_ksp_type preonly -mesh_pc_type lu -mesh_pc_factor_mat_solver_package superlu_dist +-rans2p_ksp_type preonly -rans2p_pc_type lu -rans2p_pc_factor_mat_solver_package superlu +-ncls_ksp_type preonly -ncls_pc_type lu -ncls_pc_factor_mat_solver_package superlu +-vof_ksp_type preonly -vof_pc_type lu -vof_pc_factor_mat_solver_package superlu +-rdls_ksp_type preonly -rdls_pc_type lu -rdls_pc_factor_mat_solver_package superlu +-mcorr_ksp_type preonly -mcorr_pc_type lu -mcorr_pc_factor_mat_solver_package superlu +-kappa_ksp_type preonly -kappa_pc_type lu -kappa_pc_factor_mat_solver_package superlu +-dissipation_ksp_type preonly -dissipation_pc_type lu -dissipation_pc_factor_mat_solver_package superlu +-mesh_ksp_type preonly -mesh_pc_type lu -mesh_pc_factor_mat_solver_package superlu -am_ksp_type cg -am_pc_type gamg -am_mg_coarse_ksp_type preonly -am_mg_coarse_pc_type svd diff --git a/proteus/tests/FSI/test_FSI.py b/test/FSI/test_FSI.py similarity index 98% rename from proteus/tests/FSI/test_FSI.py rename to test/FSI/test_FSI.py index ea72fd88dd..e201267c1a 100644 --- a/proteus/tests/FSI/test_FSI.py +++ b/test/FSI/test_FSI.py @@ -1,7 +1,4 @@ #!/usr/bin/env python -from __future__ import print_function -from __future__ import absolute_import -from builtins import range import os import pytest from proteus.iproteus import opts, default_s diff --git a/proteus/tests/ProjScheme_with_EV/L2_batch.py b/test/HotStart_3P/L2_batch.py old mode 100644 new mode 100755 similarity index 99% rename from proteus/tests/ProjScheme_with_EV/L2_batch.py rename to test/HotStart_3P/L2_batch.py index 3f7c9257c6..28e7edc8de --- a/proteus/tests/ProjScheme_with_EV/L2_batch.py +++ b/test/HotStart_3P/L2_batch.py @@ -15,4 +15,4 @@ # start -quit +quit \ No newline at end of file diff --git a/proteus/tests/HotStart_3P/NS_hotstart.py b/test/HotStart_3P/NS_hotstart.py similarity index 97% rename from proteus/tests/HotStart_3P/NS_hotstart.py rename to test/HotStart_3P/NS_hotstart.py index 4556521d43..a5de377029 100755 --- a/proteus/tests/HotStart_3P/NS_hotstart.py +++ b/test/HotStart_3P/NS_hotstart.py @@ -1,7 +1,3 @@ -from __future__ import print_function -from __future__ import division -from builtins import range -from past.utils import old_div from math import * import proteus.MeshTools from proteus import Domain @@ -104,7 +100,7 @@ # Domain and mesh #L = (0.584,0.350) L = (1.0, 1.0) -he = old_div(L[0],float(4*Refinement-1)) +he = L[0]/float(4*Refinement-1) he*=0.5 he*=0.5 #he*=0.5 @@ -179,7 +175,7 @@ #domain.writePLY("mesh") #domain.writeAsymptote("mesh") domain.polyfile=os.path.dirname(os.path.abspath(__file__))+"/"+"mesh" - domain.MeshOptions.triangleOptions = "VApq30Dena%8.8f" % (old_div((he ** 2), 2.0),) + domain.MeshOptions.triangleOptions = "VApq30Dena%8.8f" % ((he**2)/2.0,) domain.MeshOptions.genMesh = genMesh @@ -194,7 +190,7 @@ else: dt_init = min(dt_init,0.5*dt_fixed) runCFL=0.33 -nDTout = int(round(old_div(T,dt_fixed))) +nDTout = int(round(T/dt_fixed)) if dt_init 1, dim = domain.nd) + mesh.convertFromPUMI(domain,domain.AdaptManager.PUMIAdapter, + domain.faceList,domain.regList, parallel = comm.size() > 1, dim = domain.nd) domain.AdaptManager.PUMIAdapter.transferFieldToPUMI(b"coordinates",mesh.nodeArray) @@ -55,7 +56,7 @@ def test_gmshLoadAndAdapt(verbose=0): Uinf = 2e-3 #hard code solution vector=numpy.zeros((mesh.nNodes_global,3),'d') - dummy = numpy.zeros(mesh.nNodes_global); + dummy = numpy.zeros((mesh.nNodes_global,),'d') vector[:,0] = dummy vector[:,1] = Uinf*mesh.nodeArray[:,2]/Lz #v-velocity vector[:,2] = dummy @@ -65,18 +66,20 @@ def test_gmshLoadAndAdapt(verbose=0): scalar=numpy.zeros((mesh.nNodes_global,1),'d') domain.AdaptManager.PUMIAdapter.transferFieldToPUMI(b"p", scalar) - + scalar[:,0] = mesh.nodeArray[:,2] domain.AdaptManager.PUMIAdapter.transferFieldToPUMI(b"phi", scalar) del scalar - scalar = numpy.zeros((mesh.nNodes_global,1),'d')+1.0 + scalar = numpy.ones((mesh.nNodes_global,1),'d') domain.AdaptManager.PUMIAdapter.transferFieldToPUMI(b"vof", scalar) - + del scalar + errorTotal=domain.AdaptManager.PUMIAdapter.get_local_error() - assert (errorTotal<1e-14) + assert errorTotal<1e-14 - #assert (domain.AdaptManager.willAdapt(),1) + #assert domain.AdaptManager.PUMIAdapter.willAdapt() + domain.AdaptManager.PUMIAdapter.adaptPUMIMesh(b"") mesh = MeshTools.TetrahedralMesh() @@ -86,9 +89,9 @@ def test_gmshLoadAndAdapt(verbose=0): parallel = comm.size() > 1, dim = domain.nd) nElements_final = mesh.nElements_global - assert (nElements_final>nElements_initial) + assert nElements_final>nElements_initial -def test_2DgmshLoadAndAdapt(verbose=0): +def test2DgmshLoadAndAdapt(verbose=0): """Test for loading gmsh mesh through PUMI, estimating error and adapting for a 2D Couette flow case""" testDir=os.path.dirname(os.path.abspath(__file__)) @@ -152,10 +155,10 @@ def test_2DgmshLoadAndAdapt(verbose=0): domain.AdaptManager.PUMIAdapter.transferFieldToPUMI(b"vof", scalar) errorTotal=domain.AdaptManager.PUMIAdapter.get_local_error() - assert (errorTotal<1e-14) - - #assert (domain.AdaptManager.willAdapt(),1) + assert errorTotal<1e-14 + #assert domain.AdaptManager.PUMIAdapter.willAdapt() + domain.AdaptManager.PUMIAdapter.adaptPUMIMesh(b"") mesh = MeshTools.TriangularMesh() @@ -167,7 +170,7 @@ def test_2DgmshLoadAndAdapt(verbose=0): nElements_final = mesh.nElements_global assert (nElements_final>nElements_initial) -def test_2DmultiRegion(verbose=0): +def t2DmultiRegion(verbose=0): """Test for loading gmsh mesh through PUMI with multiple-regions""" testDir=os.path.dirname(os.path.abspath(__file__)) Model=testDir + '/TwoQuads.dmg' @@ -186,4 +189,3 @@ def test_2DmultiRegion(verbose=0): mesh.convertFromPUMI(domain,domain.AdaptManager.PUMIAdapter, domain.faceList,domain.regList, parallel = comm.size() > 1, dim = domain.nd) assert mesh.elementMaterialTypes[0]==1 assert mesh.elementMaterialTypes[-1]==2 - diff --git a/proteus/tests/MeshAdaptPUMI/test_meshLoad.py b/test/MeshAdaptPUMI/test_meshLoad.py similarity index 79% rename from proteus/tests/MeshAdaptPUMI/test_meshLoad.py rename to test/MeshAdaptPUMI/test_meshLoad.py index 3babefa225..a339ab9c2f 100755 --- a/proteus/tests/MeshAdaptPUMI/test_meshLoad.py +++ b/test/MeshAdaptPUMI/test_meshLoad.py @@ -7,15 +7,16 @@ import os import pytest -@pytest.mark.skip(reason=".smb file was removed during cleaning") +#@pytest.mark.skip(reason=".smb file was removed during cleaning") def test_meshLoadPUMI(verbose=0): """Test to load serial PUMI model and mesh""" testDir=os.path.dirname(os.path.abspath(__file__)) cubeMdl=testDir + '/cube.dmg' cube670p1=testDir + '/cube.smb' - PUMIAdapter=MeshAdaptPUMI.MeshAdapt() - PUMIAdapter.loadModelAndMesh(bytes(cubeMdl,'utf-8'), bytes(cube670p1,'utf-8')) + manager=MeshAdapt.AdaptManager() + PUMIAdapter=manager.PUMIAdapter + PUMIAdapter.loadModelAndMesh(cubeMdl.encode('ascii'), cube670p1.encode('ascii')) mesh = MeshTools.TetrahedralMesh() mesh.cmesh = cmeshTools.CMesh() diff --git a/test/MeshAdaptPUMI/test_parallelMeshLoad.py b/test/MeshAdaptPUMI/test_parallelMeshLoad.py new file mode 100644 index 0000000000..0f2a8be35b --- /dev/null +++ b/test/MeshAdaptPUMI/test_parallelMeshLoad.py @@ -0,0 +1,58 @@ +from ctypes import * +from proteus import MeshTools +from proteus import cmeshTools +from proteus import Domain +from proteus.MeshAdaptPUMI import MeshAdapt +from proteus import Comm +import os +from petsc4py import PETSc +import pytest + +#Run these tests with `mpirun -n 2 py.test --boxed test_parallelMeshLoad.py` + +def test_3DparallelLoadPUMI(verbose=0): + """Test to load 3D parallel PUMI model and mesh""" + comm = Comm.init() + if comm.size()!= 2: + print("Skipping 3DprallelLoadPUMI,must be run on 2 MPI tasks") + return + testDir=os.path.dirname(os.path.abspath(__file__)) + domain = Domain.PUMIDomain(manager=MeshAdapt.AdaptManager()) + Model=testDir+ '/cubepar.dmg' + Mesh=testDir + '/cubepar.smb' + #domain.PUMIMesh=MeshAdapt.MeshAdaptPUMI() + domain.AdaptManager.PUMIAdapter.loadModelAndMesh(bytes(Model,'utf-8'), bytes(Mesh,'utf-8')) + mesh = MeshTools.TetrahedralMesh() + mesh.cmesh = cmeshTools.CMesh() + mesh.convertFromPUMI(domain, domain.AdaptManager.PUMIAdapter, domain.faceList, domain.regList,parallel = comm.size() > 1, dim = domain.nd) + assert mesh.nElements_global == 670 + assert mesh.nNodes_global == 190 + assert mesh.nEdges_global == 977 + assert mesh.nElementBoundaries_global == 1458 + #Ideally, we can assert whether each rank gets the proper number of mesh entities/ + #With the present setup, that information doesn't seem accessible + #if(comm.rank()==0): + # eq(mesh.nElements_owned,4074) + # eq(mesh.nNodes_owned,994) + # eq(mesh.nEdges_owned,8729) + # eq(mesh.nElementBoundaries_owned,5648) + +def test_2DparallelLoadPUMI(verbose=0): + """Test to load 2D parallel PUMI model and mesh""" + comm = Comm.init() + if comm.size()!= 2: + print("Skipping 3DprallelLoadPUMI,must be run on 2 MPI tasks") + return + testDir=os.path.dirname(os.path.abspath(__file__)) + domain = Domain.PUMIDomain(dim=2,manager=MeshAdapt.AdaptManager()) + Model=testDir+ '/squarepar.dmg' + Mesh=testDir + '/squarepar.smb' + #domain.PUMIMesh=MeshAdapt.MeshAdaptPUMI() + domain.AdaptManager.PUMIAdapter.loadModelAndMesh(bytes(Model,'utf-8'), bytes(Mesh,'utf-8')) + mesh = MeshTools.TriangularMesh() + mesh.cmesh = cmeshTools.CMesh() + mesh.convertFromPUMI(domain, domain.AdaptManager.PUMIAdapter, domain.faceList, domain.regList,parallel = comm.size() > 1, dim = domain.nd) + assert mesh.nElements_global == 40 + assert mesh.nNodes_global == 29 + assert mesh.nEdges_global == 68 + assert mesh.nElementBoundaries_global == 68 diff --git a/proteus/tests/MeshAdaptPUMI/test_poiseuilleError.py b/test/MeshAdaptPUMI/test_poiseuilleError.py similarity index 99% rename from proteus/tests/MeshAdaptPUMI/test_poiseuilleError.py rename to test/MeshAdaptPUMI/test_poiseuilleError.py index edc5befeeb..56cf6a2ab4 100755 --- a/proteus/tests/MeshAdaptPUMI/test_poiseuilleError.py +++ b/test/MeshAdaptPUMI/test_poiseuilleError.py @@ -1,4 +1,3 @@ -from builtins import range import numpy from proteus import MeshTools from proteus import cmeshTools diff --git a/proteus/tests/poisson_2d/L2_batch.py b/test/MiscibleDisplacement/L2_batch.py similarity index 99% rename from proteus/tests/poisson_2d/L2_batch.py rename to test/MiscibleDisplacement/L2_batch.py index 0e5a8ed516..7056cac62d 100644 --- a/proteus/tests/poisson_2d/L2_batch.py +++ b/test/MiscibleDisplacement/L2_batch.py @@ -10,4 +10,4 @@ simFlags['storeTimes'] = ['Last'] # start -quit +quit \ No newline at end of file diff --git a/proteus/tests/MiscibleDisplacement/batch.py b/test/MiscibleDisplacement/batch.py similarity index 96% rename from proteus/tests/MiscibleDisplacement/batch.py rename to test/MiscibleDisplacement/batch.py index d7179bcf1b..2cc20cba16 100644 --- a/proteus/tests/MiscibleDisplacement/batch.py +++ b/test/MiscibleDisplacement/batch.py @@ -3,4 +3,4 @@ simFlagsList[0]['storeTimes'] = ['Last'] # start -quit +quit \ No newline at end of file diff --git a/proteus/tests/MiscibleDisplacement/md_flow_c0p1_n.py b/test/MiscibleDisplacement/md_flow_c0p1_n.py similarity index 99% rename from proteus/tests/MiscibleDisplacement/md_flow_c0p1_n.py rename to test/MiscibleDisplacement/md_flow_c0p1_n.py index 5f1f0b07b1..3b41f75b9d 100644 --- a/proteus/tests/MiscibleDisplacement/md_flow_c0p1_n.py +++ b/test/MiscibleDisplacement/md_flow_c0p1_n.py @@ -57,4 +57,3 @@ #need this for sun-wheeler-gs if cfluxtag == 'sun-gs-rt0': numericalFluxType = Advection_DiagonalUpwind_Diffusion_SIPG_exterior - diff --git a/proteus/tests/MiscibleDisplacement/md_flow_ncp1_n.py b/test/MiscibleDisplacement/md_flow_ncp1_n.py similarity index 99% rename from proteus/tests/MiscibleDisplacement/md_flow_ncp1_n.py rename to test/MiscibleDisplacement/md_flow_ncp1_n.py index 196f196248..7e22bed9d0 100644 --- a/proteus/tests/MiscibleDisplacement/md_flow_ncp1_n.py +++ b/test/MiscibleDisplacement/md_flow_ncp1_n.py @@ -50,4 +50,3 @@ cfluxtag = 'p1-nc' conservativeFlux = {0:cfluxtag} - diff --git a/proteus/tests/MiscibleDisplacement/md_flow_p.py b/test/MiscibleDisplacement/md_flow_p.py similarity index 94% rename from proteus/tests/MiscibleDisplacement/md_flow_p.py rename to test/MiscibleDisplacement/md_flow_p.py index 76e8e3e617..4f38a83f1b 100644 --- a/proteus/tests/MiscibleDisplacement/md_flow_p.py +++ b/test/MiscibleDisplacement/md_flow_p.py @@ -22,4 +22,4 @@ advectiveFluxBoundaryConditions = {0:noflux} -diffusiveFluxBoundaryConditions = {0:{0:noflux}} +diffusiveFluxBoundaryConditions = {0:{0:noflux}} \ No newline at end of file diff --git a/proteus/tests/MiscibleDisplacement/md_so.py b/test/MiscibleDisplacement/md_so.py similarity index 93% rename from proteus/tests/MiscibleDisplacement/md_so.py rename to test/MiscibleDisplacement/md_so.py index fcab4dc64e..fd2b557582 100644 --- a/proteus/tests/MiscibleDisplacement/md_so.py +++ b/test/MiscibleDisplacement/md_so.py @@ -1,4 +1,3 @@ -from builtins import range from proteus.default_so import * from miscible_displacement import * pnList = [("md_flow_p","md_flow_ncp1_n"), diff --git a/proteus/tests/MiscibleDisplacement/md_trans_c0p1_n.py b/test/MiscibleDisplacement/md_trans_c0p1_n.py similarity index 98% rename from proteus/tests/MiscibleDisplacement/md_trans_c0p1_n.py rename to test/MiscibleDisplacement/md_trans_c0p1_n.py index 4a5754ebcb..0bb4a4962d 100644 --- a/proteus/tests/MiscibleDisplacement/md_trans_c0p1_n.py +++ b/test/MiscibleDisplacement/md_trans_c0p1_n.py @@ -47,4 +47,4 @@ linTolFac = 1.0e-10 -conservativeFlux = None +conservativeFlux = None \ No newline at end of file diff --git a/proteus/tests/MiscibleDisplacement/md_trans_p.py b/test/MiscibleDisplacement/md_trans_p.py similarity index 99% rename from proteus/tests/MiscibleDisplacement/md_trans_p.py rename to test/MiscibleDisplacement/md_trans_p.py index b62ce5c2aa..ddf8f72969 100644 --- a/proteus/tests/MiscibleDisplacement/md_trans_p.py +++ b/test/MiscibleDisplacement/md_trans_p.py @@ -29,4 +29,3 @@ diffusiveFluxBoundaryConditions = {0:{}} - diff --git a/proteus/tests/MiscibleDisplacement/miscible_displacement.py b/test/MiscibleDisplacement/miscible_displacement.py similarity index 97% rename from proteus/tests/MiscibleDisplacement/miscible_displacement.py rename to test/MiscibleDisplacement/miscible_displacement.py index 0bf1fe3433..96c1b1ea63 100644 --- a/proteus/tests/MiscibleDisplacement/miscible_displacement.py +++ b/test/MiscibleDisplacement/miscible_displacement.py @@ -20,11 +20,6 @@ We'll assume \hat{\mu}(c) = a*(c-c_0) + b """ -from __future__ import print_function -from __future__ import division -from builtins import range -from builtins import object -from past.utils import old_div from proteus import * from proteus import SubsurfaceTransportCoefficients as STC @@ -165,9 +160,9 @@ def evaluate(self,t,c): genMesh = True refinement_level = 32 #define characteristic length -he = old_div(L[0],float(refinement_level)) +he = L[0]/float(refinement_level) -triangleOptions = "VApq30Dena{area:8.8f}".format(area=old_div((he**2),2.0)) +triangleOptions = "VApq30Dena{area:8.8f}".format(area=(he**2)/2.0) ### Material Properties ### @@ -264,7 +259,7 @@ def uOfXT(self,x,t): # numerics parallel = False -nnx = nny = int(old_div(L[0],he)) +nnx = nny = int(L[0]/he) nLevels = 1 if parallel: nLevels = 1 diff --git a/proteus/tests/LS_with_edgeBased_EV/NCLS/__init__.py b/test/MoveMeshMonitor/__init__.py similarity index 100% rename from proteus/tests/LS_with_edgeBased_EV/NCLS/__init__.py rename to test/MoveMeshMonitor/__init__.py diff --git a/proteus/tests/MoveMeshMonitor/moveMesh_n.py b/test/MoveMeshMonitor/moveMesh_n.py similarity index 96% rename from proteus/tests/MoveMeshMonitor/moveMesh_n.py rename to test/MoveMeshMonitor/moveMesh_n.py index 2d420cc1ab..40c1f44a81 100644 --- a/proteus/tests/MoveMeshMonitor/moveMesh_n.py +++ b/test/MoveMeshMonitor/moveMesh_n.py @@ -7,7 +7,11 @@ LinearSolvers, StepControl, LinearAlgebraTools) -from . import moveMesh_p as physics +try: + from . import moveMesh_p as physics +except: + import moveMesh_p as physics + from proteus import Context from proteus.mprans import AddedMass @@ -77,4 +81,3 @@ maxLineSearches = 0 periodicDirichletCOnditions = None conservativeFlux = None - diff --git a/proteus/tests/MoveMeshMonitor/moveMesh_p.py b/test/MoveMeshMonitor/moveMesh_p.py similarity index 96% rename from proteus/tests/MoveMeshMonitor/moveMesh_p.py rename to test/MoveMeshMonitor/moveMesh_p.py index 5ee2923a4b..68287be68a 100644 --- a/proteus/tests/MoveMeshMonitor/moveMesh_p.py +++ b/test/MoveMeshMonitor/moveMesh_p.py @@ -40,4 +40,4 @@ def getDBC(x,flag): def getDFBC(x, flag): return lambda x, t: 0. -diffusiveFluxBoundaryConditions = {0:{0:getDFBC}} +diffusiveFluxBoundaryConditions = {0:{0:getDFBC}} \ No newline at end of file diff --git a/proteus/tests/MoveMeshMonitor/movemesh_monitor.py b/test/MoveMeshMonitor/movemesh_monitor.py similarity index 99% rename from proteus/tests/MoveMeshMonitor/movemesh_monitor.py rename to test/MoveMeshMonitor/movemesh_monitor.py index 66a18717a3..9a268eded5 100644 --- a/proteus/tests/MoveMeshMonitor/movemesh_monitor.py +++ b/test/MoveMeshMonitor/movemesh_monitor.py @@ -141,4 +141,3 @@ def my_func(x, t): basis=C0_AffineQuadraticOnSimplexWithNodalBasis elementQuadrature = SimplexGaussQuadrature(nd,4) elementBoundaryQuadrature = SimplexGaussQuadrature(nd-1,4) - diff --git a/proteus/tests/MoveMeshMonitor/movemesh_monitor_so.py b/test/MoveMeshMonitor/movemesh_monitor_so.py similarity index 91% rename from proteus/tests/MoveMeshMonitor/movemesh_monitor_so.py rename to test/MoveMeshMonitor/movemesh_monitor_so.py index 21fc13c4e3..636b4d48e8 100644 --- a/proteus/tests/MoveMeshMonitor/movemesh_monitor_so.py +++ b/test/MoveMeshMonitor/movemesh_monitor_so.py @@ -5,8 +5,10 @@ import os from proteus.default_so import * from proteus import Context -from . import movemesh_monitor - +try: + from . import movemesh_monitor +except: + import movemesh_monitor # Create context from main module name_so = os.path.basename(__file__) if '_so.py' in name_so[-6:]: diff --git a/proteus/tests/MoveMeshMonitor/nodesResult.csv b/test/MoveMeshMonitor/nodesResult.csv similarity index 100% rename from proteus/tests/MoveMeshMonitor/nodesResult.csv rename to test/MoveMeshMonitor/nodesResult.csv diff --git a/proteus/tests/MoveMeshMonitor/petsc.options.asm b/test/MoveMeshMonitor/petsc.options.asm similarity index 100% rename from proteus/tests/MoveMeshMonitor/petsc.options.asm rename to test/MoveMeshMonitor/petsc.options.asm diff --git a/proteus/tests/MoveMeshMonitor/test_movemesh_monitor.py b/test/MoveMeshMonitor/test_movemesh_monitor.py similarity index 94% rename from proteus/tests/MoveMeshMonitor/test_movemesh_monitor.py rename to test/MoveMeshMonitor/test_movemesh_monitor.py index 3b233f5aa9..f97a96cc8a 100644 --- a/proteus/tests/MoveMeshMonitor/test_movemesh_monitor.py +++ b/test/MoveMeshMonitor/test_movemesh_monitor.py @@ -38,11 +38,13 @@ def test_MoveMeshMonitor(self): from . import movemesh_monitor_so pList = [] nList = [] + sys.path.append(os.path.dirname(__file__)) for (p,n) in movemesh_monitor_so.pnList: - pList.append(import_module("."+p,"proteus.tests.MoveMeshMonitor")) - nList.append(import_module("."+n,"proteus.tests.MoveMeshMonitor")) + pList.append(import_module(p)) + nList.append(import_module(n)) if pList[-1].name == None: pList[-1].name = p + sys.path.remove(os.path.dirname(__file__)) so = movemesh_monitor_so so.name = "movemesh_monitor" if so.sList == []: diff --git a/proteus/tests/POD/POD-DEIM_offline.ipynb b/test/POD/POD-DEIM_offline.ipynb similarity index 100% rename from proteus/tests/POD/POD-DEIM_offline.ipynb rename to test/POD/POD-DEIM_offline.ipynb diff --git a/proteus/tests/POD/POD.py b/test/POD/POD.py similarity index 96% rename from proteus/tests/POD/POD.py rename to test/POD/POD.py index a2195e1c90..84117816ac 100644 --- a/proteus/tests/POD/POD.py +++ b/test/POD/POD.py @@ -2,10 +2,6 @@ """ Proper orthogonal decomposition for the heat equation solver """ -from __future__ import print_function -from __future__ import division -from builtins import range -from past.utils import old_div from heat_init import * from read_hdf5 import * @@ -117,7 +113,7 @@ err = u-u_approx err *= err - err *= old_div(1.0,9261.0) + err *= 1.0/9261.0 L2approx = np.sqrt(err.sum()) print('error is %s ' % L2approx) diff --git a/proteus/tests/POD/POD_newton_burgers.py b/test/POD/POD_newton_burgers.py similarity index 96% rename from proteus/tests/POD/POD_newton_burgers.py rename to test/POD/POD_newton_burgers.py index 261cbea239..00c47ea9ab 100644 --- a/proteus/tests/POD/POD_newton_burgers.py +++ b/test/POD/POD_newton_burgers.py @@ -6,7 +6,6 @@ .. math: \frac{\partial u}{\partial t} + \nabla \cdot (\frac{1}{2} u^2 - \epsilon \nabla u) = 0 """ -from __future__ import print_function from burgers_init import * physics.name = "pod_burgers_{0}d".format(physics.nd) diff --git a/proteus/tests/POD/README b/test/POD/README similarity index 100% rename from proteus/tests/POD/README rename to test/POD/README diff --git a/proteus/tests/LS_with_edgeBased_EV/NCLS/import_files/__init__.py b/test/POD/__init__.py similarity index 100% rename from proteus/tests/LS_with_edgeBased_EV/NCLS/import_files/__init__.py rename to test/POD/__init__.py diff --git a/proteus/tests/POD/burgers.py b/test/POD/burgers.py similarity index 97% rename from proteus/tests/POD/burgers.py rename to test/POD/burgers.py index dcab4d442a..f2fe821ec4 100644 --- a/proteus/tests/POD/burgers.py +++ b/test/POD/burgers.py @@ -6,7 +6,6 @@ .. math: \frac{\partial u}{\partial t} + \nabla \cdot (\frac{1}{2} u^2 - \epsilon \nabla u) = 0 """ -from __future__ import print_function from burgers_init import * physics.name = "burgers_{0}d".format(physics.nd) diff --git a/proteus/tests/POD/burgers_init.py b/test/POD/burgers_init.py similarity index 97% rename from proteus/tests/POD/burgers_init.py rename to test/POD/burgers_init.py index bb7064ed9d..acbb0cab4a 100644 --- a/proteus/tests/POD/burgers_init.py +++ b/test/POD/burgers_init.py @@ -6,10 +6,6 @@ .. math: \frac{\partial u}{\partial t} + \nabla \cdot (\frac{1}{2} u^2 - \epsilon \nabla u) = 0 """ -from __future__ import division -from builtins import range -from past.utils import old_div -from builtins import object from proteus.iproteus import * class Burgers(TransportCoefficients.TC_base): @@ -116,7 +112,7 @@ def uOfXT(self,x,t): #numerics nDTout = 100 -DT = old_div(T,float(nDTout)) +DT = T/float(nDTout) numerics=default_n numerics.timeIntegration = TimeIntegration.BackwardEuler_cfl diff --git a/proteus/tests/POD/check_error_heat.py b/test/POD/check_error_heat.py similarity index 81% rename from proteus/tests/POD/check_error_heat.py rename to test/POD/check_error_heat.py index c76b91e3a5..e4692e04da 100644 --- a/proteus/tests/POD/check_error_heat.py +++ b/test/POD/check_error_heat.py @@ -1,14 +1,9 @@ #!/usr/bin/env python - -from __future__ import print_function -from __future__ import division -from builtins import range -from past.utils import old_div from read_hdf5 import * T = 1.0 nDTout = 100 -DT = old_div(T,float(nDTout)) +DT = T/float(nDTout) def uex0(x,t): """ @@ -34,7 +29,7 @@ def uex0(x,t): uex_vals = uex0(coord,i*DT) err = u-uex_vals err *= err - err *= old_div(1.0,9261.0) #9261 = 21^3 + err *= 1.0/9261.0 #9261 = 21^3 L2approx = np.sqrt(err.sum()) print("Trapezoidal approximation for error at dofs for nx=21 ny=21 nz=21 is %s " % L2approx) diff --git a/proteus/tests/POD/deim-todo.md b/test/POD/deim-todo.md similarity index 100% rename from proteus/tests/POD/deim-todo.md rename to test/POD/deim-todo.md diff --git a/proteus/tests/POD/deim_utils.py b/test/POD/deim_utils.py similarity index 97% rename from proteus/tests/POD/deim_utils.py rename to test/POD/deim_utils.py index e0932711ee..d9678f8560 100644 --- a/proteus/tests/POD/deim_utils.py +++ b/test/POD/deim_utils.py @@ -2,9 +2,6 @@ """ utility module for generating deim interpolants """ -from __future__ import division -from builtins import range -from past.utils import old_div import numpy as np def read_from_hdf5(hdfFile,label,dof_map=None): @@ -77,7 +74,7 @@ def calculate_deim_indices(Uin): Up=U[rho]#Up= np.dot(Pt,U) up=u[rho]#up= np.dot(Pt,u) if j==1: - c=old_div(up,Up) + c=up/Up r=u-U*c else: c =np.linalg.solve(Up,up) diff --git a/proteus/tests/POD/gappy_pod.ipynb b/test/POD/gappy_pod.ipynb similarity index 100% rename from proteus/tests/POD/gappy_pod.ipynb rename to test/POD/gappy_pod.ipynb diff --git a/proteus/tests/POD/heat.py b/test/POD/heat.py similarity index 98% rename from proteus/tests/POD/heat.py rename to test/POD/heat.py index c30e07431e..8d2c4758da 100644 --- a/proteus/tests/POD/heat.py +++ b/test/POD/heat.py @@ -3,7 +3,6 @@ Fine-scale heat equation solver The equation is du/du - Laplace u + u + f(x,y,z,t) = 0 """ -from __future__ import print_function from heat_init import * physics.name = "heat_3d" diff --git a/proteus/tests/POD/heat_init.py b/test/POD/heat_init.py similarity index 96% rename from proteus/tests/POD/heat_init.py rename to test/POD/heat_init.py index 4177fbec62..c3be2ab5a1 100644 --- a/proteus/tests/POD/heat_init.py +++ b/test/POD/heat_init.py @@ -3,10 +3,6 @@ Fine-scale heat equation solver The equation is du/du - Laplace u + u + f(x,y,z,t) = 0 """ -from __future__ import division -from builtins import range -from past.utils import old_div -from builtins import object from proteus.iproteus import * class Heat(TransportCoefficients.TC_base): @@ -79,7 +75,7 @@ def uOfXT(self,x,t): #numerics nDTout = 100 -DT = old_div(T,float(nDTout)) +DT = T/float(nDTout) numerics=default_n numerics.timeIntegration=TimeIntegration.BackwardEuler diff --git a/proteus/tests/POD/read_hdf5.py b/test/POD/read_hdf5.py similarity index 97% rename from proteus/tests/POD/read_hdf5.py rename to test/POD/read_hdf5.py index f80a06b4d7..0f3968ea12 100644 --- a/proteus/tests/POD/read_hdf5.py +++ b/test/POD/read_hdf5.py @@ -14,4 +14,4 @@ def read_from_hdf5(hdfFile,label,dof_map=None): else: dof = vals - return dof + return dof \ No newline at end of file diff --git a/proteus/tests/POD/svd.py b/test/POD/svd.py similarity index 80% rename from proteus/tests/POD/svd.py rename to test/POD/svd.py index e5b6371fe2..ff3886d6de 100644 --- a/proteus/tests/POD/svd.py +++ b/test/POD/svd.py @@ -1,14 +1,9 @@ #!/usr/bin/env python - -from __future__ import print_function -from __future__ import division -from builtins import range -from past.utils import old_div from read_hdf5 import * T = 1.0 nDTout = 100 -DT = old_div(T,float(nDTout)) +DT = T/float(nDTout) archive = Archiver.XdmfArchive(".","heat_3d",readOnly=True) diff --git a/proteus/tests/POD/svd_burgers.py b/test/POD/svd_burgers.py similarity index 88% rename from proteus/tests/POD/svd_burgers.py rename to test/POD/svd_burgers.py index 792485330b..284c09c472 100644 --- a/proteus/tests/POD/svd_burgers.py +++ b/test/POD/svd_burgers.py @@ -1,15 +1,11 @@ #!/usr/bin/env python - -from __future__ import print_function -from __future__ import division -from past.utils import old_div from burgers_init import use_deim from proteus import deim_utils,Archiver from proteus.deim_utils import read_snapshots T = 1.0 nDTout = 100 -DT = old_div(T,float(nDTout)) +DT = T/float(nDTout) archive = Archiver.XdmfArchive(".",burgers_init.physics.name,readOnly=True) diff --git a/proteus/tests/POD/test_deim.py b/test/POD/test_deim.py similarity index 96% rename from proteus/tests/POD/test_deim.py rename to test/POD/test_deim.py index edddd6b9b8..9087f3b4ad 100644 --- a/proteus/tests/POD/test_deim.py +++ b/test/POD/test_deim.py @@ -1,24 +1,22 @@ #!/usr/bin/env python - """ some tests for initial DEIM implementation in proteus """ -from __future__ import division -from builtins import range -from past.utils import old_div import numpy as np import numpy.testing as npt - +import sys, os from proteus import deim_utils def get_burgers_ns(name,T=0.1,nDTout=10,archive_pod_res=False): + sys.path.append(os.path.dirname(__file__)) import burgers_init as bu + sys.path.remove(os.path.dirname(__file__)) bu.physics.name=name bu.so.name = bu.physics.name #adjust default end time and number of output steps bu.T=T bu.nDTout=nDTout - bu.DT=old_div(bu.T,float(bu.nDTout)) + bu.DT=bu.T/float(bu.nDTout) bu.so.tnList = [i*bu.DT for i in range(bu.nDTout+1)] #request archiving of spatial residuals ... simFlagsList=None @@ -140,8 +138,8 @@ def test_deim_indices(): test_svd_space_res(file_prefix='F_s') U = np.loadtxt(basis_file) from proteus.deim_utils import calculate_deim_indices - rho_half = calculate_deim_indices(U[:,:old_div(U.shape[1],2)]) - assert rho_half.shape[0] == old_div(U.shape[1],2) + rho_half = calculate_deim_indices(U[:,:U.shape[1]//2]) + assert rho_half.shape[0] == U.shape[1]//2 rho = calculate_deim_indices(U) assert rho.shape[0] == U.shape[1] diff --git a/proteus/tests/HotStart_3P/L2_batch.py b/test/ProjScheme_with_EV/L2_batch.py old mode 100755 new mode 100644 similarity index 99% rename from proteus/tests/HotStart_3P/L2_batch.py rename to test/ProjScheme_with_EV/L2_batch.py index 3f7c9257c6..28e7edc8de --- a/proteus/tests/HotStart_3P/L2_batch.py +++ b/test/ProjScheme_with_EV/L2_batch.py @@ -15,4 +15,4 @@ # start -quit +quit \ No newline at end of file diff --git a/proteus/tests/ProjScheme_with_EV/NS_convergence.py b/test/ProjScheme_with_EV/NS_convergence.py similarity index 96% rename from proteus/tests/ProjScheme_with_EV/NS_convergence.py rename to test/ProjScheme_with_EV/NS_convergence.py index 3606968099..67fd3d0ff5 100644 --- a/proteus/tests/ProjScheme_with_EV/NS_convergence.py +++ b/test/ProjScheme_with_EV/NS_convergence.py @@ -1,7 +1,3 @@ -from __future__ import print_function -from __future__ import absolute_import -from __future__ import division -from past.utils import old_div from math import * import proteus.MeshTools from proteus import Domain @@ -88,7 +84,7 @@ # Domain and mesh L = (1.0, 1.0) -he = old_div(L[0],float(4*Refinement-1)) +he = L[0]/float(4*Refinement-1) he*=0.5 he*=0.5 @@ -141,7 +137,7 @@ domain.writePoly("mesh") domain.writePLY("mesh") domain.writeAsymptote("mesh") - triangleOptions = "VApq30Dena%8.8f" % (old_div((he ** 2), 2.0),) + triangleOptions = "VApq30Dena%8.8f" % ((he**2)/2.0,) domain.MeshOptions.nn = nn domain.MeshOptions.nnx = nnx @@ -155,7 +151,7 @@ dt_fixed = 0.1 dt_init = min(0.1*dt_fixed,0.001) runCFL=0.33 -nDTout = int(round(old_div(T,dt_fixed))) +nDTout = int(round(T/dt_fixed)) # Numerical parameters ns_sed_forceStrongDirichlet = False diff --git a/proteus/tests/ProjScheme_with_EV/NS_convergence_so.py b/test/ProjScheme_with_EV/NS_convergence_so.py similarity index 94% rename from proteus/tests/ProjScheme_with_EV/NS_convergence_so.py rename to test/ProjScheme_with_EV/NS_convergence_so.py index afec2f3533..071f12bb4b 100644 --- a/proteus/tests/ProjScheme_with_EV/NS_convergence_so.py +++ b/test/ProjScheme_with_EV/NS_convergence_so.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import range from proteus.default_so import * from . import NS_convergence diff --git a/proteus/tests/LS_with_edgeBased_EV/VOF/__init__.py b/test/ProjScheme_with_EV/__init__.py similarity index 100% rename from proteus/tests/LS_with_edgeBased_EV/VOF/__init__.py rename to test/ProjScheme_with_EV/__init__.py diff --git a/proteus/tests/ProjScheme_with_EV/clean.sh b/test/ProjScheme_with_EV/clean.sh similarity index 100% rename from proteus/tests/ProjScheme_with_EV/clean.sh rename to test/ProjScheme_with_EV/clean.sh diff --git a/proteus/tests/ProjScheme_with_EV/parameters.py b/test/ProjScheme_with_EV/parameters.py similarity index 94% rename from proteus/tests/ProjScheme_with_EV/parameters.py rename to test/ProjScheme_with_EV/parameters.py index ccbfe47d93..b0845d2dc2 100644 --- a/proteus/tests/ProjScheme_with_EV/parameters.py +++ b/test/ProjScheme_with_EV/parameters.py @@ -4,4 +4,4 @@ ("USE_SUPG_NS",0,"Use SUPG stabilization"), ("ARTIFICIAL_VISCOSITY_NS",2,"0: no art visc., 1: shock capturing, 2: entropy-viscosity"), ("INT_BY_PARTS_PRESSURE",0,"int or not by parts pressure in momentum equation") -],mutable=True) +],mutable=True) \ No newline at end of file diff --git a/proteus/tests/HotStart_3P/pressureInitial_n.py b/test/ProjScheme_with_EV/pressureInitial_n.py old mode 100755 new mode 100644 similarity index 96% rename from proteus/tests/HotStart_3P/pressureInitial_n.py rename to test/ProjScheme_with_EV/pressureInitial_n.py index 835b110ade..b401081fef --- a/proteus/tests/HotStart_3P/pressureInitial_n.py +++ b/test/ProjScheme_with_EV/pressureInitial_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * from .pressureInitial_p import * diff --git a/proteus/tests/ProjScheme_with_EV/pressureInitial_p.py b/test/ProjScheme_with_EV/pressureInitial_p.py similarity index 93% rename from proteus/tests/ProjScheme_with_EV/pressureInitial_p.py rename to test/ProjScheme_with_EV/pressureInitial_p.py index e79036d837..c8ced12620 100644 --- a/proteus/tests/ProjScheme_with_EV/pressureInitial_p.py +++ b/test/ProjScheme_with_EV/pressureInitial_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from math import * from proteus import * from proteus.default_p import * diff --git a/proteus/tests/ProjScheme_with_EV/pressure_n.py b/test/ProjScheme_with_EV/pressure_n.py similarity index 96% rename from proteus/tests/ProjScheme_with_EV/pressure_n.py rename to test/ProjScheme_with_EV/pressure_n.py index a1024fce96..a1caaf56b1 100644 --- a/proteus/tests/ProjScheme_with_EV/pressure_n.py +++ b/test/ProjScheme_with_EV/pressure_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * from .pressure_p import * diff --git a/proteus/tests/ProjScheme_with_EV/pressure_p.py b/test/ProjScheme_with_EV/pressure_p.py similarity index 91% rename from proteus/tests/ProjScheme_with_EV/pressure_p.py rename to test/ProjScheme_with_EV/pressure_p.py index 7b62e95e1d..5c3c5bb0d9 100644 --- a/proteus/tests/ProjScheme_with_EV/pressure_p.py +++ b/test/ProjScheme_with_EV/pressure_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from math import * from proteus import * from proteus.default_p import * diff --git a/proteus/tests/ProjScheme_with_EV/pressureincrement_n.py b/test/ProjScheme_with_EV/pressureincrement_n.py similarity index 95% rename from proteus/tests/ProjScheme_with_EV/pressureincrement_n.py rename to test/ProjScheme_with_EV/pressureincrement_n.py index 0f6d1a1a17..b3e5446828 100644 --- a/proteus/tests/ProjScheme_with_EV/pressureincrement_n.py +++ b/test/ProjScheme_with_EV/pressureincrement_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * from .pressureincrement_p import * diff --git a/proteus/tests/ProjScheme_with_EV/pressureincrement_p.py b/test/ProjScheme_with_EV/pressureincrement_p.py similarity index 96% rename from proteus/tests/ProjScheme_with_EV/pressureincrement_p.py rename to test/ProjScheme_with_EV/pressureincrement_p.py index 6aab06d126..e314cd7f27 100644 --- a/proteus/tests/ProjScheme_with_EV/pressureincrement_p.py +++ b/test/ProjScheme_with_EV/pressureincrement_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from math import * from proteus import * from proteus.default_p import * diff --git a/proteus/tests/ProjScheme_with_EV/test_ns_convergence.py b/test/ProjScheme_with_EV/test_ns_convergence.py similarity index 76% rename from proteus/tests/ProjScheme_with_EV/test_ns_convergence.py rename to test/ProjScheme_with_EV/test_ns_convergence.py index d3284553d8..312d2be627 100644 --- a/proteus/tests/ProjScheme_with_EV/test_ns_convergence.py +++ b/test/ProjScheme_with_EV/test_ns_convergence.py @@ -2,8 +2,6 @@ """ Test module for projection scheme """ -from builtins import range -from builtins import object from proteus.iproteus import * from proteus import Comm comm = Comm.get() @@ -11,7 +9,7 @@ Profiling.verbose=True import os import numpy as np -import tables +import h5py from . import (parameters, NS_convergence_so, NS_convergence, twp_navier_stokes_p, @@ -84,18 +82,18 @@ def test_no_stab(self): opts) ns.calculateSolution('no_stab') # COMPARE VS REFERENCE # - actual = tables.open_file('NS_convergence_no_stab.h5','r') + actual = h5py.File('NS_convergence_no_stab.h5','r') if self.verbose: - print (np.amax(actual.root.p_t11) - np.amin(actual.root.p_t11)) - print (np.amax(actual.root.u_t11) - np.amin(actual.root.u_t11)) - print (np.amax(actual.root.v_t11) - np.amin(actual.root.v_t11)) - assert np.isclose(np.amax(actual.root.p_t11) - np.amin(actual.root.p_t11), + print (np.amax(actual['p_t11']) - np.amin(actual['p_t11'])) + print (np.amax(actual['u_t11']) - np.amin(actual['u_t11'])) + print (np.amax(actual['v_t11']) - np.amin(actual['v_t11'])) + assert np.isclose(np.amax(actual['p_t11']) - np.amin(actual['p_t11']), 0.57387646058, atol=1e-10) - assert np.isclose(np.amax(actual.root.u_t11) - np.amin(actual.root.u_t11), + assert np.isclose(np.amax(actual['u_t11']) - np.amin(actual['u_t11']), 1.68689338205, atol=1e-10) - assert np.isclose(np.amax(actual.root.v_t11) - np.amin(actual.root.v_t11), + assert np.isclose(np.amax(actual['v_t11']) - np.amin(actual['v_t11']), 1.68689335359, atol=1e-10) actual.close() @@ -131,18 +129,18 @@ def test_supg_with_shock_capturing(self): opts) ns.calculateSolution('supg') # COMPARE VS REFERENCE # - actual = tables.open_file('NS_convergence_supg.h5','r') + actual =h5py.File('NS_convergence_supg.h5','r') if self.verbose: - print (np.amax(actual.root.p_t11) - np.amin(actual.root.p_t11)) - print (np.amax(actual.root.u_t11) - np.amin(actual.root.u_t11)) - print (np.amax(actual.root.v_t11) - np.amin(actual.root.v_t11)) - assert np.isclose(np.amax(actual.root.p_t11) - np.amin(actual.root.p_t11), + print (np.amax(actual['p_t11']) - np.amin(actual['p_t11'])) + print (np.amax(actual['u_t11']) - np.amin(actual['u_t11'])) + print (np.amax(actual['v_t11']) - np.amin(actual['v_t11'])) + assert np.isclose(np.amax(actual['p_t11']) - np.amin(actual['p_t11']), 0.691428927609, atol=1e-10) - assert np.isclose(np.amax(actual.root.u_t11) - np.amin(actual.root.u_t11), + assert np.isclose(np.amax(actual['u_t11']) - np.amin(actual['u_t11']), 1.68689322528, atol=1e-10) - assert np.isclose(np.amax(actual.root.v_t11) - np.amin(actual.root.v_t11), + assert np.isclose(np.amax(actual['v_t11']) - np.amin(actual['v_t11']), 1.68689322528, atol=1e-10) actual.close() @@ -178,18 +176,18 @@ def test_ev(self): opts) ns.calculateSolution('ev') # COMPARE VS REFERENCE # - actual = tables.open_file('NS_convergence_ev.h5','r') + actual = h5py.File('NS_convergence_ev.h5','r') if self.verbose: - print (np.amax(actual.root.p_t11) - np.amin(actual.root.p_t11)) - print (np.amax(actual.root.u_t11) - np.amin(actual.root.u_t11)) - print (np.amax(actual.root.v_t11) - np.amin(actual.root.v_t11)) - assert np.isclose(np.amax(actual.root.p_t11) - np.amin(actual.root.p_t11), + print (np.amax(actual['p_t11']) - np.amin(actual['p_t11'])) + print (np.amax(actual['u_t11']) - np.amin(actual['u_t11'])) + print (np.amax(actual['v_t11']) - np.amin(actual['v_t11'])) + assert np.isclose(np.amax(actual['p_t11']) - np.amin(actual['p_t11']), 0.700588229005, atol=1e-10) - assert np.isclose(np.amax(actual.root.u_t11) - np.amin(actual.root.u_t11), + assert np.isclose(np.amax(actual['u_t11']) - np.amin(actual['u_t11']), 1.68689331381, atol=1e-10) - assert np.isclose(np.amax(actual.root.v_t11) - np.amin(actual.root.v_t11), + assert np.isclose(np.amax(actual['v_t11']) - np.amin(actual['v_t11']), 1.68689327141, atol=1e-10) actual.close() @@ -225,18 +223,18 @@ def test_edge_based_visc_1(self): opts) ns.calculateSolution('edge_based_visc_1') # COMPARE VS REFERENCE # - actual = tables.open_file('NS_convergence_edge_based_visc_1.h5','r') + actual = h5py.File('NS_convergence_edge_based_visc_1.h5','r') if self.verbose: - print (np.amax(actual.root.p_t11) - np.amin(actual.root.p_t11)) - print (np.amax(actual.root.u_t11) - np.amin(actual.root.u_t11)) - print (np.amax(actual.root.v_t11) - np.amin(actual.root.v_t11)) - assert np.isclose(np.amax(actual.root.p_t11) - np.amin(actual.root.p_t11), + print (np.amax(actual['p_t11']) - np.amin(actual['p_t11'])) + print (np.amax(actual['u_t11']) - np.amin(actual['u_t11'])) + print (np.amax(actual['v_t11']) - np.amin(actual['v_t11'])) + assert np.isclose(np.amax(actual['p_t11']) - np.amin(actual['p_t11']), 0.56488226811, atol=1e-10) - assert np.isclose(np.amax(actual.root.u_t11) - np.amin(actual.root.u_t11), + assert np.isclose(np.amax(actual['u_t11']) - np.amin(actual['u_t11']), 1.68689324190, atol=1e-10) - assert np.isclose(np.amax(actual.root.v_t11) - np.amin(actual.root.v_t11), + assert np.isclose(np.amax(actual['v_t11']) - np.amin(actual['v_t11']), 1.68689318024, atol=1e-10) actual.close() @@ -272,18 +270,18 @@ def test_edge_based_visc_2(self): opts) ns.calculateSolution('edge_based_visc_2') # COMPARE VS REFERENCE # - actual = tables.open_file('NS_convergence_edge_based_visc_2.h5','r') + actual = h5py.File('NS_convergence_edge_based_visc_2.h5','r') if self.verbose: - print (np.amax(actual.root.p_t11) - np.amin(actual.root.p_t11)) - print (np.amax(actual.root.u_t11) - np.amin(actual.root.u_t11)) - print (np.amax(actual.root.v_t11) - np.amin(actual.root.v_t11)) - assert np.isclose(np.amax(actual.root.p_t11) - np.amin(actual.root.p_t11), + print (np.amax(actual['p_t11']) - np.amin(actual['p_t11'])) + print (np.amax(actual['u_t11']) - np.amin(actual['u_t11'])) + print (np.amax(actual['v_t11']) - np.amin(actual['v_t11'])) + assert np.isclose(np.amax(actual['p_t11']) - np.amin(actual['p_t11']), 0.71189509274, atol=1e-8) - assert np.isclose(np.amax(actual.root.u_t11) - np.amin(actual.root.u_t11), + assert np.isclose(np.amax(actual['u_t11']) - np.amin(actual['u_t11']), 1.68689324820, atol=1e-8) - assert np.isclose(np.amax(actual.root.v_t11) - np.amin(actual.root.v_t11), + assert np.isclose(np.amax(actual['v_t11']) - np.amin(actual['v_t11']), 1.68689335043, atol=1e-8) actual.close() diff --git a/proteus/tests/ProjScheme_with_EV/twp_navier_stokes_n.py b/test/ProjScheme_with_EV/twp_navier_stokes_n.py similarity index 97% rename from proteus/tests/ProjScheme_with_EV/twp_navier_stokes_n.py rename to test/ProjScheme_with_EV/twp_navier_stokes_n.py index 7cbc473c19..9e92db4564 100644 --- a/proteus/tests/ProjScheme_with_EV/twp_navier_stokes_n.py +++ b/test/ProjScheme_with_EV/twp_navier_stokes_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from .twp_navier_stokes_p import * from .NS_convergence import * diff --git a/proteus/tests/ProjScheme_with_EV/twp_navier_stokes_p.py b/test/ProjScheme_with_EV/twp_navier_stokes_p.py similarity index 99% rename from proteus/tests/ProjScheme_with_EV/twp_navier_stokes_p.py rename to test/ProjScheme_with_EV/twp_navier_stokes_p.py index a85abc6863..74ef84b4af 100644 --- a/proteus/tests/ProjScheme_with_EV/twp_navier_stokes_p.py +++ b/test/ProjScheme_with_EV/twp_navier_stokes_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * from .NS_convergence import * @@ -285,4 +283,3 @@ def __init__(self): def uOfXT(self,x,t): return np.cos(x[0])*np.sin(x[1]+t) analyticalPressureSolution={0:pressure()} - diff --git a/proteus/tests/LS_with_edgeBased_EV/VOF/import_files/__init__.py b/test/SWFlow/__init__.py similarity index 100% rename from proteus/tests/LS_with_edgeBased_EV/VOF/import_files/__init__.py rename to test/SWFlow/__init__.py diff --git a/proteus/tests/SWFlow/beji_periodic.py b/test/SWFlow/beji_periodic.py similarity index 98% rename from proteus/tests/SWFlow/beji_periodic.py rename to test/SWFlow/beji_periodic.py index d36955407f..b4286e4439 100644 --- a/proteus/tests/SWFlow/beji_periodic.py +++ b/test/SWFlow/beji_periodic.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import object -from past.utils import old_div from proteus import Domain, Context, MeshTools as mt from proteus.mprans import (SW2DCV, GN_SW2DCV) from proteus.mprans import SpatialTools as st @@ -245,4 +242,4 @@ def h_beta_DBC(X, flag): mySWFlowProblem.physical_parameters['abs_start'] = abs_start mySWFlowProblem.physical_parameters['abs_length'] = abs_length if opts.want_gauges: - mySWFlowProblem.auxiliaryVariables = [HeightPointGauges] + mySWFlowProblem.auxiliaryVariables = [HeightPointGauges] \ No newline at end of file diff --git a/proteus/tests/SWFlow/circular_damBreak.py b/test/SWFlow/circular_damBreak.py similarity index 97% rename from proteus/tests/SWFlow/circular_damBreak.py rename to test/SWFlow/circular_damBreak.py index ba0469de44..2438acad66 100644 --- a/proteus/tests/SWFlow/circular_damBreak.py +++ b/test/SWFlow/circular_damBreak.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import object -from past.utils import old_div from proteus.mprans import (SW2DCV, GN_SW2DCV) from proteus.Domain import RectangularDomain, PlanarStraightLineGraphDomain import numpy as np @@ -44,7 +41,7 @@ # CREATE REFINEMENT # nnx = 50 nny = 50 -he = old_div(L[0], float(nnx - 1)) +he = L[0]/float(nnx-1) if opts.structured: domain = rectangle else: diff --git a/proteus/tests/SWFlow/comparison_files/comparison_conical_island_h_t2.csv b/test/SWFlow/comparison_files/comparison_conical_island_h_t2.csv similarity index 100% rename from proteus/tests/SWFlow/comparison_files/comparison_conical_island_h_t2.csv rename to test/SWFlow/comparison_files/comparison_conical_island_h_t2.csv diff --git a/proteus/tests/SWFlow/comparison_files/comparison_dSWEs_steady_state_h_t2.csv b/test/SWFlow/comparison_files/comparison_dSWEs_steady_state_h_t2.csv similarity index 100% rename from proteus/tests/SWFlow/comparison_files/comparison_dSWEs_steady_state_h_t2.csv rename to test/SWFlow/comparison_files/comparison_dSWEs_steady_state_h_t2.csv diff --git a/proteus/tests/SWFlow/comparison_files/comparison_dam3Bumps_h_t2.csv b/test/SWFlow/comparison_files/comparison_dam3Bumps_h_t2.csv similarity index 100% rename from proteus/tests/SWFlow/comparison_files/comparison_dam3Bumps_h_t2.csv rename to test/SWFlow/comparison_files/comparison_dam3Bumps_h_t2.csv diff --git a/proteus/tests/SWFlow/comparison_files/comparison_obstacle_flow_h_t2.csv b/test/SWFlow/comparison_files/comparison_obstacle_flow_h_t2.csv similarity index 100% rename from proteus/tests/SWFlow/comparison_files/comparison_obstacle_flow_h_t2.csv rename to test/SWFlow/comparison_files/comparison_obstacle_flow_h_t2.csv diff --git a/proteus/tests/SWFlow/comparison_files/comparison_parab1D_h_t2.csv b/test/SWFlow/comparison_files/comparison_parab1D_h_t2.csv similarity index 100% rename from proteus/tests/SWFlow/comparison_files/comparison_parab1D_h_t2.csv rename to test/SWFlow/comparison_files/comparison_parab1D_h_t2.csv diff --git a/proteus/tests/SWFlow/comparison_files/comparison_reef_island_runup_h_t2.csv b/test/SWFlow/comparison_files/comparison_reef_island_runup_h_t2.csv similarity index 100% rename from proteus/tests/SWFlow/comparison_files/comparison_reef_island_runup_h_t2.csv rename to test/SWFlow/comparison_files/comparison_reef_island_runup_h_t2.csv diff --git a/proteus/tests/SWFlow/comparison_files/comparison_santos_step_h_t2.csv b/test/SWFlow/comparison_files/comparison_santos_step_h_t2.csv similarity index 100% rename from proteus/tests/SWFlow/comparison_files/comparison_santos_step_h_t2.csv rename to test/SWFlow/comparison_files/comparison_santos_step_h_t2.csv diff --git a/proteus/tests/SWFlow/comparison_files/comparison_seawall_h_t2.csv b/test/SWFlow/comparison_files/comparison_seawall_h_t2.csv similarity index 100% rename from proteus/tests/SWFlow/comparison_files/comparison_seawall_h_t2.csv rename to test/SWFlow/comparison_files/comparison_seawall_h_t2.csv diff --git a/proteus/tests/SWFlow/comparison_files/comparison_solitary_wave_h_t2.csv b/test/SWFlow/comparison_files/comparison_solitary_wave_h_t2.csv similarity index 100% rename from proteus/tests/SWFlow/comparison_files/comparison_solitary_wave_h_t2.csv rename to test/SWFlow/comparison_files/comparison_solitary_wave_h_t2.csv diff --git a/proteus/tests/SWFlow/comparison_files/comparison_transcritical_bump_h_t2.csv b/test/SWFlow/comparison_files/comparison_transcritical_bump_h_t2.csv similarity index 100% rename from proteus/tests/SWFlow/comparison_files/comparison_transcritical_bump_h_t2.csv rename to test/SWFlow/comparison_files/comparison_transcritical_bump_h_t2.csv diff --git a/proteus/tests/SWFlow/conical_island.py b/test/SWFlow/conical_island.py similarity index 95% rename from proteus/tests/SWFlow/conical_island.py rename to test/SWFlow/conical_island.py index 0700979036..192af2ab18 100644 --- a/proteus/tests/SWFlow/conical_island.py +++ b/test/SWFlow/conical_island.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import object -from past.utils import old_div from proteus.mprans import (SW2DCV, GN_SW2DCV) from proteus.Domain import RectangularDomain, PlanarStraightLineGraphDomain from proteus import (Domain, Context, @@ -46,8 +43,8 @@ # CREATE REFINEMENT # nnx0 = 6 nnx = (nnx0 - 1) * (2**refinement) + 1 -nny = old_div((nnx - 1), 1) + 1 -he = old_div(L[0], float(nnx - 1)) +nny = nnx +he = L[0]/float(nnx-1) if opts.structured: domain = rectangle else: @@ -70,7 +67,7 @@ alpha = 0.091 * h0 xs = 6.81474 -r = np.sqrt(old_div(3. * alpha, (4. * h0**2 * (h0 + alpha)))) +r = np.sqrt(3.*alpha/(4.*h0**2*(h0+alpha))) c = np.sqrt(g * (h0 + alpha)) # stuff for cone bathymetry @@ -113,7 +110,7 @@ class x_mom_at_t0(object): def uOfXT(self, X, t): hTilde = h0 + solitary_wave(X[0], 0) h = max(hTilde - bathymetry_function(X), 0.) - return h * c * old_div(hTilde - h0, hTilde) + return h * c * (hTilde-h0)/hTilde class y_mom_at_t0(object): @@ -143,7 +140,7 @@ def uOfXT(self, X, t): hTilde = h0 + solitary_wave(X[0], 0) h = max(hTilde - bathymetry_function(X), 0.) hTildePrime = -2.0 * alpha * r * np.tanh(r * (X[0] - xs)) * sechSqd - hw = -h**2 * old_div(c * h0 * hTildePrime, hTilde**2) + hw = -h**2 * c*h0*hTildePrime/hTilde**2 return hw diff --git a/proteus/tests/SWFlow/dSWEs_steady_state.py b/test/SWFlow/dSWEs_steady_state.py similarity index 94% rename from proteus/tests/SWFlow/dSWEs_steady_state.py rename to test/SWFlow/dSWEs_steady_state.py index 31c858f1d6..959ad1d8bc 100644 --- a/proteus/tests/SWFlow/dSWEs_steady_state.py +++ b/test/SWFlow/dSWEs_steady_state.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import object -from past.utils import old_div from proteus.mprans import (SW2DCV, GN_SW2DCV) from proteus.Domain import RectangularDomain import numpy as np @@ -41,8 +38,8 @@ # CREATE REFINEMENT # nnx0 = 6 nnx = (nnx0 - 1) * (2**refinement) + 1 -nny = old_div((nnx - 1), 10) + 1 -he = old_div(L[0], float(nnx - 1)) +nny = (nnx - 1)//10 + 1 +he = L[0]/float(nnx-1) triangleOptions = "pAq30Dena%f" % (0.5 * he**2,) ############################### @@ -59,13 +56,13 @@ # Functions defined here # ############################### def solitary_wave(x, t): - sechSqd = old_div(1.0, np.cosh(r*(x-x0))**2) + sechSqd = 1.0/np.cosh(r*(x-x0))**2 return h0 + a * h0 * sechSqd def bathymetry_function(X): x = X[0] - sechSqd = old_div(1.0, np.cosh(r*(x-x0))**2) + sechSqd = 1.0/np.cosh(r*(x-x0))**2 waterh = h0 * (1.0 + a * sechSqd) z = -1.0/2.0 * (waterh - h0) return z @@ -107,7 +104,7 @@ def uOfXT(self, X, t): class hw_at_t0(object): def uOfXT(self, X, t): x = X[0] - sechSqd = old_div(1.0, np.cosh(r*(x-x0))**2) + sechSqd = 1.0/np.cosh(r*(x-x0))**2 hw = -a * h0 * q * r * (2.0 + 3.0*(-0.50)) * sechSqd * np.tanh(r * x) return hw @@ -115,7 +112,7 @@ def uOfXT(self, X, t): class hbeta_at_t0(object): def uOfXT(self, X, t): x = X[0] - sechSqd = old_div(1.0, np.cosh(r*(x-x0))**2) + sechSqd = 1.0/np.cosh(r*(x-x0))**2 hbeta = -2.0 * a * h0 * r * q * (-1.0/2.0) * sechSqd * np.tanh(r * x) return hbeta diff --git a/proteus/tests/SWFlow/dam3Bumps.py b/test/SWFlow/dam3Bumps.py similarity index 97% rename from proteus/tests/SWFlow/dam3Bumps.py rename to test/SWFlow/dam3Bumps.py index 483f59cfdb..d6070a3220 100644 --- a/proteus/tests/SWFlow/dam3Bumps.py +++ b/test/SWFlow/dam3Bumps.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import object -from past.utils import old_div from proteus.mprans import (SW2DCV, GN_SW2DCV) from proteus.Domain import RectangularDomain, PlanarStraightLineGraphDomain import numpy as np @@ -43,8 +40,8 @@ # CREATE REFINEMENT # nnx0 = 6 nnx = (nnx0 - 1) * (2**refinement) + 1 -nny = old_div((nnx - 1), 2) + 1 -he = old_div(L[0], float(nnx - 1)) +nny = (nnx - 1)//2 + 1 +he = L[0]/float(nnx-1) if opts.structured: domain = rectangle else: diff --git a/proteus/tests/SWFlow/for_testMeshes/obstacle.1.neigh b/test/SWFlow/for_testMeshes/obstacle.1.neigh similarity index 100% rename from proteus/tests/SWFlow/for_testMeshes/obstacle.1.neigh rename to test/SWFlow/for_testMeshes/obstacle.1.neigh diff --git a/proteus/tests/SWFlow/for_testMeshes/obstacle.1.poly b/test/SWFlow/for_testMeshes/obstacle.1.poly similarity index 100% rename from proteus/tests/SWFlow/for_testMeshes/obstacle.1.poly rename to test/SWFlow/for_testMeshes/obstacle.1.poly diff --git a/proteus/tests/SWFlow/for_testMeshes/obstacle.edge b/test/SWFlow/for_testMeshes/obstacle.edge similarity index 100% rename from proteus/tests/SWFlow/for_testMeshes/obstacle.edge rename to test/SWFlow/for_testMeshes/obstacle.edge diff --git a/proteus/tests/SWFlow/for_testMeshes/obstacle.ele b/test/SWFlow/for_testMeshes/obstacle.ele similarity index 100% rename from proteus/tests/SWFlow/for_testMeshes/obstacle.ele rename to test/SWFlow/for_testMeshes/obstacle.ele diff --git a/proteus/tests/SWFlow/for_testMeshes/obstacle.node b/test/SWFlow/for_testMeshes/obstacle.node similarity index 100% rename from proteus/tests/SWFlow/for_testMeshes/obstacle.node rename to test/SWFlow/for_testMeshes/obstacle.node diff --git a/proteus/tests/SWFlow/for_testMeshes/obstacle.poly b/test/SWFlow/for_testMeshes/obstacle.poly similarity index 100% rename from proteus/tests/SWFlow/for_testMeshes/obstacle.poly rename to test/SWFlow/for_testMeshes/obstacle.poly diff --git a/proteus/tests/SWFlow/mach_flow.py b/test/SWFlow/mach_flow.py similarity index 97% rename from proteus/tests/SWFlow/mach_flow.py rename to test/SWFlow/mach_flow.py index 7932efbc6d..9399cad189 100644 --- a/proteus/tests/SWFlow/mach_flow.py +++ b/test/SWFlow/mach_flow.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import object -from past.utils import old_div from proteus.mprans import (SW2DCV, GN_SW2DCV) from proteus.Domain import RectangularDomain, PlanarStraightLineGraphDomain import numpy as np @@ -170,4 +167,4 @@ def hw_DBC(X, flag): boundaryConditions=boundaryConditions, reflectingBCs=opts.reflecting_BCs, bathymetry=bathymetry_function) -mySWFlowProblem.physical_parameters['mannings'] = opts.mannings +mySWFlowProblem.physical_parameters['mannings'] = opts.mannings \ No newline at end of file diff --git a/proteus/tests/SWFlow/obstacle_flow.py b/test/SWFlow/obstacle_flow.py similarity index 97% rename from proteus/tests/SWFlow/obstacle_flow.py rename to test/SWFlow/obstacle_flow.py index 12d833c789..fcaa1ea757 100644 --- a/proteus/tests/SWFlow/obstacle_flow.py +++ b/test/SWFlow/obstacle_flow.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import object -from past.utils import old_div from proteus.mprans import (SW2DCV, GN_SW2DCV) from proteus.Domain import RectangularDomain, PlanarStraightLineGraphDomain import numpy as np @@ -210,4 +207,4 @@ def hw_DBC(X, flag): reflectingBCs=opts.reflecting_BCs, bathymetry=bathymetry_function, genMesh=False) -mySWFlowProblem.physical_parameters['mannings'] = opts.mannings +mySWFlowProblem.physical_parameters['mannings'] = opts.mannings \ No newline at end of file diff --git a/proteus/tests/SWFlow/parab1D.py b/test/SWFlow/parab1D.py similarity index 87% rename from proteus/tests/SWFlow/parab1D.py rename to test/SWFlow/parab1D.py index a87b911f98..5692b007f0 100644 --- a/proteus/tests/SWFlow/parab1D.py +++ b/test/SWFlow/parab1D.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import object -from past.utils import old_div from proteus import * from proteus.default_p import * from proteus.mprans import SW2D @@ -32,9 +29,9 @@ # CREATE REFINEMENT # nnx0=6 nnx = (nnx0-1)*(2**refinement)+1 -nny = old_div((nnx-1),10)+1 +nny = (nnx-1)//10+1 -he = old_div(L[0],float(nnx-1)) +he = L[0]/float(nnx-1) triangleOptions="pAq30Dena%f" % (0.5*he**2,) ###################### @@ -45,22 +42,22 @@ B=2 k=0.001 g = SWFlowProblem.default_physical_parameters['gravity'] -p = old_div(np.sqrt(8*g*h0),a) -s = old_div(np.sqrt(p**2 - k**2),2.) +p = np.sqrt(8*g*h0)/a +s = np.sqrt(p**2-k**2)/2. mannings=k def bathymetry(X): x=X[0] - return h0*(x-old_div(L[0],2))**2/a/a + return h0*(x-L[0]/2)**2/a/a def eta_function(x,t): coeff1 = a**2*B**2/8./g/g/h0 coeff2 = -B**2/4./g - coeff3 = old_div(-1.,g) + coeff3 = -1./g - eta_part1 = coeff1*np.exp(-k*t)*(-s*k*np.sin(2*s*t)+(old_div(k**2,4.)-s**2)*np.cos(2*s*t)) + eta_part1 = coeff1*np.exp(-k*t)*(-s*k*np.sin(2*s*t)+(k**2/4.-s**2)*np.cos(2*s*t)) eta_part2 = coeff2*np.exp(-k*t) - eta_part3 = coeff3*np.exp(-k*t/2.)*(B*s*np.cos(s*t)+k*B/2.*np.sin(s*t))*(x-old_div(L[0],2)) + eta_part3 = coeff3*np.exp(-k*t/2.)*(B*s*np.cos(s*t)+k*B/2.*np.sin(s*t))*(x-L[0]/2) return h0 + eta_part1 + eta_part2 + eta_part3 diff --git a/proteus/tests/SWFlow/reef_island_runup.py b/test/SWFlow/reef_island_runup.py similarity index 96% rename from proteus/tests/SWFlow/reef_island_runup.py rename to test/SWFlow/reef_island_runup.py index 679deed5a7..093584bd8c 100644 --- a/proteus/tests/SWFlow/reef_island_runup.py +++ b/test/SWFlow/reef_island_runup.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import object -from past.utils import old_div from proteus.mprans import (SW2DCV, GN_SW2DCV) from proteus.Domain import RectangularDomain, PlanarStraightLineGraphDomain import numpy as np @@ -55,8 +52,8 @@ # CREATE REFINEMENT # nnx0 = 6 nnx = (nnx0 - 1) * (2**refinement) + 1 -nny = old_div((nnx - 1), 2) + 1 -he = old_div(L[0], float(nnx - 1)) +nny = (nnx - 1)//2 + 1 +he = L[0]/float(nnx-1) if opts.structured: domain = rectangle else: @@ -75,7 +72,7 @@ h0 = opts.still_water_depth alpha = opts.solitary_amplitude xs = opts.solitary_position -r = np.sqrt(old_div(3. * alpha, (4. * h0**2 * (h0 + alpha)))) +r = np.sqrt(3.*alpha/(4.*h0**2*(h0+alpha))) c = np.sqrt(g * (h0 + alpha)) # stuff for bathymetry, including shelf and cone @@ -147,7 +144,7 @@ class x_mom_at_t0(object): def uOfXT(self, X, t): hTilde = h0 + solitary_wave(X[0], 0) h = max(hTilde - bathymetry_function(X), 0.) - return h * c * old_div(hTilde - h0, hTilde) + return h * c * (hTilde-h0)/hTilde """ heta and hw are needed for the hyperbolic serre-green-naghdi equations. @@ -170,7 +167,7 @@ def uOfXT(self, X, t): hTilde = h0 + solitary_wave(X[0], 0) h = max(hTilde - bathymetry_function(X), 0.) hTildePrime = -2.0 * alpha * r * np.tanh(r * (X[0] - xs)) * sechSqd - hw = -h**2 * old_div(c * h0 * hTildePrime, hTilde**2) + hw = -h**2 * c*h0*hTildePrime/hTilde**2 return hw class Zero(object): diff --git a/proteus/tests/SWFlow/runup_solitaryWave.py b/test/SWFlow/runup_solitaryWave.py similarity index 97% rename from proteus/tests/SWFlow/runup_solitaryWave.py rename to test/SWFlow/runup_solitaryWave.py index e58065f083..2679060ee1 100644 --- a/proteus/tests/SWFlow/runup_solitaryWave.py +++ b/test/SWFlow/runup_solitaryWave.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import object -from past.utils import old_div from proteus.mprans import (SW2DCV, GN_SW2DCV) from proteus.Domain import RectangularDomain, PlanarStraightLineGraphDomain import numpy as np @@ -42,8 +39,8 @@ # CREATE REFINEMENT # nnx0 = 6 nnx = (nnx0 - 1) * (2**refinement) + 1 -nny = old_div((nnx - 1), 20) + 1 -he = old_div(L[0], float(nnx - 1)) +nny = (nnx - 1)//20 + 1 +he = L[0]/float(nnx-1) if opts.structured: domain = rectangle else: diff --git a/proteus/tests/SWFlow/santos_step.py b/test/SWFlow/santos_step.py similarity index 94% rename from proteus/tests/SWFlow/santos_step.py rename to test/SWFlow/santos_step.py index ba2b43f439..1b2027c1b4 100644 --- a/proteus/tests/SWFlow/santos_step.py +++ b/test/SWFlow/santos_step.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import object -from past.utils import old_div from proteus.mprans import (SW2DCV, GN_SW2DCV) from proteus.Domain import RectangularDomain, PlanarStraightLineGraphDomain import numpy as np @@ -40,8 +37,8 @@ # CREATE REFINEMENT # nnx0 = 6 nnx = (nnx0 - 1) * (2**refinement) + 1 -nny = old_div((nnx - 1), 10) + 1 -he = old_div(L[0], float(nnx - 1)) +nny = (nnx - 1)//10 + 1 +he = L[0]/float(nnx-1) triangleOptions = "pAq30Dena%f" % (0.5 * he**2,) if opts.structured: domain = rectangle @@ -61,7 +58,7 @@ h0 = 0.20 alpha = 0.0365 xs = -3.0 -r = np.sqrt(old_div(3. * alpha, (4. * h0**2 * (h0 + alpha)))) +r = np.sqrt(3.*alpha/(4.*h0**2*(h0+alpha))) c = np.sqrt(g * (h0 + alpha)) def solitary_wave(x, t): @@ -89,7 +86,7 @@ class x_mom_at_t0(object): def uOfXT(self, X, t): hTilde = h0 + solitary_wave(X[0], 0) h = max(hTilde - bathymetry_function(X), 0.) - return h * c * old_div(hTilde - h0, hTilde) + return h * c * (hTilde-h0)/hTilde """ heta and hw are needed for the hyperbolic serre-green-naghdi equations. @@ -112,7 +109,7 @@ def uOfXT(self, X, t): hTilde = h0 + solitary_wave(X[0], 0) h = max(hTilde - bathymetry_function(X), 0.) hTildePrime = -2.0 * alpha * r * np.tanh(r * (X[0] - xs)) * sechSqd - hw = -h**2 * old_div(c * h0 * hTildePrime, hTilde**2) + hw = -h**2 * c*h0*hTildePrime/hTilde**2 return hw class Zero(object): diff --git a/proteus/tests/SWFlow/seawall.py b/test/SWFlow/seawall.py similarity index 97% rename from proteus/tests/SWFlow/seawall.py rename to test/SWFlow/seawall.py index 8986765add..d9a63c9fe3 100644 --- a/proteus/tests/SWFlow/seawall.py +++ b/test/SWFlow/seawall.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import object -from past.utils import old_div from proteus.mprans import (SW2DCV, GN_SW2DCV) from proteus.Domain import RectangularDomain, PlanarStraightLineGraphDomain import numpy as np @@ -39,8 +36,8 @@ # CREATE REFINEMENT # nnx0 = 6 nnx = (nnx0 - 1) * (2**refinement) + 1 -nny = old_div((nnx - 1), 10) + 1 -he = old_div(L[0], float(nnx - 1)) +nny = (nnx - 1)//10 + 1 +he = L[0]/float(nnx-1) if opts.structured: domain = rectangle else: diff --git a/proteus/tests/SWFlow/solitary_wave.py b/test/SWFlow/solitary_wave.py similarity index 94% rename from proteus/tests/SWFlow/solitary_wave.py rename to test/SWFlow/solitary_wave.py index 53ab581773..cf3d6da6d8 100644 --- a/proteus/tests/SWFlow/solitary_wave.py +++ b/test/SWFlow/solitary_wave.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import object -from past.utils import old_div from proteus.mprans import (SW2DCV, GN_SW2DCV) from proteus.Domain import RectangularDomain, PlanarStraightLineGraphDomain import numpy as np @@ -39,8 +36,8 @@ # CREATE REFINEMENT # nnx0 = 6 nnx = (nnx0 - 1) * (2**refinement) + 1 -nny = old_div((nnx - 1), 10) + 1 -he = old_div(L[0], float(nnx - 1)) +nny = (nnx - 1)//10 + 1 +he = L[0]/float(nnx-1) triangleOptions = "pAq30Dena%f" % (0.5 * he**2,) if opts.structured: domain = rectangle @@ -60,7 +57,7 @@ h0 = 0.5 alpha = 0.2 * h0 xs = 5.0 -r = np.sqrt(old_div(3. * alpha, (4. * h0**2 * (h0 + alpha)))) +r = np.sqrt(3.*alpha/(4.*h0**2*(h0+alpha))) c = np.sqrt(g * (h0 + alpha)) @@ -89,7 +86,7 @@ def uOfXT(self, X, t): class x_mom_at_t0(object): def uOfXT(self, X, t): h = h0 + solitary_wave(X[0], 0) - return h * c * old_div(h - h0, h) + return h * c * (h-h0)/h class y_mom_at_t0(object): @@ -118,7 +115,7 @@ def uOfXT(self, X, t): sechSqd = (1.0 / np.cosh(r * (X[0] - xs)))**2.0 h = h0 + solitary_wave(X[0], 0) hPrime = -2.0 * alpha * r * np.tanh(r * (X[0] - xs)) * sechSqd - hw = -h**2 * old_div(c * h0 * hPrime, h**2) + hw = -h**2 * c*h0*hPrime/h**2 return hw ################################### diff --git a/proteus/tests/SWFlow/test_SWFlow.py b/test/SWFlow/test_SWFlow.py similarity index 86% rename from proteus/tests/SWFlow/test_SWFlow.py rename to test/SWFlow/test_SWFlow.py index a3fbcba897..2af6836d71 100644 --- a/proteus/tests/SWFlow/test_SWFlow.py +++ b/test/SWFlow/test_SWFlow.py @@ -3,7 +3,7 @@ Test module for SWFlow """ import pytest -import tables +import h5py import numpy as np import proteus.defaults from proteus import Context @@ -18,24 +18,24 @@ class TestSWFlow(object): def setup_method(self,method): self._scriptdir = os.path.dirname(__file__) - self.path = proteus.__path__[0]+"/tests/SWFlow/" + self.path = self._scriptdir def compare_vs_saved_files(self,name, write=False): #expected_path = 'comparison_files/' + name + '.h5' - #expected = tables.open_file(os.path.join(self._scriptdir,expected_path)) - #actual = tables.open_file(name+'.h5','r') - #assert np.allclose(expected.root.h_t2,actual.root.h_t2,atol=1e-8) + #expected = h5py.File(os.path.join(self._scriptdir,expected_path)) + #actual = h5py.File(name+'.h5','r') + #assert np.allclose(expected.root.h_t2,actual['h_t2'],atol=1e-8) #expected.close() #actual.close() - actual = tables.open_file(name+'.h5','r') + actual = h5py.File(name+'.h5','r') expected_path = 'comparison_files/' + 'comparison_' + name + '_h_t2.csv' if write: write_path = './comparison_files/' + 'comparison_' + name + '_h_t2.csv' - np.array(actual.root.h_t2).tofile(os.path.join(self._scriptdir, write_path),sep=",") + np.array(actual['h_t2']).tofile(os.path.join(self._scriptdir, write_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.h_t2).flatten(),decimal=7) + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['h_t2']).flatten(),decimal=7) actual.close() def test_solitary_wave(self): diff --git a/proteus/tests/SWFlow/transcritical_bump.py b/test/SWFlow/transcritical_bump.py similarity index 96% rename from proteus/tests/SWFlow/transcritical_bump.py rename to test/SWFlow/transcritical_bump.py index 3c1730922c..73a04bc553 100644 --- a/proteus/tests/SWFlow/transcritical_bump.py +++ b/test/SWFlow/transcritical_bump.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import object -from past.utils import old_div from proteus.mprans import (SW2DCV, GN_SW2DCV) from proteus.Domain import RectangularDomain, PlanarStraightLineGraphDomain import numpy as np @@ -38,8 +35,8 @@ # CREATE REFINEMENT # nnx0 = 6 nnx = (nnx0 - 1) * (2**refinement) + 1 -nny = old_div((nnx - 1), 10) + 1 -he = old_div(L[0], float(nnx - 1)) +nny = (nnx - 1)//10 + 1 +he = L[0]/float(nnx-1) triangleOptions = "pAq30Dena%f" % (0.5 * he**2,) if opts.structured: domain = rectangle diff --git a/proteus/tests/SWFlow/wet_well_balancing.py b/test/SWFlow/wet_well_balancing.py similarity index 97% rename from proteus/tests/SWFlow/wet_well_balancing.py rename to test/SWFlow/wet_well_balancing.py index e26de5b922..347c62d8a4 100644 --- a/proteus/tests/SWFlow/wet_well_balancing.py +++ b/test/SWFlow/wet_well_balancing.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import object -from past.utils import old_div from proteus.mprans import (SW2DCV, GN_SW2DCV) from proteus.Domain import RectangularDomain, PlanarStraightLineGraphDomain import numpy as np @@ -37,8 +34,8 @@ # CREATE REFINEMENT # nnx0 = 6 nnx = (nnx0 - 1) * (2**refinement) + 1 -nny = old_div((nnx - 1), 2) + 1 -he = old_div(L[0], float(nnx - 1)) +nny = (nnx - 1)//2 + 1 +he = L[0]/float(nnx-1) triangleOptions = "pAq30Dena%f" % (0.5 * he**2,) if opts.structured: domain = rectangle diff --git a/proteus/tests/LS_with_edgeBased_EV/__init__.py b/test/TADR/__init__.py similarity index 100% rename from proteus/tests/LS_with_edgeBased_EV/__init__.py rename to test/TADR/__init__.py diff --git a/test/TADR/comparison_files/tadr_level_0_EV1_u_t2.csv b/test/TADR/comparison_files/tadr_level_0_EV1_u_t2.csv new file mode 100644 index 0000000000..95ad2f0fee --- /dev/null +++ b/test/TADR/comparison_files/tadr_level_0_EV1_u_t2.csv @@ -0,0 +1 @@ +0.00029208363383364237,0.0004699608994679058,0.03308030559884424,0.35447620092969256,0.8649826467597768,0.9926835615686443,0.9627380295631388,0.6456093182864071,0.13821580885411155,0.008048888338038617,0.0005829930156896374,0.00030699808735015207,0.00023701033376224105,0.0033823833769541854,0.13667088417434645,0.6577443760047454,0.9589884898963226,0.9966375985895066,0.8616925711253118,0.34257358614598143,0.04099796472313176,0.0005099585404300191 \ No newline at end of file diff --git a/test/TADR/comparison_files/tadr_level_0_EV2_u_t2.csv b/test/TADR/comparison_files/tadr_level_0_EV2_u_t2.csv new file mode 100644 index 0000000000..e67c68e90d --- /dev/null +++ b/test/TADR/comparison_files/tadr_level_0_EV2_u_t2.csv @@ -0,0 +1 @@ +0.0016111948533818806,0.0009199278076460111,0.017756831608846745,0.32049767875191726,0.8994561170994826,0.9926618461770849,0.9778904620862396,0.6871252010910724,0.09850194161172757,0.006380629494615838,0.0008802623326641652,0.0010265881882152456,0.0005241673108221727,0.006293183156885703,0.0821436318421644,0.7052430437900512,0.977011615938272,0.9929093697636207,0.9136233872688998,0.2995661146499926,0.019280837903120872,0.0008512817504184474 \ No newline at end of file diff --git a/test/TADR/comparison_files/tadr_level_0_SUPG_u_t2.csv b/test/TADR/comparison_files/tadr_level_0_SUPG_u_t2.csv new file mode 100644 index 0000000000..95f1ac8e0a --- /dev/null +++ b/test/TADR/comparison_files/tadr_level_0_SUPG_u_t2.csv @@ -0,0 +1 @@ +0.00037923497329754694,-0.0007189172615847199,-0.10104997747684114,0.3393702734098521,0.816868374003203,0.9673017061996425,1.0956580913385923,0.6600429740635356,0.18445817852318883,0.032572201990336086,0.00820914164019527,-2.233643613340221e-05,-0.0003579570572207908,-0.007858910175890034,0.2358599433346788,0.776834324155063,0.9755836811177002,1.011503183386623,0.765758146672075,0.22216368301680517,0.024208983165761425,-0.0034397256512755116 \ No newline at end of file diff --git a/test/TADR/comparison_files/tadr_level_0_SmoothnessBased_u_t2.csv b/test/TADR/comparison_files/tadr_level_0_SmoothnessBased_u_t2.csv new file mode 100644 index 0000000000..10eee1dcb3 --- /dev/null +++ b/test/TADR/comparison_files/tadr_level_0_SmoothnessBased_u_t2.csv @@ -0,0 +1 @@ +0.0004774113106135165,0.0001333058459387944,0.023412691276985847,0.33412239262391097,0.8847102615952672,0.9951316548495008,0.9754432040141849,0.6653105008470095,0.11681594273882365,0.005145587645710981,0.000282170236637135,0.00014177124268884993,0.00013166194060896928,0.004410098886127218,0.1001039648326821,0.6881604355460376,0.9721221292066446,0.9949777548676876,0.8997136155948386,0.3128533052717142,0.026720331967203328,0.00024368999017106065 \ No newline at end of file diff --git a/test/TADR/comparison_files/tadr_level_0_TaylorGalerkin_u_t2.csv b/test/TADR/comparison_files/tadr_level_0_TaylorGalerkin_u_t2.csv new file mode 100644 index 0000000000..92b842158c --- /dev/null +++ b/test/TADR/comparison_files/tadr_level_0_TaylorGalerkin_u_t2.csv @@ -0,0 +1 @@ +0.0020765657576904987,0.03330667048992776,-0.1353171423598348,0.23230077486140954,0.8486808540268551,1.0159254044437933,1.0006595280505761,0.8567211792173726,0.13700202652042548,-0.0019152061997132121,0.019014598440525207,0.01620982712410569,-0.020906291895699897,0.01822862859344318,0.1730638137533076,0.7706557129151912,1.0721929850981007,0.9832673681642582,0.8348608987013938,0.27923211417243565,-0.1093596351588692,0.001013087975939615 \ No newline at end of file diff --git a/test/TADR/comparison_files/tadr_level_0_stab4_u_t2.csv b/test/TADR/comparison_files/tadr_level_0_stab4_u_t2.csv new file mode 100644 index 0000000000..319fa7938d --- /dev/null +++ b/test/TADR/comparison_files/tadr_level_0_stab4_u_t2.csv @@ -0,0 +1 @@ +1.7706936303191305e-09,7.95472032039577e-22,-4.4888217574732695e-27,0.31545007391295526,0.8762357255436768,0.9999480775783246,1.0,0.6845384080895546,0.12378907998378996,8.138083718486952e-05,2.6469443261929058e-23,1.2195153084322259e-08,8.213118127509481e-12,-4.518127886499327e-27,0.14861015246966305,0.6696834329023859,0.9902508325043806,0.999999989497628,0.8512301125878283,0.33031147239133124,0.00987111177189374,2.1801895017756102e-07 \ No newline at end of file diff --git a/proteus/tests/TADR/test_tadr.py b/test/TADR/test_tadr.py similarity index 99% rename from proteus/tests/TADR/test_tadr.py rename to test/TADR/test_tadr.py index 4ad0ffe6f6..9d84828af0 100644 --- a/proteus/tests/TADR/test_tadr.py +++ b/test/TADR/test_tadr.py @@ -2,9 +2,6 @@ """ Test module for TADR with EV """ -from __future__ import absolute_import - -from builtins import object from proteus.iproteus import * from proteus import Comm comm = Comm.get() diff --git a/proteus/tests/TADR/thelper_tadr.py b/test/TADR/thelper_tadr.py similarity index 99% rename from proteus/tests/TADR/thelper_tadr.py rename to test/TADR/thelper_tadr.py index 3e28659e52..52049093c2 100644 --- a/proteus/tests/TADR/thelper_tadr.py +++ b/test/TADR/thelper_tadr.py @@ -95,4 +95,4 @@ def attachModels(self,modelList): self.q_v = np.zeros(self.model.q[('grad(u)',0)].shape,'d') self.ebqe_v = np.zeros(self.model.ebqe[('grad(u)',0)].shape,'d') self.ebqe_phi = np.zeros(self.model.ebqe[('u',0)].shape,'d')#cek hack, we don't need this - + \ No newline at end of file diff --git a/proteus/tests/TADR/thelper_tadr_n.py b/test/TADR/thelper_tadr_n.py similarity index 96% rename from proteus/tests/TADR/thelper_tadr_n.py rename to test/TADR/thelper_tadr_n.py index 605c16d494..1a60927a41 100644 --- a/proteus/tests/TADR/thelper_tadr_n.py +++ b/test/TADR/thelper_tadr_n.py @@ -1,6 +1,3 @@ -from __future__ import print_function -from __future__ import absolute_import -from builtins import range from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/TADR/thelper_tadr_p.py b/test/TADR/thelper_tadr_p.py similarity index 97% rename from proteus/tests/TADR/thelper_tadr_p.py rename to test/TADR/thelper_tadr_p.py index 71d58c9bf4..4240b84afd 100644 --- a/proteus/tests/TADR/thelper_tadr_p.py +++ b/test/TADR/thelper_tadr_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * from proteus.ctransportCoefficients import smoothedHeaviside diff --git a/proteus/tests/TwoPhaseFlow/TwoDimBucklingFlow.py b/test/TwoPhaseFlow/TwoDimBucklingFlow.py similarity index 99% rename from proteus/tests/TwoPhaseFlow/TwoDimBucklingFlow.py rename to test/TwoPhaseFlow/TwoDimBucklingFlow.py index b115d8a97c..012e3ea094 100644 --- a/proteus/tests/TwoPhaseFlow/TwoDimBucklingFlow.py +++ b/test/TwoPhaseFlow/TwoDimBucklingFlow.py @@ -1,8 +1,6 @@ """ Multiphase Flow Test """ -from __future__ import division -from past.utils import old_div import numpy as np from proteus import (Domain, Context, MeshTools as mt) @@ -83,7 +81,7 @@ domain.boundaryTags = boundaryTags domain.polyfile=os.path.dirname(os.path.abspath(__file__))+"/"+"meshBucklingFlow" #domain.writePoly("meshBucklingFlow") - #domain.MeshOptions.triangleOptions = "VApq30Dena%8.8f" % (old_div((he ** 2), 2.0),) + #domain.MeshOptions.triangleOptions = "VApq30Dena%8.8f" % ((he**2)/2.0,) domain.MeshOptions.triangleOptions = "VApq30Dena%8.8f" % ((he ** 2) / 2.0,) domain.MeshOptions.he = opts.he domain.MeshOptions.triangleFlag=0 diff --git a/proteus/tests/MeshAdaptPUMI/Sizefields/cylinder2D_ibm/__init__.py b/test/TwoPhaseFlow/__init__.py similarity index 100% rename from proteus/tests/MeshAdaptPUMI/Sizefields/cylinder2D_ibm/__init__.py rename to test/TwoPhaseFlow/__init__.py diff --git a/proteus/tests/TwoPhaseFlow/clean.sh b/test/TwoPhaseFlow/clean.sh similarity index 100% rename from proteus/tests/TwoPhaseFlow/clean.sh rename to test/TwoPhaseFlow/clean.sh diff --git a/proteus/tests/TwoPhaseFlow/comparison_files/comparison_TwoDimBucklingFlow_phi_t2.csv b/test/TwoPhaseFlow/comparison_files/comparison_TwoDimBucklingFlow_phi_t2.csv similarity index 100% rename from proteus/tests/TwoPhaseFlow/comparison_files/comparison_TwoDimBucklingFlow_phi_t2.csv rename to test/TwoPhaseFlow/comparison_files/comparison_TwoDimBucklingFlow_phi_t2.csv diff --git a/proteus/tests/TwoPhaseFlow/comparison_files/comparison_TwoDimBucklingFlow_velocity_t2.csv b/test/TwoPhaseFlow/comparison_files/comparison_TwoDimBucklingFlow_velocity_t2.csv similarity index 100% rename from proteus/tests/TwoPhaseFlow/comparison_files/comparison_TwoDimBucklingFlow_velocity_t2.csv rename to test/TwoPhaseFlow/comparison_files/comparison_TwoDimBucklingFlow_velocity_t2.csv diff --git a/proteus/tests/TwoPhaseFlow/comparison_files/comparison_damBreak_PUMI_phi_t2.csv b/test/TwoPhaseFlow/comparison_files/comparison_damBreak_PUMI_phi_t2.csv similarity index 100% rename from proteus/tests/TwoPhaseFlow/comparison_files/comparison_damBreak_PUMI_phi_t2.csv rename to test/TwoPhaseFlow/comparison_files/comparison_damBreak_PUMI_phi_t2.csv diff --git a/proteus/tests/TwoPhaseFlow/comparison_files/comparison_damBreak_PUMI_velocity_t2.csv b/test/TwoPhaseFlow/comparison_files/comparison_damBreak_PUMI_velocity_t2.csv similarity index 100% rename from proteus/tests/TwoPhaseFlow/comparison_files/comparison_damBreak_PUMI_velocity_t2.csv rename to test/TwoPhaseFlow/comparison_files/comparison_damBreak_PUMI_velocity_t2.csv diff --git a/proteus/tests/TwoPhaseFlow/comparison_files/comparison_damBreak_phi_t2.csv b/test/TwoPhaseFlow/comparison_files/comparison_damBreak_phi_t2.csv similarity index 100% rename from proteus/tests/TwoPhaseFlow/comparison_files/comparison_damBreak_phi_t2.csv rename to test/TwoPhaseFlow/comparison_files/comparison_damBreak_phi_t2.csv diff --git a/proteus/tests/TwoPhaseFlow/comparison_files/comparison_damBreak_solver_options_phi_t2.csv b/test/TwoPhaseFlow/comparison_files/comparison_damBreak_solver_options_phi_t2.csv similarity index 100% rename from proteus/tests/TwoPhaseFlow/comparison_files/comparison_damBreak_solver_options_phi_t2.csv rename to test/TwoPhaseFlow/comparison_files/comparison_damBreak_solver_options_phi_t2.csv diff --git a/proteus/tests/TwoPhaseFlow/comparison_files/comparison_damBreak_solver_options_velocity_t2.csv b/test/TwoPhaseFlow/comparison_files/comparison_damBreak_solver_options_velocity_t2.csv similarity index 100% rename from proteus/tests/TwoPhaseFlow/comparison_files/comparison_damBreak_solver_options_velocity_t2.csv rename to test/TwoPhaseFlow/comparison_files/comparison_damBreak_solver_options_velocity_t2.csv diff --git a/proteus/tests/TwoPhaseFlow/comparison_files/comparison_damBreak_velocity_t2.csv b/test/TwoPhaseFlow/comparison_files/comparison_damBreak_velocity_t2.csv similarity index 100% rename from proteus/tests/TwoPhaseFlow/comparison_files/comparison_damBreak_velocity_t2.csv rename to test/TwoPhaseFlow/comparison_files/comparison_damBreak_velocity_t2.csv diff --git a/proteus/tests/TwoPhaseFlow/comparison_files/comparison_fillingTank_phi_t2.csv b/test/TwoPhaseFlow/comparison_files/comparison_fillingTank_phi_t2.csv similarity index 100% rename from proteus/tests/TwoPhaseFlow/comparison_files/comparison_fillingTank_phi_t2.csv rename to test/TwoPhaseFlow/comparison_files/comparison_fillingTank_phi_t2.csv diff --git a/proteus/tests/TwoPhaseFlow/comparison_files/comparison_fillingTank_velocity_t2.csv b/test/TwoPhaseFlow/comparison_files/comparison_fillingTank_velocity_t2.csv similarity index 100% rename from proteus/tests/TwoPhaseFlow/comparison_files/comparison_fillingTank_velocity_t2.csv rename to test/TwoPhaseFlow/comparison_files/comparison_fillingTank_velocity_t2.csv diff --git a/proteus/tests/TwoPhaseFlow/comparison_files/comparison_marin_phi_t2.csv b/test/TwoPhaseFlow/comparison_files/comparison_marin_phi_t2.csv similarity index 100% rename from proteus/tests/TwoPhaseFlow/comparison_files/comparison_marin_phi_t2.csv rename to test/TwoPhaseFlow/comparison_files/comparison_marin_phi_t2.csv diff --git a/proteus/tests/TwoPhaseFlow/comparison_files/comparison_marin_velocity_t2.csv b/test/TwoPhaseFlow/comparison_files/comparison_marin_velocity_t2.csv similarity index 100% rename from proteus/tests/TwoPhaseFlow/comparison_files/comparison_marin_velocity_t2.csv rename to test/TwoPhaseFlow/comparison_files/comparison_marin_velocity_t2.csv diff --git a/proteus/tests/TwoPhaseFlow/comparison_files/comparison_moses_phi_t2.csv b/test/TwoPhaseFlow/comparison_files/comparison_moses_phi_t2.csv similarity index 100% rename from proteus/tests/TwoPhaseFlow/comparison_files/comparison_moses_phi_t2.csv rename to test/TwoPhaseFlow/comparison_files/comparison_moses_phi_t2.csv diff --git a/proteus/tests/TwoPhaseFlow/comparison_files/comparison_moses_velocity_t2.csv b/test/TwoPhaseFlow/comparison_files/comparison_moses_velocity_t2.csv similarity index 100% rename from proteus/tests/TwoPhaseFlow/comparison_files/comparison_moses_velocity_t2.csv rename to test/TwoPhaseFlow/comparison_files/comparison_moses_velocity_t2.csv diff --git a/proteus/tests/TwoPhaseFlow/comparison_files/comparison_risingBubble_phi_t2.csv b/test/TwoPhaseFlow/comparison_files/comparison_risingBubble_phi_t2.csv similarity index 100% rename from proteus/tests/TwoPhaseFlow/comparison_files/comparison_risingBubble_phi_t2.csv rename to test/TwoPhaseFlow/comparison_files/comparison_risingBubble_phi_t2.csv diff --git a/proteus/tests/TwoPhaseFlow/comparison_files/comparison_risingBubble_velocity_t2.csv b/test/TwoPhaseFlow/comparison_files/comparison_risingBubble_velocity_t2.csv similarity index 100% rename from proteus/tests/TwoPhaseFlow/comparison_files/comparison_risingBubble_velocity_t2.csv rename to test/TwoPhaseFlow/comparison_files/comparison_risingBubble_velocity_t2.csv diff --git a/proteus/tests/TwoPhaseFlow/damBreak.py b/test/TwoPhaseFlow/damBreak.py similarity index 97% rename from proteus/tests/TwoPhaseFlow/damBreak.py rename to test/TwoPhaseFlow/damBreak.py index 68a00abbcf..6ce26f366e 100644 --- a/proteus/tests/TwoPhaseFlow/damBreak.py +++ b/test/TwoPhaseFlow/damBreak.py @@ -1,8 +1,6 @@ """ danbreak 2-D """ -from __future__ import division -from past.utils import old_div import numpy as np from proteus import (Domain, Context) from proteus.Profiling import logEvent @@ -81,7 +79,7 @@ he = tank_dim[0]*opts.he domain.MeshOptions.he = he st.assembleDomain(domain) -domain.MeshOptions.triangleOptions = "VApq30Dena%8.8f" % (old_div((he ** 2), 2.0),) +domain.MeshOptions.triangleOptions = "VApq30Dena%8.8f" % ((he**2)/2.0,) domain.polyfile=os.path.dirname(os.path.abspath(__file__))+"/"+"meshDambreak" domain.MeshOptions.triangleFlag=0 domain.MeshOptions.genMesh=False diff --git a/proteus/tests/TwoPhaseFlow/damBreak_PUMI.py b/test/TwoPhaseFlow/damBreak_PUMI.py similarity index 98% rename from proteus/tests/TwoPhaseFlow/damBreak_PUMI.py rename to test/TwoPhaseFlow/damBreak_PUMI.py index 35b74ddb81..b83109fd91 100644 --- a/proteus/tests/TwoPhaseFlow/damBreak_PUMI.py +++ b/test/TwoPhaseFlow/damBreak_PUMI.py @@ -1,8 +1,6 @@ """ dambreak 2-D """ -from __future__ import division -from past.utils import old_div import numpy as np from proteus import (Domain, Context) from proteus.Profiling import logEvent @@ -102,7 +100,7 @@ he = tank_dim[0]*opts.he domain.MeshOptions.he = he st.assembleDomain(domain) -domain.MeshOptions.triangleOptions = "VApq30Dena%8.8f" % (old_div((he ** 2), 2.0),) +domain.MeshOptions.triangleOptions = "VApq30Dena%8.8f" % ((he**2)/2.0,) domain.polyfile=os.path.dirname(os.path.abspath(__file__))+"/"+"meshDambreak" domain.MeshOptions.genMesh=False diff --git a/proteus/tests/TwoPhaseFlow/damBreak_solver_options.py b/test/TwoPhaseFlow/damBreak_solver_options.py similarity index 97% rename from proteus/tests/TwoPhaseFlow/damBreak_solver_options.py rename to test/TwoPhaseFlow/damBreak_solver_options.py index e4014d675a..4722c11406 100644 --- a/proteus/tests/TwoPhaseFlow/damBreak_solver_options.py +++ b/test/TwoPhaseFlow/damBreak_solver_options.py @@ -1,8 +1,6 @@ """ danbreak 2-D """ -from __future__ import division -from past.utils import old_div import numpy as np from proteus import (Domain, Context, LinearSolvers) from proteus.Profiling import logEvent @@ -80,7 +78,7 @@ domain.MeshOptions.he = he st.assembleDomain(domain) domain.polyfile=os.path.dirname(os.path.abspath(__file__))+"/"+"meshDambreak" -domain.MeshOptions.triangleOptions = "VApq30Dena%8.8f" % (old_div((he ** 2), 2.0),) +domain.MeshOptions.triangleOptions = "VApq30Dena%8.8f" % ((he**2)/2.0,) # ****************************** # # ***** INITIAL CONDITIONS ***** # @@ -174,5 +172,5 @@ def uOfXT(self,x,t): myTpFlowProblem.Parameters.Models.rans2p.n.nl_atol_res = 1e-9 myTpFlowProblem.Parameters.mesh.he = he -myTpFlowProblem.Parameters.mesh.triangleOptions = "VApq30Dena%8.8f" % (old_div((he ** 2), 2.0),) +myTpFlowProblem.Parameters.mesh.triangleOptions = "VApq30Dena%8.8f" % ((he**2)/2.0,) myTpFlowProblem.Parameters.mesh.genMesh=False diff --git a/proteus/tests/TwoPhaseFlow/fillingTank.py b/test/TwoPhaseFlow/fillingTank.py similarity index 98% rename from proteus/tests/TwoPhaseFlow/fillingTank.py rename to test/TwoPhaseFlow/fillingTank.py index 1a0539de92..f742df5aef 100644 --- a/proteus/tests/TwoPhaseFlow/fillingTank.py +++ b/test/TwoPhaseFlow/fillingTank.py @@ -1,8 +1,6 @@ """ Multiphase Flow Test """ -from __future__ import division -from past.utils import old_div import numpy as np from proteus import (Domain, Context, MeshTools as mt) @@ -76,7 +74,7 @@ #domain.writePoly("meshFilling") he = opts.he domain.MeshOptions.he = he - domain.MeshOptions.triangleOptions = "VApq30Dena%8.8f" % (old_div((he ** 2), 2.0),) + domain.MeshOptions.triangleOptions = "VApq30Dena%8.8f" % ((he**2)/2.0,) domain.MeshOptions.genMesh=False diff --git a/proteus/tests/TwoPhaseFlow/marin.py b/test/TwoPhaseFlow/marin.py similarity index 99% rename from proteus/tests/TwoPhaseFlow/marin.py rename to test/TwoPhaseFlow/marin.py index 6fdc5a17b5..c86450dd48 100644 --- a/proteus/tests/TwoPhaseFlow/marin.py +++ b/test/TwoPhaseFlow/marin.py @@ -1,8 +1,6 @@ """ TwoPhaseFlow """ -from __future__ import division -from past.utils import old_div import numpy as np from proteus import (Domain, Context, Gauges, MeshTools as mt) @@ -29,7 +27,7 @@ ("ARTIFICIAL_VISCOSITY",3,"artificial viscosity") ]) -assert opts.ns_model==1, "use ns_model=1 (rans3pf) for this" +#assert opts.ns_model==1, "use ns_model=1 (rans3pf) for this" # ****************** # # ***** GAUGES ***** # @@ -344,4 +342,3 @@ def pressure_increment_DFBC(x,flag): myTpFlowProblem.SystemNumerics.cfl=opts.cfl myTpFlowProblem.SystemNumerics.useSuperlu=True - diff --git a/proteus/tests/TwoPhaseFlow/meshBucklingFlow.1.neigh b/test/TwoPhaseFlow/meshBucklingFlow.1.neigh similarity index 100% rename from proteus/tests/TwoPhaseFlow/meshBucklingFlow.1.neigh rename to test/TwoPhaseFlow/meshBucklingFlow.1.neigh diff --git a/proteus/tests/TwoPhaseFlow/meshBucklingFlow.1.poly b/test/TwoPhaseFlow/meshBucklingFlow.1.poly similarity index 100% rename from proteus/tests/TwoPhaseFlow/meshBucklingFlow.1.poly rename to test/TwoPhaseFlow/meshBucklingFlow.1.poly diff --git a/proteus/tests/TwoPhaseFlow/meshBucklingFlow.edge b/test/TwoPhaseFlow/meshBucklingFlow.edge similarity index 100% rename from proteus/tests/TwoPhaseFlow/meshBucklingFlow.edge rename to test/TwoPhaseFlow/meshBucklingFlow.edge diff --git a/proteus/tests/TwoPhaseFlow/meshBucklingFlow.ele b/test/TwoPhaseFlow/meshBucklingFlow.ele similarity index 100% rename from proteus/tests/TwoPhaseFlow/meshBucklingFlow.ele rename to test/TwoPhaseFlow/meshBucklingFlow.ele diff --git a/proteus/tests/TwoPhaseFlow/meshBucklingFlow.node b/test/TwoPhaseFlow/meshBucklingFlow.node similarity index 100% rename from proteus/tests/TwoPhaseFlow/meshBucklingFlow.node rename to test/TwoPhaseFlow/meshBucklingFlow.node diff --git a/proteus/tests/TwoPhaseFlow/meshBucklingFlow.poly b/test/TwoPhaseFlow/meshBucklingFlow.poly similarity index 100% rename from proteus/tests/TwoPhaseFlow/meshBucklingFlow.poly rename to test/TwoPhaseFlow/meshBucklingFlow.poly diff --git a/proteus/tests/TwoPhaseFlow/meshDambreak.1.neigh b/test/TwoPhaseFlow/meshDambreak.1.neigh similarity index 100% rename from proteus/tests/TwoPhaseFlow/meshDambreak.1.neigh rename to test/TwoPhaseFlow/meshDambreak.1.neigh diff --git a/proteus/tests/TwoPhaseFlow/meshDambreak.1.poly b/test/TwoPhaseFlow/meshDambreak.1.poly similarity index 100% rename from proteus/tests/TwoPhaseFlow/meshDambreak.1.poly rename to test/TwoPhaseFlow/meshDambreak.1.poly diff --git a/proteus/tests/TwoPhaseFlow/meshDambreak.edge b/test/TwoPhaseFlow/meshDambreak.edge similarity index 100% rename from proteus/tests/TwoPhaseFlow/meshDambreak.edge rename to test/TwoPhaseFlow/meshDambreak.edge diff --git a/proteus/tests/TwoPhaseFlow/meshDambreak.ele b/test/TwoPhaseFlow/meshDambreak.ele similarity index 100% rename from proteus/tests/TwoPhaseFlow/meshDambreak.ele rename to test/TwoPhaseFlow/meshDambreak.ele diff --git a/proteus/tests/TwoPhaseFlow/meshDambreak.node b/test/TwoPhaseFlow/meshDambreak.node similarity index 100% rename from proteus/tests/TwoPhaseFlow/meshDambreak.node rename to test/TwoPhaseFlow/meshDambreak.node diff --git a/proteus/tests/TwoPhaseFlow/meshDambreak.poly b/test/TwoPhaseFlow/meshDambreak.poly similarity index 100% rename from proteus/tests/TwoPhaseFlow/meshDambreak.poly rename to test/TwoPhaseFlow/meshDambreak.poly diff --git a/proteus/tests/TwoPhaseFlow/meshFilling.1.neigh b/test/TwoPhaseFlow/meshFilling.1.neigh similarity index 100% rename from proteus/tests/TwoPhaseFlow/meshFilling.1.neigh rename to test/TwoPhaseFlow/meshFilling.1.neigh diff --git a/proteus/tests/TwoPhaseFlow/meshFilling.1.poly b/test/TwoPhaseFlow/meshFilling.1.poly similarity index 100% rename from proteus/tests/TwoPhaseFlow/meshFilling.1.poly rename to test/TwoPhaseFlow/meshFilling.1.poly diff --git a/proteus/tests/TwoPhaseFlow/meshFilling.edge b/test/TwoPhaseFlow/meshFilling.edge similarity index 100% rename from proteus/tests/TwoPhaseFlow/meshFilling.edge rename to test/TwoPhaseFlow/meshFilling.edge diff --git a/proteus/tests/TwoPhaseFlow/meshFilling.ele b/test/TwoPhaseFlow/meshFilling.ele similarity index 100% rename from proteus/tests/TwoPhaseFlow/meshFilling.ele rename to test/TwoPhaseFlow/meshFilling.ele diff --git a/proteus/tests/TwoPhaseFlow/meshFilling.node b/test/TwoPhaseFlow/meshFilling.node similarity index 100% rename from proteus/tests/TwoPhaseFlow/meshFilling.node rename to test/TwoPhaseFlow/meshFilling.node diff --git a/proteus/tests/TwoPhaseFlow/meshFilling.poly b/test/TwoPhaseFlow/meshFilling.poly similarity index 100% rename from proteus/tests/TwoPhaseFlow/meshFilling.poly rename to test/TwoPhaseFlow/meshFilling.poly diff --git a/proteus/tests/TwoPhaseFlow/meshMarin.edge b/test/TwoPhaseFlow/meshMarin.edge similarity index 100% rename from proteus/tests/TwoPhaseFlow/meshMarin.edge rename to test/TwoPhaseFlow/meshMarin.edge diff --git a/proteus/tests/TwoPhaseFlow/meshMarin.ele b/test/TwoPhaseFlow/meshMarin.ele similarity index 100% rename from proteus/tests/TwoPhaseFlow/meshMarin.ele rename to test/TwoPhaseFlow/meshMarin.ele diff --git a/proteus/tests/TwoPhaseFlow/meshMarin.face b/test/TwoPhaseFlow/meshMarin.face similarity index 100% rename from proteus/tests/TwoPhaseFlow/meshMarin.face rename to test/TwoPhaseFlow/meshMarin.face diff --git a/proteus/tests/TwoPhaseFlow/meshMarin.neigh b/test/TwoPhaseFlow/meshMarin.neigh similarity index 100% rename from proteus/tests/TwoPhaseFlow/meshMarin.neigh rename to test/TwoPhaseFlow/meshMarin.neigh diff --git a/proteus/tests/TwoPhaseFlow/meshMarin.node b/test/TwoPhaseFlow/meshMarin.node similarity index 100% rename from proteus/tests/TwoPhaseFlow/meshMarin.node rename to test/TwoPhaseFlow/meshMarin.node diff --git a/proteus/tests/TwoPhaseFlow/meshMarin.poly b/test/TwoPhaseFlow/meshMarin.poly similarity index 100% rename from proteus/tests/TwoPhaseFlow/meshMarin.poly rename to test/TwoPhaseFlow/meshMarin.poly diff --git a/proteus/tests/TwoPhaseFlow/moses.py b/test/TwoPhaseFlow/moses.py similarity index 99% rename from proteus/tests/TwoPhaseFlow/moses.py rename to test/TwoPhaseFlow/moses.py index ea5cbdba81..7c7791e99a 100644 --- a/proteus/tests/TwoPhaseFlow/moses.py +++ b/test/TwoPhaseFlow/moses.py @@ -1,8 +1,6 @@ """ Rising bubble test """ -from __future__ import division -from past.utils import old_div import numpy as np from proteus import (Domain, Context) from proteus.Profiling import logEvent @@ -325,4 +323,3 @@ def forcez(X,t): m['flow'].p.coefficients.eb_penalty_constant = 1e6 m['flow'].n.ShockCapturingOptions.shockCapturingFactor = 0.5 - diff --git a/proteus/tests/TwoPhaseFlow/petsc.options.asm b/test/TwoPhaseFlow/petsc.options.asm similarity index 100% rename from proteus/tests/TwoPhaseFlow/petsc.options.asm rename to test/TwoPhaseFlow/petsc.options.asm diff --git a/proteus/tests/TwoPhaseFlow/risingBubble.py b/test/TwoPhaseFlow/risingBubble.py similarity index 97% rename from proteus/tests/TwoPhaseFlow/risingBubble.py rename to test/TwoPhaseFlow/risingBubble.py index 13ccd3d47e..b0481f7ab1 100644 --- a/proteus/tests/TwoPhaseFlow/risingBubble.py +++ b/test/TwoPhaseFlow/risingBubble.py @@ -1,8 +1,6 @@ """ Rising bubble test """ -from __future__ import division -from past.utils import old_div import numpy as np from proteus import (Domain, Context) from proteus.Profiling import logEvent @@ -80,11 +78,11 @@ #domain.polyfile="meshMarin" domain.polyfile=os.path.dirname(os.path.abspath(__file__))+"/"+"meshRisingBubble" #domain.writePoly("meshRisingBubble") - he = old_div(tank_dim[0], float(4 * refinement - 1)) + he = tank_dim[0]/float(4*refinement-1) domain.MeshOptions.he = opts.he domain.MeshOptions.genMesh=False domain.MeshOptions.triangleFlag=0 - triangleOptions = "VApq30Dena%8.8f" % (old_div((he ** 2), 2.0),) + triangleOptions = "VApq30Dena%8.8f" % ((he**2)/2.0,) # ****************************** # # ***** INITIAL CONDITIONS ***** # diff --git a/proteus/tests/TwoPhaseFlow/test_TwoPhaseFlow.py b/test/TwoPhaseFlow/test_TwoPhaseFlow.py similarity index 78% rename from proteus/tests/TwoPhaseFlow/test_TwoPhaseFlow.py rename to test/TwoPhaseFlow/test_TwoPhaseFlow.py index 8decef09c5..a8a41aa05f 100644 --- a/proteus/tests/TwoPhaseFlow/test_TwoPhaseFlow.py +++ b/test/TwoPhaseFlow/test_TwoPhaseFlow.py @@ -2,8 +2,8 @@ """ Test module for TwoPhaseFlow """ +import h5py import pytest -import tables import numpy as np import proteus.defaults from proteus import Context @@ -18,7 +18,7 @@ class TestTwoPhaseFlow(object): def setup_method(self,method): self._scriptdir = os.path.dirname(__file__) - self.path = proteus.__path__[0]+"/tests/TwoPhaseFlow/" + self.path = self._scriptdir def teardown_method(self, method): """ Tear down function """ @@ -35,19 +35,19 @@ def teardown_method(self, method): pass def compare_vs_saved_files(self,name,write=False): - actual = tables.open_file(name+'.h5','r') + actual = h5py.File(name+'.h5','r') expected_path = 'comparison_files/' + 'comparison_' + name + '_phi_t2.csv' #write comparison file if(write): - np.array(actual.root.phi_t2).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.phi_t2).flatten(),decimal=6) + np.array(actual['phi_t2']).tofile(os.path.join(self._scriptdir, expected_path),sep=",") + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['phi_t2'][:]).flatten(),decimal=6) expected_path = 'comparison_files/' + 'comparison_' + name + '_velocity_t2.csv' #write comparison file if(write): - np.array(actual.root.velocity_t2).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.velocity_t2).flatten(),decimal=6) + np.array(actual['velocity_t2']).tofile(os.path.join(self._scriptdir, expected_path),sep=",") + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['velocity_t2']).flatten(),decimal=6) actual.close() @@ -66,7 +66,6 @@ def test_damBreak_hotstart(self): os.system("parun --TwoPhaseFlow --path " + self.path + " " "damBreak.py -l5 -v -H -C 'final_time=0.1 dt_output=0.1 he=0.1 hotstart=True'") - @pytest.mark.skipif(sys.platform == "darwin", reason="does not run on macOS") def test_TwoDimBucklingFlow(self): os.system("parun --TwoPhaseFlow --path " + self.path + " " "TwoDimBucklingFlow.py -l5 -v -C 'final_time=0.1 dt_output=0.1 he=0.09'") @@ -78,7 +77,6 @@ def test_fillingTank(self): self.compare_vs_saved_files("fillingTank") # *** 3D tests *** # - @pytest.mark.skipif(sys.platform == "darwin", reason="does not run on macOS") def test_marin(self): os.system("parun --TwoPhaseFlow --path " + self.path + " " "marin.py -l5 -v -C 'final_time=0.1 dt_output=0.1 he=0.5'") @@ -89,16 +87,13 @@ def test_moses(self): "moses.py -l5 -v -C 'final_time=0.1 dt_output=0.1 he=0.5'") self.compare_vs_saved_files("moses") + @pytest.mark.skip(reason="PUMI is broken") def test_damBreak_genPUMI(self): os.system("parun --TwoPhaseFlow --genPUMI --path " + self.path + " " "damBreak.py -l5 -v -C 'final_time=0.1 dt_output=0.1 he=0.1'") + @pytest.mark.skip(reason="PUMI is broken") def test_damBreak_runPUMI(self): os.system("parun --TwoPhaseFlow --path " + self.path + " " "damBreak_PUMI.py -l5 -v -C 'final_time=0.1 dt_output=0.1 he=0.1 adapt=0'") self.compare_vs_saved_files("damBreak_PUMI") - - def test_damBreak_pseudo_CLSVOF(self): - os.system("parun --TwoPhaseFlow --path " + self.path + " " - "damBreak_PUMI.py -l5 -v -C 'final_time=0.1 dt_output=0.1 he=0.1 adapt=1'") - self.compare_vs_saved_files("damBreak_PUMI") diff --git a/proteus/tests/VOS/clean.sh b/test/VOS/clean.sh similarity index 100% rename from proteus/tests/VOS/clean.sh rename to test/VOS/clean.sh diff --git a/proteus/tests/VOS/vos.py b/test/VOS/vos.py similarity index 96% rename from proteus/tests/VOS/vos.py rename to test/VOS/vos.py index b025726054..23282be2b0 100644 --- a/proteus/tests/VOS/vos.py +++ b/test/VOS/vos.py @@ -1,5 +1,3 @@ -from __future__ import division -from past.utils import old_div from proteus import Domain from proteus import Norms from proteus import Profiling @@ -62,7 +60,7 @@ if ct.problem==0: nny=int((nnx-1)/10+1) nnz=1 -he=old_div(1.0,(nnx-1.0)) +he=1.0/(nnx-1.0) unstructured=False box=Domain.RectangularDomain(L=(1.0,0.1 if ct.problem==0 else 1.0), diff --git a/proteus/tests/VOS/vos_n.py b/test/VOS/vos_n.py similarity index 96% rename from proteus/tests/VOS/vos_n.py rename to test/VOS/vos_n.py index 17ee7d813b..a62abe2b68 100644 --- a/proteus/tests/VOS/vos_n.py +++ b/test/VOS/vos_n.py @@ -1,6 +1,3 @@ -from __future__ import print_function -from __future__ import absolute_import -from builtins import range from proteus import * from proteus.default_n import * from vos_p import * @@ -82,4 +79,3 @@ #tnList=[0.,0.001,0.002,0.003] #tnList=[0.001*i for i in range(10)] - diff --git a/proteus/tests/VOS/vos_p.py b/test/VOS/vos_p.py similarity index 97% rename from proteus/tests/VOS/vos_p.py rename to test/VOS/vos_p.py index e2d83ec6e5..0afa4ca08f 100644 --- a/proteus/tests/VOS/vos_p.py +++ b/test/VOS/vos_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * from proteus.ctransportCoefficients import smoothedHeaviside diff --git a/proteus/tests/MeshAdaptPUMI/__init__.py b/test/ci/__init__.py similarity index 100% rename from proteus/tests/MeshAdaptPUMI/__init__.py rename to test/ci/__init__.py diff --git a/proteus/tests/ci/adr.py b/test/ci/adr.py similarity index 95% rename from proteus/tests/ci/adr.py rename to test/ci/adr.py index 656b9d6bc0..4c96f674db 100644 --- a/proteus/tests/ci/adr.py +++ b/test/ci/adr.py @@ -25,4 +25,4 @@ def evaluate(self,t,c): c[('df',0,0)][...,0] = self.B[0] c[('df',0,0)][...,1] = self.B[1] c[('a',0,0)][...,0,0] = self.A[0][0] - c[('a',0,0)][...,1,1] = self.A[1][1] + c[('a',0,0)][...,1,1] = self.A[1][1] \ No newline at end of file diff --git a/proteus/tests/ci/adr_3d_c0p1_n.py b/test/ci/adr_3d_c0p1_n.py similarity index 94% rename from proteus/tests/ci/adr_3d_c0p1_n.py rename to test/ci/adr_3d_c0p1_n.py index 39a8cf7531..24b8ed10e9 100644 --- a/proteus/tests/ci/adr_3d_c0p1_n.py +++ b/test/ci/adr_3d_c0p1_n.py @@ -1,6 +1,3 @@ -from __future__ import absolute_import -from __future__ import division -from past.utils import old_div from proteus import * from proteus.default_n import * try: @@ -20,7 +17,7 @@ elementBoundaryQuadrature = SimplexGaussQuadrature(nd-1,3) logEvent("""Mesh generated using: tetgen -%s %s""" % (triangleOptions,domain.polyfile+".poly")) -triangleOptions="VApq1.35q12feena%e" % (old_div((he**3),6.0),) +triangleOptions="VApq1.35q12feena%e" % ((he**3)/6.0,) #number of levels in mesh nLevels = 1 diff --git a/proteus/tests/ci/adr_3d_p.py b/test/ci/adr_3d_p.py similarity index 94% rename from proteus/tests/ci/adr_3d_p.py rename to test/ci/adr_3d_p.py index a3cf936ddb..d6d6002d3e 100644 --- a/proteus/tests/ci/adr_3d_p.py +++ b/test/ci/adr_3d_p.py @@ -1,7 +1,3 @@ -from __future__ import division -from builtins import range -from builtins import object -from past.utils import old_div from proteus import * from proteus.default_p import * """ @@ -46,7 +42,7 @@ nLevels = 1 -he = old_div(L[0],10.0) +he = L[0]/10.0 #he = hull_draft/1.0 #he = hull_draft/6.0 genMesh=True#False @@ -91,13 +87,13 @@ holes=[] if vessel is 'wigley': from math import log - he_hull = old_div(log(64.0*he+1.0),64.0) + he_hull = log(64.0*he+1.0)/64.0 #print he,he_hull #he_hull = he - n_points_length = int(ceil(old_div(hull_length,he_hull)))+1 - n_points_draft = 2*int(ceil(old_div(hull_draft,he_hull)))+1 + n_points_length = int(ceil(hull_length/he_hull))+1 + n_points_draft = 2*int(ceil(hull_draft/he_hull))+1 #print "points",n_points_length,n_points_draft - dx = old_div(hull_length,float(n_points_length-1)) + dx = hull_length/float(n_points_length-1) dz = 2.0*hull_draft/float(n_points_draft-1) #print "he",he,dx,dz #grid on right half of hull @@ -106,7 +102,7 @@ x = i*dx - 0.5*hull_length z = j*dz - hull_draft zStar = min(0.0,z) - y = 0.5*hull_beam*(1.0 - 4.0*(old_div(x,hull_length))**2) * (1.0 - (old_div(zStar,hull_draft))**2) + y = 0.5*hull_beam*(1.0 - 4.0*(x/hull_length)**2) * (1.0 - (zStar/hull_draft)**2) vertices.append([x+hull_center[0], y+hull_center[1], z+hull_center[2]]) @@ -115,7 +111,7 @@ def vN_right(i,j): return 8 + i*n_points_draft+j for i in range(n_points_length-1): for j in range(n_points_draft-1): - if i < old_div(n_points_length,2): + if i < n_points_length//2: facets.append([[vN_right(i,j),vN_right(i+1,j+1),vN_right(i+1,j)]]) facetFlags.append(boundaryTags['obstacle']) facets.append([[vN_right(i,j),vN_right(i,j+1),vN_right(i+1,j+1)]]) @@ -131,7 +127,7 @@ def vN_right(i,j): x = i*dx - 0.5*hull_length z = j*dz - hull_draft zStar = min(0.0,z) - y = 0.5*hull_beam*(1.0 - 4.0*(old_div(x,hull_length))**2) * (1.0 - (old_div(zStar,hull_draft))**2) + y = 0.5*hull_beam*(1.0 - 4.0*(x/hull_length)**2) * (1.0 - (zStar/hull_draft)**2) vertices.append([x+hull_center[0], hull_center[1] - y, z+hull_center[2]]) @@ -145,7 +141,7 @@ def vN_left(i,j): return 8 + n_points_length*n_points_draft+(i-1)*(n_points_draft-1)+j-1 for i in range(n_points_length-1): for j in range(n_points_draft-1): - if i < old_div(n_points_length,2): + if i < n_points_length/2: facets.append([[vN_left(i,j),vN_left(i+1,j+1),vN_left(i+1,j)]]) facetFlags.append(boundaryTags['obstacle']) facets.append([[vN_left(i,j),vN_left(i,j+1),vN_left(i+1,j+1)]]) diff --git a/proteus/tests/ci/adr_bl_3d_c0p1_n.py b/test/ci/adr_bl_3d_c0p1_n.py similarity index 94% rename from proteus/tests/ci/adr_bl_3d_c0p1_n.py rename to test/ci/adr_bl_3d_c0p1_n.py index 0a63683ee1..e0e34bd2ce 100644 --- a/proteus/tests/ci/adr_bl_3d_c0p1_n.py +++ b/test/ci/adr_bl_3d_c0p1_n.py @@ -1,6 +1,3 @@ -from __future__ import absolute_import -from __future__ import division -from past.utils import old_div from proteus import * from proteus.default_n import * try: @@ -20,7 +17,7 @@ elementBoundaryQuadrature = SimplexGaussQuadrature(nd-1,3) logEvent("""Mesh generated using: tetgen -%s %s""" % (triangleOptions,domain.polyfile+".poly")) -triangleOptions="VApq1.35q12feena%e" % (old_div((he**3),6.0),) +triangleOptions="VApq1.35q12feena%e" % ((he**3)/6.0,) #number of levels in mesh nLevels = 1 diff --git a/proteus/tests/ci/adr_bl_3d_p.py b/test/ci/adr_bl_3d_p.py similarity index 91% rename from proteus/tests/ci/adr_bl_3d_p.py rename to test/ci/adr_bl_3d_p.py index 9f45887a98..90e23b6d7a 100644 --- a/proteus/tests/ci/adr_bl_3d_p.py +++ b/test/ci/adr_bl_3d_p.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import range -from past.utils import old_div from proteus import * from proteus.default_p import * """ @@ -45,7 +42,7 @@ nLevels = 1 -he = old_div(L[0],10.0) +he = L[0]/10.0 #he*=0.5 #he = hull_draft/1.0 #he = hull_draft/6.0 @@ -91,13 +88,13 @@ holes=[] if vessel is 'wigley': from math import log - he_hull = old_div(log(64.0*he+1.0),64.0) + he_hull = log(64.0*he+1.0)/64.0 #print he,he_hull #he_hull = he - n_points_length = int(ceil(old_div(hull_length,he_hull)))+1 - n_points_draft = 2*int(ceil(old_div(hull_draft,he_hull)))+1 + n_points_length = int(ceil(hull_length/he_hull))+1 + n_points_draft = 2*int(ceil(hull_draft/he_hull))+1 #print "points",n_points_length,n_points_draft - dx = old_div(hull_length,float(n_points_length-1)) + dx = hull_length/float(n_points_length-1) dz = 2.0*hull_draft/float(n_points_draft-1) #print "he",he,dx,dz #grid on right half of hull @@ -106,7 +103,7 @@ x = i*dx - 0.5*hull_length z = j*dz - hull_draft zStar = min(0.0,z) - y = 0.5*hull_beam*(1.0 - 4.0*(old_div(x,hull_length))**2) * (1.0 - (old_div(zStar,hull_draft))**2) + y = 0.5*hull_beam*(1.0 - 4.0*(x/hull_length)**2) * (1.0 - (zStar/hull_draft)**2) vertices.append([x+hull_center[0], y+hull_center[1], z+hull_center[2]]) @@ -115,7 +112,7 @@ def vN_right(i,j): return 8 + i*n_points_draft+j for i in range(n_points_length-1): for j in range(n_points_draft-1): - if i < old_div(n_points_length,2): + if i < n_points_length//2: facets.append([[vN_right(i,j),vN_right(i+1,j+1),vN_right(i+1,j)]]) facetFlags.append(boundaryTags['obstacle']) facets.append([[vN_right(i,j),vN_right(i,j+1),vN_right(i+1,j+1)]]) @@ -131,7 +128,7 @@ def vN_right(i,j): x = i*dx - 0.5*hull_length z = j*dz - hull_draft zStar = min(0.0,z) - y = 0.5*hull_beam*(1.0 - 4.0*(old_div(x,hull_length))**2) * (1.0 - (old_div(zStar,hull_draft))**2) + y = 0.5*hull_beam*(1.0 - 4.0*(x/hull_length)**2) * (1.0 - (zStar/hull_draft)**2) vertices.append([x+hull_center[0], hull_center[1] - y, z+hull_center[2]]) @@ -145,7 +142,7 @@ def vN_left(i,j): return 8 + n_points_length*n_points_draft+(i-1)*(n_points_draft-1)+j-1 for i in range(n_points_length-1): for j in range(n_points_draft-1): - if i < old_div(n_points_length,2): + if i < n_points_length/2: facets.append([[vN_left(i,j),vN_left(i+1,j+1),vN_left(i+1,j)]]) facetFlags.append(boundaryTags['obstacle']) facets.append([[vN_left(i,j),vN_left(i,j+1),vN_left(i+1,j+1)]]) @@ -258,16 +255,16 @@ def __init__(self,b=[1.0,0,0],a=5.0e-1): bn = sqrt(b[0]**2 + b[1]**2 + b[2]**2) self.bn=bn if bn!=0.0: - self.D_ = (old_div(1.0,(exp(old_div(bn,a))-1.0))) + self.D_ = 1.0/(exp(bn/a)-1.0) else: self.D_ = 0.0 - self.C_ = -self.D_*exp(old_div(bn,a)) + self.C_ = -self.D_*exp(bn/a) def uOfX(self,X): x=X if self.D_ !=0.0: - return -self.D_*exp(old_div((self.b_[0]*x[0]+self.b_[1]*x[1]+ self.b_[2]*x[2]),self.a_)) - self.C_ + return -self.D_*exp((self.b_[0]*x[0]+self.b_[1]*x[1]+self.b_[2]*x[2])/self.a_) - self.C_ else: - return 1.0-old_div((self.b_[0]*x[0]+self.b_[1]*x[1]+ self.b_[2]*x[2]),self.bn) + return 1.0-(self.b_[0]*x[0]+self.b_[1]*x[1]+self.b_[2]*x[2])/self.bn import numpy as np sol = LinearAD_SteadyState(b=np.array([velocity,0.0,0.0]),a=diffusion) diff --git a/proteus/tests/ci/blockDomain.py b/test/ci/blockDomain.py similarity index 95% rename from proteus/tests/ci/blockDomain.py rename to test/ci/blockDomain.py index 786121da09..df579c0329 100644 --- a/proteus/tests/ci/blockDomain.py +++ b/test/ci/blockDomain.py @@ -1,9 +1,4 @@ #!/usr/bin/env python - -from __future__ import print_function -from __future__ import division -from builtins import range -from past.utils import old_div import numpy def genPoly(polyfileBase="blockDomain", @@ -12,7 +7,7 @@ def genPoly(polyfileBase="blockDomain", """ create a simple block domain in 2d """ - dx=old_div(Lx,nx); dy = old_div(Ly,ny) + dx=Lx/nx; dy = Ly/ny vertices = [] for j in range(ny+1): diff --git a/proteus/tests/ci/hex_cube_3x3.h5 b/test/ci/hex_cube_3x3.h5 similarity index 100% rename from proteus/tests/ci/hex_cube_3x3.h5 rename to test/ci/hex_cube_3x3.h5 diff --git a/proteus/tests/ci/hex_cube_3x3.xmf b/test/ci/hex_cube_3x3.xmf similarity index 100% rename from proteus/tests/ci/hex_cube_3x3.xmf rename to test/ci/hex_cube_3x3.xmf diff --git a/proteus/tests/ci/ladr_2d_n.py b/test/ci/ladr_2d_n.py similarity index 84% rename from proteus/tests/ci/ladr_2d_n.py rename to test/ci/ladr_2d_n.py index 38cfec6325..82beacaf0c 100644 --- a/proteus/tests/ci/ladr_2d_n.py +++ b/test/ci/ladr_2d_n.py @@ -1,7 +1,3 @@ -from __future__ import absolute_import -from __future__ import division -from builtins import range -from past.utils import old_div from proteus import * from proteus.default_n import * try: @@ -24,7 +20,7 @@ hex = False quad = False triangleFlag=0 -tnList=[old_div(float(i),40.0) for i in range(11)] +tnList=[float(i)/40.0 for i in range(11)] matrix = SparseMatrix multilevelLinearSolver = KSP_petsc4py#LU linearSmoother = None diff --git a/proteus/tests/ci/ladr_2d_p.py b/test/ci/ladr_2d_p.py similarity index 92% rename from proteus/tests/ci/ladr_2d_p.py rename to test/ci/ladr_2d_p.py index e1d1652e49..40e2676e5f 100644 --- a/proteus/tests/ci/ladr_2d_p.py +++ b/test/ci/ladr_2d_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * try: diff --git a/proteus/tests/ci/ladr_ss_2d_c0p1_n.py b/test/ci/ladr_ss_2d_c0p1_n.py similarity index 98% rename from proteus/tests/ci/ladr_ss_2d_c0p1_n.py rename to test/ci/ladr_ss_2d_c0p1_n.py index 724be3bf21..1a17450a1a 100644 --- a/proteus/tests/ci/ladr_ss_2d_c0p1_n.py +++ b/test/ci/ladr_ss_2d_c0p1_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/ci/ladr_ss_2d_p.py b/test/ci/ladr_ss_2d_p.py similarity index 97% rename from proteus/tests/ci/ladr_ss_2d_p.py rename to test/ci/ladr_ss_2d_p.py index 63d8dde3e9..8381904fde 100644 --- a/proteus/tests/ci/ladr_ss_2d_p.py +++ b/test/ci/ladr_ss_2d_p.py @@ -73,4 +73,4 @@ def getFlux(x,flag): advectiveFluxBoundaryConditions = {0:getFlux} -diffusiveFluxBoundaryConditions = {0:{0:getFlux}} +diffusiveFluxBoundaryConditions = {0:{0:getFlux}} \ No newline at end of file diff --git a/proteus/tests/ci/poisson_3d_c0p1_n.py b/test/ci/poisson_3d_c0p1_n.py similarity index 98% rename from proteus/tests/ci/poisson_3d_c0p1_n.py rename to test/ci/poisson_3d_c0p1_n.py index c515c57371..066a9075cf 100644 --- a/proteus/tests/ci/poisson_3d_c0p1_n.py +++ b/test/ci/poisson_3d_c0p1_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/ci/poisson_3d_c0p2_n.py b/test/ci/poisson_3d_c0p2_n.py similarity index 98% rename from proteus/tests/ci/poisson_3d_c0p2_n.py rename to test/ci/poisson_3d_c0p2_n.py index 8c35cf944a..d8241b2b23 100644 --- a/proteus/tests/ci/poisson_3d_c0p2_n.py +++ b/test/ci/poisson_3d_c0p2_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/ci/poisson_3d_c0q1_n.py b/test/ci/poisson_3d_c0q1_n.py similarity index 98% rename from proteus/tests/ci/poisson_3d_c0q1_n.py rename to test/ci/poisson_3d_c0q1_n.py index 3bede169cc..c0c6c0ed7b 100644 --- a/proteus/tests/ci/poisson_3d_c0q1_n.py +++ b/test/ci/poisson_3d_c0q1_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/ci/poisson_3d_c0q2_n.py b/test/ci/poisson_3d_c0q2_n.py similarity index 98% rename from proteus/tests/ci/poisson_3d_c0q2_n.py rename to test/ci/poisson_3d_c0q2_n.py index 45553dc568..a5a935bb9d 100644 --- a/proteus/tests/ci/poisson_3d_c0q2_n.py +++ b/test/ci/poisson_3d_c0q2_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/ci/poisson_3d_p.py b/test/ci/poisson_3d_p.py similarity index 99% rename from proteus/tests/ci/poisson_3d_p.py rename to test/ci/poisson_3d_p.py index 410d299830..da4e84d28a 100644 --- a/proteus/tests/ci/poisson_3d_p.py +++ b/test/ci/poisson_3d_p.py @@ -1,4 +1,3 @@ -from builtins import object from proteus import * from proteus.default_p import * """ diff --git a/proteus/tests/ci/poisson_3d_tetgen_c0p1_n.py b/test/ci/poisson_3d_tetgen_c0p1_n.py similarity index 93% rename from proteus/tests/ci/poisson_3d_tetgen_c0p1_n.py rename to test/ci/poisson_3d_tetgen_c0p1_n.py index 6d3649db07..eacc54a1f0 100644 --- a/proteus/tests/ci/poisson_3d_tetgen_c0p1_n.py +++ b/test/ci/poisson_3d_tetgen_c0p1_n.py @@ -1,6 +1,3 @@ -from __future__ import absolute_import -from __future__ import division -from past.utils import old_div from proteus import * from proteus.default_n import * try: @@ -19,7 +16,9 @@ elementQuadrature = SimplexGaussQuadrature(nd,3) elementBoundaryQuadrature = SimplexGaussQuadrature(nd-1,3) -domain.MeshOptions.triangleOptions="VApq1.35q12feena%e" % (old_div((he**3),6.0),) +triangleOptions="VApq1.35q12feena%e" % ((he**3)/6.0,) +domain.MeshOptions.triangleOptions="VApq1.35q12feena%e" % ((he**3)/6.0,) + logEvent("""Mesh generated using: tetgen -%s %s""" % (triangleOptions,domain.polyfile+".poly")) #number of levels in mesh diff --git a/proteus/tests/ci/poisson_3d_tetgen_c0p2_n.py b/test/ci/poisson_3d_tetgen_c0p2_n.py similarity index 93% rename from proteus/tests/ci/poisson_3d_tetgen_c0p2_n.py rename to test/ci/poisson_3d_tetgen_c0p2_n.py index 3539d0076f..44773bda68 100644 --- a/proteus/tests/ci/poisson_3d_tetgen_c0p2_n.py +++ b/test/ci/poisson_3d_tetgen_c0p2_n.py @@ -1,6 +1,3 @@ -from __future__ import absolute_import -from __future__ import division -from past.utils import old_div from proteus import * from proteus.default_n import * try: @@ -20,7 +17,8 @@ elementBoundaryQuadrature = SimplexGaussQuadrature(nd-1,4) logEvent("""Mesh generated using: tetgen -%s %s""" % (triangleOptions,domain.polyfile+".poly")) -domain.MeshOptions.triangleOptions="VApq1.35q12feena%e" % (old_div((he**3),6.0),) +domain.MeshOptions.triangleOptions="VApq1.35q12feena%e" % ((he**3)/6.0,) +triangleOptions="VApq1.35q12feena%e" % ((he**3)/6.0,) #number of levels in mesh nLevels = 1 diff --git a/proteus/tests/ci/poisson_3d_tetgen_p.py b/test/ci/poisson_3d_tetgen_p.py similarity index 93% rename from proteus/tests/ci/poisson_3d_tetgen_p.py rename to test/ci/poisson_3d_tetgen_p.py index 03afc19097..e431ae7929 100644 --- a/proteus/tests/ci/poisson_3d_tetgen_p.py +++ b/test/ci/poisson_3d_tetgen_p.py @@ -1,7 +1,3 @@ -from __future__ import division -from builtins import range -from builtins import object -from past.utils import old_div from proteus import * from proteus.default_p import * """ @@ -41,15 +37,15 @@ nLevels = 1 -he = old_div(L[0],10.0) +he = L[0]/10.0 #he = hull_draft/1.0 #he = hull_draft/6.0 -genMesh=True#False +genMesh=True vessel = None #vessel = 'cube' #vessel = 'wigley' boundaryTags = { 'bottom': 1, 'front':2, 'right':3, 'back': 4, 'left':5, 'top':6, 'obstacle':7} -if vessel is 'wigley-gmsh': +if vessel == 'wigley-gmsh': domain = Domain.MeshTetgenDomain(fileprefix="mesh") domain.boundaryTags = boundaryTags else: @@ -84,15 +80,15 @@ regions=[[x_ll[0]+0.5*L[0],x_ll[1]+0.5*L[1],x_ll[2]+0.5*L[2]]] regionFlags=[1.0] holes=[] - if vessel is 'wigley': + if vessel == 'wigley': from math import log - he_hull = old_div(log(64.0*he+1.0),64.0) + he_hull = log(64.0*he+1.0)/64.0 #print he,he_hull #he_hull = he - n_points_length = int(ceil(old_div(hull_length,he_hull)))+1 - n_points_draft = 2*int(ceil(old_div(hull_draft,he_hull)))+1 + n_points_length = int(ceil(hull_length/he_hull))+1 + n_points_draft = 2*int(ceil(hull_draft/he_hull))+1 #print "points",n_points_length,n_points_draft - dx = old_div(hull_length,float(n_points_length-1)) + dx = hull_length/float(n_points_length-1) dz = 2.0*hull_draft/float(n_points_draft-1) #print "he",he,dx,dz #grid on right half of hull @@ -101,7 +97,7 @@ x = i*dx - 0.5*hull_length z = j*dz - hull_draft zStar = min(0.0,z) - y = 0.5*hull_beam*(1.0 - 4.0*(old_div(x,hull_length))**2) * (1.0 - (old_div(zStar,hull_draft))**2) + y = 0.5*hull_beam*(1.0 - 4.0*(x/hull_length)**2) * (1.0 - (zStar/hull_draft)**2) vertices.append([x+hull_center[0], y+hull_center[1], z+hull_center[2]]) @@ -110,7 +106,7 @@ def vN_right(i,j): return 8 + i*n_points_draft+j for i in range(n_points_length-1): for j in range(n_points_draft-1): - if i < old_div(n_points_length,2): + if i < n_points_length/2: facets.append([[vN_right(i,j),vN_right(i+1,j+1),vN_right(i+1,j)]]) facetFlags.append(boundaryTags['obstacle']) facets.append([[vN_right(i,j),vN_right(i,j+1),vN_right(i+1,j+1)]]) @@ -126,7 +122,7 @@ def vN_right(i,j): x = i*dx - 0.5*hull_length z = j*dz - hull_draft zStar = min(0.0,z) - y = 0.5*hull_beam*(1.0 - 4.0*(old_div(x,hull_length))**2) * (1.0 - (old_div(zStar,hull_draft))**2) + y = 0.5*hull_beam*(1.0 - 4.0*(x/hull_length)**2) * (1.0 - (zStar/hull_draft)**2) vertices.append([x+hull_center[0], hull_center[1] - y, z+hull_center[2]]) @@ -140,7 +136,7 @@ def vN_left(i,j): return 8 + n_points_length*n_points_draft+(i-1)*(n_points_draft-1)+j-1 for i in range(n_points_length-1): for j in range(n_points_draft-1): - if i < old_div(n_points_length,2): + if i < n_points_length/2: facets.append([[vN_left(i,j),vN_left(i+1,j+1),vN_left(i+1,j)]]) facetFlags.append(boundaryTags['obstacle']) facets.append([[vN_left(i,j),vN_left(i,j+1),vN_left(i+1,j+1)]]) @@ -160,7 +156,7 @@ def vN_left(i,j): #for v in vertices: print v #for f in facets: print f holes.append(hull_center) - if vessel is 'cube': + if vessel == 'cube': nStart = len(vertices) vertices.append([hull_center[0] - 0.5*hull_length, hull_center[1] - 0.5*hull_beam, @@ -226,7 +222,7 @@ def vN_left(i,j): domain.writePoly(polyfile) else: domain.polyfile=polyfile - + comm.barrier() domain.MeshOptions.genMesh=genMesh restrictFineSolutionToAllMeshes=False parallelPartitioningType = MeshTools.MeshParallelPartitioningTypes.node diff --git a/proteus/tests/ci/test_Isosurface.py b/test/ci/test_Isosurface.py similarity index 94% rename from proteus/tests/ci/test_Isosurface.py rename to test/ci/test_Isosurface.py index 7f1e16425b..677032b02f 100644 --- a/proteus/tests/ci/test_Isosurface.py +++ b/test/ci/test_Isosurface.py @@ -1,7 +1,3 @@ -from future import standard_library -standard_library.install_aliases() -from builtins import range -from builtins import object import os import pytest diff --git a/proteus/tests/ci/test_import.py b/test/ci/test_import.py similarity index 93% rename from proteus/tests/ci/test_import.py rename to test/ci/test_import.py index 9a683ebc2b..55d5839542 100644 --- a/proteus/tests/ci/test_import.py +++ b/test/ci/test_import.py @@ -1,4 +1,3 @@ -from __future__ import print_function import sys import traceback import importlib diff --git a/proteus/tests/ci/test_meshPartitionFromTetgenFiles.py b/test/ci/test_meshPartitionFromTetgenFiles.py similarity index 99% rename from proteus/tests/ci/test_meshPartitionFromTetgenFiles.py rename to test/ci/test_meshPartitionFromTetgenFiles.py index 9a1cd56910..e837f50498 100644 --- a/proteus/tests/ci/test_meshPartitionFromTetgenFiles.py +++ b/test/ci/test_meshPartitionFromTetgenFiles.py @@ -9,7 +9,6 @@ \nabla \cdot \left( a(x) \nabla u \right) = f(x) """ -from builtins import object import os, pytest from proteus.iproteus import * from proteus import Comm, defaults diff --git a/proteus/tests/ci/test_poisson.py b/test/ci/test_poisson.py similarity index 99% rename from proteus/tests/ci/test_poisson.py rename to test/ci/test_poisson.py index 505707ade4..29c5c3d2d6 100644 --- a/proteus/tests/ci/test_poisson.py +++ b/test/ci/test_poisson.py @@ -9,7 +9,6 @@ \nabla \cdot \left( a(x) \nabla u \right) = f(x) """ -from builtins import object from proteus.iproteus import * from proteus.defaults import load_physics, load_numerics, System_base from petsc4py import PETSc diff --git a/proteus/tests/ci/test_systemStep.py b/test/ci/test_systemStep.py similarity index 99% rename from proteus/tests/ci/test_systemStep.py rename to test/ci/test_systemStep.py index 805cbba390..8793426bdc 100644 --- a/proteus/tests/ci/test_systemStep.py +++ b/test/ci/test_systemStep.py @@ -9,7 +9,6 @@ u_t + \nabla \cdot \left( u \mathbf{v} - a(x) \nabla u \right) = 0 """ -from __future__ import absolute_import import pytest from proteus.iproteus import * from proteus import Comm diff --git a/proteus/tests/ci/test_wdot.py b/test/ci/test_wdot.py similarity index 94% rename from proteus/tests/ci/test_wdot.py rename to test/ci/test_wdot.py index 348cc165e8..d9e65c5f15 100644 --- a/proteus/tests/ci/test_wdot.py +++ b/test/ci/test_wdot.py @@ -1,4 +1,3 @@ -from __future__ import print_function from pytest import approx def test_wdot(): diff --git a/proteus/tests/cylinder2D/README.md b/test/cylinder2D/README.md similarity index 100% rename from proteus/tests/cylinder2D/README.md rename to test/cylinder2D/README.md diff --git a/proteus/tests/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/__init__.py b/test/cylinder2D/__init__.py similarity index 100% rename from proteus/tests/MeshAdaptPUMI/gauge_compare/dambreak_Colagrossi_2D/__init__.py rename to test/cylinder2D/__init__.py diff --git a/proteus/tests/cylinder2D/conforming_rans2p/README.md b/test/cylinder2D/conforming_rans2p/README.md similarity index 100% rename from proteus/tests/cylinder2D/conforming_rans2p/README.md rename to test/cylinder2D/conforming_rans2p/README.md diff --git a/proteus/tests/MoveMeshMonitor/__init__.py b/test/cylinder2D/conforming_rans2p/__init__.py similarity index 100% rename from proteus/tests/MoveMeshMonitor/__init__.py rename to test/cylinder2D/conforming_rans2p/__init__.py diff --git a/proteus/tests/cylinder2D/conforming_rans2p/comparison_files/comparison_T1_rans2p_u_t2.csv b/test/cylinder2D/conforming_rans2p/comparison_files/comparison_T1_rans2p_u_t2.csv similarity index 100% rename from proteus/tests/cylinder2D/conforming_rans2p/comparison_files/comparison_T1_rans2p_u_t2.csv rename to test/cylinder2D/conforming_rans2p/comparison_files/comparison_T1_rans2p_u_t2.csv diff --git a/proteus/tests/cylinder2D/conforming_rans2p/cylinder2d.py b/test/cylinder2D/conforming_rans2p/cylinder2d.py similarity index 93% rename from proteus/tests/cylinder2D/conforming_rans2p/cylinder2d.py rename to test/cylinder2D/conforming_rans2p/cylinder2d.py index fc3796217c..c961b71e10 100644 --- a/proteus/tests/cylinder2D/conforming_rans2p/cylinder2d.py +++ b/test/cylinder2D/conforming_rans2p/cylinder2d.py @@ -1,8 +1,3 @@ -from __future__ import print_function -from __future__ import absolute_import -from __future__ import division -from builtins import range -from past.utils import old_div from math import * import proteus.MeshTools from proteus import Domain @@ -85,7 +80,7 @@ runCFL = 0.9 dt_fixed = 0.005 dt_init = 0.005 -nDTout = int(old_div(T,dt_fixed)) +nDTout = int(T/dt_fixed) dt_init = min(dt_init,0.5*dt_fixed) tnList = [0.0,dt_init]+[i*dt_fixed for i in range(1,nDTout+1)] if opts.onlySaveFinalSolution == True: diff --git a/proteus/tests/cylinder2D/conforming_rans2p/cylinder_so.py b/test/cylinder2D/conforming_rans2p/cylinder_so.py similarity index 95% rename from proteus/tests/cylinder2D/conforming_rans2p/cylinder_so.py rename to test/cylinder2D/conforming_rans2p/cylinder_so.py index bca4c3e299..241bf765a5 100644 --- a/proteus/tests/cylinder2D/conforming_rans2p/cylinder_so.py +++ b/test/cylinder2D/conforming_rans2p/cylinder_so.py @@ -32,4 +32,4 @@ def __init__(self,modelList,system=defaultSystem,stepExact=True): # # tnList = [0.0,cylinder.dt_init]+[i*cylinder.dt_fixed for i in range(1,cylinder.nDTout+1)] tnList = cylinder.tnList -#archiveFlag = ArchiveFlags.EVERY_SEQUENCE_STEP +#archiveFlag = ArchiveFlags.EVERY_SEQUENCE_STEP \ No newline at end of file diff --git a/proteus/tests/cylinder2D/conforming_rans2p/mesh_cylinder2D.1.poly b/test/cylinder2D/conforming_rans2p/mesh_cylinder2D.1.poly similarity index 100% rename from proteus/tests/cylinder2D/conforming_rans2p/mesh_cylinder2D.1.poly rename to test/cylinder2D/conforming_rans2p/mesh_cylinder2D.1.poly diff --git a/proteus/tests/cylinder2D/conforming_rans2p/mesh_cylinder2D.edge b/test/cylinder2D/conforming_rans2p/mesh_cylinder2D.edge similarity index 100% rename from proteus/tests/cylinder2D/conforming_rans2p/mesh_cylinder2D.edge rename to test/cylinder2D/conforming_rans2p/mesh_cylinder2D.edge diff --git a/proteus/tests/cylinder2D/conforming_rans2p/mesh_cylinder2D.ele b/test/cylinder2D/conforming_rans2p/mesh_cylinder2D.ele similarity index 100% rename from proteus/tests/cylinder2D/conforming_rans2p/mesh_cylinder2D.ele rename to test/cylinder2D/conforming_rans2p/mesh_cylinder2D.ele diff --git a/proteus/tests/cylinder2D/conforming_rans2p/mesh_cylinder2D.node b/test/cylinder2D/conforming_rans2p/mesh_cylinder2D.node similarity index 100% rename from proteus/tests/cylinder2D/conforming_rans2p/mesh_cylinder2D.node rename to test/cylinder2D/conforming_rans2p/mesh_cylinder2D.node diff --git a/proteus/tests/cylinder2D/conforming_rans2p/mesh_cylinder2D.poly b/test/cylinder2D/conforming_rans2p/mesh_cylinder2D.poly similarity index 100% rename from proteus/tests/cylinder2D/conforming_rans2p/mesh_cylinder2D.poly rename to test/cylinder2D/conforming_rans2p/mesh_cylinder2D.poly diff --git a/proteus/tests/cylinder2D/conforming_rans2p/petsc.options b/test/cylinder2D/conforming_rans2p/petsc.options similarity index 100% rename from proteus/tests/cylinder2D/conforming_rans2p/petsc.options rename to test/cylinder2D/conforming_rans2p/petsc.options diff --git a/proteus/tests/cylinder2D/conforming_rans2p/symmetricDomain_john.py b/test/cylinder2D/conforming_rans2p/symmetricDomain_john.py similarity index 93% rename from proteus/tests/cylinder2D/conforming_rans2p/symmetricDomain_john.py rename to test/cylinder2D/conforming_rans2p/symmetricDomain_john.py index 9680b1cb08..3f9c2974a6 100644 --- a/proteus/tests/cylinder2D/conforming_rans2p/symmetricDomain_john.py +++ b/test/cylinder2D/conforming_rans2p/symmetricDomain_john.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import range -from past.utils import old_div import math from proteus import Domain import os @@ -16,14 +13,14 @@ def symmetric2D(box=(1.0,0.41), DX_coarse = 0.02): boundaries = ['left', 'right', 'front', 'back', 'obstacle'] boundaryFlags=dict([(key,i+1) for i,key in enumerate(boundaries)]) - left_nPoints = int(math.ceil(old_div((H-r),DX))) - top_nPoints = int(math.ceil(old_div(L,DX))) - right_nPoints = int(math.ceil(old_div(H,DX))) - bottom_nPoints = int(math.ceil(old_div((L-r),DX))) - DX_left = old_div((H-r),float(left_nPoints)) - DX_top = old_div(L,float(top_nPoints)) - DX_right = old_div(H,float(right_nPoints)) - DX_bottom = old_div((L-r),float(bottom_nPoints)) + left_nPoints = int(math.ceil((H-r)/DX)) + top_nPoints = int(math.ceil(L/DX)) + right_nPoints = int(math.ceil(H/DX)) + bottom_nPoints = int(math.ceil((L-r)/DX)) + DX_left = (H-r)/float(left_nPoints) + DX_top = L/float(top_nPoints) + DX_right = H/float(right_nPoints) + DX_bottom = (L-r)/float(bottom_nPoints) vertices0 = [(0.0, r)] vertexFlags0 = [boundaryFlags['obstacle']] @@ -51,7 +48,7 @@ def symmetric2D(box=(1.0,0.41), vertexFlags0.append(0) arclength= 0.5*math.pi*r - nPoints_cyl = int(math.ceil(old_div(arclength,DX))) + nPoints_cyl = int(math.ceil(arclength/DX)) #DX_cyl = arclength/float(nPoints_cyl) nPoints_cyl = max([nPoints_cyl,10]) # cyl diff --git a/proteus/tests/cylinder2D/conforming_rans2p/test_cylinder2D_conforming_rans2p.py b/test/cylinder2D/conforming_rans2p/test_cylinder2D_conforming_rans2p.py similarity index 76% rename from proteus/tests/cylinder2D/conforming_rans2p/test_cylinder2D_conforming_rans2p.py rename to test/cylinder2D/conforming_rans2p/test_cylinder2D_conforming_rans2p.py index ac7d11f719..433e10b93e 100644 --- a/proteus/tests/cylinder2D/conforming_rans2p/test_cylinder2D_conforming_rans2p.py +++ b/test/cylinder2D/conforming_rans2p/test_cylinder2D_conforming_rans2p.py @@ -1,10 +1,8 @@ """Tests for 2d flow around a cylinder with a conforming mesh and rans2p""" -from builtins import range -from builtins import object from proteus.iproteus import * from proteus import Comm from proteus import Context -import tables +import h5py import importlib comm = Comm.get() @@ -60,11 +58,9 @@ def example_setting(self, pre_setting): sList=[] for (pModule,nModule) in my_so.pnList: pList.append( - importlib.import_module("."+pModule, - "proteus.tests.cylinder2D.conforming_rans2p")) + importlib.import_module(pModule)) nList.append( - importlib.import_module("."+nModule, - "proteus.tests.cylinder2D.conforming_rans2p")) + importlib.import_module(nModule)) if pList[-1].name == None: pList[-1].name = pModule reload(pList[-1]) # Serious error @@ -86,16 +82,9 @@ def example_setting(self, pre_setting): self.aux_names.append(ns.modelList[0].name) ns.calculateSolution(my_so.name) # COMPARE VS SAVED FILES # - #expected_path = 'comparison_files/' + self.compare_name + '.h5' - #with tables.open_file(os.path.join(self._scriptdir, expected_path)) as expected, \ - # tables.open_file( my_so.name + '.h5') as actual: - # assert np.allclose(expected.root.u_t2, - # actual.root.u_t2, - # atol=1e-8) - - actual = tables.open_file( my_so.name + '.h5') + actual = h5py.File( my_so.name + '.h5') expected_path = 'comparison_files/' + 'comparison_' + self.compare_name + '_u_t2.csv' #write comparison file #np.array(actual.root.u_t2).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.u_t2).flatten(),decimal=6) + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['u_t2']).flatten(),decimal=6) actual.close() diff --git a/proteus/tests/cylinder2D/conforming_rans2p/top_right.1.edge b/test/cylinder2D/conforming_rans2p/top_right.1.edge similarity index 100% rename from proteus/tests/cylinder2D/conforming_rans2p/top_right.1.edge rename to test/cylinder2D/conforming_rans2p/top_right.1.edge diff --git a/proteus/tests/cylinder2D/conforming_rans2p/top_right.1.ele b/test/cylinder2D/conforming_rans2p/top_right.1.ele similarity index 100% rename from proteus/tests/cylinder2D/conforming_rans2p/top_right.1.ele rename to test/cylinder2D/conforming_rans2p/top_right.1.ele diff --git a/proteus/tests/cylinder2D/conforming_rans2p/top_right.1.neigh b/test/cylinder2D/conforming_rans2p/top_right.1.neigh similarity index 100% rename from proteus/tests/cylinder2D/conforming_rans2p/top_right.1.neigh rename to test/cylinder2D/conforming_rans2p/top_right.1.neigh diff --git a/proteus/tests/cylinder2D/conforming_rans2p/top_right.1.node b/test/cylinder2D/conforming_rans2p/top_right.1.node similarity index 100% rename from proteus/tests/cylinder2D/conforming_rans2p/top_right.1.node rename to test/cylinder2D/conforming_rans2p/top_right.1.node diff --git a/proteus/tests/cylinder2D/conforming_rans2p/top_right.1.poly b/test/cylinder2D/conforming_rans2p/top_right.1.poly similarity index 100% rename from proteus/tests/cylinder2D/conforming_rans2p/top_right.1.poly rename to test/cylinder2D/conforming_rans2p/top_right.1.poly diff --git a/proteus/tests/cylinder2D/conforming_rans2p/twp_navier_stokes_cylinder_2d_n.py b/test/cylinder2D/conforming_rans2p/twp_navier_stokes_cylinder_2d_n.py similarity index 97% rename from proteus/tests/cylinder2D/conforming_rans2p/twp_navier_stokes_cylinder_2d_n.py rename to test/cylinder2D/conforming_rans2p/twp_navier_stokes_cylinder_2d_n.py index eacf9ebc54..75afb6eb57 100644 --- a/proteus/tests/cylinder2D/conforming_rans2p/twp_navier_stokes_cylinder_2d_n.py +++ b/test/cylinder2D/conforming_rans2p/twp_navier_stokes_cylinder_2d_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/cylinder2D/conforming_rans2p/twp_navier_stokes_cylinder_2d_p.py b/test/cylinder2D/conforming_rans2p/twp_navier_stokes_cylinder_2d_p.py similarity index 95% rename from proteus/tests/cylinder2D/conforming_rans2p/twp_navier_stokes_cylinder_2d_p.py rename to test/cylinder2D/conforming_rans2p/twp_navier_stokes_cylinder_2d_p.py index c4850a945e..c472c0ee3f 100644 --- a/proteus/tests/cylinder2D/conforming_rans2p/twp_navier_stokes_cylinder_2d_p.py +++ b/test/cylinder2D/conforming_rans2p/twp_navier_stokes_cylinder_2d_p.py @@ -1,10 +1,6 @@ """ Incompressible Navier-Stokes flow around a cylinder in 2D. """ -from __future__ import absolute_import -from __future__ import division -from builtins import object -from past.utils import old_div from proteus import * from proteus.default_p import * import sys @@ -35,7 +31,7 @@ def vel(x,t): - U = Um*x[1]*(fl_H-x[1])/(old_div(fl_H,2.0))**2 + U = Um*x[1]*(fl_H-x[1])/(fl_H/2.0)**2 if t < 2.0: return t*U/2.0 else: diff --git a/proteus/tests/cylinder2D/conforming_rans3p/README.md b/test/cylinder2D/conforming_rans3p/README.md similarity index 100% rename from proteus/tests/cylinder2D/conforming_rans3p/README.md rename to test/cylinder2D/conforming_rans3p/README.md diff --git a/proteus/tests/ProjScheme_with_EV/__init__.py b/test/cylinder2D/conforming_rans3p/__init__.py similarity index 100% rename from proteus/tests/ProjScheme_with_EV/__init__.py rename to test/cylinder2D/conforming_rans3p/__init__.py diff --git a/proteus/tests/cylinder2D/conforming_rans3p/comparison_files/comparison_T1P1_u_t2.csv b/test/cylinder2D/conforming_rans3p/comparison_files/comparison_T1P1_u_t2.csv similarity index 100% rename from proteus/tests/cylinder2D/conforming_rans3p/comparison_files/comparison_T1P1_u_t2.csv rename to test/cylinder2D/conforming_rans3p/comparison_files/comparison_T1P1_u_t2.csv diff --git a/proteus/tests/cylinder2D/conforming_rans3p/cylinder.py b/test/cylinder2D/conforming_rans3p/cylinder3p.py similarity index 86% rename from proteus/tests/cylinder2D/conforming_rans3p/cylinder.py rename to test/cylinder2D/conforming_rans3p/cylinder3p.py index 93441f4b5f..4324c41734 100644 --- a/proteus/tests/cylinder2D/conforming_rans3p/cylinder.py +++ b/test/cylinder2D/conforming_rans3p/cylinder3p.py @@ -1,8 +1,3 @@ -from __future__ import print_function -from __future__ import absolute_import -from __future__ import division -from builtins import range -from past.utils import old_div from math import * import proteus.MeshTools from proteus import Domain @@ -127,7 +122,7 @@ dt_fixed = 0.005#0.03 dt_init = 0.005#min(0.1*dt_fixed,0.001) runCFL=0.33 -nDTout = int(round(old_div(T,dt_fixed))) +nDTout = int(round(T/dt_fixed)) tnList = [0.0,dt_init]+[i*dt_fixed for i in range(1,nDTout+1)] if opts.onlySaveFinalSolution == True: @@ -247,3 +242,37 @@ #domain.writePoly('mesh_cylinder2D') domain.polyfile = domain.polyfile=os.path.dirname(os.path.abspath(__file__))+"/../conforming_rans2p/"+"mesh_cylinder2D" +if sedimentDynamics: + pnList = [("vos_p", "vos_n"),#0 + ("vof_p", "vof_n"),#1 + ("ls_p", "ls_n"),#2 + ("redist_p", "redist_n"),#3 + ("ls_consrv_p", "ls_consrv_n"),#4 + ("threep_navier_stokes_sed_p", "threep_navier_stokes_sed_n"),#5 + ("twp_navier_stokes_p", "twp_navier_stokes_n"),#6 + ("pressureincrement_p", "pressureincrement_n"),#7 + ("pressure_p", "pressure_n"),#8 + ("pressureInitial_p", "pressureInitial_n")]#9 + VOS_model=0 + VOF_model=1 + LS_model=2 + RD_model=3 + MCORR_model=4 + SED_model=5 + V_model=6 + PINC_model=7 + PRESSURE_model=8 + PINIT_model=9 +else: + pnList = [("twp_navier_stokes_p", "twp_navier_stokes_n"),#0 + ("pressureincrement_p", "pressureincrement_n"),#1 + ("pressure_p", "pressure_n"),#2 + ("pressureInitial_p", "pressureInitial_n")]#3 + + VOF_model=None + VOS_model=None + SED_model=None + V_model=0 + PINC_model=1 + PRESSURE_model=2 + PINIT_model=3 diff --git a/test/cylinder2D/conforming_rans3p/cylinder_so.py b/test/cylinder2D/conforming_rans3p/cylinder_so.py new file mode 100644 index 0000000000..0b08611542 --- /dev/null +++ b/test/cylinder2D/conforming_rans3p/cylinder_so.py @@ -0,0 +1,47 @@ +import proteus.default_so +from importlib import reload +reload(proteus.default_so) +from proteus.default_so import * +try: + from . import cylinder3p +except: + import cylinder3p + +from proteus.SplitOperator import Sequential_FixedStep_Simple, defaultSystem + +pnList = cylinder3p.pnList + +# if cylinder3p.useRANS > 0: +# pnList.append(("kappa_p", +# "kappa_n")) +# pnList.append(("dissipation_p", +# "dissipation_n")) +name = "cylinder" +soname=name +#modelSpinUpList = [cylinder3p.VOF_model, cylinder3p.LS_model, cylinder3p.V_model, cylinder3p.PINIT_model] +modelSpinUpList = [cylinder3p.PINIT_model] + +class Sequential_MinAdaptiveModelStepPS(Sequential_MinAdaptiveModelStep): + def __init__(self,modelList,system=defaultSystem,stepExact=True): + Sequential_MinAdaptiveModelStep.__init__(self,modelList,system,stepExact) + self.modelList = modelList[:len(pnList)-1] + +class Sequential_MinAdaptiveModelStepPS(Sequential_FixedStep): + def __init__(self,modelList,system=defaultSystem,stepExact=True): + Sequential_FixedStep.__init__(self,modelList,system,stepExact) + self.modelList = modelList[:len(pnList)-1] + +dt_system_fixed = cylinder3p.dt_fixed +systemStepControllerType = Sequential_MinAdaptiveModelStepPS + +needEBQ_GLOBAL = False +needEBQ = False + +systemStepExact=False + +tnList = cylinder3p.tnList + + + +info = open("TimeList.txt","w") +#archiveFlag = ArchiveFlags.EVERY_SEQUENCE_STEP diff --git a/proteus/tests/cylinder2D/conforming_rans3p/pressureInitial_n.py b/test/cylinder2D/conforming_rans3p/pressureInitial_n.py similarity index 97% rename from proteus/tests/cylinder2D/conforming_rans3p/pressureInitial_n.py rename to test/cylinder2D/conforming_rans3p/pressureInitial_n.py index 1c36574304..0a6c03148e 100644 --- a/proteus/tests/cylinder2D/conforming_rans3p/pressureInitial_n.py +++ b/test/cylinder2D/conforming_rans3p/pressureInitial_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/cylinder2D/conforming_rans3p/pressureInitial_p.py b/test/cylinder2D/conforming_rans3p/pressureInitial_p.py similarity index 90% rename from proteus/tests/cylinder2D/conforming_rans3p/pressureInitial_p.py rename to test/cylinder2D/conforming_rans3p/pressureInitial_p.py index 09e7e17c1d..880712b5ca 100644 --- a/proteus/tests/cylinder2D/conforming_rans3p/pressureInitial_p.py +++ b/test/cylinder2D/conforming_rans3p/pressureInitial_p.py @@ -1,12 +1,10 @@ -from __future__ import absolute_import -from builtins import object from math import * from proteus import * from proteus.default_p import * try: - from .cylinder import * + from .cylinder3p import * except: - from cylinder import * + from cylinder3p import * from proteus.mprans import PresInit diff --git a/proteus/tests/cylinder2D/conforming_rans3p/pressure_n.py b/test/cylinder2D/conforming_rans3p/pressure_n.py similarity index 97% rename from proteus/tests/cylinder2D/conforming_rans3p/pressure_n.py rename to test/cylinder2D/conforming_rans3p/pressure_n.py index 44ad92475e..9fffbf2a4f 100644 --- a/proteus/tests/cylinder2D/conforming_rans3p/pressure_n.py +++ b/test/cylinder2D/conforming_rans3p/pressure_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/cylinder2D/conforming_rans3p/pressure_p.py b/test/cylinder2D/conforming_rans3p/pressure_p.py similarity index 86% rename from proteus/tests/cylinder2D/conforming_rans3p/pressure_p.py rename to test/cylinder2D/conforming_rans3p/pressure_p.py index 125c330691..32a8a9ffbb 100644 --- a/proteus/tests/cylinder2D/conforming_rans3p/pressure_p.py +++ b/test/cylinder2D/conforming_rans3p/pressure_p.py @@ -1,12 +1,10 @@ -from __future__ import absolute_import -from builtins import object from math import * from proteus import * from proteus.default_p import * try: - from .cylinder import * + from .cylinder3p import * except: - from cylinder import * + from cylinder3p import * from proteus.mprans import Pres diff --git a/proteus/tests/cylinder2D/conforming_rans3p/pressureincrement_n.py b/test/cylinder2D/conforming_rans3p/pressureincrement_n.py similarity index 97% rename from proteus/tests/cylinder2D/conforming_rans3p/pressureincrement_n.py rename to test/cylinder2D/conforming_rans3p/pressureincrement_n.py index 47a3047906..72530a3610 100644 --- a/proteus/tests/cylinder2D/conforming_rans3p/pressureincrement_n.py +++ b/test/cylinder2D/conforming_rans3p/pressureincrement_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/cylinder2D/conforming_rans3p/pressureincrement_p.py b/test/cylinder2D/conforming_rans3p/pressureincrement_p.py similarity index 88% rename from proteus/tests/cylinder2D/conforming_rans3p/pressureincrement_p.py rename to test/cylinder2D/conforming_rans3p/pressureincrement_p.py index 49d1094da2..9423ac1fe9 100644 --- a/proteus/tests/cylinder2D/conforming_rans3p/pressureincrement_p.py +++ b/test/cylinder2D/conforming_rans3p/pressureincrement_p.py @@ -1,14 +1,10 @@ -from __future__ import absolute_import -from __future__ import division -from builtins import object -from past.utils import old_div from math import * from proteus import * from proteus.default_p import * try: - from .cylinder import * + from .cylinder3p import * except: - from cylinder import * + from cylinder3p import * #domain = ctx.domain @@ -39,7 +35,7 @@ def getDBC_phi(x,flag): #the advectiveFlux should be zero on any no-flow boundaries def flux(x,t): - U = Um*x[1]*(fl_H-x[1])/(old_div(fl_H,2.0))**2 + U = Um*x[1]*(fl_H-x[1])/(fl_H/2.0)**2 if t < 2.0: return -t*U/2.0 else: diff --git a/proteus/tests/cylinder2D/conforming_rans3p/save_batch.py b/test/cylinder2D/conforming_rans3p/save_batch.py similarity index 99% rename from proteus/tests/cylinder2D/conforming_rans3p/save_batch.py rename to test/cylinder2D/conforming_rans3p/save_batch.py index 09d6650c2f..e9bd7a2ee1 100644 --- a/proteus/tests/cylinder2D/conforming_rans3p/save_batch.py +++ b/test/cylinder2D/conforming_rans3p/save_batch.py @@ -18,4 +18,4 @@ simFlagsList[4]['storeQuantities'] = ["q:('phis',0)"] start -end +end \ No newline at end of file diff --git a/proteus/tests/cylinder2D/conforming_rans3p/symmetricDomain_john.py b/test/cylinder2D/conforming_rans3p/symmetricDomain_john.py similarity index 93% rename from proteus/tests/cylinder2D/conforming_rans3p/symmetricDomain_john.py rename to test/cylinder2D/conforming_rans3p/symmetricDomain_john.py index dd9dad9c93..5f387bb091 100644 --- a/proteus/tests/cylinder2D/conforming_rans3p/symmetricDomain_john.py +++ b/test/cylinder2D/conforming_rans3p/symmetricDomain_john.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import range -from past.utils import old_div import math from proteus import Domain import os @@ -16,14 +13,14 @@ def symmetric2D(box=(1.0,0.41), DX_coarse = 0.02): boundaries = ['left', 'right', 'front', 'back', 'obstacle'] boundaryFlags=dict([(key,i+1) for i,key in enumerate(boundaries)]) - left_nPoints = int(math.ceil(old_div((H-r),DX))) - top_nPoints = int(math.ceil(old_div(L,DX))) - right_nPoints = int(math.ceil(old_div(H,DX))) - bottom_nPoints = int(math.ceil(old_div((L-r),DX))) - DX_left = old_div((H-r),float(left_nPoints)) - DX_top = old_div(L,float(top_nPoints)) - DX_right = old_div(H,float(right_nPoints)) - DX_bottom = old_div((L-r),float(bottom_nPoints)) + left_nPoints = int(math.ceil((H-r)/DX)) + top_nPoints = int(math.ceil(L/DX)) + right_nPoints = int(math.ceil(H/DX)) + bottom_nPoints = int(math.ceil((L-r)/DX)) + DX_left = (H-r)/float(left_nPoints) + DX_top = L/float(top_nPoints) + DX_right = H/float(right_nPoints) + DX_bottom = (L-r)/float(bottom_nPoints) vertices0 = [(0.0, r)] vertexFlags0 = [boundaryFlags['obstacle']] @@ -51,7 +48,7 @@ def symmetric2D(box=(1.0,0.41), vertexFlags0.append(0) arclength= 0.5*math.pi*r - nPoints_cyl = int(math.ceil(old_div(arclength,DX))) + nPoints_cyl = int(math.ceil(arclength/DX)) #DX_cyl = arclength/float(nPoints_cyl) nPoints_cyl = max([nPoints_cyl,10]) # cyl diff --git a/proteus/tests/cylinder2D/conforming_rans3p/test_cylinder2D_conforming_rans3p.py b/test/cylinder2D/conforming_rans3p/test_cylinder2D_conforming_rans3p.py similarity index 83% rename from proteus/tests/cylinder2D/conforming_rans3p/test_cylinder2D_conforming_rans3p.py rename to test/cylinder2D/conforming_rans3p/test_cylinder2D_conforming_rans3p.py index a55222fe5e..49cc72b6ba 100644 --- a/proteus/tests/cylinder2D/conforming_rans3p/test_cylinder2D_conforming_rans3p.py +++ b/test/cylinder2D/conforming_rans3p/test_cylinder2D_conforming_rans3p.py @@ -1,10 +1,8 @@ """Tests for 2d flow around a cylinder with a conforming mesh and rans3p""" -from builtins import range -from builtins import object from proteus.iproteus import * from proteus import Comm from proteus import Context -import tables +import h5py import importlib comm = Comm.get() @@ -51,13 +49,13 @@ def example_setting(self, pre_setting): pList=[] nList=[] sList=[] + _scriptdir = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0,_scriptdir) for (pModule,nModule) in my_so.pnList: pList.append( - importlib.import_module("."+pModule, - "proteus.tests.cylinder2D.conforming_rans3p")) + importlib.import_module(pModule)) nList.append( - importlib.import_module("."+nModule, - "proteus.tests.cylinder2D.conforming_rans3p")) + importlib.import_module(nModule)) if pList[-1].name == None: pList[-1].name = pModule reload(pList[-1]) # Serious error @@ -69,6 +67,7 @@ def example_setting(self, pre_setting): sList.append(s) else: sList = my_so.sList + sys.path.remove(_scriptdir) my_so.name += "_rans3p_"+self.compare_name #save data with different filename # NUMERICAL SOLUTION # ns = proteus.NumericalSolution.NS_base(my_so, @@ -79,8 +78,11 @@ def example_setting(self, pre_setting): self.aux_names.append(ns.modelList[0].name) ns.calculateSolution(my_so.name) # COMPARE VS SAVED FILES # - actual=tables.open_file( my_so.name + '.h5') + actual=h5py.File( my_so.name + '.h5') expected_path = 'comparison_files/' + 'comparison_' + self.compare_name + '_u_t2.csv' #write comparison file #np.array(actual.root.u_t2).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.u_t2).flatten(),decimal=10) + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['u_t2']).flatten(),decimal=10) + + + diff --git a/proteus/tests/cylinder2D/conforming_rans3p/twp_navier_stokes_n.py b/test/cylinder2D/conforming_rans3p/twp_navier_stokes_n.py similarity index 95% rename from proteus/tests/cylinder2D/conforming_rans3p/twp_navier_stokes_n.py rename to test/cylinder2D/conforming_rans3p/twp_navier_stokes_n.py index 8d20fbd448..202b738e80 100644 --- a/proteus/tests/cylinder2D/conforming_rans3p/twp_navier_stokes_n.py +++ b/test/cylinder2D/conforming_rans3p/twp_navier_stokes_n.py @@ -1,11 +1,10 @@ -from __future__ import absolute_import from proteus import * try: from .twp_navier_stokes_p import * - from .cylinder import * + from .cylinder3p import * except: from twp_navier_stokes_p import * - from cylinder import * + from cylinder3p import * if timeDiscretization=='vbdf': timeIntegration = VBDF diff --git a/proteus/tests/cylinder2D/conforming_rans3p/twp_navier_stokes_p.py b/test/cylinder2D/conforming_rans3p/twp_navier_stokes_p.py similarity index 94% rename from proteus/tests/cylinder2D/conforming_rans3p/twp_navier_stokes_p.py rename to test/cylinder2D/conforming_rans3p/twp_navier_stokes_p.py index 81b959a8b2..489a4aa6c2 100644 --- a/proteus/tests/cylinder2D/conforming_rans3p/twp_navier_stokes_p.py +++ b/test/cylinder2D/conforming_rans3p/twp_navier_stokes_p.py @@ -1,13 +1,9 @@ -from __future__ import absolute_import -from __future__ import division -from builtins import object -from past.utils import old_div from proteus import * from proteus.default_p import * try: - from .cylinder import * + from .cylinder3p import * except: - from cylinder import * + from cylinder3p import * from proteus.mprans import RANS3PF LevelModelType = RANS3PF.LevelModel @@ -59,7 +55,7 @@ USE_SUPG=0.0, ARTIFICIAL_VISCOSITY=1) def vel(x,t): - U = Um*x[1]*(fl_H-x[1])/(old_div(fl_H,2.0))**2 + U = Um*x[1]*(fl_H-x[1])/(fl_H/2.0)**2 if t < 2.0: return t*U/2.0 else: diff --git a/proteus/tests/cylinder2D/ibm_method/README.md b/test/cylinder2D/ibm_method/README.md similarity index 100% rename from proteus/tests/cylinder2D/ibm_method/README.md rename to test/cylinder2D/ibm_method/README.md diff --git a/proteus/tests/cylinder2D/ibm_method/comparison_files/comparison_T1_rans3p_u_t2.csv b/test/cylinder2D/ibm_method/comparison_files/comparison_T1_rans3p_u_t2.csv similarity index 100% rename from proteus/tests/cylinder2D/ibm_method/comparison_files/comparison_T1_rans3p_u_t2.csv rename to test/cylinder2D/ibm_method/comparison_files/comparison_T1_rans3p_u_t2.csv diff --git a/proteus/tests/cylinder2D/ibm_method/cylinder.py b/test/cylinder2D/ibm_method/cylinder.py similarity index 97% rename from proteus/tests/cylinder2D/ibm_method/cylinder.py rename to test/cylinder2D/ibm_method/cylinder.py index 6540341969..a7b7bbdd88 100644 --- a/proteus/tests/cylinder2D/ibm_method/cylinder.py +++ b/test/cylinder2D/ibm_method/cylinder.py @@ -1,7 +1,3 @@ -from __future__ import print_function -from __future__ import division -from builtins import range -from past.utils import old_div from math import * import proteus.MeshTools from proteus import Domain @@ -177,7 +173,7 @@ regions = [[0.95*L[0], 0.2],[0.2-0.15,0.2],[0.2,0.2]] regionFlags = [1,2,3] - regionConstraints=[0.5*he**2,0.5*(old_div(he,2.0))**2,0.5*(old_div(he,6.0))**2] + regionConstraints=[0.5*he**2,0.5*(he/2.0)**2,0.5*(he/6.0)**2] # for gaugeName,gaugeCoordinates in pointGauges.locations.iteritems(): # vertices.append(gaugeCoordinates) # vertexFlags.append(pointGauges.flags[gaugeName]) @@ -243,7 +239,7 @@ dt_fixed = 0.005#0.03 dt_init = 0.005#min(0.1*dt_fixed,0.001) runCFL=0.33 -nDTout = int(round(old_div(T,dt_fixed))) +nDTout = int(round(T/dt_fixed)) tnList = [0.0,dt_init]+[i*dt_fixed for i in range(1,nDTout+1)] if ct.onlySaveFinalSolution == True: @@ -365,13 +361,13 @@ def velRamp(t): return U def signedDistance(x): - return x[1]-old_div(L[1],2) + return x[1]-L[1]/2 def particle_sdf(t, x): cx = 0.2 cy = 0.2 r = math.sqrt( (x[0]-cx)**2 + (x[1]-cy)**2) - n = (old_div((x[0]-cx),r),old_div((x[1]-cy),r)) + n = ((x[0]-cx)/r,(x[1]-cy)/r) return r - 0.05,n def particle_vel(t, x): diff --git a/proteus/tests/cylinder2D/sbm_method/cylinder_so.py b/test/cylinder2D/ibm_method/cylinder_so.py similarity index 100% rename from proteus/tests/cylinder2D/sbm_method/cylinder_so.py rename to test/cylinder2D/ibm_method/cylinder_so.py diff --git a/proteus/tests/cylinder2D/ibm_method/mesh.1.poly b/test/cylinder2D/ibm_method/mesh.1.poly similarity index 100% rename from proteus/tests/cylinder2D/ibm_method/mesh.1.poly rename to test/cylinder2D/ibm_method/mesh.1.poly diff --git a/proteus/tests/cylinder2D/ibm_method/mesh.edge b/test/cylinder2D/ibm_method/mesh.edge similarity index 100% rename from proteus/tests/cylinder2D/ibm_method/mesh.edge rename to test/cylinder2D/ibm_method/mesh.edge diff --git a/proteus/tests/cylinder2D/ibm_method/mesh.ele b/test/cylinder2D/ibm_method/mesh.ele similarity index 100% rename from proteus/tests/cylinder2D/ibm_method/mesh.ele rename to test/cylinder2D/ibm_method/mesh.ele diff --git a/proteus/tests/cylinder2D/ibm_method/mesh.node b/test/cylinder2D/ibm_method/mesh.node similarity index 100% rename from proteus/tests/cylinder2D/ibm_method/mesh.node rename to test/cylinder2D/ibm_method/mesh.node diff --git a/proteus/tests/cylinder2D/ibm_method/mesh.poly b/test/cylinder2D/ibm_method/mesh.poly similarity index 100% rename from proteus/tests/cylinder2D/ibm_method/mesh.poly rename to test/cylinder2D/ibm_method/mesh.poly diff --git a/proteus/tests/cylinder2D/ibm_method/pressureInitial_n.py b/test/cylinder2D/ibm_method/pressureInitial_n.py similarity index 97% rename from proteus/tests/cylinder2D/ibm_method/pressureInitial_n.py rename to test/cylinder2D/ibm_method/pressureInitial_n.py index 1c36574304..0a6c03148e 100644 --- a/proteus/tests/cylinder2D/ibm_method/pressureInitial_n.py +++ b/test/cylinder2D/ibm_method/pressureInitial_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/cylinder2D/sbm_method/pressureInitial_p.py b/test/cylinder2D/ibm_method/pressureInitial_p.py similarity index 95% rename from proteus/tests/cylinder2D/sbm_method/pressureInitial_p.py rename to test/cylinder2D/ibm_method/pressureInitial_p.py index e285e017bb..afd55201ab 100644 --- a/proteus/tests/cylinder2D/sbm_method/pressureInitial_p.py +++ b/test/cylinder2D/ibm_method/pressureInitial_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from math import * from proteus import * from proteus.default_p import * diff --git a/proteus/tests/cylinder2D/sbm_method/pressure_n.py b/test/cylinder2D/ibm_method/pressure_n.py similarity index 97% rename from proteus/tests/cylinder2D/sbm_method/pressure_n.py rename to test/cylinder2D/ibm_method/pressure_n.py index fb98276020..568b0a9665 100644 --- a/proteus/tests/cylinder2D/sbm_method/pressure_n.py +++ b/test/cylinder2D/ibm_method/pressure_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/cylinder2D/ibm_method/pressure_p.py b/test/cylinder2D/ibm_method/pressure_p.py similarity index 94% rename from proteus/tests/cylinder2D/ibm_method/pressure_p.py rename to test/cylinder2D/ibm_method/pressure_p.py index f66a6e4e64..7a084b2653 100644 --- a/proteus/tests/cylinder2D/ibm_method/pressure_p.py +++ b/test/cylinder2D/ibm_method/pressure_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from math import * from proteus import * from proteus.default_p import * diff --git a/proteus/tests/cylinder2D/ibm_method/pressureincrement_n.py b/test/cylinder2D/ibm_method/pressureincrement_n.py similarity index 97% rename from proteus/tests/cylinder2D/ibm_method/pressureincrement_n.py rename to test/cylinder2D/ibm_method/pressureincrement_n.py index 692e61e472..953d530667 100644 --- a/proteus/tests/cylinder2D/ibm_method/pressureincrement_n.py +++ b/test/cylinder2D/ibm_method/pressureincrement_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/cylinder2D/sbm_method/pressureincrement_p.py b/test/cylinder2D/ibm_method/pressureincrement_p.py similarity index 96% rename from proteus/tests/cylinder2D/sbm_method/pressureincrement_p.py rename to test/cylinder2D/ibm_method/pressureincrement_p.py index 3a6209fd8d..cb4fb12025 100644 --- a/proteus/tests/cylinder2D/sbm_method/pressureincrement_p.py +++ b/test/cylinder2D/ibm_method/pressureincrement_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from math import * from proteus import * from proteus.default_p import * diff --git a/proteus/tests/cylinder2D/ibm_method/solids_batch.py b/test/cylinder2D/ibm_method/solids_batch.py similarity index 99% rename from proteus/tests/cylinder2D/ibm_method/solids_batch.py rename to test/cylinder2D/ibm_method/solids_batch.py index 09d6650c2f..e9bd7a2ee1 100644 --- a/proteus/tests/cylinder2D/ibm_method/solids_batch.py +++ b/test/cylinder2D/ibm_method/solids_batch.py @@ -18,4 +18,4 @@ simFlagsList[4]['storeQuantities'] = ["q:('phis',0)"] start -end +end \ No newline at end of file diff --git a/proteus/tests/cylinder2D/ibm_method/test_cylinder2D_ibm_rans3p.py b/test/cylinder2D/ibm_method/test_cylinder2D_ibm_rans3p.py similarity index 93% rename from proteus/tests/cylinder2D/ibm_method/test_cylinder2D_ibm_rans3p.py rename to test/cylinder2D/ibm_method/test_cylinder2D_ibm_rans3p.py index c36f9865af..2e09cf6bab 100644 --- a/proteus/tests/cylinder2D/ibm_method/test_cylinder2D_ibm_rans3p.py +++ b/test/cylinder2D/ibm_method/test_cylinder2D_ibm_rans3p.py @@ -1,11 +1,9 @@ """Tests for 2d flow around an immersed boundary cylinder with rans3p""" -from builtins import range -from builtins import object import pytest from proteus.iproteus import * from proteus import Comm from proteus import Context -import tables +import h5py import importlib @@ -88,9 +86,9 @@ def example_setting(self, pre_setting): opts) self.aux_names.append(ns.modelList[0].name) ns.calculateSolution(my_so.name) - actual = tables.open_file( my_so.name + '.h5') + actual = h5py.File( my_so.name + '.h5') expected_path = 'comparison_files/' + 'comparison_' + self.compare_name + '_u_t2.csv' #write comparison file #np.array(actual.root.u_t2).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.u_t2).flatten(),decimal=10) + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['u_t2']).flatten(),decimal=10) actual.close() diff --git a/proteus/tests/cylinder2D/sbm_method/twp_navier_stokes_n.py b/test/cylinder2D/ibm_method/twp_navier_stokes_n.py similarity index 98% rename from proteus/tests/cylinder2D/sbm_method/twp_navier_stokes_n.py rename to test/cylinder2D/ibm_method/twp_navier_stokes_n.py index 2f2661ae5d..01bbcfc200 100644 --- a/proteus/tests/cylinder2D/sbm_method/twp_navier_stokes_n.py +++ b/test/cylinder2D/ibm_method/twp_navier_stokes_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * try: from .twp_navier_stokes_p import * diff --git a/proteus/tests/cylinder2D/ibm_method/twp_navier_stokes_p.py b/test/cylinder2D/ibm_method/twp_navier_stokes_p.py similarity index 98% rename from proteus/tests/cylinder2D/ibm_method/twp_navier_stokes_p.py rename to test/cylinder2D/ibm_method/twp_navier_stokes_p.py index d29fea544d..9f2a405ddf 100644 --- a/proteus/tests/cylinder2D/ibm_method/twp_navier_stokes_p.py +++ b/test/cylinder2D/ibm_method/twp_navier_stokes_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * try: diff --git a/proteus/tests/cylinder2D/ibm_rans2p/README.md b/test/cylinder2D/ibm_rans2p/README.md similarity index 100% rename from proteus/tests/cylinder2D/ibm_rans2p/README.md rename to test/cylinder2D/ibm_rans2p/README.md diff --git a/proteus/tests/cylinder2D/ibm_rans2p/comparison_files/comparison_T1_ibm_rans2p_u_t2.csv b/test/cylinder2D/ibm_rans2p/comparison_files/comparison_T1_ibm_rans2p_u_t2.csv similarity index 100% rename from proteus/tests/cylinder2D/ibm_rans2p/comparison_files/comparison_T1_ibm_rans2p_u_t2.csv rename to test/cylinder2D/ibm_rans2p/comparison_files/comparison_T1_ibm_rans2p_u_t2.csv diff --git a/proteus/tests/cylinder2D/ibm_rans2p/cylinder.py b/test/cylinder2D/ibm_rans2p/cylinder.py similarity index 99% rename from proteus/tests/cylinder2D/ibm_rans2p/cylinder.py rename to test/cylinder2D/ibm_rans2p/cylinder.py index 8c4488ab7d..6d23239bee 100644 --- a/proteus/tests/cylinder2D/ibm_rans2p/cylinder.py +++ b/test/cylinder2D/ibm_rans2p/cylinder.py @@ -223,7 +223,7 @@ regions = [[0.95*L[0], 0.2],[0.2-0.15,0.2],[0.2,0.2]] regionFlags = [1,2,3] - regionConstraints=[0.5*he**2,0.5*(old_div(he,2.0))**2,0.5*(old_div(he,6.0))**2] + regionConstraints=[0.5*he**2,0.5*(he/2.0)**2,0.5*(he/6.0)**2] # for gaugeName,gaugeCoordinates in pointGauges.locations.iteritems(): # vertices.append(gaugeCoordinates) # vertexFlags.append(pointGauges.flags[gaugeName]) diff --git a/proteus/tests/cylinder2D/ibm_rans2p/cylinder_so.py b/test/cylinder2D/ibm_rans2p/cylinder_so.py similarity index 96% rename from proteus/tests/cylinder2D/ibm_rans2p/cylinder_so.py rename to test/cylinder2D/ibm_rans2p/cylinder_so.py index 547d8d73cf..b03b6aaf03 100644 --- a/proteus/tests/cylinder2D/ibm_rans2p/cylinder_so.py +++ b/test/cylinder2D/ibm_rans2p/cylinder_so.py @@ -35,4 +35,4 @@ def __init__(self,modelList,system=defaultSystem,stepExact=True): tnList = cylinder.tnList info = open("TimeList.txt","w") -#archiveFlag = ArchiveFlags.EVERY_SEQUENCE_STEP +#archiveFlag = ArchiveFlags.EVERY_SEQUENCE_STEP \ No newline at end of file diff --git a/proteus/tests/cylinder2D/ibm_rans2p/test_cylinder2D_ibm_rans2p.py b/test/cylinder2D/ibm_rans2p/test_cylinder2D_ibm_rans2p.py similarity index 95% rename from proteus/tests/cylinder2D/ibm_rans2p/test_cylinder2D_ibm_rans2p.py rename to test/cylinder2D/ibm_rans2p/test_cylinder2D_ibm_rans2p.py index 0b6738d041..2cb6f76bc6 100644 --- a/proteus/tests/cylinder2D/ibm_rans2p/test_cylinder2D_ibm_rans2p.py +++ b/test/cylinder2D/ibm_rans2p/test_cylinder2D_ibm_rans2p.py @@ -2,7 +2,7 @@ from proteus.iproteus import * from proteus import Comm from proteus import Context -import tables +import h5py import importlib import pytest @@ -96,8 +96,8 @@ def example_setting(self, pre_setting): self.aux_names.append(ns.modelList[0].name) ns.calculateSolution(my_so.name) # COMPARE VS SAVED FILES # - actual = tables.open_file( my_so.name + '.h5') + actual = h5py.File( my_so.name + '.h5') expected_path = 'comparison_files/' + 'comparison_' + self.compare_name + '_u_t2.csv' #write comparison file #np.array(actual.root.u_t2).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.u_t2).flatten(),decimal=10) + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['u_t2']).flatten(),decimal=10) diff --git a/proteus/tests/cylinder2D/ibm_rans2p/twp_navier_stokes_n.py b/test/cylinder2D/ibm_rans2p/twp_navier_stokes_n.py similarity index 97% rename from proteus/tests/cylinder2D/ibm_rans2p/twp_navier_stokes_n.py rename to test/cylinder2D/ibm_rans2p/twp_navier_stokes_n.py index 27c76c96e7..0d4457697e 100644 --- a/proteus/tests/cylinder2D/ibm_rans2p/twp_navier_stokes_n.py +++ b/test/cylinder2D/ibm_rans2p/twp_navier_stokes_n.py @@ -66,4 +66,4 @@ maxNonlinearIts = 50 maxLineSearches = 0 #conservativeFlux = {0:'point-eval'} -#auxiliaryVariables=[pointGauges,lineGauges] +#auxiliaryVariables=[pointGauges,lineGauges] \ No newline at end of file diff --git a/proteus/tests/MeshAdaptPUMI/Sizefields/cylinder2D_ibm/twp_navier_stokes_p.py b/test/cylinder2D/ibm_rans2p/twp_navier_stokes_p.py similarity index 99% rename from proteus/tests/MeshAdaptPUMI/Sizefields/cylinder2D_ibm/twp_navier_stokes_p.py rename to test/cylinder2D/ibm_rans2p/twp_navier_stokes_p.py index 26e5b53950..af0cc66550 100644 --- a/proteus/tests/MeshAdaptPUMI/Sizefields/cylinder2D_ibm/twp_navier_stokes_p.py +++ b/test/cylinder2D/ibm_rans2p/twp_navier_stokes_p.py @@ -136,4 +136,4 @@ def uOfXT(self,x,t): initialConditions = {0:init_p(), 1:init_u(), - 2:init_v()} + 2:init_v()} \ No newline at end of file diff --git a/proteus/tests/cylinder2D/ibm_rans2p_3D/comparison_files/comparison_u_t2.csv b/test/cylinder2D/ibm_rans2p_3D/comparison_files/comparison_u_t2.csv similarity index 100% rename from proteus/tests/cylinder2D/ibm_rans2p_3D/comparison_files/comparison_u_t2.csv rename to test/cylinder2D/ibm_rans2p_3D/comparison_files/comparison_u_t2.csv diff --git a/proteus/tests/cylinder2D/ibm_rans2p_3D/cylinder.py b/test/cylinder2D/ibm_rans2p_3D/cylinder.py similarity index 99% rename from proteus/tests/cylinder2D/ibm_rans2p_3D/cylinder.py rename to test/cylinder2D/ibm_rans2p_3D/cylinder.py index 8b2e9374df..38f38d60ae 100644 --- a/proteus/tests/cylinder2D/ibm_rans2p_3D/cylinder.py +++ b/test/cylinder2D/ibm_rans2p_3D/cylinder.py @@ -342,4 +342,4 @@ def particle_vel(t, x): ball_center = np.array([[0.2,0.2,0.0],]) ball_radius = np.array([0.05,]) ball_velocity = np.array([[0.0,0.0,0.0],]) -ball_angular_velocity = np.array([[0.0,0.0,0.0],]) +ball_angular_velocity = np.array([[0.0,0.0,0.0],]) \ No newline at end of file diff --git a/proteus/tests/cylinder2D/ibm_rans2p_3D/cylinder_so.py b/test/cylinder2D/ibm_rans2p_3D/cylinder_so.py similarity index 96% rename from proteus/tests/cylinder2D/ibm_rans2p_3D/cylinder_so.py rename to test/cylinder2D/ibm_rans2p_3D/cylinder_so.py index 1463fcbc58..9011217b96 100644 --- a/proteus/tests/cylinder2D/ibm_rans2p_3D/cylinder_so.py +++ b/test/cylinder2D/ibm_rans2p_3D/cylinder_so.py @@ -40,4 +40,4 @@ def __init__(self,modelList,system=defaultSystem,stepExact=True): tnList = cylinder.tnList info = open("TimeList.txt","w") -#archiveFlag = ArchiveFlags.EVERY_SEQUENCE_STEP +#archiveFlag = ArchiveFlags.EVERY_SEQUENCE_STEP \ No newline at end of file diff --git a/proteus/tests/cylinder2D/ibm_rans2p_3D/meshCylinder.edge b/test/cylinder2D/ibm_rans2p_3D/meshCylinder.edge similarity index 100% rename from proteus/tests/cylinder2D/ibm_rans2p_3D/meshCylinder.edge rename to test/cylinder2D/ibm_rans2p_3D/meshCylinder.edge diff --git a/proteus/tests/cylinder2D/ibm_rans2p_3D/meshCylinder.ele b/test/cylinder2D/ibm_rans2p_3D/meshCylinder.ele similarity index 100% rename from proteus/tests/cylinder2D/ibm_rans2p_3D/meshCylinder.ele rename to test/cylinder2D/ibm_rans2p_3D/meshCylinder.ele diff --git a/proteus/tests/cylinder2D/ibm_rans2p_3D/meshCylinder.face b/test/cylinder2D/ibm_rans2p_3D/meshCylinder.face similarity index 100% rename from proteus/tests/cylinder2D/ibm_rans2p_3D/meshCylinder.face rename to test/cylinder2D/ibm_rans2p_3D/meshCylinder.face diff --git a/proteus/tests/cylinder2D/ibm_rans2p_3D/meshCylinder.neigh b/test/cylinder2D/ibm_rans2p_3D/meshCylinder.neigh similarity index 100% rename from proteus/tests/cylinder2D/ibm_rans2p_3D/meshCylinder.neigh rename to test/cylinder2D/ibm_rans2p_3D/meshCylinder.neigh diff --git a/proteus/tests/cylinder2D/ibm_rans2p_3D/meshCylinder.node b/test/cylinder2D/ibm_rans2p_3D/meshCylinder.node similarity index 100% rename from proteus/tests/cylinder2D/ibm_rans2p_3D/meshCylinder.node rename to test/cylinder2D/ibm_rans2p_3D/meshCylinder.node diff --git a/proteus/tests/cylinder2D/ibm_rans2p_3D/meshCylinder.poly b/test/cylinder2D/ibm_rans2p_3D/meshCylinder.poly similarity index 100% rename from proteus/tests/cylinder2D/ibm_rans2p_3D/meshCylinder.poly rename to test/cylinder2D/ibm_rans2p_3D/meshCylinder.poly diff --git a/proteus/tests/cylinder2D/ibm_rans2p_3D/my_domain.py b/test/cylinder2D/ibm_rans2p_3D/my_domain.py similarity index 99% rename from proteus/tests/cylinder2D/ibm_rans2p_3D/my_domain.py rename to test/cylinder2D/ibm_rans2p_3D/my_domain.py index b80b3ce7e4..eaa6a9aa66 100644 --- a/proteus/tests/cylinder2D/ibm_rans2p_3D/my_domain.py +++ b/test/cylinder2D/ibm_rans2p_3D/my_domain.py @@ -544,4 +544,4 @@ def get_pseudo_3D_cylinder_box_domain( facetHoles=facetHoles3d, regions=regions,regionFlags=regionFlags,regionConstraints=regionConstraints) domain.boundaryTags = boundaryTags - return domain,boundaryTags + return domain,boundaryTags \ No newline at end of file diff --git a/proteus/tests/cylinder2D/ibm_rans2p_3D/test_cylinder3D_ibm_rans2p.py b/test/cylinder2D/ibm_rans2p_3D/test_cylinder3D_ibm_rans2p.py similarity index 94% rename from proteus/tests/cylinder2D/ibm_rans2p_3D/test_cylinder3D_ibm_rans2p.py rename to test/cylinder2D/ibm_rans2p_3D/test_cylinder3D_ibm_rans2p.py index d3f044796a..3260a232a8 100644 --- a/proteus/tests/cylinder2D/ibm_rans2p_3D/test_cylinder3D_ibm_rans2p.py +++ b/test/cylinder2D/ibm_rans2p_3D/test_cylinder3D_ibm_rans2p.py @@ -2,7 +2,7 @@ from proteus.iproteus import * from proteus import Comm from proteus import Context -import tables +import h5py import importlib import pytest @@ -90,8 +90,7 @@ def example_setting(self, pre_setting): self.aux_names.append(ns.modelList[0].name) ns.calculateSolution(my_so.name) - actual = tables.open_file('cylinder_ibm_T1_ibm_3D_rans2p'+'.h5','r') + actual = h5py.File('cylinder_ibm_T1_ibm_3D_rans2p'+'.h5','r') expected_path = 'comparison_files/' + 'comparison_u_t2.csv' - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.u_t2),decimal=10) + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['u_t2']),decimal=10) actual.close() - diff --git a/proteus/tests/cylinder2D/ibm_rans2p_3D/twp_navier_stokes_n.py b/test/cylinder2D/ibm_rans2p_3D/twp_navier_stokes_n.py similarity index 97% rename from proteus/tests/cylinder2D/ibm_rans2p_3D/twp_navier_stokes_n.py rename to test/cylinder2D/ibm_rans2p_3D/twp_navier_stokes_n.py index 2f16db8f5c..bd232be1c9 100644 --- a/proteus/tests/cylinder2D/ibm_rans2p_3D/twp_navier_stokes_n.py +++ b/test/cylinder2D/ibm_rans2p_3D/twp_navier_stokes_n.py @@ -61,4 +61,4 @@ maxNonlinearIts = 10 maxLineSearches = 0 #conservativeFlux = {0:'point-eval'} -#auxiliaryVariables=[pointGauges,lineGauges] +#auxiliaryVariables=[pointGauges,lineGauges] \ No newline at end of file diff --git a/proteus/tests/cylinder2D/ibm_rans2p_3D/twp_navier_stokes_p.py b/test/cylinder2D/ibm_rans2p_3D/twp_navier_stokes_p.py similarity index 99% rename from proteus/tests/cylinder2D/ibm_rans2p_3D/twp_navier_stokes_p.py rename to test/cylinder2D/ibm_rans2p_3D/twp_navier_stokes_p.py index 752e8613fa..9af9e8a4b6 100644 --- a/proteus/tests/cylinder2D/ibm_rans2p_3D/twp_navier_stokes_p.py +++ b/test/cylinder2D/ibm_rans2p_3D/twp_navier_stokes_p.py @@ -146,4 +146,4 @@ def uOfXT(self,x,t): initialConditions = {0:AtRest(), 1:AtRest(), 2:AtRest(), - 3:AtRest()} + 3:AtRest()} \ No newline at end of file diff --git a/proteus/tests/cylinder2D/sbm_3Dmesh/comparison_files/comparison_u_t2.csv b/test/cylinder2D/sbm_3Dmesh/comparison_files/comparison_u_t2.csv similarity index 100% rename from proteus/tests/cylinder2D/sbm_3Dmesh/comparison_files/comparison_u_t2.csv rename to test/cylinder2D/sbm_3Dmesh/comparison_files/comparison_u_t2.csv diff --git a/proteus/tests/cylinder2D/sbm_3Dmesh/cylinder.py b/test/cylinder2D/sbm_3Dmesh/cylinder.py similarity index 97% rename from proteus/tests/cylinder2D/sbm_3Dmesh/cylinder.py rename to test/cylinder2D/sbm_3Dmesh/cylinder.py index 522f3af0ea..703fc586f5 100644 --- a/proteus/tests/cylinder2D/sbm_3Dmesh/cylinder.py +++ b/test/cylinder2D/sbm_3Dmesh/cylinder.py @@ -1,7 +1,3 @@ -from __future__ import print_function -from __future__ import division -from builtins import range -from past.utils import old_div from math import * import proteus.MeshTools from proteus import Domain @@ -140,7 +136,7 @@ # Domain and mesh #=============================================================================== L = [1.5, 0.41, 0.01] -he = old_div(L[0],(2**Refinement)) +he = L[0]/(2**Refinement) he*=0.5 he*=0.5 @@ -179,7 +175,7 @@ runCFL=0.33 nDTout = ct.nDTout # nDTout = int(T/dt_fixed) -dt_output = old_div(T,nDTout) +dt_output = T/nDTout tnList = [0.0,dt_init]+[i*dt_output for i in range(1,nDTout+1)] if ct.onlySaveFinalSolution == True: @@ -316,7 +312,7 @@ def particle_sdf(t, x): cx = 0.2 cy = 0.2 r = math.sqrt( (x[0]-cx)**2 + (x[1]-cy)**2) - n = (old_div((x[0]-cx),(r+1e-10)),old_div((x[1]-cy),(r+1e-10)), 0.0) + n = ((x[0]-cx)/(r+1e-10),(x[1]-cy)/(r+1e-10), 0.0) return r - 0.05,n def particle_vel(t, x): diff --git a/proteus/tests/cylinder2D/sbm_3Dmesh/cylinder_so.py b/test/cylinder2D/sbm_3Dmesh/cylinder_so.py similarity index 97% rename from proteus/tests/cylinder2D/sbm_3Dmesh/cylinder_so.py rename to test/cylinder2D/sbm_3Dmesh/cylinder_so.py index be19cebf89..1a3361e0ea 100644 --- a/proteus/tests/cylinder2D/sbm_3Dmesh/cylinder_so.py +++ b/test/cylinder2D/sbm_3Dmesh/cylinder_so.py @@ -51,4 +51,4 @@ def __init__(self,modelList,system=defaultSystem,stepExact=True): tnList = cylinder.tnList info = open("TimeList.txt","w") -#archiveFlag = ArchiveFlags.EVERY_SEQUENCE_STEP +#archiveFlag = ArchiveFlags.EVERY_SEQUENCE_STEP \ No newline at end of file diff --git a/proteus/tests/cylinder2D/sbm_3Dmesh/my_domain.py b/test/cylinder2D/sbm_3Dmesh/my_domain.py similarity index 99% rename from proteus/tests/cylinder2D/sbm_3Dmesh/my_domain.py rename to test/cylinder2D/sbm_3Dmesh/my_domain.py index f072ed3587..f8b3438e6d 100644 --- a/proteus/tests/cylinder2D/sbm_3Dmesh/my_domain.py +++ b/test/cylinder2D/sbm_3Dmesh/my_domain.py @@ -1,4 +1,3 @@ -from builtins import range from proteus import Domain # |y # | @@ -545,4 +544,4 @@ def get_pseudo_3D_cylinder_box_domain( facetHoles=facetHoles3d, regions=regions,regionFlags=regionFlags,regionConstraints=regionConstraints) domain.boundaryTags = boundaryTags - return domain,boundaryTags \ No newline at end of file + return domain,boundaryTags diff --git a/proteus/tests/cylinder2D/sbm_3Dmesh/pressureInitial_n.py b/test/cylinder2D/sbm_3Dmesh/pressureInitial_n.py similarity index 98% rename from proteus/tests/cylinder2D/sbm_3Dmesh/pressureInitial_n.py rename to test/cylinder2D/sbm_3Dmesh/pressureInitial_n.py index 3c628f26e7..6f2ab8e421 100644 --- a/proteus/tests/cylinder2D/sbm_3Dmesh/pressureInitial_n.py +++ b/test/cylinder2D/sbm_3Dmesh/pressureInitial_n.py @@ -42,4 +42,4 @@ maxLineSearches=0 periodicDirichletConditions=None -conservativeFlux=None +conservativeFlux=None \ No newline at end of file diff --git a/proteus/tests/cylinder2D/sbm_3Dmesh/pressureInitial_p.py b/test/cylinder2D/sbm_3Dmesh/pressureInitial_p.py similarity index 98% rename from proteus/tests/cylinder2D/sbm_3Dmesh/pressureInitial_p.py rename to test/cylinder2D/sbm_3Dmesh/pressureInitial_p.py index f397b08f08..5bf059823a 100644 --- a/proteus/tests/cylinder2D/sbm_3Dmesh/pressureInitial_p.py +++ b/test/cylinder2D/sbm_3Dmesh/pressureInitial_p.py @@ -1,4 +1,3 @@ -from builtins import object from math import * from proteus import * from proteus.default_p import * diff --git a/proteus/tests/cylinder2D/sbm_3Dmesh/pressure_n.py b/test/cylinder2D/sbm_3Dmesh/pressure_n.py similarity index 98% rename from proteus/tests/cylinder2D/sbm_3Dmesh/pressure_n.py rename to test/cylinder2D/sbm_3Dmesh/pressure_n.py index 7f5418761e..b7c3d45dcd 100644 --- a/proteus/tests/cylinder2D/sbm_3Dmesh/pressure_n.py +++ b/test/cylinder2D/sbm_3Dmesh/pressure_n.py @@ -48,4 +48,4 @@ periodicDirichletConditions=None -conservativeFlux=None +conservativeFlux=None \ No newline at end of file diff --git a/proteus/tests/cylinder2D/sbm_3Dmesh/pressure_p.py b/test/cylinder2D/sbm_3Dmesh/pressure_p.py similarity index 96% rename from proteus/tests/cylinder2D/sbm_3Dmesh/pressure_p.py rename to test/cylinder2D/sbm_3Dmesh/pressure_p.py index abe23b9275..93d090b050 100644 --- a/proteus/tests/cylinder2D/sbm_3Dmesh/pressure_p.py +++ b/test/cylinder2D/sbm_3Dmesh/pressure_p.py @@ -1,4 +1,3 @@ -from builtins import object from math import * from proteus import * from proteus.default_p import * diff --git a/proteus/tests/cylinder2D/sbm_3Dmesh/pressureincrement_n.py b/test/cylinder2D/sbm_3Dmesh/pressureincrement_n.py similarity index 98% rename from proteus/tests/cylinder2D/sbm_3Dmesh/pressureincrement_n.py rename to test/cylinder2D/sbm_3Dmesh/pressureincrement_n.py index 1e482b17a2..00c0e53d45 100644 --- a/proteus/tests/cylinder2D/sbm_3Dmesh/pressureincrement_n.py +++ b/test/cylinder2D/sbm_3Dmesh/pressureincrement_n.py @@ -46,4 +46,4 @@ periodicDirichletConditions=None #conservativeFlux = {0:'point-eval'} #'point-eval','pwl-bdm-opt' -conservativeFlux=None +conservativeFlux=None \ No newline at end of file diff --git a/proteus/tests/cylinder2D/sbm_3Dmesh/pressureincrement_p.py b/test/cylinder2D/sbm_3Dmesh/pressureincrement_p.py similarity index 96% rename from proteus/tests/cylinder2D/sbm_3Dmesh/pressureincrement_p.py rename to test/cylinder2D/sbm_3Dmesh/pressureincrement_p.py index b43597dd13..92e3d30153 100644 --- a/proteus/tests/cylinder2D/sbm_3Dmesh/pressureincrement_p.py +++ b/test/cylinder2D/sbm_3Dmesh/pressureincrement_p.py @@ -1,4 +1,3 @@ -from builtins import object from math import * from proteus import * from proteus.default_p import * @@ -51,4 +50,4 @@ def uOfXT(self,x,t): dirichletConditions = {0:getDBC_phi } advectiveFluxBoundaryConditions = {0:getAdvectiveFlux_qt} diffusiveFluxBoundaryConditions = {0:{0:getDiffusiveFlux_phi}} -initialConditions = {0:getIBC_phi()} \ No newline at end of file +initialConditions = {0:getIBC_phi()} diff --git a/proteus/tests/cylinder2D/sbm_3Dmesh/test_cylinder2D_on_3D_mesh_sbm.py b/test/cylinder2D/sbm_3Dmesh/test_cylinder2D_on_3D_mesh_sbm.py similarity index 88% rename from proteus/tests/cylinder2D/sbm_3Dmesh/test_cylinder2D_on_3D_mesh_sbm.py rename to test/cylinder2D/sbm_3Dmesh/test_cylinder2D_on_3D_mesh_sbm.py index 0ca41ac6b8..eb48e59e64 100644 --- a/proteus/tests/cylinder2D/sbm_3Dmesh/test_cylinder2D_on_3D_mesh_sbm.py +++ b/test/cylinder2D/sbm_3Dmesh/test_cylinder2D_on_3D_mesh_sbm.py @@ -1,17 +1,15 @@ """Tests for 2d flow around a cylinder with shifted boundary method on a 3D mesh""" -from builtins import range -from builtins import object from proteus.iproteus import * from proteus import Comm, defaults from proteus import Context -import tables +import h5py import importlib - +import os +import numpy as np comm = Comm.get() Profiling.logLevel = 7 Profiling.verbose = False -import numpy as np modulepath = os.path.dirname(os.path.abspath(__file__)) @@ -51,6 +49,11 @@ def test_ex1(self): def example_setting(self, pre_setting): + from petsc4py import PETSc + import sys + OptDB = PETSc.Options() + OptDB.clear() + Context.contextOptionsString = pre_setting my_so = defaults.load_system("cylinder_so",modulepath) @@ -63,7 +66,9 @@ def example_setting(self, pre_setting): sList=[] for (pModule,nModule) in my_so.pnList: pList.append(defaults.load_physics(pModule,modulepath)) + sys.modules[pModule]=pList[-1] nList.append(defaults.load_numerics(nModule,modulepath)) + sys.modules[nModule]=nList[-1] if pList[-1].name == None: pList[-1].name = pModule @@ -88,10 +93,10 @@ def example_setting(self, pre_setting): except: assert 0, "NS calculation failed" - actual = tables.open_file('cylinder_sbm_mesh3D_T001_P1_sbm_3Dmesh'+'.h5','r') + actual = h5py.File('cylinder_sbm_mesh3D_T001_P1_sbm_3Dmesh'+'.h5','r') expected_path = 'comparison_files/' + 'comparison_u_t2.csv' #write comparison file #np.array(actual.root.u_t2).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.u_t2),decimal=10) + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['u_t2']),decimal=10) actual.close() diff --git a/proteus/tests/cylinder2D/sbm_3Dmesh/twp_navier_stokes_n.py b/test/cylinder2D/sbm_3Dmesh/twp_navier_stokes_n.py similarity index 97% rename from proteus/tests/cylinder2D/sbm_3Dmesh/twp_navier_stokes_n.py rename to test/cylinder2D/sbm_3Dmesh/twp_navier_stokes_n.py index 21347bbf21..4f9e021305 100644 --- a/proteus/tests/cylinder2D/sbm_3Dmesh/twp_navier_stokes_n.py +++ b/test/cylinder2D/sbm_3Dmesh/twp_navier_stokes_n.py @@ -63,4 +63,4 @@ maxNonlinearIts = 50 maxLineSearches = 0 #conservativeFlux = {0:'point-eval'} -#auxiliaryVariables=[pointGauges,lineGauges] +#auxiliaryVariables=[pointGauges,lineGauges] \ No newline at end of file diff --git a/proteus/tests/cylinder2D/sbm_3Dmesh/twp_navier_stokes_p.py b/test/cylinder2D/sbm_3Dmesh/twp_navier_stokes_p.py similarity index 99% rename from proteus/tests/cylinder2D/sbm_3Dmesh/twp_navier_stokes_p.py rename to test/cylinder2D/sbm_3Dmesh/twp_navier_stokes_p.py index 926dffff31..60fb887feb 100644 --- a/proteus/tests/cylinder2D/sbm_3Dmesh/twp_navier_stokes_p.py +++ b/test/cylinder2D/sbm_3Dmesh/twp_navier_stokes_p.py @@ -1,4 +1,3 @@ -from builtins import object from proteus import * from proteus.default_p import * from cylinder import * diff --git a/proteus/tests/cylinder2D/sbm_method/README.md b/test/cylinder2D/sbm_method/README.md similarity index 100% rename from proteus/tests/cylinder2D/sbm_method/README.md rename to test/cylinder2D/sbm_method/README.md diff --git a/proteus/tests/SWFlow/__init__.py b/test/cylinder2D/sbm_method/__init__.py similarity index 100% rename from proteus/tests/SWFlow/__init__.py rename to test/cylinder2D/sbm_method/__init__.py diff --git a/proteus/tests/cylinder2D/sbm_method/comparison_files/comparison_T1_sbm_rans3p_u_t2.csv b/test/cylinder2D/sbm_method/comparison_files/comparison_T1_sbm_rans3p_u_t2.csv similarity index 100% rename from proteus/tests/cylinder2D/sbm_method/comparison_files/comparison_T1_sbm_rans3p_u_t2.csv rename to test/cylinder2D/sbm_method/comparison_files/comparison_T1_sbm_rans3p_u_t2.csv diff --git a/proteus/tests/cylinder2D/sbm_method/cylinder.py b/test/cylinder2D/sbm_method/cylinder.py similarity index 87% rename from proteus/tests/cylinder2D/sbm_method/cylinder.py rename to test/cylinder2D/sbm_method/cylinder.py index 8d8f7f5e74..63a71112ff 100644 --- a/proteus/tests/cylinder2D/sbm_method/cylinder.py +++ b/test/cylinder2D/sbm_method/cylinder.py @@ -1,7 +1,3 @@ -from __future__ import print_function -from __future__ import division -from builtins import range -from past.utils import old_div from math import * import proteus.MeshTools from proteus import Domain @@ -183,7 +179,7 @@ regions = [[0.95*L[0], 0.2],[0.2-0.15,0.2],[0.2,0.2]] regionFlags = [1,2,3] - regionConstraints=[0.5*he**2,0.5*(old_div(he,2.0))**2,0.5*(old_div(he,6.0))**2] + regionConstraints=[0.5*he**2,0.5*(he/2.0)**2,0.5*(he/6.0)**2] # for gaugeName,gaugeCoordinates in pointGauges.locations.iteritems(): # vertices.append(gaugeCoordinates) # vertexFlags.append(pointGauges.flags[gaugeName]) @@ -250,7 +246,7 @@ dt_fixed = 0.005#0.03 dt_init = 0.005#min(0.1*dt_fixed,0.001) runCFL=0.33 -nDTout = int(round(old_div(T,dt_fixed))) +nDTout = int(round(T/dt_fixed)) tnList = [0.0,dt_init]+[i*dt_fixed for i in range(1,nDTout+1)] if ct.onlySaveFinalSolution == True: @@ -375,15 +371,68 @@ def velRamp(t): def signedDistance(x): - return x[1]-old_div(L[1],2) + return x[1]-L[1]/2 def particle_sdf(t, x): cx = 0.2 cy = 0.2 r = math.sqrt( (x[0]-cx)**2 + (x[1]-cy)**2) - n = (old_div((x[0]-cx),r),old_div((x[1]-cy),r)) + n = ((x[0]-cx)/r,(x[1]-cy)/r) return r - 0.05,n def particle_vel(t, x): return (0.0,0.0) +if sedimentDynamics: + pnList = [("vos_p", "vos_n"),#0 + ("vof_p", "vof_n"),#1 + ("ls_p", "ls_n"),#2 + ("redist_p", "redist_n"),#3 + ("ls_consrv_p", "ls_consrv_n"),#4 + ("threep_navier_stokes_sed_p", "threep_navier_stokes_sed_n"),#5 + ("twp_navier_stokes_p", "twp_navier_stokes_n"),#6 + ("pressureincrement_p", "pressureincrement_n"),#7 + ("pressure_p", "pressure_n"),#8 + ("pressureInitial_p", "pressureInitial_n")]#9 + VOS_model=0 + VOF_model=1 + LS_model=2 + RD_model=3 + MCORR_model=4 + SED_model=5 + V_model=6 + PINC_model=7 + PRESSURE_model=8 + PINIT_model=9 +else: +# pnList = [("vof_p", "vof_n"),#0 +# ("ls_p", "ls_n"),#1 +# ("redist_p", "redist_n"),#2 +# ("ls_consrv_p", "ls_consrv_n"),#3 +# ("twp_navier_stokes_p", "twp_navier_stokes_n"),#4 +# ("pressureincrement_p", "pressureincrement_n"),#5 +# ("pressure_p", "pressure_n"),#6 +# ("pressureInitial_p", "pressureInitial_n")]#7 +# VOS_model=None +# SED_model=None +# VOF_model=0 +# LS_model=1 +# RD_model=2 +# MCORR_model=3 +# V_model=4 +# PINC_model=5 +# PRESSURE_model=6 +# PINIT_model=7 + + pnList = [("twp_navier_stokes_p", "twp_navier_stokes_n"),#0 + ("pressureincrement_p", "pressureincrement_n"),#1 + ("pressure_p", "pressure_n"),#2 + ("pressureInitial_p", "pressureInitial_n")]#3 + + VOF_model=None + VOS_model=None + SED_model=None + V_model=0 + PINC_model=1 + PRESSURE_model=2 + PINIT_model=3 diff --git a/test/cylinder2D/sbm_method/cylinder_so.py b/test/cylinder2D/sbm_method/cylinder_so.py new file mode 100644 index 0000000000..0178d6cb40 --- /dev/null +++ b/test/cylinder2D/sbm_method/cylinder_so.py @@ -0,0 +1,50 @@ +import proteus.default_so +from importlib import reload +reload(proteus.default_so) +from proteus.default_so import * +try: + from . import cylinder +except: + import cylinder +reload(cylinder) + +from proteus.SplitOperator import Sequential_FixedStep_Simple, defaultSystem + +pnList = cylinder.pnList + +if cylinder.useRANS > 0: + pnList.append(("kappa_p", + "kappa_n")) + pnList.append(("dissipation_p", + "dissipation_n")) +name = "cylinder" +soname=name +#modelSpinUpList = [cylinder.VOF_model, cylinder.LS_model, cylinder.V_model, cylinder.PINIT_model] +modelSpinUpList = [cylinder.PINIT_model] + +# class Sequential_MinAdaptiveModelStepPS(Sequential_MinAdaptiveModelStep): +# def __init__(self,modelList,system=defaultSystem,stepExact=True): +# Sequential_MinAdaptiveModelStep.__init__(self,modelList,system,stepExact) +# self.modelList = modelList[:len(pnList)-1] + + +class Sequential_MinAdaptiveModelStepPS(Sequential_FixedStep): + def __init__(self,modelList,system=defaultSystem,stepExact=True): + Sequential_FixedStep.__init__(self,modelList,system,stepExact) + self.modelList = modelList[:len(pnList)-1] + +dt_system_fixed = cylinder.dt_fixed +systemStepControllerType = Sequential_MinAdaptiveModelStepPS + +# systemStepControllerType = Sequential_FixedStep #Sequential_FixedStep_Simple # uses time steps in so.tnList +# dt_system_fixed = 0.01; +systemStepExact=False + + +needEBQ_GLOBAL = False +needEBQ = False + +# tnList = [0.0,cylinder.dt_init]+[i*cylinder.dt_fixed for i in range(1,cylinder.nDTout+1)] +tnList = cylinder.tnList +info = open("TimeList.txt","w") +#archiveFlag = ArchiveFlags.EVERY_SEQUENCE_STEP diff --git a/proteus/tests/cylinder2D/sbm_method/pressureInitial_n.py b/test/cylinder2D/sbm_method/pressureInitial_n.py similarity index 97% rename from proteus/tests/cylinder2D/sbm_method/pressureInitial_n.py rename to test/cylinder2D/sbm_method/pressureInitial_n.py index 1c36574304..0a6c03148e 100644 --- a/proteus/tests/cylinder2D/sbm_method/pressureInitial_n.py +++ b/test/cylinder2D/sbm_method/pressureInitial_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/cylinder2D/ibm_method/pressureInitial_p.py b/test/cylinder2D/sbm_method/pressureInitial_p.py similarity index 95% rename from proteus/tests/cylinder2D/ibm_method/pressureInitial_p.py rename to test/cylinder2D/sbm_method/pressureInitial_p.py index e285e017bb..afd55201ab 100644 --- a/proteus/tests/cylinder2D/ibm_method/pressureInitial_p.py +++ b/test/cylinder2D/sbm_method/pressureInitial_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from math import * from proteus import * from proteus.default_p import * diff --git a/proteus/tests/cylinder2D/ibm_method/pressure_n.py b/test/cylinder2D/sbm_method/pressure_n.py similarity index 97% rename from proteus/tests/cylinder2D/ibm_method/pressure_n.py rename to test/cylinder2D/sbm_method/pressure_n.py index fb98276020..568b0a9665 100644 --- a/proteus/tests/cylinder2D/ibm_method/pressure_n.py +++ b/test/cylinder2D/sbm_method/pressure_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/cylinder2D/sbm_method/pressure_p.py b/test/cylinder2D/sbm_method/pressure_p.py similarity index 93% rename from proteus/tests/cylinder2D/sbm_method/pressure_p.py rename to test/cylinder2D/sbm_method/pressure_p.py index 12229ae19c..aa0c963794 100644 --- a/proteus/tests/cylinder2D/sbm_method/pressure_p.py +++ b/test/cylinder2D/sbm_method/pressure_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from math import * from proteus import * from proteus.default_p import * diff --git a/proteus/tests/cylinder2D/sbm_method/pressureincrement_n.py b/test/cylinder2D/sbm_method/pressureincrement_n.py similarity index 97% rename from proteus/tests/cylinder2D/sbm_method/pressureincrement_n.py rename to test/cylinder2D/sbm_method/pressureincrement_n.py index 692e61e472..953d530667 100644 --- a/proteus/tests/cylinder2D/sbm_method/pressureincrement_n.py +++ b/test/cylinder2D/sbm_method/pressureincrement_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/cylinder2D/ibm_method/pressureincrement_p.py b/test/cylinder2D/sbm_method/pressureincrement_p.py similarity index 96% rename from proteus/tests/cylinder2D/ibm_method/pressureincrement_p.py rename to test/cylinder2D/sbm_method/pressureincrement_p.py index 3a6209fd8d..cb4fb12025 100644 --- a/proteus/tests/cylinder2D/ibm_method/pressureincrement_p.py +++ b/test/cylinder2D/sbm_method/pressureincrement_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from math import * from proteus import * from proteus.default_p import * diff --git a/proteus/tests/cylinder2D/sbm_method/test_cylinder2D_sbm_rans3p.py b/test/cylinder2D/sbm_method/test_cylinder2D_sbm_rans3p.py similarity index 80% rename from proteus/tests/cylinder2D/sbm_method/test_cylinder2D_sbm_rans3p.py rename to test/cylinder2D/sbm_method/test_cylinder2D_sbm_rans3p.py index fdec83c665..0bb979f6bb 100644 --- a/proteus/tests/cylinder2D/sbm_method/test_cylinder2D_sbm_rans3p.py +++ b/test/cylinder2D/sbm_method/test_cylinder2D_sbm_rans3p.py @@ -1,10 +1,9 @@ """Tests for 2d flow around a cylinder with shifted boundary method""" -from builtins import range -from builtins import object from proteus.iproteus import * from proteus import Comm from proteus import Context -import tables +import h5py + import importlib @@ -54,9 +53,7 @@ def test_ex2(self): def example_setting(self, pre_setting): Context.contextOptionsString = pre_setting - #from . import cylinder_so as my_so - my_so = importlib.import_module(".cylinder_so", - "proteus.tests.cylinder2D.sbm_method") + from . import cylinder_so as my_so reload(my_so) # defined in iproteus opts.profile = False @@ -67,11 +64,9 @@ def example_setting(self, pre_setting): sList=[] for (pModule,nModule) in my_so.pnList: pList.append( - importlib.import_module("."+pModule, - "proteus.tests.cylinder2D.sbm_method")) + importlib.import_module(pModule)) nList.append( - importlib.import_module("."+nModule, - "proteus.tests.cylinder2D.sbm_method")) + importlib.import_module(nModule)) if pList[-1].name == None: pList[-1].name = pModule reload(pList[-1]) # Serious error @@ -94,8 +89,8 @@ def example_setting(self, pre_setting): ns.calculateSolution(my_so.name) # COMPARE VS SAVED FILES # - actual = tables.open_file( my_so.name + '.h5') + actual = h5py.File( my_so.name + '.h5') expected_path = 'comparison_files/' + 'comparison_' + self.compare_name + '_u_t2.csv' #write comparison file #np.array(actual.root.u_t2).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.u_t2).flatten(),decimal=10) + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['u_t2']).flatten(),decimal=10) diff --git a/proteus/tests/cylinder2D/ibm_method/twp_navier_stokes_n.py b/test/cylinder2D/sbm_method/twp_navier_stokes_n.py similarity index 98% rename from proteus/tests/cylinder2D/ibm_method/twp_navier_stokes_n.py rename to test/cylinder2D/sbm_method/twp_navier_stokes_n.py index 2f2661ae5d..01bbcfc200 100644 --- a/proteus/tests/cylinder2D/ibm_method/twp_navier_stokes_n.py +++ b/test/cylinder2D/sbm_method/twp_navier_stokes_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * try: from .twp_navier_stokes_p import * diff --git a/proteus/tests/cylinder2D/sbm_method/twp_navier_stokes_p.py b/test/cylinder2D/sbm_method/twp_navier_stokes_p.py similarity index 98% rename from proteus/tests/cylinder2D/sbm_method/twp_navier_stokes_p.py rename to test/cylinder2D/sbm_method/twp_navier_stokes_p.py index ba06bff737..d133365145 100644 --- a/proteus/tests/cylinder2D/sbm_method/twp_navier_stokes_p.py +++ b/test/cylinder2D/sbm_method/twp_navier_stokes_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * try: diff --git a/proteus/tests/dg/la_gauss_2d_dgp0_n.py b/test/dg/la_gauss_2d_dgp0_n.py similarity index 95% rename from proteus/tests/dg/la_gauss_2d_dgp0_n.py rename to test/dg/la_gauss_2d_dgp0_n.py index 6c431a2c8a..352fa4c48a 100644 --- a/proteus/tests/dg/la_gauss_2d_dgp0_n.py +++ b/test/dg/la_gauss_2d_dgp0_n.py @@ -56,4 +56,4 @@ checkMass = True -archiveFlag = ArchiveFlags.EVERY_USER_STEP +archiveFlag = ArchiveFlags.EVERY_USER_STEP \ No newline at end of file diff --git a/proteus/tests/dg/la_gauss_2d_dgp1_n.py b/test/dg/la_gauss_2d_dgp1_n.py similarity index 97% rename from proteus/tests/dg/la_gauss_2d_dgp1_n.py rename to test/dg/la_gauss_2d_dgp1_n.py index d91b46c313..8a44936298 100644 --- a/proteus/tests/dg/la_gauss_2d_dgp1_n.py +++ b/test/dg/la_gauss_2d_dgp1_n.py @@ -72,4 +72,4 @@ checkMass = True -archiveFlag = ArchiveFlags.EVERY_USER_STEP +archiveFlag = ArchiveFlags.EVERY_USER_STEP \ No newline at end of file diff --git a/proteus/tests/dg/la_gauss_2d_dgp2_n.py b/test/dg/la_gauss_2d_dgp2_n.py similarity index 97% rename from proteus/tests/dg/la_gauss_2d_dgp2_n.py rename to test/dg/la_gauss_2d_dgp2_n.py index f603565283..9deb090b2a 100644 --- a/proteus/tests/dg/la_gauss_2d_dgp2_n.py +++ b/test/dg/la_gauss_2d_dgp2_n.py @@ -73,4 +73,4 @@ checkMass = True -archiveFlag = ArchiveFlags.EVERY_USER_STEP +archiveFlag = ArchiveFlags.EVERY_USER_STEP \ No newline at end of file diff --git a/proteus/tests/dg/la_gauss_2d_p.py b/test/dg/la_gauss_2d_p.py similarity index 99% rename from proteus/tests/dg/la_gauss_2d_p.py rename to test/dg/la_gauss_2d_p.py index 31672ee9b3..22d1eec85e 100644 --- a/proteus/tests/dg/la_gauss_2d_p.py +++ b/test/dg/la_gauss_2d_p.py @@ -110,4 +110,4 @@ def getDBC(x,tag): #rotation T = 1.0 -## @} +## @} \ No newline at end of file diff --git a/proteus/tests/TADR/__init__.py b/test/elliptic_redist/RDLS/__init__.py similarity index 100% rename from proteus/tests/TADR/__init__.py rename to test/elliptic_redist/RDLS/__init__.py diff --git a/proteus/tests/elliptic_redist/RDLS/clean.sh b/test/elliptic_redist/RDLS/clean.sh similarity index 100% rename from proteus/tests/elliptic_redist/RDLS/clean.sh rename to test/elliptic_redist/RDLS/clean.sh diff --git a/proteus/tests/elliptic_redist/RDLS/ncls_n.py b/test/elliptic_redist/RDLS/ncls_n.py similarity index 96% rename from proteus/tests/elliptic_redist/RDLS/ncls_n.py rename to test/elliptic_redist/RDLS/ncls_n.py index 1d4224e04f..af1c9421e9 100644 --- a/proteus/tests/elliptic_redist/RDLS/ncls_n.py +++ b/test/elliptic_redist/RDLS/ncls_n.py @@ -1,5 +1,3 @@ -from __future__ import print_function -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/elliptic_redist/RDLS/ncls_p.py b/test/elliptic_redist/RDLS/ncls_p.py similarity index 98% rename from proteus/tests/elliptic_redist/RDLS/ncls_p.py rename to test/elliptic_redist/RDLS/ncls_p.py index a057b39538..bb73580fb5 100644 --- a/proteus/tests/elliptic_redist/RDLS/ncls_p.py +++ b/test/elliptic_redist/RDLS/ncls_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * from math import * @@ -128,4 +126,3 @@ def zeroadv(x): return lambda x,t: 0.0 advectiveFluxBoundaryConditions = {} diffusiveFluxBoundaryConditions = {0:{}} - diff --git a/proteus/tests/elliptic_redist/RDLS/rdls_n.py b/test/elliptic_redist/RDLS/rdls_n.py similarity index 97% rename from proteus/tests/elliptic_redist/RDLS/rdls_n.py rename to test/elliptic_redist/RDLS/rdls_n.py index 80529489cd..9ccbd3f31e 100644 --- a/proteus/tests/elliptic_redist/RDLS/rdls_n.py +++ b/test/elliptic_redist/RDLS/rdls_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/elliptic_redist/RDLS/rdls_p.py b/test/elliptic_redist/RDLS/rdls_p.py similarity index 98% rename from proteus/tests/elliptic_redist/RDLS/rdls_p.py rename to test/elliptic_redist/RDLS/rdls_p.py index e1cd56fc66..36767380a9 100644 --- a/proteus/tests/elliptic_redist/RDLS/rdls_p.py +++ b/test/elliptic_redist/RDLS/rdls_p.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_p import * from math import * diff --git a/proteus/tests/elliptic_redist/RDLS/test_redist.py b/test/elliptic_redist/RDLS/test_redist.py similarity index 89% rename from proteus/tests/elliptic_redist/RDLS/test_redist.py rename to test/elliptic_redist/RDLS/test_redist.py index 209666335b..eb6d5eadaa 100644 --- a/proteus/tests/elliptic_redist/RDLS/test_redist.py +++ b/test/elliptic_redist/RDLS/test_redist.py @@ -2,8 +2,6 @@ """ Test module for Elliptic Re-distancing """ -from builtins import range -from builtins import object from proteus.iproteus import * from proteus import Comm comm = Comm.get() @@ -11,7 +9,7 @@ Profiling.verbose=True import os import numpy as np -import tables +import h5py import pytest from petsc4py import PETSc from . import (vortex2D, vortex2D_so, @@ -68,8 +66,8 @@ def test_ELLIPTIC_REDISTANCING_0(self): sList, opts) ns.calculateSolution('rdls') - actual = tables.open_file('vortex_c0p1_level_1_ELLIPTIC_REDIST_0.h5','r') - assert np.isclose(np.amax(actual.root.u_t1),0.13600213609175285,atol=1e-10) + actual = h5py.File('vortex_c0p1_level_1_ELLIPTIC_REDIST_0.h5','r') + assert np.isclose(np.amax(actual['u_t1']),0.13600213609175285,atol=1e-10) actual.close() def test_ELLIPTIC_REDISTANCING_1(self): @@ -106,8 +104,8 @@ def test_ELLIPTIC_REDISTANCING_1(self): sList, opts) ns.calculateSolution('rdls') - actual = tables.open_file('vortex_c0p1_level_1_ELLIPTIC_REDIST_1.h5','r') - assert np.isclose(np.amax(actual.root.u_t1),0.13084321505201912,atol=1e-10) + actual = h5py.File('vortex_c0p1_level_1_ELLIPTIC_REDIST_1.h5','r') + assert np.isclose(np.amax(actual['u_t1']),0.13084321505201912,atol=1e-10) actual.close() def test_ELLIPTIC_REDISTANCING_2(self): @@ -146,9 +144,9 @@ def test_ELLIPTIC_REDISTANCING_2(self): sList, opts) ns.calculateSolution('rdls') - actual = tables.open_file('vortex_c0p1_level_1_ELLIPTIC_REDIST_2.h5','r') - print(np.amax(actual.root.u_t1)) - assert np.isclose(np.amax(actual.root.u_t1),0.1060107277952287,atol=1e-10) + actual = h5py.File('vortex_c0p1_level_1_ELLIPTIC_REDIST_2.h5','r') + print(np.amax(actual['u_t1'])) + assert np.isclose(np.amax(actual['u_t1']),0.1060107277952287,atol=1e-10) actual.close() def test_ELLIPTIC_REDISTANCING_3(self): @@ -185,6 +183,6 @@ def test_ELLIPTIC_REDISTANCING_3(self): sList, opts) ns.calculateSolution('rdls') - actual = tables.open_file('vortex_c0p1_level_1_ELLIPTIC_REDIST_3.h5','r') - assert np.isclose(np.amax(actual.root.u_t1),0.10593090830115062,atol=1e-10) + actual = h5py.File('vortex_c0p1_level_1_ELLIPTIC_REDIST_3.h5','r') + assert np.isclose(np.amax(actual['u_t1']),0.10593090830115062,atol=1e-10) actual.close() diff --git a/proteus/tests/elliptic_redist/RDLS/vortex2D.py b/test/elliptic_redist/RDLS/vortex2D.py similarity index 97% rename from proteus/tests/elliptic_redist/RDLS/vortex2D.py rename to test/elliptic_redist/RDLS/vortex2D.py index 0189b49920..c1ad659d9b 100644 --- a/proteus/tests/elliptic_redist/RDLS/vortex2D.py +++ b/test/elliptic_redist/RDLS/vortex2D.py @@ -1,5 +1,3 @@ -from __future__ import division -from past.utils import old_div from proteus import Domain from proteus import Context from proteus.mprans import NCLS @@ -49,7 +47,7 @@ # create mesh # nn=nnx=nny=(2**ct.refinement)*10+1 nnz=1 -he=old_div(1.0,(nnx-1.0)) +he=1.0/(nnx-1.0) unstructured=ct.unstructured #True for tetgen, false for tet or hex from rectangular grid box=Domain.RectangularDomain(L=(1.0,1.0), diff --git a/proteus/tests/elliptic_redist/RDLS/vortex2D_so.py b/test/elliptic_redist/RDLS/vortex2D_so.py similarity index 88% rename from proteus/tests/elliptic_redist/RDLS/vortex2D_so.py rename to test/elliptic_redist/RDLS/vortex2D_so.py index 450f1a512f..c275e836b6 100644 --- a/proteus/tests/elliptic_redist/RDLS/vortex2D_so.py +++ b/test/elliptic_redist/RDLS/vortex2D_so.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import range from proteus.default_so import * try: from .vortex2D import * @@ -24,4 +22,3 @@ #tnList=[0.,1E-6]+[float(n)*ct.T/float(ct.nDTout) for n in range(1,ct.nDTout+1)] tnList=[0.,1E-6] - diff --git a/proteus/tests/TwoPhaseFlow/__init__.py b/test/elliptic_redist/RDLS3P/__init__.py similarity index 100% rename from proteus/tests/TwoPhaseFlow/__init__.py rename to test/elliptic_redist/RDLS3P/__init__.py diff --git a/proteus/tests/elliptic_redist/RDLS3P/clean.sh b/test/elliptic_redist/RDLS3P/clean.sh similarity index 100% rename from proteus/tests/elliptic_redist/RDLS3P/clean.sh rename to test/elliptic_redist/RDLS3P/clean.sh diff --git a/proteus/tests/elliptic_redist/RDLS3P/ncls_n.py b/test/elliptic_redist/RDLS3P/ncls_n.py similarity index 96% rename from proteus/tests/elliptic_redist/RDLS3P/ncls_n.py rename to test/elliptic_redist/RDLS3P/ncls_n.py index 6e5c119d8f..c80f92ec59 100644 --- a/proteus/tests/elliptic_redist/RDLS3P/ncls_n.py +++ b/test/elliptic_redist/RDLS3P/ncls_n.py @@ -1,5 +1,3 @@ -from __future__ import print_function -from __future__ import absolute_import from proteus import * from proteus.default_n import * from .ncls_p import * diff --git a/proteus/tests/elliptic_redist/RDLS3P/ncls_p.py b/test/elliptic_redist/RDLS3P/ncls_p.py similarity index 98% rename from proteus/tests/elliptic_redist/RDLS3P/ncls_p.py rename to test/elliptic_redist/RDLS3P/ncls_p.py index e9fd2f384d..d6ed133510 100644 --- a/proteus/tests/elliptic_redist/RDLS3P/ncls_p.py +++ b/test/elliptic_redist/RDLS3P/ncls_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * from math import * @@ -115,4 +113,3 @@ def zeroadv(x): return lambda x,t: 0.0 advectiveFluxBoundaryConditions = {} diffusiveFluxBoundaryConditions = {0:{}} - diff --git a/proteus/tests/elliptic_redist/RDLS3P/rdls_n.py b/test/elliptic_redist/RDLS3P/rdls_n.py similarity index 97% rename from proteus/tests/elliptic_redist/RDLS3P/rdls_n.py rename to test/elliptic_redist/RDLS3P/rdls_n.py index 9e30a9086f..908f168f21 100644 --- a/proteus/tests/elliptic_redist/RDLS3P/rdls_n.py +++ b/test/elliptic_redist/RDLS3P/rdls_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * from .rdls_p import * diff --git a/proteus/tests/elliptic_redist/RDLS3P/rdls_p.py b/test/elliptic_redist/RDLS3P/rdls_p.py similarity index 96% rename from proteus/tests/elliptic_redist/RDLS3P/rdls_p.py rename to test/elliptic_redist/RDLS3P/rdls_p.py index 2dad15debd..5157427852 100644 --- a/proteus/tests/elliptic_redist/RDLS3P/rdls_p.py +++ b/test/elliptic_redist/RDLS3P/rdls_p.py @@ -34,4 +34,4 @@ def getDBC(x,flag): initialConditions = ncls_p.initialConditions fluxBoundaryConditions = {0:'noFlow'} advectiveFluxBoundaryConditions = {} -diffusiveFluxBoundaryConditions = {0:{}} +diffusiveFluxBoundaryConditions = {0:{}} \ No newline at end of file diff --git a/proteus/tests/elliptic_redist/RDLS3P/test_redist.py b/test/elliptic_redist/RDLS3P/test_redist.py similarity index 88% rename from proteus/tests/elliptic_redist/RDLS3P/test_redist.py rename to test/elliptic_redist/RDLS3P/test_redist.py index ffb5e89bc5..b8b2230025 100644 --- a/proteus/tests/elliptic_redist/RDLS3P/test_redist.py +++ b/test/elliptic_redist/RDLS3P/test_redist.py @@ -2,9 +2,6 @@ """ Test module for Elliptic Re-distancing """ -from __future__ import print_function -from builtins import range -from builtins import object from proteus.iproteus import * from proteus import Comm comm = Comm.get() @@ -12,7 +9,7 @@ Profiling.verbose=True import os import numpy as np -import tables +import h5py import pytest from petsc4py import PETSc from . import (vortex2D, vortex2D_so, @@ -69,8 +66,8 @@ def test_ELLIPTIC_REDISTANCING_0(self): sList, opts) ns.calculateSolution('rdls') - actual = tables.open_file('vortex_c0p1_level_1_ELLIPTIC_REDIST_0.h5','r') - assert np.isclose(np.amax(actual.root.u_t1),0.13600213609175285,atol=1e-10) + actual = h5py.File('vortex_c0p1_level_1_ELLIPTIC_REDIST_0.h5','r') + assert np.isclose(np.amax(actual['u_t1']),0.13600213609175285,atol=1e-10) actual.close() def test_ELLIPTIC_REDISTANCING_1(self): @@ -106,8 +103,8 @@ def test_ELLIPTIC_REDISTANCING_1(self): sList, opts) ns.calculateSolution('rdls') - actual = tables.open_file('vortex_c0p1_level_1_ELLIPTIC_REDIST_1.h5','r') - assert np.isclose(np.amax(actual.root.u_t1),0.13084321505201912,atol=1e-10) + actual = h5py.File('vortex_c0p1_level_1_ELLIPTIC_REDIST_1.h5','r') + assert np.isclose(np.amax(actual['u_t1']),0.13084321505201912,atol=1e-10) actual.close() def test_ELLIPTIC_REDISTANCING_2(self): @@ -145,9 +142,9 @@ def test_ELLIPTIC_REDISTANCING_2(self): sList, opts) ns.calculateSolution('rdls') - actual = tables.open_file('vortex_c0p1_level_1_ELLIPTIC_REDIST_2.h5','r') - Profiling.logEvent("max u"+repr(np.amax(actual.root.u_t1))) - assert np.isclose(np.amax(actual.root.u_t1),0.1060107277952287,atol=1e-10) + actual = h5py.File('vortex_c0p1_level_1_ELLIPTIC_REDIST_2.h5','r') + Profiling.logEvent("max u"+repr(np.amax(actual['u_t1']))) + assert np.isclose(np.amax(actual['u_t1']),0.1060107277952287,atol=1e-10) actual.close() def test_ELLIPTIC_REDISTANCING_3(self): @@ -183,6 +180,6 @@ def test_ELLIPTIC_REDISTANCING_3(self): sList, opts) ns.calculateSolution('rdls') - actual = tables.open_file('vortex_c0p1_level_1_ELLIPTIC_REDIST_3.h5','r') - assert np.isclose(np.amax(actual.root.u_t1),0.10593090830115062,atol=1e-10) + actual = h5py.File('vortex_c0p1_level_1_ELLIPTIC_REDIST_3.h5','r') + assert np.isclose(np.amax(actual['u_t1']),0.10593090830115062,atol=1e-10) actual.close() diff --git a/proteus/tests/elliptic_redist/RDLS3P/vortex2D.py b/test/elliptic_redist/RDLS3P/vortex2D.py similarity index 96% rename from proteus/tests/elliptic_redist/RDLS3P/vortex2D.py rename to test/elliptic_redist/RDLS3P/vortex2D.py index 73cd2def70..24f2a36c73 100644 --- a/proteus/tests/elliptic_redist/RDLS3P/vortex2D.py +++ b/test/elliptic_redist/RDLS3P/vortex2D.py @@ -1,5 +1,3 @@ -from __future__ import division -from past.utils import old_div from proteus import Domain from proteus import Context from proteus.mprans import NCLS @@ -45,7 +43,7 @@ # create mesh # nn=nnx=nny=(2**ct.refinement)*10+1 nnz=1 -he=old_div(1.0,(nnx-1.0)) +he=1.0/(nnx-1.0) unstructured=ct.unstructured #True for tetgen, false for tet or hex from rectangular grid box=Domain.RectangularDomain(L=(1.0,1.0), diff --git a/proteus/tests/elliptic_redist/RDLS3P/vortex2D_so.py b/test/elliptic_redist/RDLS3P/vortex2D_so.py similarity index 87% rename from proteus/tests/elliptic_redist/RDLS3P/vortex2D_so.py rename to test/elliptic_redist/RDLS3P/vortex2D_so.py index 087ddd050a..3f3d120d5d 100644 --- a/proteus/tests/elliptic_redist/RDLS3P/vortex2D_so.py +++ b/test/elliptic_redist/RDLS3P/vortex2D_so.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import range from proteus.default_so import * from . import vortex2D from .vortex2D import * @@ -22,4 +20,3 @@ #tnList=[0.,1E-6]+[float(n)*ct.T/float(ct.nDTout) for n in range(1,ct.nDTout+1)] tnList=[0.,1E-6] - diff --git a/proteus/tests/flopTest.c b/test/flopTest.c similarity index 100% rename from proteus/tests/flopTest.c rename to test/flopTest.c diff --git a/proteus/tests/__init__.py b/test/griffiths_lane_6/__init__.py similarity index 100% rename from proteus/tests/__init__.py rename to test/griffiths_lane_6/__init__.py diff --git a/proteus/tests/griffiths_lane_6/comparison_files/comparison_3D_displacement_t1.csv b/test/griffiths_lane_6/comparison_files/comparison_3D_displacement_t1.csv similarity index 100% rename from proteus/tests/griffiths_lane_6/comparison_files/comparison_3D_displacement_t1.csv rename to test/griffiths_lane_6/comparison_files/comparison_3D_displacement_t1.csv diff --git a/proteus/tests/griffiths_lane_6/comparison_files/comparison_3D_pressure_t1.csv b/test/griffiths_lane_6/comparison_files/comparison_3D_pressure_t1.csv similarity index 100% rename from proteus/tests/griffiths_lane_6/comparison_files/comparison_3D_pressure_t1.csv rename to test/griffiths_lane_6/comparison_files/comparison_3D_pressure_t1.csv diff --git a/proteus/tests/griffiths_lane_6/gl_6_3d.edge b/test/griffiths_lane_6/gl_6_3d.edge similarity index 100% rename from proteus/tests/griffiths_lane_6/gl_6_3d.edge rename to test/griffiths_lane_6/gl_6_3d.edge diff --git a/proteus/tests/griffiths_lane_6/gl_6_3d.ele b/test/griffiths_lane_6/gl_6_3d.ele similarity index 100% rename from proteus/tests/griffiths_lane_6/gl_6_3d.ele rename to test/griffiths_lane_6/gl_6_3d.ele diff --git a/proteus/tests/griffiths_lane_6/gl_6_3d.face b/test/griffiths_lane_6/gl_6_3d.face similarity index 100% rename from proteus/tests/griffiths_lane_6/gl_6_3d.face rename to test/griffiths_lane_6/gl_6_3d.face diff --git a/proteus/tests/griffiths_lane_6/gl_6_3d.neigh b/test/griffiths_lane_6/gl_6_3d.neigh similarity index 100% rename from proteus/tests/griffiths_lane_6/gl_6_3d.neigh rename to test/griffiths_lane_6/gl_6_3d.neigh diff --git a/proteus/tests/griffiths_lane_6/gl_6_3d.node b/test/griffiths_lane_6/gl_6_3d.node similarity index 100% rename from proteus/tests/griffiths_lane_6/gl_6_3d.node rename to test/griffiths_lane_6/gl_6_3d.node diff --git a/proteus/tests/griffiths_lane_6/gl_6_3d.ply b/test/griffiths_lane_6/gl_6_3d.ply similarity index 100% rename from proteus/tests/griffiths_lane_6/gl_6_3d.ply rename to test/griffiths_lane_6/gl_6_3d.ply diff --git a/proteus/tests/griffiths_lane_6/gl_6_3d.poly b/test/griffiths_lane_6/gl_6_3d.poly similarity index 100% rename from proteus/tests/griffiths_lane_6/gl_6_3d.poly rename to test/griffiths_lane_6/gl_6_3d.poly diff --git a/proteus/tests/griffiths_lane_6/griffiths_lane_6.py b/test/griffiths_lane_6/griffiths_lane_6.py similarity index 91% rename from proteus/tests/griffiths_lane_6/griffiths_lane_6.py rename to test/griffiths_lane_6/griffiths_lane_6.py index 1722ab595f..7b49e82590 100644 --- a/proteus/tests/griffiths_lane_6/griffiths_lane_6.py +++ b/test/griffiths_lane_6/griffiths_lane_6.py @@ -1,7 +1,4 @@ #! /usr/bin/env python -from __future__ import print_function -from __future__ import division -from past.utils import old_div from math import * from proteus import Domain @@ -20,8 +17,8 @@ def gl_6_3d(width): vertices_front = [[0.0,0.0,0.0],#0 [0.0,0.0,7.3],#1 [33.5,0.0,7.3],#2 - [33.5 + old_div(21.3,tan(2.0*pi*18.0/360.0)),0.0,7.3+21.3],#3 - [33.5 + old_div(21.3,tan(2.0*pi*18.0/360.0))+7.3,0.0,7.3+21.3],#4 + [33.5 + 21.3/tan(2.0*pi*18.0/360.0),0.0,7.3+21.3],#3 + [33.5 + 21.3/tan(2.0*pi*18.0/360.0)+7.3,0.0,7.3+21.3],#4 [33.5 + 124.4,0.0,7.3],#5 [2*33.5+124.4,0.0,7.3],#6 [2*33.5+124.4,0.0,0.0]]#7 diff --git a/proteus/tests/griffiths_lane_6/re_gl_6_3d_n.py b/test/griffiths_lane_6/re_gl_6_3d_n.py similarity index 98% rename from proteus/tests/griffiths_lane_6/re_gl_6_3d_n.py rename to test/griffiths_lane_6/re_gl_6_3d_n.py index f7e903d42f..3454692232 100644 --- a/proteus/tests/griffiths_lane_6/re_gl_6_3d_n.py +++ b/test/griffiths_lane_6/re_gl_6_3d_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/griffiths_lane_6/re_gl_6_3d_p.py b/test/griffiths_lane_6/re_gl_6_3d_p.py similarity index 95% rename from proteus/tests/griffiths_lane_6/re_gl_6_3d_p.py rename to test/griffiths_lane_6/re_gl_6_3d_p.py index 93dcebee3c..2258eed30e 100644 --- a/proteus/tests/griffiths_lane_6/re_gl_6_3d_p.py +++ b/test/griffiths_lane_6/re_gl_6_3d_p.py @@ -1,8 +1,3 @@ -from __future__ import absolute_import -from __future__ import division -from builtins import range -from builtins import object -from past.utils import old_div from proteus import * from proteus.default_p import * from proteus.richards import Richards @@ -21,7 +16,7 @@ #he*=0.5 domain = gl_6_3d(width=he) boundaryFlags = domain.boundaryFlags -#domain.regionConstraints = [old_div((he**3),6.0)] +#domain.regionConstraints = [(he**3)/6.0] domain.regionConstraints = [128.0] domain.polyfile=os.path.dirname(os.path.abspath(__file__))+"/"+"gl_6_3d" #domain.writePoly("gl_6_3d") @@ -146,4 +141,6 @@ def getSeepageFace(flag): density=dimensionless_density, beta=0.0001, diagonal_conductivity=True, + STABILIZATION_TYPE=0, + FCT=False, getSeepageFace=getSeepageFace) diff --git a/proteus/tests/griffiths_lane_6/sm_gl_6_3d_n.py b/test/griffiths_lane_6/sm_gl_6_3d_n.py similarity index 96% rename from proteus/tests/griffiths_lane_6/sm_gl_6_3d_n.py rename to test/griffiths_lane_6/sm_gl_6_3d_n.py index 652afde1de..22521fa516 100644 --- a/proteus/tests/griffiths_lane_6/sm_gl_6_3d_n.py +++ b/test/griffiths_lane_6/sm_gl_6_3d_n.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import range from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/griffiths_lane_6/sm_gl_6_3d_p.py b/test/griffiths_lane_6/sm_gl_6_3d_p.py similarity index 92% rename from proteus/tests/griffiths_lane_6/sm_gl_6_3d_p.py rename to test/griffiths_lane_6/sm_gl_6_3d_p.py index c975194998..bc4d559603 100644 --- a/proteus/tests/griffiths_lane_6/sm_gl_6_3d_p.py +++ b/test/griffiths_lane_6/sm_gl_6_3d_p.py @@ -1,8 +1,3 @@ -from __future__ import print_function -from __future__ import absolute_import -from __future__ import division -from builtins import range -from past.utils import old_div from proteus import * from proteus.default_p import * from proteus.elastoplastic import ElastoPlastic @@ -23,7 +18,7 @@ #he*=0.5 domain = gl_6_3d(width=he) boundaryFlags = domain.boundaryFlags -#domain.regionConstraints = [old_div((he**3),6.0)] +#domain.regionConstraints = [(he**3)/6.0] domain.regionConstraints = [128.0] domain.polyfile=os.path.dirname(os.path.abspath(__file__))+"/"+"gl_6_3d" domain.MeshOptions.genMesh=False#True @@ -35,15 +30,15 @@ SRF = 1.0#65#15 SRF_init=1.0 g = [0.0,0.0,-9.8] -rhos = old_div(18.2,9.8) #1000 kg/m^3 = tonnes/m^3 +rhos = 18.2/9.8 #1000 kg/m^3 = tonnes/m^3 rhow = 1.0 #1000 kg/m^3 = tonnes/m^3 E=1.0e5 #kN/m^2 Young's modulus nu=0.3 #- Poisson's ratio -D = old_div(E,((1.0+nu)*(1-2.0*nu))) +D = E/((1.0+nu)*(1-2.0*nu)) D11 = D*(1.0 - nu) D12 = D*nu D44 = 0.5*D*(1.0-2*nu) -pa= old_div(101325.0,1000.0) #kN/m^2 atmospheric pressure +pa= 101325.0/1000.0 #kN/m^2 atmospheric pressure #soil models soilModelFlag=0 #Lade soil model params @@ -51,13 +46,13 @@ ne = 0.6 Psi1 = 3.69 ah=0.001 -bh=old_div(1.0,45.0) +bh=1.0/45.0 Fyc=15 Vr=0.1 # #Mohr-Coulomb soil model params soilModelFlag=1 -phi_mc = atan(old_div(tan((old_div(37.0,360.0))*2.0*math.pi),SRF)) #friction angle +phi_mc = atan(tan((37.0/360.0)*2.0*math.pi)/SRF) #friction angle c_mc = 13.8#0.05*rhos*fabs(g[2])*H psi_mc = 0.0 #dilation angle # @@ -210,5 +205,5 @@ def calculate(self): plasticWork += sig[I]*eps_p[I]*m.q[('dV_u',0)][eN,k] totalWork += sig[I]*eps[I]*m.q[('dV_u',0)][eN,k] if fabs(totalWork) < 1.0e-8: totalWork = 1.0e-8#make sure denom is nonzero - log("Plastic Work = %12.5e, Total Work = %12.5e, Ratio = %12.5e" % (plasticWork,totalWork,old_div(plasticWork,totalWork))) + log("Plastic Work = %12.5e, Total Work = %12.5e, Ratio = %12.5e" % (plasticWork,totalWork,plasticWork/totalWork)) log("Max Displacement = %12.5e" % (max_displacement,)) diff --git a/proteus/tests/griffiths_lane_6/test_griffiths_lane6.py b/test/griffiths_lane_6/test_griffiths_lane6.py similarity index 82% rename from proteus/tests/griffiths_lane_6/test_griffiths_lane6.py rename to test/griffiths_lane_6/test_griffiths_lane6.py index d0561e5c89..a2e817043c 100644 --- a/proteus/tests/griffiths_lane_6/test_griffiths_lane6.py +++ b/test/griffiths_lane_6/test_griffiths_lane6.py @@ -9,13 +9,10 @@ \nabla \cdot \left( a(x) \nabla u \right) = f(x) """ -from __future__ import print_function -from builtins import object from proteus.iproteus import * import os -from past.utils import old_div import numpy as np -import tables +import h5py from . import re_gl_6_3d_p from . import re_gl_6_3d_n from . import sm_gl_6_3d_p @@ -70,11 +67,11 @@ def test_richards(self,use_strong_constraints=False): ns.calculateSolution(so.name) self.aux_names.append(so.name) # COMPARE VS SAVED FILES # - actual = tables.open_file(so.name+'.h5','r') + actual = h5py.File(so.name+'.h5','r') expected_path = 'comparison_files/' + 'comparison_3D_pressure_t1.csv' #write comparison file - #np.array(actual.root.pressure_head_t1).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.pressure_head_t1),decimal=10) + #np.array(actual['pressure_head_t1]).tofile(os.path.join(self._scriptdir, expected_path),sep=",") + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['pressure_head_t1']),decimal=10) actual.close() @@ -100,11 +97,11 @@ def test_elastoplastic(self,use_strong_constraints=False): ns.calculateSolution(so.name) self.aux_names.append(so.name) # COMPARE VS SAVED FILES # - actual = tables.open_file(so.name+'.h5','r') + actual = h5py.File(so.name+'.h5','r') expected_path = 'comparison_files/' + 'comparison_3D_displacement_t1.csv' #write comparison file - #np.array(actual.root.displacement_t1).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.displacement_t1).flatten(),decimal=10) + #np.array(actual['displacement_t1']).tofile(os.path.join(self._scriptdir, expected_path),sep=",") + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['displacement_t1']).flatten(),decimal=10) actual.close() del ns diff --git a/proteus/tests/hex_cube_3x3.h5 b/test/hex_cube_3x3.h5 similarity index 100% rename from proteus/tests/hex_cube_3x3.h5 rename to test/hex_cube_3x3.h5 diff --git a/proteus/tests/hex_cube_3x3.xmf b/test/hex_cube_3x3.xmf similarity index 100% rename from proteus/tests/hex_cube_3x3.xmf rename to test/hex_cube_3x3.xmf diff --git a/proteus/tests/ci/__init__.py b/test/levelset/rotation/__init__.py similarity index 100% rename from proteus/tests/ci/__init__.py rename to test/levelset/rotation/__init__.py diff --git a/proteus/tests/levelset/rotation/box.1.neigh b/test/levelset/rotation/box.1.neigh similarity index 100% rename from proteus/tests/levelset/rotation/box.1.neigh rename to test/levelset/rotation/box.1.neigh diff --git a/proteus/tests/levelset/rotation/box.1.poly b/test/levelset/rotation/box.1.poly similarity index 100% rename from proteus/tests/levelset/rotation/box.1.poly rename to test/levelset/rotation/box.1.poly diff --git a/proteus/tests/levelset/rotation/box.edge b/test/levelset/rotation/box.edge similarity index 100% rename from proteus/tests/levelset/rotation/box.edge rename to test/levelset/rotation/box.edge diff --git a/proteus/tests/levelset/rotation/box.ele b/test/levelset/rotation/box.ele similarity index 100% rename from proteus/tests/levelset/rotation/box.ele rename to test/levelset/rotation/box.ele diff --git a/proteus/tests/levelset/rotation/box.node b/test/levelset/rotation/box.node similarity index 100% rename from proteus/tests/levelset/rotation/box.node rename to test/levelset/rotation/box.node diff --git a/proteus/tests/levelset/rotation/box.poly b/test/levelset/rotation/box.poly similarity index 100% rename from proteus/tests/levelset/rotation/box.poly rename to test/levelset/rotation/box.poly diff --git a/proteus/tests/levelset/rotation/comparison_files/comparison_rotation_c0p1cg_vbdf_2_level_0_phid_t10.csv b/test/levelset/rotation/comparison_files/comparison_rotation_c0p1cg_vbdf_2_level_0_phid_t10.csv similarity index 100% rename from proteus/tests/levelset/rotation/comparison_files/comparison_rotation_c0p1cg_vbdf_2_level_0_phid_t10.csv rename to test/levelset/rotation/comparison_files/comparison_rotation_c0p1cg_vbdf_2_level_0_phid_t10.csv diff --git a/proteus/tests/levelset/rotation/comparison_files/comparison_rotation_c0p1cg_vbdf_2_level_0_u_t10.csv b/test/levelset/rotation/comparison_files/comparison_rotation_c0p1cg_vbdf_2_level_0_u_t10.csv similarity index 100% rename from proteus/tests/levelset/rotation/comparison_files/comparison_rotation_c0p1cg_vbdf_2_level_0_u_t10.csv rename to test/levelset/rotation/comparison_files/comparison_rotation_c0p1cg_vbdf_2_level_0_u_t10.csv diff --git a/proteus/tests/levelset/rotation/comparison_files/comparison_rotation_c0p1cg_vbdf_2_level_0_vof_t10.csv b/test/levelset/rotation/comparison_files/comparison_rotation_c0p1cg_vbdf_2_level_0_vof_t10.csv similarity index 100% rename from proteus/tests/levelset/rotation/comparison_files/comparison_rotation_c0p1cg_vbdf_2_level_0_vof_t10.csv rename to test/levelset/rotation/comparison_files/comparison_rotation_c0p1cg_vbdf_2_level_0_vof_t10.csv diff --git a/proteus/tests/levelset/rotation/ls_consrv_rotation_2d_n.py b/test/levelset/rotation/ls_consrv_rotation_2d_n.py similarity index 98% rename from proteus/tests/levelset/rotation/ls_consrv_rotation_2d_n.py rename to test/levelset/rotation/ls_consrv_rotation_2d_n.py index 5c7f4cec1a..952e7659df 100644 --- a/proteus/tests/levelset/rotation/ls_consrv_rotation_2d_n.py +++ b/test/levelset/rotation/ls_consrv_rotation_2d_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/levelset/rotation/ls_consrv_rotation_2d_p.py b/test/levelset/rotation/ls_consrv_rotation_2d_p.py similarity index 95% rename from proteus/tests/levelset/rotation/ls_consrv_rotation_2d_p.py rename to test/levelset/rotation/ls_consrv_rotation_2d_p.py index 8cf2ac999f..3b2d477719 100644 --- a/proteus/tests/levelset/rotation/ls_consrv_rotation_2d_p.py +++ b/test/levelset/rotation/ls_consrv_rotation_2d_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * try: diff --git a/proteus/tests/levelset/rotation/ls_rotation_2d_n.py b/test/levelset/rotation/ls_rotation_2d_n.py similarity index 97% rename from proteus/tests/levelset/rotation/ls_rotation_2d_n.py rename to test/levelset/rotation/ls_rotation_2d_n.py index 9c8f2b0532..b3e6f2677f 100644 --- a/proteus/tests/levelset/rotation/ls_rotation_2d_n.py +++ b/test/levelset/rotation/ls_rotation_2d_n.py @@ -1,5 +1,3 @@ -from __future__ import print_function -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/levelset/rotation/ls_rotation_2d_p.py b/test/levelset/rotation/ls_rotation_2d_p.py similarity index 99% rename from proteus/tests/levelset/rotation/ls_rotation_2d_p.py rename to test/levelset/rotation/ls_rotation_2d_p.py index 42588f8dd1..45d6e5aadd 100644 --- a/proteus/tests/levelset/rotation/ls_rotation_2d_p.py +++ b/test/levelset/rotation/ls_rotation_2d_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * from math import * diff --git a/proteus/tests/levelset/rotation/ls_rotation_2d_so.py b/test/levelset/rotation/ls_rotation_2d_so.py similarity index 89% rename from proteus/tests/levelset/rotation/ls_rotation_2d_so.py rename to test/levelset/rotation/ls_rotation_2d_so.py index ec9ece586f..958fe4681b 100644 --- a/proteus/tests/levelset/rotation/ls_rotation_2d_so.py +++ b/test/levelset/rotation/ls_rotation_2d_so.py @@ -1,7 +1,3 @@ -from __future__ import absolute_import -from __future__ import division -from builtins import range -from past.utils import old_div from proteus.default_so import * try: from . import rotation2D @@ -40,7 +36,7 @@ archiveFlag = ArchiveFlags.EVERY_USER_STEP #archiveFlag = ArchiveFlags.EVERY_MODEL_STEP -DT = old_div(T,float(nDTout)) +DT = T/float(nDTout) tnList = [i*DT for i in range(nDTout+1)] #cek hard coded steps for article snapshots #tnList = [0.0,4.0,8.0] diff --git a/proteus/tests/levelset/rotation/redist_rotation_2d_n.py b/test/levelset/rotation/redist_rotation_2d_n.py similarity index 95% rename from proteus/tests/levelset/rotation/redist_rotation_2d_n.py rename to test/levelset/rotation/redist_rotation_2d_n.py index 4c709b5fc1..9b3e541263 100644 --- a/proteus/tests/levelset/rotation/redist_rotation_2d_n.py +++ b/test/levelset/rotation/redist_rotation_2d_n.py @@ -1,6 +1,3 @@ -from __future__ import absolute_import -from __future__ import division -from past.utils import old_div from proteus import * from proteus.default_n import * try: @@ -67,7 +64,7 @@ stepController = Osher_PsiTC_controller runCFL=1.0 rtol_res[0] = 0.0 - atol_res[0] = old_div(0.01,float(nn-1))#1.0e-6 + atol_res[0] = 0.01/float(nn-1)#1.0e-6 if pDegree_ls==0: femSpaces = {0:DG_AffineP0_OnSimplexWithMonomialBasis} elif pDegree_ls==1: diff --git a/proteus/tests/levelset/rotation/redist_rotation_2d_p.py b/test/levelset/rotation/redist_rotation_2d_p.py similarity index 96% rename from proteus/tests/levelset/rotation/redist_rotation_2d_p.py rename to test/levelset/rotation/redist_rotation_2d_p.py index 3e38da7cd0..4c79ead2bf 100644 --- a/proteus/tests/levelset/rotation/redist_rotation_2d_p.py +++ b/test/levelset/rotation/redist_rotation_2d_p.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_p import * from math import * diff --git a/proteus/tests/levelset/rotation/rotation2D.py b/test/levelset/rotation/rotation2D.py similarity index 96% rename from proteus/tests/levelset/rotation/rotation2D.py rename to test/levelset/rotation/rotation2D.py index 264042cf9a..23027873a0 100644 --- a/proteus/tests/levelset/rotation/rotation2D.py +++ b/test/levelset/rotation/rotation2D.py @@ -1,6 +1,3 @@ -from __future__ import absolute_import -from __future__ import division -from past.utils import old_div from proteus import Domain import os @@ -46,7 +43,7 @@ #soname="rotationcgp2_bdf2_mc"+`lRefinement` nn=nnx=nny=8#(2**lRefinement)*5+1 nnz=1 -he=old_div(1.0,(nnx-1.0)) +he=1.0/(nnx-1.0) L=[1.0,1.0] unstructured=True#True for tetgen, false for tet or hex from rectangular grid diff --git a/proteus/tests/levelset/rotation/rotationDomain.py b/test/levelset/rotation/rotationDomain.py similarity index 99% rename from proteus/tests/levelset/rotation/rotationDomain.py rename to test/levelset/rotation/rotationDomain.py index 3ccc4c8577..c184fa7433 100644 --- a/proteus/tests/levelset/rotation/rotationDomain.py +++ b/test/levelset/rotation/rotationDomain.py @@ -39,4 +39,3 @@ def tank2d(L=[1.0,1.0,1.0],fileprefix=None): domain.writePoly("tank2d") domain.writePLY("tank2d") os.system("asy -V tank2d") - diff --git a/proteus/tests/levelset/rotation/test_rotation2D.py b/test/levelset/rotation/test_rotation2D.py similarity index 82% rename from proteus/tests/levelset/rotation/test_rotation2D.py rename to test/levelset/rotation/test_rotation2D.py index 916782647e..2b5c269b0c 100755 --- a/proteus/tests/levelset/rotation/test_rotation2D.py +++ b/test/levelset/rotation/test_rotation2D.py @@ -2,13 +2,10 @@ """ Test module for level set transport """ -from __future__ import print_function -from builtins import range -from builtins import object from proteus.iproteus import * import os import numpy as np -import tables +import h5py class TestRotation2D(object): @@ -79,21 +76,21 @@ def test_rotation2D(self,use_strong_constraints=False): ns.calculateSolution(ls_rotation_2d_so.name) self.aux_names.append(ls_rotation_2d_so.name) # COMPARE VS SAVED FILES # - actual = tables.open_file(ls_rotation_2d_so.name+'.h5','r') + actual = h5py.File(ls_rotation_2d_so.name+'.h5','r') expected_path = 'comparison_files/' + 'comparison_' + ls_rotation_2d_so.name + '_u_t10.csv' #write comparison file - #np.array(actual.root.u_t10).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.u_t10).flatten(),decimal=6) + #np.array(actual['u_t10']).tofile(os.path.join(self._scriptdir, expected_path),sep=",") + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['u_t10']).flatten(),decimal=6) expected_path = 'comparison_files/' + 'comparison_' + ls_rotation_2d_so.name + '_phid_t10.csv' #write comparison file - #np.array(actual.root.phid_t10).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.phid_t10).flatten(),decimal=10) + #np.array(actual['phid_t10']).tofile(os.path.join(self._scriptdir, expected_path),sep=",") + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['phid_t10']).flatten(),decimal=10) expected_path = 'comparison_files/' + 'comparison_' + ls_rotation_2d_so.name + '_vof_t10.csv' #write comparison file - #np.array(actual.root.vof_t10).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.vof_t10).flatten(),decimal=10) + #np.array(actual['vof_t10']).tofile(os.path.join(self._scriptdir, expected_path),sep=",") + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['vof_t10']).flatten(),decimal=10) actual.close() del ns diff --git a/proteus/tests/levelset/rotation/vof_rotation_2d_n.py b/test/levelset/rotation/vof_rotation_2d_n.py similarity index 98% rename from proteus/tests/levelset/rotation/vof_rotation_2d_n.py rename to test/levelset/rotation/vof_rotation_2d_n.py index 504c3073a3..78ae545b40 100644 --- a/proteus/tests/levelset/rotation/vof_rotation_2d_n.py +++ b/test/levelset/rotation/vof_rotation_2d_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/levelset/rotation/vof_rotation_2d_p.py b/test/levelset/rotation/vof_rotation_2d_p.py similarity index 97% rename from proteus/tests/levelset/rotation/vof_rotation_2d_p.py rename to test/levelset/rotation/vof_rotation_2d_p.py index 4a2a8135fe..fd9707bc0f 100644 --- a/proteus/tests/levelset/rotation/vof_rotation_2d_p.py +++ b/test/levelset/rotation/vof_rotation_2d_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * from proteus.ctransportCoefficients import smoothedHeaviside diff --git a/proteus/tests/cylinder2D/__init__.py b/test/levelset/vortex/__init__.py similarity index 100% rename from proteus/tests/cylinder2D/__init__.py rename to test/levelset/vortex/__init__.py diff --git a/proteus/tests/levelset/vortex/comparison_files/comparison_3D_phid_t80.csv b/test/levelset/vortex/comparison_files/comparison_3D_phid_t80.csv similarity index 100% rename from proteus/tests/levelset/vortex/comparison_files/comparison_3D_phid_t80.csv rename to test/levelset/vortex/comparison_files/comparison_3D_phid_t80.csv diff --git a/proteus/tests/levelset/vortex/comparison_files/comparison_3D_u_t80.csv b/test/levelset/vortex/comparison_files/comparison_3D_u_t80.csv similarity index 100% rename from proteus/tests/levelset/vortex/comparison_files/comparison_3D_u_t80.csv rename to test/levelset/vortex/comparison_files/comparison_3D_u_t80.csv diff --git a/proteus/tests/levelset/vortex/comparison_files/comparison_3D_vof_t80.csv b/test/levelset/vortex/comparison_files/comparison_3D_vof_t80.csv similarity index 100% rename from proteus/tests/levelset/vortex/comparison_files/comparison_3D_vof_t80.csv rename to test/levelset/vortex/comparison_files/comparison_3D_vof_t80.csv diff --git a/proteus/tests/levelset/vortex/ls_consrv_vortex_3d_n.py b/test/levelset/vortex/ls_consrv_vortex_3d_n.py similarity index 98% rename from proteus/tests/levelset/vortex/ls_consrv_vortex_3d_n.py rename to test/levelset/vortex/ls_consrv_vortex_3d_n.py index 6876f0b713..cab2b30c00 100644 --- a/proteus/tests/levelset/vortex/ls_consrv_vortex_3d_n.py +++ b/test/levelset/vortex/ls_consrv_vortex_3d_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * from .ls_consrv_vortex_3d_p import * diff --git a/proteus/tests/levelset/vortex/ls_consrv_vortex_3d_p.py b/test/levelset/vortex/ls_consrv_vortex_3d_p.py similarity index 94% rename from proteus/tests/levelset/vortex/ls_consrv_vortex_3d_p.py rename to test/levelset/vortex/ls_consrv_vortex_3d_p.py index 2c13aef932..9326bf35bf 100644 --- a/proteus/tests/levelset/vortex/ls_consrv_vortex_3d_p.py +++ b/test/levelset/vortex/ls_consrv_vortex_3d_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * from .vortex import * diff --git a/proteus/tests/levelset/vortex/ls_vortex_3d_n.py b/test/levelset/vortex/ls_vortex_3d_n.py similarity index 96% rename from proteus/tests/levelset/vortex/ls_vortex_3d_n.py rename to test/levelset/vortex/ls_vortex_3d_n.py index a535ad8545..413687ffba 100644 --- a/proteus/tests/levelset/vortex/ls_vortex_3d_n.py +++ b/test/levelset/vortex/ls_vortex_3d_n.py @@ -1,5 +1,3 @@ -from __future__ import print_function -from __future__ import absolute_import from proteus import * from proteus.default_n import * from .ls_vortex_3d_p import * diff --git a/proteus/tests/levelset/vortex/ls_vortex_3d_p.py b/test/levelset/vortex/ls_vortex_3d_p.py similarity index 99% rename from proteus/tests/levelset/vortex/ls_vortex_3d_p.py rename to test/levelset/vortex/ls_vortex_3d_p.py index e91b232db5..a1e6d5286e 100644 --- a/proteus/tests/levelset/vortex/ls_vortex_3d_p.py +++ b/test/levelset/vortex/ls_vortex_3d_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * from math import * diff --git a/proteus/tests/levelset/vortex/ls_vortex_3d_so.py b/test/levelset/vortex/ls_vortex_3d_so.py similarity index 87% rename from proteus/tests/levelset/vortex/ls_vortex_3d_so.py rename to test/levelset/vortex/ls_vortex_3d_so.py index c50b1e1354..9f40b345b9 100644 --- a/proteus/tests/levelset/vortex/ls_vortex_3d_so.py +++ b/test/levelset/vortex/ls_vortex_3d_so.py @@ -1,7 +1,3 @@ -from __future__ import absolute_import -from __future__ import division -from builtins import range -from past.utils import old_div from proteus.default_so import * from . import vortex from .vortex import * @@ -34,7 +30,7 @@ archiveFlag = ArchiveFlags.EVERY_USER_STEP #archiveFlag = ArchiveFlags.EVERY_MODEL_STEP -DT = old_div(T,float(nDTout)) +DT = T/float(nDTout) tnList = [i*DT for i in range(nDTout+1)] #cek hard coded steps for article snapshots #tnList = [0.0,4.0,8.0] diff --git a/proteus/tests/levelset/vortex/redist_vortex_3d_n.py b/test/levelset/vortex/redist_vortex_3d_n.py similarity index 94% rename from proteus/tests/levelset/vortex/redist_vortex_3d_n.py rename to test/levelset/vortex/redist_vortex_3d_n.py index bcd8f32b5c..63d4e6caf8 100644 --- a/proteus/tests/levelset/vortex/redist_vortex_3d_n.py +++ b/test/levelset/vortex/redist_vortex_3d_n.py @@ -1,6 +1,3 @@ -from __future__ import absolute_import -from __future__ import division -from past.utils import old_div from proteus import * from proteus.default_n import * from .redist_vortex_3d_p import * @@ -36,7 +33,7 @@ stepController = Osher_PsiTC_controller runCFL=1.0 rtol_res[0] = 0.0 - atol_res[0] = old_div(0.01,float(nn-1))#1.0e-6 + atol_res[0] = 0.01/float(nn-1)#1.0e-6 if pDegree_ls==0: femSpaces = {0:DG_AffineP0_OnSimplexWithMonomialBasis} elif pDegree_ls==1: diff --git a/proteus/tests/levelset/vortex/redist_vortex_3d_p.py b/test/levelset/vortex/redist_vortex_3d_p.py similarity index 96% rename from proteus/tests/levelset/vortex/redist_vortex_3d_p.py rename to test/levelset/vortex/redist_vortex_3d_p.py index 4aefb55f09..49778453bf 100644 --- a/proteus/tests/levelset/vortex/redist_vortex_3d_p.py +++ b/test/levelset/vortex/redist_vortex_3d_p.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_p import * from math import * diff --git a/proteus/tests/levelset/vortex/tank3d.asy b/test/levelset/vortex/tank3d.asy similarity index 100% rename from proteus/tests/levelset/vortex/tank3d.asy rename to test/levelset/vortex/tank3d.asy diff --git a/proteus/tests/levelset/vortex/tank3d.edge b/test/levelset/vortex/tank3d.edge similarity index 100% rename from proteus/tests/levelset/vortex/tank3d.edge rename to test/levelset/vortex/tank3d.edge diff --git a/proteus/tests/levelset/vortex/tank3d.ele b/test/levelset/vortex/tank3d.ele similarity index 100% rename from proteus/tests/levelset/vortex/tank3d.ele rename to test/levelset/vortex/tank3d.ele diff --git a/proteus/tests/levelset/vortex/tank3d.face b/test/levelset/vortex/tank3d.face similarity index 100% rename from proteus/tests/levelset/vortex/tank3d.face rename to test/levelset/vortex/tank3d.face diff --git a/proteus/tests/levelset/vortex/tank3d.neigh b/test/levelset/vortex/tank3d.neigh similarity index 100% rename from proteus/tests/levelset/vortex/tank3d.neigh rename to test/levelset/vortex/tank3d.neigh diff --git a/proteus/tests/levelset/vortex/tank3d.node b/test/levelset/vortex/tank3d.node similarity index 100% rename from proteus/tests/levelset/vortex/tank3d.node rename to test/levelset/vortex/tank3d.node diff --git a/proteus/tests/levelset/vortex/tank3d.ply b/test/levelset/vortex/tank3d.ply similarity index 100% rename from proteus/tests/levelset/vortex/tank3d.ply rename to test/levelset/vortex/tank3d.ply diff --git a/proteus/tests/levelset/vortex/tank3d.poly b/test/levelset/vortex/tank3d.poly similarity index 100% rename from proteus/tests/levelset/vortex/tank3d.poly rename to test/levelset/vortex/tank3d.poly diff --git a/proteus/tests/levelset/vortex/tank3dDomain.py b/test/levelset/vortex/tank3dDomain.py similarity index 99% rename from proteus/tests/levelset/vortex/tank3dDomain.py rename to test/levelset/vortex/tank3dDomain.py index 207001e09b..409dbe713a 100644 --- a/proteus/tests/levelset/vortex/tank3dDomain.py +++ b/test/levelset/vortex/tank3dDomain.py @@ -51,4 +51,3 @@ def tank3d(L=[1.0,1.0,1.0]): domain.writePoly("tank3d") domain.writePLY("tank3d") os.system("asy -V tank3d") - diff --git a/proteus/tests/levelset/vortex/tank3d_boundaryLegend.asy b/test/levelset/vortex/tank3d_boundaryLegend.asy similarity index 100% rename from proteus/tests/levelset/vortex/tank3d_boundaryLegend.asy rename to test/levelset/vortex/tank3d_boundaryLegend.asy diff --git a/proteus/tests/levelset/vortex/test_vortex.py b/test/levelset/vortex/test_vortex.py similarity index 82% rename from proteus/tests/levelset/vortex/test_vortex.py rename to test/levelset/vortex/test_vortex.py index c3efa6cea5..dc835935c9 100755 --- a/proteus/tests/levelset/vortex/test_vortex.py +++ b/test/levelset/vortex/test_vortex.py @@ -2,13 +2,10 @@ """ Test module for level set transport """ -from __future__ import print_function -from builtins import range -from builtins import object from proteus.iproteus import * import os import numpy as np -import tables +import h5py from . import (ls_vortex_3d_p, redist_vortex_3d_p, vof_vortex_3d_p, @@ -80,21 +77,21 @@ def test_vortex3D(self,use_strong_constraints=False): assert 0, "Calculate solution failed" self.aux_names.append(ls_vortex_3d_so.name) # COMPARE VS SAVED FILES # - actual = tables.open_file(ls_vortex_3d_so.name+'.h5','r') + actual = h5py.File(ls_vortex_3d_so.name+'.h5','r') expected_path = 'comparison_files/' + 'comparison_3D_u_t80.csv' #write comparison file - #np.array(actual.root.u_t80).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.u_t80),decimal=10) + #np.array(actual['u_t80']).tofile(os.path.join(self._scriptdir, expected_path),sep=",") + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['u_t80']),decimal=10) expected_path = 'comparison_files/' + 'comparison_3D_phid_t80.csv' #write comparison file - #np.array(actual.root.phid_t80).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.phid_t80),decimal=10) + #np.array(actual['phid_t80']).tofile(os.path.join(self._scriptdir, expected_path),sep=",") + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['phid_t80']),decimal=10) expected_path = 'comparison_files/' + 'comparison_3D_vof_t80.csv' #write comparison file - #np.array(actual.root.vof_t80).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.vof_t80),decimal=10) + #np.array(actual['vof_t80']).tofile(os.path.join(self._scriptdir, expected_path),sep=",") + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['vof_t80']),decimal=10) actual.close() del ns diff --git a/proteus/tests/levelset/vortex/vof_vortex_3d_n.py b/test/levelset/vortex/vof_vortex_3d_n.py similarity index 98% rename from proteus/tests/levelset/vortex/vof_vortex_3d_n.py rename to test/levelset/vortex/vof_vortex_3d_n.py index b5db4f4d2e..94678bdf7b 100644 --- a/proteus/tests/levelset/vortex/vof_vortex_3d_n.py +++ b/test/levelset/vortex/vof_vortex_3d_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * from .vof_vortex_3d_p import * diff --git a/proteus/tests/levelset/vortex/vof_vortex_3d_p.py b/test/levelset/vortex/vof_vortex_3d_p.py similarity index 97% rename from proteus/tests/levelset/vortex/vof_vortex_3d_p.py rename to test/levelset/vortex/vof_vortex_3d_p.py index be59eb15f0..d200491911 100644 --- a/proteus/tests/levelset/vortex/vof_vortex_3d_p.py +++ b/test/levelset/vortex/vof_vortex_3d_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * from proteus.ctransportCoefficients import smoothedHeaviside diff --git a/proteus/tests/levelset/vortex/vortex.py b/test/levelset/vortex/vortex.py similarity index 92% rename from proteus/tests/levelset/vortex/vortex.py rename to test/levelset/vortex/vortex.py index 66b5ce5007..06bc4e9709 100644 --- a/proteus/tests/levelset/vortex/vortex.py +++ b/test/levelset/vortex/vortex.py @@ -1,7 +1,4 @@ -from __future__ import absolute_import -from __future__ import division #if True uses PETSc solvers -from past.utils import old_div import os parallel = False @@ -47,11 +44,11 @@ nn=nnx=nny=(2**lRefinement)*5+1 nnz=2 he = 0.5 - #he=old_div(1.0,(nnx-1.0)) + #he=1.0/(nnx-1.0) L=[1.0,1.0,he] else: nn=nnx=nny=nnz=(2**lRefinement)*10+1 - he = old_div(1.0,(nnx-1.0)) + he = 1.0/(nnx-1.0) L = [1.0,1.0,1.0] unstructured=True#True for tetgen, false for tet or hex from rectangular grid genMesh=False @@ -63,7 +60,7 @@ #domain.writePLY("tank3d") #domain.writeAsymptote("tank3d") domain.polyfile=os.path.dirname(os.path.abspath(__file__))+"/"+"tank3d" - triangleOptions="VApq1.3q18ena%21.16e" % (old_div((he**3),6.0),) + triangleOptions="VApq1.3q18ena%21.16e" % ((he**3)/6.0,) else: from proteus.Domain import RectangularDomain domain = RectangularDomain(L) diff --git a/proteus/tests/cylinder2D/conforming_rans2p/__init__.py b/test/levelset/vortex2D/__init__.py similarity index 100% rename from proteus/tests/cylinder2D/conforming_rans2p/__init__.py rename to test/levelset/vortex2D/__init__.py diff --git a/proteus/tests/levelset/vortex2D/clean.sh b/test/levelset/vortex2D/clean.sh similarity index 100% rename from proteus/tests/levelset/vortex2D/clean.sh rename to test/levelset/vortex2D/clean.sh diff --git a/proteus/tests/levelset/vortex2D/comparison_files/comparison_vortex_c0p1cg_be_1_level_1_exactHeaviside_phid_t80.csv b/test/levelset/vortex2D/comparison_files/comparison_vortex_c0p1cg_be_1_level_1_exactHeaviside_phid_t80.csv similarity index 100% rename from proteus/tests/levelset/vortex2D/comparison_files/comparison_vortex_c0p1cg_be_1_level_1_exactHeaviside_phid_t80.csv rename to test/levelset/vortex2D/comparison_files/comparison_vortex_c0p1cg_be_1_level_1_exactHeaviside_phid_t80.csv diff --git a/proteus/tests/levelset/vortex2D/comparison_files/comparison_vortex_c0p1cg_be_1_level_1_exactHeaviside_u_t80.csv b/test/levelset/vortex2D/comparison_files/comparison_vortex_c0p1cg_be_1_level_1_exactHeaviside_u_t80.csv similarity index 100% rename from proteus/tests/levelset/vortex2D/comparison_files/comparison_vortex_c0p1cg_be_1_level_1_exactHeaviside_u_t80.csv rename to test/levelset/vortex2D/comparison_files/comparison_vortex_c0p1cg_be_1_level_1_exactHeaviside_u_t80.csv diff --git a/proteus/tests/levelset/vortex2D/comparison_files/comparison_vortex_c0p1cg_be_1_level_1_exactHeaviside_vof_t80.csv b/test/levelset/vortex2D/comparison_files/comparison_vortex_c0p1cg_be_1_level_1_exactHeaviside_vof_t80.csv similarity index 100% rename from proteus/tests/levelset/vortex2D/comparison_files/comparison_vortex_c0p1cg_be_1_level_1_exactHeaviside_vof_t80.csv rename to test/levelset/vortex2D/comparison_files/comparison_vortex_c0p1cg_be_1_level_1_exactHeaviside_vof_t80.csv diff --git a/proteus/tests/levelset/vortex2D/comparison_files/comparison_vortex_c0p1cg_be_1_level_1_phid_t80.csv b/test/levelset/vortex2D/comparison_files/comparison_vortex_c0p1cg_be_1_level_1_phid_t80.csv similarity index 100% rename from proteus/tests/levelset/vortex2D/comparison_files/comparison_vortex_c0p1cg_be_1_level_1_phid_t80.csv rename to test/levelset/vortex2D/comparison_files/comparison_vortex_c0p1cg_be_1_level_1_phid_t80.csv diff --git a/proteus/tests/levelset/vortex2D/comparison_files/comparison_vortex_c0p1cg_be_1_level_1_u_t80.csv b/test/levelset/vortex2D/comparison_files/comparison_vortex_c0p1cg_be_1_level_1_u_t80.csv similarity index 100% rename from proteus/tests/levelset/vortex2D/comparison_files/comparison_vortex_c0p1cg_be_1_level_1_u_t80.csv rename to test/levelset/vortex2D/comparison_files/comparison_vortex_c0p1cg_be_1_level_1_u_t80.csv diff --git a/proteus/tests/levelset/vortex2D/comparison_files/comparison_vortex_c0p1cg_be_1_level_1_vof_t80.csv b/test/levelset/vortex2D/comparison_files/comparison_vortex_c0p1cg_be_1_level_1_vof_t80.csv similarity index 100% rename from proteus/tests/levelset/vortex2D/comparison_files/comparison_vortex_c0p1cg_be_1_level_1_vof_t80.csv rename to test/levelset/vortex2D/comparison_files/comparison_vortex_c0p1cg_be_1_level_1_vof_t80.csv diff --git a/proteus/tests/levelset/vortex2D/ls_consrv_vortex_2d_n.py b/test/levelset/vortex2D/ls_consrv_vortex_2d_n.py similarity index 98% rename from proteus/tests/levelset/vortex2D/ls_consrv_vortex_2d_n.py rename to test/levelset/vortex2D/ls_consrv_vortex_2d_n.py index f6400422e3..4629b77dc0 100644 --- a/proteus/tests/levelset/vortex2D/ls_consrv_vortex_2d_n.py +++ b/test/levelset/vortex2D/ls_consrv_vortex_2d_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/levelset/vortex2D/ls_consrv_vortex_2d_p.py b/test/levelset/vortex2D/ls_consrv_vortex_2d_p.py similarity index 95% rename from proteus/tests/levelset/vortex2D/ls_consrv_vortex_2d_p.py rename to test/levelset/vortex2D/ls_consrv_vortex_2d_p.py index 9d88d30cea..4e2424124f 100644 --- a/proteus/tests/levelset/vortex2D/ls_consrv_vortex_2d_p.py +++ b/test/levelset/vortex2D/ls_consrv_vortex_2d_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * try: diff --git a/proteus/tests/levelset/vortex2D/ls_vortex_2d_n.py b/test/levelset/vortex2D/ls_vortex_2d_n.py similarity index 97% rename from proteus/tests/levelset/vortex2D/ls_vortex_2d_n.py rename to test/levelset/vortex2D/ls_vortex_2d_n.py index 20c9bbdf04..3b543e6554 100644 --- a/proteus/tests/levelset/vortex2D/ls_vortex_2d_n.py +++ b/test/levelset/vortex2D/ls_vortex_2d_n.py @@ -1,5 +1,3 @@ -from __future__ import print_function -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/levelset/vortex2D/ls_vortex_2d_p.py b/test/levelset/vortex2D/ls_vortex_2d_p.py similarity index 99% rename from proteus/tests/levelset/vortex2D/ls_vortex_2d_p.py rename to test/levelset/vortex2D/ls_vortex_2d_p.py index 2ae63a2a1c..f72d52bf98 100644 --- a/proteus/tests/levelset/vortex2D/ls_vortex_2d_p.py +++ b/test/levelset/vortex2D/ls_vortex_2d_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus import ctransportCoefficients from proteus.default_p import * diff --git a/proteus/tests/levelset/vortex2D/ls_vortex_2d_so.py b/test/levelset/vortex2D/ls_vortex_2d_so.py similarity index 89% rename from proteus/tests/levelset/vortex2D/ls_vortex_2d_so.py rename to test/levelset/vortex2D/ls_vortex_2d_so.py index ea65e2810c..3749804a5e 100644 --- a/proteus/tests/levelset/vortex2D/ls_vortex_2d_so.py +++ b/test/levelset/vortex2D/ls_vortex_2d_so.py @@ -1,7 +1,3 @@ -from __future__ import absolute_import -from __future__ import division -from builtins import range -from past.utils import old_div from proteus.default_so import * try: from . import vortex2D @@ -40,7 +36,7 @@ archiveFlag = ArchiveFlags.EVERY_USER_STEP #archiveFlag = ArchiveFlags.EVERY_MODEL_STEP -DT = old_div(T,float(nDTout)) +DT = T/float(nDTout) tnList = [i*DT for i in range(nDTout+1)] #cek hard coded steps for article snapshots #tnList = [0.0,4.0,8.0] diff --git a/proteus/tests/levelset/vortex2D/redist_vortex_2d_n.py b/test/levelset/vortex2D/redist_vortex_2d_n.py similarity index 95% rename from proteus/tests/levelset/vortex2D/redist_vortex_2d_n.py rename to test/levelset/vortex2D/redist_vortex_2d_n.py index 5d8fa21c55..8cff6ed30a 100644 --- a/proteus/tests/levelset/vortex2D/redist_vortex_2d_n.py +++ b/test/levelset/vortex2D/redist_vortex_2d_n.py @@ -1,6 +1,3 @@ -from __future__ import absolute_import -from __future__ import division -from past.utils import old_div from proteus import * from proteus.default_n import * try: @@ -71,7 +68,7 @@ stepController = Osher_PsiTC_controller runCFL=1.0 rtol_res[0] = 0.0 - atol_res[0] = old_div(0.01,float(nn-1))#1.0e-6 + atol_res[0] = 0.01/float(nn-1)#1.0e-6 if pDegree_ls==0: femSpaces = {0:DG_AffineP0_OnSimplexWithMonomialBasis} elif pDegree_ls==1: diff --git a/proteus/tests/levelset/vortex2D/redist_vortex_2d_p.py b/test/levelset/vortex2D/redist_vortex_2d_p.py similarity index 97% rename from proteus/tests/levelset/vortex2D/redist_vortex_2d_p.py rename to test/levelset/vortex2D/redist_vortex_2d_p.py index 146b74ddc2..1ab90fc37a 100644 --- a/proteus/tests/levelset/vortex2D/redist_vortex_2d_p.py +++ b/test/levelset/vortex2D/redist_vortex_2d_p.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_p import * from math import * diff --git a/proteus/tests/levelset/vortex2D/tank2dDomain.py b/test/levelset/vortex2D/tank2dDomain.py similarity index 99% rename from proteus/tests/levelset/vortex2D/tank2dDomain.py rename to test/levelset/vortex2D/tank2dDomain.py index 3ccc4c8577..c184fa7433 100644 --- a/proteus/tests/levelset/vortex2D/tank2dDomain.py +++ b/test/levelset/vortex2D/tank2dDomain.py @@ -39,4 +39,3 @@ def tank2d(L=[1.0,1.0,1.0],fileprefix=None): domain.writePoly("tank2d") domain.writePLY("tank2d") os.system("asy -V tank2d") - diff --git a/proteus/tests/levelset/vortex2D/test_vortex2D.py b/test/levelset/vortex2D/test_vortex2D.py similarity index 79% rename from proteus/tests/levelset/vortex2D/test_vortex2D.py rename to test/levelset/vortex2D/test_vortex2D.py index 153983c929..eb200abdc4 100755 --- a/proteus/tests/levelset/vortex2D/test_vortex2D.py +++ b/test/levelset/vortex2D/test_vortex2D.py @@ -2,13 +2,10 @@ """ Test module for level set transport """ -from __future__ import print_function -from builtins import range -from builtins import object from proteus.iproteus import * import os import numpy as np -import tables +import h5py from . import (vortex2D, ls_vortex_2d_p, redist_vortex_2d_p, @@ -79,21 +76,21 @@ def test_vortex2D(self,use_strong_constraints=False): ns.calculateSolution(ls_vortex_2d_so.name) self.aux_names.append(ls_vortex_2d_so.name) # COMPARE VS SAVED FILES # - actual = tables.open_file(ls_vortex_2d_so.name+'.h5','r') + actual = h5py.File(ls_vortex_2d_so.name+'.h5','r') expected_path = 'comparison_files/' + 'comparison_' + ls_vortex_2d_so.name + '_u_t80.csv' #write comparison file - #np.array(actual.root.u_t80).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.u_t80).flatten(),decimal=10) + #np.array(actual['u_t80']).tofile(os.path.join(self._scriptdir, expected_path),sep=",") + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['u_t80']).flatten(),decimal=10) expected_path = 'comparison_files/' + 'comparison_' + ls_vortex_2d_so.name + '_phid_t80.csv' #write comparison file - #np.array(actual.root.phid_t80).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.phid_t80).flatten(),decimal=10) + #np.array(actual['phid_t80']).tofile(os.path.join(self._scriptdir, expected_path),sep=",") + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['phid_t80']).flatten(),decimal=10) expected_path = 'comparison_files/' + 'comparison_' + ls_vortex_2d_so.name + '_vof_t80.csv' #write comparison file - #np.array(actual.root.vof_t80).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.vof_t80).flatten(),decimal=10) + #np.array(actual['vof_t80']).tofile(os.path.join(self._scriptdir, expected_path),sep=",") + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['vof_t80']).flatten(),decimal=10) actual.close() del ns @@ -130,21 +127,21 @@ def test_vortex2D_exactHeaviside(self,use_strong_constraints=False): ns.calculateSolution(ls_vortex_2d_so.name) self.aux_names.append(ls_vortex_2d_so.name) # COMPARE VS SAVED FILES # - actual = tables.open_file(ls_vortex_2d_so.name+'.h5','r') + actual = h5py.File(ls_vortex_2d_so.name+'.h5','r') expected_path = 'comparison_files/' + 'comparison_' + ls_vortex_2d_so.name + '_u_t80.csv' #write comparison file - #np.array(actual.root.u_t80).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.u_t80).flatten(),decimal=10) + #np.array(actual['u_t80']).tofile(os.path.join(self._scriptdir, expected_path),sep=",") + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['u_t80']).flatten(),decimal=10) expected_path = 'comparison_files/' + 'comparison_' + ls_vortex_2d_so.name + '_phid_t80.csv' #write comparison file - #np.array(actual.root.phid_t80).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.phid_t80).flatten(),decimal=10) + #np.array(actual['phid_t80']).tofile(os.path.join(self._scriptdir, expected_path),sep=",") + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['phid_t80']).flatten(),decimal=10) expected_path = 'comparison_files/' + 'comparison_' + ls_vortex_2d_so.name + '_vof_t80.csv' #write comparison file - #np.array(actual.root.vof_t80).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.vof_t80).flatten(),decimal=10) + #np.array(actual['vof_t80']).tofile(os.path.join(self._scriptdir, expected_path),sep=",") + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['vof_t80']).flatten(),decimal=10) actual.close() diff --git a/proteus/tests/levelset/vortex2D/vof_vortex_2d_n.py b/test/levelset/vortex2D/vof_vortex_2d_n.py similarity index 98% rename from proteus/tests/levelset/vortex2D/vof_vortex_2d_n.py rename to test/levelset/vortex2D/vof_vortex_2d_n.py index 1356f92499..e43a3351fc 100644 --- a/proteus/tests/levelset/vortex2D/vof_vortex_2d_n.py +++ b/test/levelset/vortex2D/vof_vortex_2d_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/levelset/vortex2D/vof_vortex_2d_p.py b/test/levelset/vortex2D/vof_vortex_2d_p.py similarity index 97% rename from proteus/tests/levelset/vortex2D/vof_vortex_2d_p.py rename to test/levelset/vortex2D/vof_vortex_2d_p.py index c1d007d115..672e4c3859 100644 --- a/proteus/tests/levelset/vortex2D/vof_vortex_2d_p.py +++ b/test/levelset/vortex2D/vof_vortex_2d_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * from proteus.ctransportCoefficients import smoothedHeaviside diff --git a/proteus/tests/levelset/vortex2D/vortex2D.py b/test/levelset/vortex2D/vortex2D.py similarity index 96% rename from proteus/tests/levelset/vortex2D/vortex2D.py rename to test/levelset/vortex2D/vortex2D.py index c0de9aad20..80d82d1501 100644 --- a/proteus/tests/levelset/vortex2D/vortex2D.py +++ b/test/levelset/vortex2D/vortex2D.py @@ -1,7 +1,4 @@ -from __future__ import absolute_import -from __future__ import division #if True uses PETSc solvers -from past.utils import old_div parallel = False linearSmoother = None #compute mass balance statistics or not diff --git a/proteus/tests/linalgebra_tests/jac.bin b/test/linalgebra_tests/jac.bin similarity index 100% rename from proteus/tests/linalgebra_tests/jac.bin rename to test/linalgebra_tests/jac.bin diff --git a/proteus/tests/linalgebra_tests/sparse_mat_1.txt b/test/linalgebra_tests/sparse_mat_1.txt similarity index 100% rename from proteus/tests/linalgebra_tests/sparse_mat_1.txt rename to test/linalgebra_tests/sparse_mat_1.txt diff --git a/proteus/tests/linalgebra_tests/test_linear_algebra.py b/test/linalgebra_tests/test_linear_algebra.py similarity index 99% rename from proteus/tests/linalgebra_tests/test_linear_algebra.py rename to test/linalgebra_tests/test_linear_algebra.py index 51f41f999e..3491cad3b0 100644 --- a/proteus/tests/linalgebra_tests/test_linear_algebra.py +++ b/test/linalgebra_tests/test_linear_algebra.py @@ -1,5 +1,3 @@ -from builtins import range -from builtins import object from proteus import Comm, Profiling import numpy as np import numpy.testing as npt diff --git a/proteus/tests/linalgebra_tests/test_sparse_conversions.py b/test/linalgebra_tests/test_sparse_conversions.py similarity index 99% rename from proteus/tests/linalgebra_tests/test_sparse_conversions.py rename to test/linalgebra_tests/test_sparse_conversions.py index ef5bbc98be..c8201a4ef3 100644 --- a/proteus/tests/linalgebra_tests/test_sparse_conversions.py +++ b/test/linalgebra_tests/test_sparse_conversions.py @@ -124,4 +124,4 @@ def test_petsc4py_has_pressure_null_space_2(med_petsc_with_const_pressure): if __name__ == '__main__': test_sparse_2_dense() test_superlu_2_dense() - test_superlu_2_petsc() + test_superlu_2_petsc() \ No newline at end of file diff --git a/proteus/tests/makefile-fmmtest b/test/makefile-fmmtest similarity index 100% rename from proteus/tests/makefile-fmmtest rename to test/makefile-fmmtest diff --git a/proteus/tests/matrix_constructor/comparison_files/mass_reference_TH_2D.npy b/test/matrix_constructor/comparison_files/mass_reference_TH_2D.npy similarity index 100% rename from proteus/tests/matrix_constructor/comparison_files/mass_reference_TH_2D.npy rename to test/matrix_constructor/comparison_files/mass_reference_TH_2D.npy diff --git a/proteus/tests/matrix_constructor/comparison_files/mass_reference_c0p1_2D.txt b/test/matrix_constructor/comparison_files/mass_reference_c0p1_2D.txt similarity index 100% rename from proteus/tests/matrix_constructor/comparison_files/mass_reference_c0p1_2D.txt rename to test/matrix_constructor/comparison_files/mass_reference_c0p1_2D.txt diff --git a/proteus/tests/matrix_constructor/comparison_files/single_phase_THQuad_4_expected.data b/test/matrix_constructor/comparison_files/single_phase_THQuad_4_expected.data similarity index 100% rename from proteus/tests/matrix_constructor/comparison_files/single_phase_THQuad_4_expected.data rename to test/matrix_constructor/comparison_files/single_phase_THQuad_4_expected.data diff --git a/proteus/tests/matrix_constructor/comparison_files/velocity_laplace_C0P2_mesh.npy b/test/matrix_constructor/comparison_files/velocity_laplace_C0P2_mesh.npy similarity index 100% rename from proteus/tests/matrix_constructor/comparison_files/velocity_laplace_C0P2_mesh.npy rename to test/matrix_constructor/comparison_files/velocity_laplace_C0P2_mesh.npy diff --git a/proteus/tests/matrix_constructor/import_modules/mass_matrix_reference_C0P1_2D.py b/test/matrix_constructor/import_modules/mass_matrix_reference_C0P1_2D.py similarity index 98% rename from proteus/tests/matrix_constructor/import_modules/mass_matrix_reference_C0P1_2D.py rename to test/matrix_constructor/import_modules/mass_matrix_reference_C0P1_2D.py index 4c9739e3e7..5cfb299bbb 100644 --- a/proteus/tests/matrix_constructor/import_modules/mass_matrix_reference_C0P1_2D.py +++ b/test/matrix_constructor/import_modules/mass_matrix_reference_C0P1_2D.py @@ -1,4 +1,3 @@ -from builtins import range from proteus import iproteus as ip from proteus import default_p as p from proteus import default_n as n diff --git a/proteus/tests/matrix_constructor/import_modules/mass_matrix_reference_TH_2D.py b/test/matrix_constructor/import_modules/mass_matrix_reference_TH_2D.py similarity index 96% rename from proteus/tests/matrix_constructor/import_modules/mass_matrix_reference_TH_2D.py rename to test/matrix_constructor/import_modules/mass_matrix_reference_TH_2D.py index e2adbca179..06dc29caf5 100644 --- a/proteus/tests/matrix_constructor/import_modules/mass_matrix_reference_TH_2D.py +++ b/test/matrix_constructor/import_modules/mass_matrix_reference_TH_2D.py @@ -69,4 +69,4 @@ def getDBC(x,flag): ######################################################################## from proteus import * opts = None -ns = NumericalSolution.NS_base(so,[p],[n],so.sList,ip.opts) +ns = NumericalSolution.NS_base(so,[p],[n],so.sList,ip.opts) \ No newline at end of file diff --git a/proteus/tests/matrix_constructor/import_modules/singlephase_mass_matrix_THQuad_2D_4.py b/test/matrix_constructor/import_modules/singlephase_mass_matrix_THQuad_2D_4.py similarity index 95% rename from proteus/tests/matrix_constructor/import_modules/singlephase_mass_matrix_THQuad_2D_4.py rename to test/matrix_constructor/import_modules/singlephase_mass_matrix_THQuad_2D_4.py index b43c9d9b2b..c26717b92b 100644 --- a/proteus/tests/matrix_constructor/import_modules/singlephase_mass_matrix_THQuad_2D_4.py +++ b/test/matrix_constructor/import_modules/singlephase_mass_matrix_THQuad_2D_4.py @@ -57,4 +57,4 @@ def getDBC(x,flag): ######################################################################## from proteus import * opts = None -ns = NumericalSolution.NS_base(so,[p],[n],so.sList,ip.opts) +ns = NumericalSolution.NS_base(so,[p],[n],so.sList,ip.opts) \ No newline at end of file diff --git a/proteus/tests/matrix_constructor/test_mass_matrix_quad.py b/test/matrix_constructor/test_mass_matrix_quad.py similarity index 99% rename from proteus/tests/matrix_constructor/test_mass_matrix_quad.py rename to test/matrix_constructor/test_mass_matrix_quad.py index 0c682a05a0..92638ed34b 100644 --- a/proteus/tests/matrix_constructor/test_mass_matrix_quad.py +++ b/test/matrix_constructor/test_mass_matrix_quad.py @@ -58,4 +58,4 @@ def test_1(self): assert numpy.allclose(mass_mat,comparison_mat) if __name__ == '__main__': - pass + pass \ No newline at end of file diff --git a/proteus/tests/matrix_constructor/test_mass_matrix_reference_simplex.py b/test/matrix_constructor/test_mass_matrix_reference_simplex.py similarity index 99% rename from proteus/tests/matrix_constructor/test_mass_matrix_reference_simplex.py rename to test/matrix_constructor/test_mass_matrix_reference_simplex.py index a91ccbbaa8..80b58ba1c4 100644 --- a/proteus/tests/matrix_constructor/test_mass_matrix_reference_simplex.py +++ b/test/matrix_constructor/test_mass_matrix_reference_simplex.py @@ -95,4 +95,4 @@ def test_3(self): assert numpy.allclose(mass_mat,comparison_mat) if __name__ == '__main__': - pass + pass \ No newline at end of file diff --git a/proteus/tests/mesh_tests/comparison_files/poiseulle_global_xmf.output b/test/mesh_tests/comparison_files/poiseulle_global_xmf.output similarity index 100% rename from proteus/tests/mesh_tests/comparison_files/poiseulle_global_xmf.output rename to test/mesh_tests/comparison_files/poiseulle_global_xmf.output diff --git a/proteus/tests/mesh_tests/comparison_files/poiseulle_xmf.output b/test/mesh_tests/comparison_files/poiseulle_xmf.output similarity index 100% rename from proteus/tests/mesh_tests/comparison_files/poiseulle_xmf.output rename to test/mesh_tests/comparison_files/poiseulle_xmf.output diff --git a/proteus/tests/mesh_tests/import_modules/stokes_2d.py b/test/mesh_tests/import_modules/stokes_2d.py similarity index 96% rename from proteus/tests/mesh_tests/import_modules/stokes_2d.py rename to test/mesh_tests/import_modules/stokes_2d.py index e564e71204..466179d895 100644 --- a/proteus/tests/mesh_tests/import_modules/stokes_2d.py +++ b/test/mesh_tests/import_modules/stokes_2d.py @@ -28,4 +28,4 @@ numeric_scheme = opts.numeric_scheme useWeakBoundaryConditions = opts.useWeakBoundaryConditions solveIteratively = opts.solveIteratively -solveInParallel = opts.solveInParallel +solveInParallel = opts.solveInParallel \ No newline at end of file diff --git a/proteus/tests/mesh_tests/import_modules/stokes_2d_n.py b/test/mesh_tests/import_modules/stokes_2d_n.py similarity index 98% rename from proteus/tests/mesh_tests/import_modules/stokes_2d_n.py rename to test/mesh_tests/import_modules/stokes_2d_n.py index 7bbc0bb4fb..89f27a4b4e 100644 --- a/proteus/tests/mesh_tests/import_modules/stokes_2d_n.py +++ b/test/mesh_tests/import_modules/stokes_2d_n.py @@ -1,5 +1,3 @@ -from __future__ import print_function -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/mesh_tests/import_modules/stokes_2d_p.py b/test/mesh_tests/import_modules/stokes_2d_p.py similarity index 97% rename from proteus/tests/mesh_tests/import_modules/stokes_2d_p.py rename to test/mesh_tests/import_modules/stokes_2d_p.py index cd099352be..a0a2c56b28 100644 --- a/proteus/tests/mesh_tests/import_modules/stokes_2d_p.py +++ b/test/mesh_tests/import_modules/stokes_2d_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus import iproteus as ip from proteus.default_p import * diff --git a/proteus/tests/mesh_tests/test_interpolatedbathy.py b/test/mesh_tests/test_interpolatedbathy.py similarity index 98% rename from proteus/tests/mesh_tests/test_interpolatedbathy.py rename to test/mesh_tests/test_interpolatedbathy.py index e891cb85fb..5bd04408a0 100644 --- a/proteus/tests/mesh_tests/test_interpolatedbathy.py +++ b/test/mesh_tests/test_interpolatedbathy.py @@ -1,8 +1,3 @@ -from __future__ import print_function -from __future__ import division -from builtins import range -from builtins import object -from past.utils import old_div import os from proteus.Domain import InterpolatedBathymetryDomain @@ -50,8 +45,8 @@ def setupStepGauss(self): from math import sin,cos,pi,sqrt,exp #set up a fake LiDAR point set nPoints_x = nPoints_y = 21 - delta_x = old_div(2.0,float(nPoints_x-1)) - delta_y = old_div(2.0,float(nPoints_y-1)) + delta_x = 2.0/float(nPoints_x-1) + delta_y = 2.0/float(nPoints_y-1) bathy = np.zeros((nPoints_x*nPoints_y,3),'d') for i in range(nPoints_y): for j in range(nPoints_x): diff --git a/proteus/tests/mesh_tests/test_meshtools.py b/test/mesh_tests/test_meshtools.py similarity index 99% rename from proteus/tests/mesh_tests/test_meshtools.py rename to test/mesh_tests/test_meshtools.py index 1783f1681a..ffb98dbca7 100644 --- a/proteus/tests/mesh_tests/test_meshtools.py +++ b/test/mesh_tests/test_meshtools.py @@ -1,10 +1,3 @@ -from __future__ import print_function -from __future__ import division -from builtins import zip -from builtins import str -from builtins import range -from builtins import object -from past.utils import old_div from proteus import Comm, Profiling from collections import namedtuple import numpy.testing as npt @@ -182,7 +175,7 @@ def test_Triangle(self): assert (not t0.hasGeometricInfo) assert (t0.nodes < t1.nodes) t0.computeGeometricInfo() - assert ((t0.barycenter == EVec(old_div(1.0,3.0),old_div(1.0,3.0),0.0)).all()) + assert ((t0.barycenter == EVec(1.0/3.0,1.0/3.0,0.0)).all()) #needs more def test_Quadrilateral(self): @@ -222,7 +215,7 @@ def test_Tetrahedron(self): assert (not T0.nodes > T1.nodes) assert (not T0.hasGeometricInfo) T0.computeGeometricInfo() - assert (T0.volume == old_div(1.0,6.0)) + assert (T0.volume == 1.0/6.0) triangleDict={} for t in T0.triangles: triangleDict[t.nodes] = t diff --git a/proteus/tests/mesh_tests/test_quads.py b/test/mesh_tests/test_quads.py similarity index 96% rename from proteus/tests/mesh_tests/test_quads.py rename to test/mesh_tests/test_quads.py index 19a44fb0dc..46be9bce15 100644 --- a/proteus/tests/mesh_tests/test_quads.py +++ b/test/mesh_tests/test_quads.py @@ -4,10 +4,6 @@ Test module for 2D Quadrilateral Meshes """ -from __future__ import division -from builtins import range -from builtins import object -from past.utils import old_div from proteus.iproteus import * from proteus.test_utils import TestTools TestTools.addSubFolders( inspect.currentframe() ) @@ -94,7 +90,7 @@ def test_calc_hmax(simple_mesh): quad_mesh = mlMesh.meshList[0] for i in range(9): hmax_i = quad_mesh._calc_hmax(i) - h = quad_mesh._calc_pt_distance((-1.0,old_div(-1.,3.)),(old_div(-1.,3.),old_div(1.,3.))) + h = quad_mesh._calc_pt_distance((-1.0,-1./3.),(-1./3.,1./3.)) assert abs(h-hmax_i) < 1e-12 @pytest.mark.MeshTools diff --git a/proteus/tests/mesh_tests/test_unit_simplex.py b/test/mesh_tests/test_unit_simplex.py similarity index 97% rename from proteus/tests/mesh_tests/test_unit_simplex.py rename to test/mesh_tests/test_unit_simplex.py index 0873b65fed..ed123544a0 100644 --- a/proteus/tests/mesh_tests/test_unit_simplex.py +++ b/test/mesh_tests/test_unit_simplex.py @@ -4,8 +4,6 @@ Test module for generating unit_simplex elements """ -from __future__ import print_function -from builtins import object import pytest from proteus.iproteus import * diff --git a/proteus/tests/cylinder2D/conforming_rans3p/__init__.py b/test/periodic/__init__.py similarity index 100% rename from proteus/tests/cylinder2D/conforming_rans3p/__init__.py rename to test/periodic/__init__.py diff --git a/proteus/tests/periodic/comparison_files/comparison_ductp1t13dpghe0.4_velocity_t25.csv b/test/periodic/comparison_files/comparison_ductp1t13dpghe0.4_velocity_t25.csv similarity index 100% rename from proteus/tests/periodic/comparison_files/comparison_ductp1t13dpghe0.4_velocity_t25.csv rename to test/periodic/comparison_files/comparison_ductp1t13dpghe0.4_velocity_t25.csv diff --git a/proteus/tests/periodic/comparison_files/comparison_ductq1t12dpghe0.0975609756097561_velocity_t25.csv b/test/periodic/comparison_files/comparison_ductq1t12dpghe0.0975609756097561_velocity_t25.csv similarity index 100% rename from proteus/tests/periodic/comparison_files/comparison_ductq1t12dpghe0.0975609756097561_velocity_t25.csv rename to test/periodic/comparison_files/comparison_ductq1t12dpghe0.0975609756097561_velocity_t25.csv diff --git a/proteus/tests/periodic/dissipation_n.py b/test/periodic/dissipation_n.py similarity index 99% rename from proteus/tests/periodic/dissipation_n.py rename to test/periodic/dissipation_n.py index 49875cd6c2..6c112858df 100644 --- a/proteus/tests/periodic/dissipation_n.py +++ b/test/periodic/dissipation_n.py @@ -65,4 +65,4 @@ useEisenstatWalker = False maxNonlinearIts = 50 -maxLineSearches = 0 +maxLineSearches = 0 \ No newline at end of file diff --git a/proteus/tests/periodic/dissipation_p.py b/test/periodic/dissipation_p.py similarity index 99% rename from proteus/tests/periodic/dissipation_p.py rename to test/periodic/dissipation_p.py index 23937d6115..7360ef8d19 100644 --- a/proteus/tests/periodic/dissipation_p.py +++ b/test/periodic/dissipation_p.py @@ -61,4 +61,4 @@ def uOfXT(self, x, t): if ct.useRANS >= 2: dissipationInflow = dissipationInflow/(kInflow+1.0e-12) -initialConditions = {0: ConstantIC(cval=dissipationInflow*0.001)} +initialConditions = {0: ConstantIC(cval=dissipationInflow*0.001)} \ No newline at end of file diff --git a/proteus/tests/periodic/duct.py b/test/periodic/duct.py similarity index 99% rename from proteus/tests/periodic/duct.py rename to test/periodic/duct.py index 85cf564928..c436766b61 100644 --- a/proteus/tests/periodic/duct.py +++ b/test/periodic/duct.py @@ -634,4 +634,4 @@ def getDFBC_duct(x,flag): opts.timeOrder, opts.nd, mesh_name, - he) + he) \ No newline at end of file diff --git a/proteus/tests/periodic/ductib.py b/test/periodic/ductib.py similarity index 99% rename from proteus/tests/periodic/ductib.py rename to test/periodic/ductib.py index 0284384c9c..92f995a791 100644 --- a/proteus/tests/periodic/ductib.py +++ b/test/periodic/ductib.py @@ -663,4 +663,4 @@ def getDFBC_duct(x,flag): opts.timeOrder, opts.nd, mesh_name, - he) + he) \ No newline at end of file diff --git a/proteus/tests/periodic/hp025-new-weight/plot_soliton.py b/test/periodic/hp025-new-weight/plot_soliton.py similarity index 99% rename from proteus/tests/periodic/hp025-new-weight/plot_soliton.py rename to test/periodic/hp025-new-weight/plot_soliton.py index e074b9c619..2bb7144a10 100644 --- a/proteus/tests/periodic/hp025-new-weight/plot_soliton.py +++ b/test/periodic/hp025-new-weight/plot_soliton.py @@ -741,4 +741,4 @@ animationScene1.GoToNext() wave_ele.append([time[-1],max_numerical[-1],max_analytical[-1]]) import numpy as np -np.savetxt("wave_ele.txt",np.array(wave_ele)) +np.savetxt("wave_ele.txt",np.array(wave_ele)) \ No newline at end of file diff --git a/proteus/tests/periodic/la_periodicGauss_n.py b/test/periodic/la_periodicGauss_n.py similarity index 98% rename from proteus/tests/periodic/la_periodicGauss_n.py rename to test/periodic/la_periodicGauss_n.py index 4f12a7df08..b0fd69486a 100644 --- a/proteus/tests/periodic/la_periodicGauss_n.py +++ b/test/periodic/la_periodicGauss_n.py @@ -87,4 +87,4 @@ checkMass = True parallelPartitioningType = MeshParallelPartitioningTypes.element -nLayersOfOverlapForParallel = 0 +nLayersOfOverlapForParallel = 0 \ No newline at end of file diff --git a/proteus/tests/periodic/la_periodicGauss_p.py b/test/periodic/la_periodicGauss_p.py similarity index 99% rename from proteus/tests/periodic/la_periodicGauss_p.py rename to test/periodic/la_periodicGauss_p.py index e4b76cf408..270eca1f56 100644 --- a/proteus/tests/periodic/la_periodicGauss_p.py +++ b/test/periodic/la_periodicGauss_p.py @@ -161,4 +161,4 @@ def getFluxBC(x, flag): return lambda x,t: 0.0 advectiveFluxBoundaryConditions = {0:getFluxBC} -diffusiveFluxBoundaryConditions = {0:{}} +diffusiveFluxBoundaryConditions = {0:{}} \ No newline at end of file diff --git a/proteus/tests/periodic/ls_consrv_n.py b/test/periodic/ls_consrv_n.py similarity index 98% rename from proteus/tests/periodic/ls_consrv_n.py rename to test/periodic/ls_consrv_n.py index aefe843a94..0904795333 100644 --- a/proteus/tests/periodic/ls_consrv_n.py +++ b/test/periodic/ls_consrv_n.py @@ -59,4 +59,4 @@ useEisenstatWalker = False#True maxNonlinearIts = 50 -maxLineSearches = 0 +maxLineSearches = 0 \ No newline at end of file diff --git a/proteus/tests/periodic/ls_consrv_p.py b/test/periodic/ls_consrv_p.py similarity index 96% rename from proteus/tests/periodic/ls_consrv_p.py rename to test/periodic/ls_consrv_p.py index 84aaa11eb8..be30551d7d 100644 --- a/proteus/tests/periodic/ls_consrv_p.py +++ b/test/periodic/ls_consrv_p.py @@ -36,4 +36,4 @@ def uOfXT(self, X, t): initialConditions = {0: zero_phi()} -periodicDirichletConditions = {0:ct.getPDBC} +periodicDirichletConditions = {0:ct.getPDBC} \ No newline at end of file diff --git a/proteus/tests/periodic/ls_n.py b/test/periodic/ls_n.py similarity index 99% rename from proteus/tests/periodic/ls_n.py rename to test/periodic/ls_n.py index cbbe969b55..9945bd9e61 100644 --- a/proteus/tests/periodic/ls_n.py +++ b/test/periodic/ls_n.py @@ -70,4 +70,3 @@ maxNonlinearIts = 50 maxLineSearches = 0 - diff --git a/proteus/tests/periodic/ls_p.py b/test/periodic/ls_p.py similarity index 97% rename from proteus/tests/periodic/ls_p.py rename to test/periodic/ls_p.py index 1305537444..02c4d80ea4 100644 --- a/proteus/tests/periodic/ls_p.py +++ b/test/periodic/ls_p.py @@ -37,4 +37,4 @@ def uOfXT(self, x, t): initialConditions = {0: PHI_SOL()} -analyticalSolution = {0: PHI_SOL()} +analyticalSolution = {0: PHI_SOL()} \ No newline at end of file diff --git a/proteus/tests/periodic/periodic_solitary_waves.py b/test/periodic/periodic_solitary_waves.py similarity index 99% rename from proteus/tests/periodic/periodic_solitary_waves.py rename to test/periodic/periodic_solitary_waves.py index 5d522a58b8..0c586a5fe3 100644 --- a/proteus/tests/periodic/periodic_solitary_waves.py +++ b/test/periodic/periodic_solitary_waves.py @@ -277,4 +277,4 @@ def twpflowPressure_init(x, t): -smoothedHeaviside_integral(epsFact_consrv_heaviside*opts.he,phi))) nnx = int(math.ceil(opts.tank_dim[0]/opts.he)) -nny = int(math.ceil(opts.tank_dim[1]/opts.he)) +nny = int(math.ceil(opts.tank_dim[1]/opts.he)) \ No newline at end of file diff --git a/proteus/tests/periodic/periodic_solitary_waves_so.py b/test/periodic/periodic_solitary_waves_so.py similarity index 99% rename from proteus/tests/periodic/periodic_solitary_waves_so.py rename to test/periodic/periodic_solitary_waves_so.py index fae9356352..6d068613ab 100644 --- a/proteus/tests/periodic/periodic_solitary_waves_so.py +++ b/test/periodic/periodic_solitary_waves_so.py @@ -67,4 +67,3 @@ tnList = [0., ct.dt_init, ct.T] else: tnList=[0.0,ct.dt_init]+[ct.dt_init+ i*ct.dt_out for i in range(1,ct.nDTout+1)] - diff --git a/proteus/tests/periodic/petsc/petsc.options.schur.selfp_petsc.amg b/test/periodic/petsc/petsc.options.schur.selfp_petsc.amg similarity index 100% rename from proteus/tests/periodic/petsc/petsc.options.schur.selfp_petsc.amg rename to test/periodic/petsc/petsc.options.schur.selfp_petsc.amg diff --git a/proteus/tests/periodic/petsc/petsc.options.schur.selfp_petsc.gamg.superlu b/test/periodic/petsc/petsc.options.schur.selfp_petsc.gamg.superlu similarity index 81% rename from proteus/tests/periodic/petsc/petsc.options.schur.selfp_petsc.gamg.superlu rename to test/periodic/petsc/petsc.options.schur.selfp_petsc.gamg.superlu index a93fbe2c16..b8006852ae 100644 --- a/proteus/tests/periodic/petsc/petsc.options.schur.selfp_petsc.gamg.superlu +++ b/test/periodic/petsc/petsc.options.schur.selfp_petsc.gamg.superlu @@ -59,10 +59,10 @@ #-rans2p_fieldsplit_velocity_fieldsplit_w_pc_type hypre #-rans2p_fieldsplit_velocity_fieldsplit_w_pc_hypre_type boomeramg --ncls_ksp_type preonly -ncls_pc_type lu -ncls_pc_factor_mat_solver_type superlu_dist --vof_ksp_type preonly -vof_pc_type lu -vof_pc_factor_mat_solver_type superlu_dist --rdls_ksp_type preonly -rdls_pc_type lu -rdls_pc_factor_mat_solver_type superlu_dist --mcorr_ksp_type preonly -mcorr_pc_type lu -mcorr_pc_factor_mat_solver_type superlu_dist --kappa_ksp_type preonly -kappa_pc_type lu -kappa_pc_factor_mat_solver_type superlu_dist --dissipation_ksp_type preonly -dissipation_pc_type lu -dissipation_pc_factor_mat_solver_type superlu_dist --mesh_ksp_type preonly -mesh_pc_type lu -mesh_pc_factor_mat_solver_type superlu_dist +# -ncls_ksp_type preonly -ncls_pc_type lu -ncls_pc_factor_mat_solver_type superlu_dist +# -vof_ksp_type preonly -vof_pc_type lu -vof_pc_factor_mat_solver_type superlu_dist +# -rdls_ksp_type preonly -rdls_pc_type lu -rdls_pc_factor_mat_solver_type superlu_dist +# -mcorr_ksp_type preonly -mcorr_pc_type lu -mcorr_pc_factor_mat_solver_type superlu_dist +# -kappa_ksp_type preonly -kappa_pc_type lu -kappa_pc_factor_mat_solver_type superlu_dist +# -dissipation_ksp_type preonly -dissipation_pc_type lu -dissipation_pc_factor_mat_solver_type superlu_dist +# -mesh_ksp_type preonly -mesh_pc_type lu -mesh_pc_factor_mat_solver_type superlu_dist diff --git a/test/periodic/petsc/petsc.options.schur.selfp_petsc.superlu b/test/periodic/petsc/petsc.options.schur.selfp_petsc.superlu new file mode 100644 index 0000000000..0ebcdd6ef1 --- /dev/null +++ b/test/periodic/petsc/petsc.options.schur.selfp_petsc.superlu @@ -0,0 +1,40 @@ +# use a Schur Complement for the first set of solves + +#set petsc ksp object and preconditioner +#-log_view +-rans2p_ksp_type fgmres +-rans2p_ksp_gmres_modifiedgramschmidt 1 +-rans2p_ksp_gmres_restart 500 +#-rans2p_ksp_pc_side right + +# pc options +-rans2p_pc_fieldsplit_type schur +-rans2p_pc_fieldsplit_schur_fact_type upper +-rans2p_pc_fieldsplit_schur_precondition selfp + +# pressure block options +-rans2p_fieldsplit_pressure_ksp_type richardson # This should always be turned on +#-rans2p_fieldsplit_pressure_ksp_monitor_true_residual +-rans2p_fieldsplit_pressure_ksp_max_it 1 +#-rans2p_fieldsplit_pressure_pc_type hypre +#-rans2p_fieldsplit_pressure_pc_hypre_type boomeramg +#-rans2p_fieldsplit_pressure_pc_constant_null_space 1 +#-rans2p_fieldsplit_pressure_pc_hypre_boomeramg_coarsen_type PMIS +#-rans2p_fieldsplit_pressure_pc_hypre_boomeramg_interp_type classical +#-rans2p_fieldsplit_pressure_pc_type lu +-rans2p_fieldsplit_pressure_pc_factor_mat_solver_type superlu + +# direct solver for velocity block - ksp options +-rans2p_fieldsplit_velocity_ksp_type preonly +-rans2p_fieldsplit_velocity_pc_type lu +-rans2p_fieldsplit_velocity_pc_factor_mat_solver_type superlu +#-fieldsplit_velocity_ksp_view +#-fieldsplit_velocity_ksp_monitor_true_residual +#-fieldsplit_velocity_ksp_converged_reason +#-ncls_ksp_type preonly -ncls_pc_type lu -ncls_pc_factor_mat_solver_type superlu_dist +#-vof_ksp_type preonly -vof_pc_type lu -vof_pc_factor_mat_solver_type superlu_dist +#-rdls_ksp_type preonly -rdls_pc_type lu -rdls_pc_factor_mat_solver_type superlu_dist +#-mcorr_ksp_type preonly -mcorr_pc_type lu -mcorr_pc_factor_mat_solver_type superlu_dist +#-kappa_ksp_type preonly -kappa_pc_type lu -kappa_pc_factor_mat_solver_type superlu_dist +#-dissipation_ksp_type preonly -dissipation_pc_type lu -dissipation_pc_factor_mat_solver_type superlu_dist +#-mesh_ksp_type preonly -mesh_pc_type lu -mesh_pc_factor_mat_solver_type superlu_dist \ No newline at end of file diff --git a/proteus/tests/periodic/redist_n.py b/test/periodic/redist_n.py similarity index 98% rename from proteus/tests/periodic/redist_n.py rename to test/periodic/redist_n.py index e20c4ded58..289eb98c11 100644 --- a/proteus/tests/periodic/redist_n.py +++ b/test/periodic/redist_n.py @@ -83,4 +83,4 @@ tolFac = 0.0 linTolFac = 0.001 l_atol_res = 0.001*ct.rd_nl_atol_res -useEisenstatWalker = False#True +useEisenstatWalker = False#True \ No newline at end of file diff --git a/proteus/tests/periodic/redist_p.py b/test/periodic/redist_p.py similarity index 96% rename from proteus/tests/periodic/redist_p.py rename to test/periodic/redist_p.py index 56fe360b39..01648b7a84 100644 --- a/proteus/tests/periodic/redist_p.py +++ b/test/periodic/redist_p.py @@ -38,4 +38,4 @@ class PHI_IC: def uOfXT(self, x, t): return x[nd-1] - (ct.wave.eta(x,0) + ct.opts.water_level) -initialConditions = {0: PHI_IC()} +initialConditions = {0: PHI_IC()} \ No newline at end of file diff --git a/proteus/tests/periodic/test_periodic.py b/test/periodic/test_periodic.py similarity index 61% rename from proteus/tests/periodic/test_periodic.py rename to test/periodic/test_periodic.py index c64a3a6520..4773013e8c 100644 --- a/proteus/tests/periodic/test_periodic.py +++ b/test/periodic/test_periodic.py @@ -3,7 +3,8 @@ Test module for periodic boundary conditions and null space class. """ import proteus.test_utils.TestTools as TestTools -from proteus.iproteus import * +from proteus import defaults, default_s, Profiling, Context, Comm, NumericalSolution +from proteus.iproteus import opts Profiling.logLevel = 7 Profiling.verbose = True @@ -12,7 +13,7 @@ import sys import inspect import numpy as np -import tables +import h5py import pickle import petsc4py import pytest @@ -24,20 +25,23 @@ def load_periodic_duct(request): nList = [] pList = [] sList = [] - reload(duct) script_dir = os.path.dirname(__file__) - so = proteus.defaults.load_system('duct', - path = script_dir) + duct = defaults.load_source("duct",os.path.join(script_dir,'duct.py')) + so = defaults.load_system('duct',path = script_dir) + print(duct.opts) + from petsc4py import PETSc + OptDB=PETSc.Options() + print(OptDB) + OptDB.clear() for (pModule,nModule) in so.pnList: - if not isinstance(pModule, proteus.defaults.Physics_base): - pList.append(proteus.defaults.load_physics(pModule)) + if not isinstance(pModule, defaults.Physics_base): + pList.append(defaults.load_physics(pModule)) if pList[-1].name == None: pList[-1].name = pModule - nList.append(proteus.defaults.load_numerics(nModule)) + nList.append(defaults.load_numerics(nModule)) else: pList.append(pModule) nList.append(nModule) - # if so.sList == []: for i in range(len(so.pnList)): s = default_s @@ -48,32 +52,29 @@ def load_periodic_duct(request): @pytest.fixture() def load_periodic_opts_2D(request): - opts.contextOptions = "periodic=True grid=True nd=2 nnx=42 triangles=False spaceOrder=1 weak=True coord=True pc_type='selfp_petsc'" - proteus.Context.contextOptionsString=opts.contextOptions + Context.contextOptionsString="periodic=True grid=True nd=2 nnx=42 triangles=False spaceOrder=1 weak=True coord=True pc_type='selfp_petsc'" script_dir = os.path.dirname(__file__) relpath = 'petsc/petsc.options.schur.selfp_petsc.superlu' - opts.petscOptionsFile = os.path.join(script_dir,relpath) - proteus.Comm.argv = TestTools.fixture_set_petsc_options_from_file(opts.petscOptionsFile) + petscOptionsFile = os.path.join(script_dir,relpath) + Comm.argv = TestTools.fixture_set_petsc_options_from_file(petscOptionsFile) comm = Comm.init() @pytest.fixture() def load_periodic_opts_3D(request): - opts.contextOptions = "periodic=True nd=3 coord=True pc_type='selfp_petsc'" - proteus.Context.contextOptionsString=opts.contextOptions + Context.contextOptionsString="periodic=True nd=3 coord=True pc_type='selfp_petsc'" script_dir = os.path.dirname(__file__) relpath = 'petsc/petsc.options.schur.selfp_petsc.superlu' - opts.petscOptionsFile = os.path.join(script_dir,relpath) - proteus.Comm.argv = TestTools.fixture_set_petsc_options_from_file(opts.petscOptionsFile) + petscOptionsFile = os.path.join(script_dir,relpath) + Comm.argv = TestTools.fixture_set_petsc_options_from_file(petscOptionsFile) comm = Comm.init() @pytest.fixture() def load_periodic_opts_3D_T2(request): - opts.contextOptions = "periodic=True nd=3 coord=True pc_type='selfp_petsc' A_block_AMG=True" - proteus.Context.contextOptionsString=opts.contextOptions + Context.contextOptionsString="periodic=True nd=3 coord=True pc_type='selfp_petsc' A_block_AMG=True" script_dir = os.path.dirname(__file__) - relpath = 'petsc/petsc.options.schur.selfp_petsc.amg' - opts.petscOptionsFile = os.path.join(script_dir,relpath) - proteus.Comm.argv = TestTools.fixture_set_petsc_options_from_file(opts.petscOptionsFile) + relpath = 'petsc/petsc.options.schur.selfp_petsc.gamg.superlu' + petscOptionsFile = os.path.join(script_dir,relpath) + Comm.argv = TestTools.fixture_set_petsc_options_from_file(petscOptionsFile) comm = Comm.init() def test_periodic_2D(load_periodic_opts_2D, @@ -85,12 +86,12 @@ def test_periodic_2D(load_periodic_opts_2D, opts) ns.calculateSolution('test_run') script_dir = os.path.dirname(__file__) - actual = tables.open_file('ductq1t12dpghe0.0975609756097561.h5') + actual = h5py.File('ductq1t12dpghe0.0975609756097561.h5') expected_path = 'comparison_files/' + 'comparison_' + 'ductq1t12dpghe0.0975609756097561' + '_velocity_t25.csv' #write comparison file - #np.array(actual.root.velocity_t25).tofile(os.path.join(script_dir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(script_dir, expected_path),sep=","),np.array(actual.root.velocity_t25).flatten(),decimal=7) + #np.array(actual['velocity_t25']).tofile(os.path.join(script_dir, expected_path),sep=",") + np.testing.assert_almost_equal(np.fromfile(os.path.join(script_dir, expected_path),sep=","),np.array(actual['velocity_t25']).flatten(),decimal=7) actual.close() @@ -105,12 +106,12 @@ def test_periodic_3D(load_periodic_opts_3D, ns.calculateSolution('test_run') script_dir = os.path.dirname(__file__) - actual = tables.open_file('ductp1t13dpghe0.4.h5') + actual = h5py.File('ductp1t13dpghe0.4.h5') expected_path = 'comparison_files/' + 'comparison_' + 'ductp1t13dpghe0.4' + '_velocity_t25.csv' #write comparison file - #np.array(actual.root.velocity_t25).tofile(os.path.join(script_dir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(script_dir, expected_path),sep=","),np.array(actual.root.velocity_t25).flatten(),decimal=10) + #np.array(actual['velocity_t25']).tofile(os.path.join(script_dir, expected_path),sep=",") + np.testing.assert_almost_equal(np.fromfile(os.path.join(script_dir, expected_path),sep=","),np.array(actual['velocity_t25']).flatten(),decimal=10) actual.close() def test_periodic_3D_amg(load_periodic_opts_3D_T2, @@ -123,11 +124,7 @@ def test_periodic_3D_amg(load_periodic_opts_3D_T2, ns.calculateSolution('test_run') script_dir = os.path.dirname(__file__) - actual = tables.open_file('ductp1t13dpghe0.4.h5') + actual = h5py.File('ductp1t13dpghe0.4.h5') expected_path = 'comparison_files/' + 'comparison_' + 'ductp1t13dpghe0.4' + '_velocity_t25.csv' - np.testing.assert_almost_equal(np.fromfile(os.path.join(script_dir, expected_path),sep=","),np.array(actual.root.velocity_t25).flatten(),decimal=6) + np.testing.assert_almost_equal(np.fromfile(os.path.join(script_dir, expected_path),sep=","),np.array(actual['velocity_t25']).flatten(),decimal=6) actual.close() - - - - diff --git a/proteus/tests/periodic/tetgen.ele b/test/periodic/tetgen.ele similarity index 100% rename from proteus/tests/periodic/tetgen.ele rename to test/periodic/tetgen.ele diff --git a/proteus/tests/periodic/tetgen.face b/test/periodic/tetgen.face similarity index 100% rename from proteus/tests/periodic/tetgen.face rename to test/periodic/tetgen.face diff --git a/proteus/tests/periodic/tetgen.node b/test/periodic/tetgen.node similarity index 100% rename from proteus/tests/periodic/tetgen.node rename to test/periodic/tetgen.node diff --git a/proteus/tests/periodic/twp_navier_stokes_n.py b/test/periodic/twp_navier_stokes_n.py similarity index 98% rename from proteus/tests/periodic/twp_navier_stokes_n.py rename to test/periodic/twp_navier_stokes_n.py index 1a17b69185..4eb5c61be3 100644 --- a/proteus/tests/periodic/twp_navier_stokes_n.py +++ b/test/periodic/twp_navier_stokes_n.py @@ -77,4 +77,4 @@ useEisenstatWalker = False#True maxNonlinearIts = 50 maxLineSearches = 0 -#conservativeFlux = {0:'pwl-bdm-opt'} +#conservativeFlux = {0:'pwl-bdm-opt'} \ No newline at end of file diff --git a/proteus/tests/periodic/twp_navier_stokes_p.py b/test/periodic/twp_navier_stokes_p.py similarity index 99% rename from proteus/tests/periodic/twp_navier_stokes_p.py rename to test/periodic/twp_navier_stokes_p.py index bc319707c4..1432e1f9b0 100644 --- a/proteus/tests/periodic/twp_navier_stokes_p.py +++ b/test/periodic/twp_navier_stokes_p.py @@ -128,4 +128,4 @@ def uOfXT(self, x, t): 1: U_IC(), 2: V_IC()} if nd == 3: - initialConditions[3] = W_IC() + initialConditions[3] = W_IC() \ No newline at end of file diff --git a/proteus/tests/periodic/vof_n.py b/test/periodic/vof_n.py similarity index 99% rename from proteus/tests/periodic/vof_n.py rename to test/periodic/vof_n.py index 0bc2f62517..92dc064493 100644 --- a/proteus/tests/periodic/vof_n.py +++ b/test/periodic/vof_n.py @@ -70,4 +70,3 @@ maxNonlinearIts = 50 maxLineSearches = 0 - diff --git a/proteus/tests/periodic/vof_p.py b/test/periodic/vof_p.py similarity index 97% rename from proteus/tests/periodic/vof_p.py rename to test/periodic/vof_p.py index 6ce70f2a41..b1147bd654 100644 --- a/proteus/tests/periodic/vof_p.py +++ b/test/periodic/vof_p.py @@ -49,4 +49,4 @@ def uOfXT(self, x, t): + ct.opts.water_level))) initialConditions = {0: VF_SOL()} -analyticalSolution = {0: VF_SOL()} +analyticalSolution = {0: VF_SOL()} \ No newline at end of file diff --git a/proteus/tests/MiscibleDisplacement/L2_batch.py b/test/poisson_2d/L2_batch.py similarity index 99% rename from proteus/tests/MiscibleDisplacement/L2_batch.py rename to test/poisson_2d/L2_batch.py index 0e5a8ed516..7056cac62d 100644 --- a/proteus/tests/MiscibleDisplacement/L2_batch.py +++ b/test/poisson_2d/L2_batch.py @@ -10,4 +10,4 @@ simFlags['storeTimes'] = ['Last'] # start -quit +quit \ No newline at end of file diff --git a/proteus/tests/cylinder2D/ibm_method/__init__.py b/test/poisson_2d/__init__.py similarity index 100% rename from proteus/tests/cylinder2D/ibm_method/__init__.py rename to test/poisson_2d/__init__.py diff --git a/proteus/tests/poisson_2d/issues.txt b/test/poisson_2d/issues.txt similarity index 100% rename from proteus/tests/poisson_2d/issues.txt rename to test/poisson_2d/issues.txt diff --git a/proteus/tests/poisson_2d/poisson_het_2d_c0pk_n.py b/test/poisson_2d/poisson_het_2d_c0pk_n.py similarity index 96% rename from proteus/tests/poisson_2d/poisson_het_2d_c0pk_n.py rename to test/poisson_2d/poisson_het_2d_c0pk_n.py index 85b909f037..751b40794c 100644 --- a/proteus/tests/poisson_2d/poisson_het_2d_c0pk_n.py +++ b/test/poisson_2d/poisson_het_2d_c0pk_n.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import range from proteus import * from proteus.default_n import * from proteus import defaults diff --git a/proteus/tests/poisson_2d/poisson_het_2d_dgpk_n.py b/test/poisson_2d/poisson_het_2d_dgpk_n.py similarity index 97% rename from proteus/tests/poisson_2d/poisson_het_2d_dgpk_n.py rename to test/poisson_2d/poisson_het_2d_dgpk_n.py index e5d9e331d2..d45e4b2302 100644 --- a/proteus/tests/poisson_2d/poisson_het_2d_dgpk_n.py +++ b/test/poisson_2d/poisson_het_2d_dgpk_n.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import range from proteus import * from proteus.default_n import * from proteus import defaults diff --git a/proteus/tests/poisson_2d/poisson_het_2d_ncp1_n.py b/test/poisson_2d/poisson_het_2d_ncp1_n.py similarity index 95% rename from proteus/tests/poisson_2d/poisson_het_2d_ncp1_n.py rename to test/poisson_2d/poisson_het_2d_ncp1_n.py index 4ccff3d9ca..5b44f19d87 100644 --- a/proteus/tests/poisson_2d/poisson_het_2d_ncp1_n.py +++ b/test/poisson_2d/poisson_het_2d_ncp1_n.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import range from proteus import * from proteus.default_n import * from .poisson_het_2d_p import * @@ -61,4 +59,3 @@ cfluxtag = 'p1-nc' conservativeFlux = dict((i,cfluxtag) for i in range(nc)) - diff --git a/proteus/tests/poisson_2d/poisson_het_2d_p.py b/test/poisson_2d/poisson_het_2d_p.py similarity index 98% rename from proteus/tests/poisson_2d/poisson_het_2d_p.py rename to test/poisson_2d/poisson_het_2d_p.py index bfa1a784fe..967adc4c3d 100644 --- a/proteus/tests/poisson_2d/poisson_het_2d_p.py +++ b/test/poisson_2d/poisson_het_2d_p.py @@ -1,5 +1,3 @@ -from builtins import range -from builtins import object from proteus import * from proteus.default_p import * from proteus import defaults @@ -147,4 +145,3 @@ def getDiffFluxBC5(x,flag): fluxBoundaryConditions = dict((i,'setFlow') for i in range(nc)) - diff --git a/proteus/tests/poisson_2d/square4x4.3dm b/test/poisson_2d/square4x4.3dm similarity index 100% rename from proteus/tests/poisson_2d/square4x4.3dm rename to test/poisson_2d/square4x4.3dm diff --git a/proteus/tests/poisson_2d/square4x4.bc b/test/poisson_2d/square4x4.bc similarity index 100% rename from proteus/tests/poisson_2d/square4x4.bc rename to test/poisson_2d/square4x4.bc diff --git a/proteus/tests/poisson_2d/test_poisson2d.py b/test/poisson_2d/test_poisson2d.py similarity index 98% rename from proteus/tests/poisson_2d/test_poisson2d.py rename to test/poisson_2d/test_poisson2d.py index 06d9d31f7c..662d73204d 100644 --- a/proteus/tests/poisson_2d/test_poisson2d.py +++ b/test/poisson_2d/test_poisson2d.py @@ -9,10 +9,6 @@ \nabla \cdot \left( a(x) \nabla u \right) = f(x) """ -from __future__ import print_function -from __future__ import absolute_import -from builtins import zip -from builtins import object from proteus.iproteus import * import os import numpy as np diff --git a/proteus/tests/porosity/mesh.1.neigh b/test/porosity/mesh.1.neigh similarity index 100% rename from proteus/tests/porosity/mesh.1.neigh rename to test/porosity/mesh.1.neigh diff --git a/proteus/tests/porosity/mesh.1.poly b/test/porosity/mesh.1.poly similarity index 100% rename from proteus/tests/porosity/mesh.1.poly rename to test/porosity/mesh.1.poly diff --git a/proteus/tests/porosity/mesh.edge b/test/porosity/mesh.edge similarity index 100% rename from proteus/tests/porosity/mesh.edge rename to test/porosity/mesh.edge diff --git a/proteus/tests/porosity/mesh.ele b/test/porosity/mesh.ele similarity index 100% rename from proteus/tests/porosity/mesh.ele rename to test/porosity/mesh.ele diff --git a/proteus/tests/porosity/mesh.node b/test/porosity/mesh.node similarity index 100% rename from proteus/tests/porosity/mesh.node rename to test/porosity/mesh.node diff --git a/proteus/tests/porosity/mesh.poly b/test/porosity/mesh.poly similarity index 100% rename from proteus/tests/porosity/mesh.poly rename to test/porosity/mesh.poly diff --git a/proteus/tests/porosity/sloshing.py b/test/porosity/sloshing.py similarity index 99% rename from proteus/tests/porosity/sloshing.py rename to test/porosity/sloshing.py index cdb1214976..db883341ae 100644 --- a/proteus/tests/porosity/sloshing.py +++ b/test/porosity/sloshing.py @@ -52,7 +52,7 @@ ] # run time options context_options += [ - ("T", 3. ,"Simulation time in s"), + ("T", 0.1 ,"Simulation time in s"), ("dt_init", 0.001 ,"Value of initial time step"), ("dt_fixed", None, "Value of maximum time step"), ("archiveAllSteps", False, "archive every steps"), @@ -171,7 +171,7 @@ 'y-': np.array([ 0.0, -1.0, 0.0]), 'y+': np.array([ 0.0, 1.0, 0.0]), }) - tank.facets = np.array([[[0, 1, 2, 3, 4, 5, 6]]]) + tank.facets = np.array([[[0, 1, 2, 3, 4, 5]]]) tank.facetFlags = np.array([1]) @@ -388,7 +388,7 @@ def signedDistance(x, t): myTpFlowProblem = TpFlow.TwoPhaseFlowProblem() -myTpFlowProblem.outputStepping.final_time = 0.1 +myTpFlowProblem.outputStepping.final_time = opts.T myTpFlowProblem.outputStepping.dt_init = 0.01 myTpFlowProblem.outputStepping.dt_output = 0.1 myTpFlowProblem.outputStepping.dt_fixed = 0.01 diff --git a/proteus/tests/porosity/test_porosity.py b/test/porosity/test_porosity.py similarity index 97% rename from proteus/tests/porosity/test_porosity.py rename to test/porosity/test_porosity.py index 9430dc62c7..2ec89f0f9a 100644 --- a/proteus/tests/porosity/test_porosity.py +++ b/test/porosity/test_porosity.py @@ -39,4 +39,4 @@ def test_massConservation_wPorosity_2D(mcorr_nl_atol_res=1e-10): mcorr.append([float(lines[i+1].split()[7][:-1]),float(j.split()[-1])]) nSteps +=1 if (mcorr[0][1]+nSteps*mcorr_nl_atol_res)<=mcorr[-1][-1] or (mcorr[0][1]-nSteps*mcorr_nl_atol_res)>=mcorr[-1][-1]: - pytest.fail("Mass is not being conserved within nonlinear residual tolerance for MCorr. Absolute mass error: {0:e}\n".format(abs(mcorr[-1][-1]-mcorr[0][1]))) + pytest.fail("Mass is not being conserved within nonlinear residual tolerance for MCorr. Absolute mass error: {0:e}\n".format(abs(mcorr[-1][-1]-mcorr[0][1]))) \ No newline at end of file diff --git a/proteus/tests/post_processing/comparison_files/bdm2_ref_proj_mat.txt b/test/post_processing/comparison_files/bdm2_ref_proj_mat.txt similarity index 100% rename from proteus/tests/post_processing/comparison_files/bdm2_ref_proj_mat.txt rename to test/post_processing/comparison_files/bdm2_ref_proj_mat.txt diff --git a/proteus/tests/post_processing/comparison_files/bdm2_reference_simplex_mat.data b/test/post_processing/comparison_files/bdm2_reference_simplex_mat.data similarity index 100% rename from proteus/tests/post_processing/comparison_files/bdm2_reference_simplex_mat.data rename to test/post_processing/comparison_files/bdm2_reference_simplex_mat.data diff --git a/proteus/tests/post_processing/comparison_files/bdm2_reference_simplex_rhs.data b/test/post_processing/comparison_files/bdm2_reference_simplex_rhs.data similarity index 100% rename from proteus/tests/post_processing/comparison_files/bdm2_reference_simplex_rhs.data rename to test/post_processing/comparison_files/bdm2_reference_simplex_rhs.data diff --git a/proteus/tests/post_processing/comparison_files/bdm_bdy_func_values.npy b/test/post_processing/comparison_files/bdm_bdy_func_values.npy similarity index 100% rename from proteus/tests/post_processing/comparison_files/bdm_bdy_func_values.npy rename to test/post_processing/comparison_files/bdm_bdy_func_values.npy diff --git a/proteus/tests/post_processing/comparison_files/bdm_bdy_func_values_mesh_8.npy b/test/post_processing/comparison_files/bdm_bdy_func_values_mesh_8.npy similarity index 100% rename from proteus/tests/post_processing/comparison_files/bdm_bdy_func_values_mesh_8.npy rename to test/post_processing/comparison_files/bdm_bdy_func_values_mesh_8.npy diff --git a/proteus/tests/post_processing/comparison_files/bdm_bdy_func_values_trig.npy b/test/post_processing/comparison_files/bdm_bdy_func_values_trig.npy similarity index 100% rename from proteus/tests/post_processing/comparison_files/bdm_bdy_func_values_trig.npy rename to test/post_processing/comparison_files/bdm_bdy_func_values_trig.npy diff --git a/proteus/tests/post_processing/comparison_files/bdm_flux_values_mesh_8.npy b/test/post_processing/comparison_files/bdm_flux_values_mesh_8.npy similarity index 100% rename from proteus/tests/post_processing/comparison_files/bdm_flux_values_mesh_8.npy rename to test/post_processing/comparison_files/bdm_flux_values_mesh_8.npy diff --git a/proteus/tests/post_processing/comparison_files/bdm_func_values.npy b/test/post_processing/comparison_files/bdm_func_values.npy similarity index 100% rename from proteus/tests/post_processing/comparison_files/bdm_func_values.npy rename to test/post_processing/comparison_files/bdm_func_values.npy diff --git a/proteus/tests/post_processing/comparison_files/bdm_func_values_mesh_8.npy b/test/post_processing/comparison_files/bdm_func_values_mesh_8.npy similarity index 100% rename from proteus/tests/post_processing/comparison_files/bdm_func_values_mesh_8.npy rename to test/post_processing/comparison_files/bdm_func_values_mesh_8.npy diff --git a/proteus/tests/post_processing/comparison_files/bdm_func_values_trig.npy b/test/post_processing/comparison_files/bdm_func_values_trig.npy similarity index 100% rename from proteus/tests/post_processing/comparison_files/bdm_func_values_trig.npy rename to test/post_processing/comparison_files/bdm_func_values_trig.npy diff --git a/proteus/tests/post_processing/comparison_files/trig_velocity_rep.npy b/test/post_processing/comparison_files/trig_velocity_rep.npy similarity index 100% rename from proteus/tests/post_processing/comparison_files/trig_velocity_rep.npy rename to test/post_processing/comparison_files/trig_velocity_rep.npy diff --git a/proteus/tests/post_processing/development_tests/P2_LN.py b/test/post_processing/development_tests/P2_LN.py similarity index 99% rename from proteus/tests/post_processing/development_tests/P2_LN.py rename to test/post_processing/development_tests/P2_LN.py index d50745bbce..bf3d240b8b 100644 --- a/proteus/tests/post_processing/development_tests/P2_LN.py +++ b/test/post_processing/development_tests/P2_LN.py @@ -50,4 +50,3 @@ def test_BDM_P1(): comm = Comm.init() test_BDM_P1() # test_BDM2_P2() - diff --git a/proteus/tests/post_processing/development_tests/example1.py b/test/post_processing/development_tests/example1.py similarity index 98% rename from proteus/tests/post_processing/development_tests/example1.py rename to test/post_processing/development_tests/example1.py index 53b953202e..648bc455d1 100644 --- a/proteus/tests/post_processing/development_tests/example1.py +++ b/test/post_processing/development_tests/example1.py @@ -1,5 +1,3 @@ -from builtins import range -from builtins import object from proteus import iproteus as ip from proteus import default_p as p from proteus import default_n as n diff --git a/proteus/tests/post_processing/development_tests/expected_output.py b/test/post_processing/development_tests/expected_output.py similarity index 96% rename from proteus/tests/post_processing/development_tests/expected_output.py rename to test/post_processing/development_tests/expected_output.py index 40a7adbdbd..255f2d8c1b 100644 --- a/proteus/tests/post_processing/development_tests/expected_output.py +++ b/test/post_processing/development_tests/expected_output.py @@ -26,4 +26,4 @@ [1, 0, 3, 0, 1, 0], [2, 0, 1, 0, 1, 0], [4, 0, 2, 0, 1, 0], - [5, 2, 1, 0, 1, 1]]) + [5, 2, 1, 0, 1, 1]]) \ No newline at end of file diff --git a/proteus/tests/post_processing/import_modules/bdm2_3d_face_func_vals.data b/test/post_processing/import_modules/bdm2_3d_face_func_vals.data similarity index 100% rename from proteus/tests/post_processing/import_modules/bdm2_3d_face_func_vals.data rename to test/post_processing/import_modules/bdm2_3d_face_func_vals.data diff --git a/proteus/tests/post_processing/import_modules/bdm2_3d_interior_func_vals.data b/test/post_processing/import_modules/bdm2_3d_interior_func_vals.data similarity index 100% rename from proteus/tests/post_processing/import_modules/bdm2_3d_interior_func_vals.data rename to test/post_processing/import_modules/bdm2_3d_interior_func_vals.data diff --git a/proteus/tests/post_processing/import_modules/bdm_tests_3Dtemplate.py b/test/post_processing/import_modules/bdm_tests_3Dtemplate.py similarity index 98% rename from proteus/tests/post_processing/import_modules/bdm_tests_3Dtemplate.py rename to test/post_processing/import_modules/bdm_tests_3Dtemplate.py index 1983d47b4f..c3b378c7e4 100644 --- a/proteus/tests/post_processing/import_modules/bdm_tests_3Dtemplate.py +++ b/test/post_processing/import_modules/bdm_tests_3Dtemplate.py @@ -1,5 +1,3 @@ -from builtins import range -from builtins import object from proteus import iproteus as ip from proteus import default_p as p from proteus import default_n as n diff --git a/proteus/tests/post_processing/import_modules/bdm_tests_template.py b/test/post_processing/import_modules/bdm_tests_template.py similarity index 98% rename from proteus/tests/post_processing/import_modules/bdm_tests_template.py rename to test/post_processing/import_modules/bdm_tests_template.py index fff7139b7f..69d26a7a51 100644 --- a/proteus/tests/post_processing/import_modules/bdm_tests_template.py +++ b/test/post_processing/import_modules/bdm_tests_template.py @@ -1,5 +1,3 @@ -from builtins import range -from builtins import object from proteus import iproteus as ip from proteus import default_p as p from proteus import default_n as n diff --git a/proteus/tests/post_processing/import_modules/bdm_tests_template_3dmesh.py b/test/post_processing/import_modules/bdm_tests_template_3dmesh.py similarity index 98% rename from proteus/tests/post_processing/import_modules/bdm_tests_template_3dmesh.py rename to test/post_processing/import_modules/bdm_tests_template_3dmesh.py index 995066739d..1a91842c20 100644 --- a/proteus/tests/post_processing/import_modules/bdm_tests_template_3dmesh.py +++ b/test/post_processing/import_modules/bdm_tests_template_3dmesh.py @@ -1,5 +1,3 @@ -from builtins import range -from builtins import object from proteus import iproteus as ip from proteus import default_p as p from proteus import default_n as n diff --git a/proteus/tests/post_processing/import_modules/bdm_tests_template_mesh8.py b/test/post_processing/import_modules/bdm_tests_template_mesh8.py similarity index 98% rename from proteus/tests/post_processing/import_modules/bdm_tests_template_mesh8.py rename to test/post_processing/import_modules/bdm_tests_template_mesh8.py index c665f03184..c3666de612 100644 --- a/proteus/tests/post_processing/import_modules/bdm_tests_template_mesh8.py +++ b/test/post_processing/import_modules/bdm_tests_template_mesh8.py @@ -1,5 +1,3 @@ -from builtins import range -from builtins import object from proteus import iproteus as ip from proteus import default_p as p from proteus import default_n as n diff --git a/proteus/tests/post_processing/import_modules/blockDomain.py b/test/post_processing/import_modules/blockDomain.py similarity index 95% rename from proteus/tests/post_processing/import_modules/blockDomain.py rename to test/post_processing/import_modules/blockDomain.py index bbaad414db..a7e31e759a 100644 --- a/proteus/tests/post_processing/import_modules/blockDomain.py +++ b/test/post_processing/import_modules/blockDomain.py @@ -1,9 +1,4 @@ #!/usr/bin/env python - -from __future__ import print_function -from __future__ import division -from builtins import range -from past.utils import old_div import numpy def genPoly(polyfileBase="blockDomain", @@ -12,7 +7,7 @@ def genPoly(polyfileBase="blockDomain", """ create a simple block domain in 2d """ - dx=old_div(Lx,nx); dy = old_div(Ly,ny) + dx=Lx/nx; dy = Ly/ny vertices = [] for j in range(ny+1): diff --git a/proteus/tests/post_processing/import_modules/reference_simplex_keep.ele b/test/post_processing/import_modules/reference_simplex_keep.ele similarity index 100% rename from proteus/tests/post_processing/import_modules/reference_simplex_keep.ele rename to test/post_processing/import_modules/reference_simplex_keep.ele diff --git a/proteus/tests/post_processing/import_modules/reference_simplex_keep.face b/test/post_processing/import_modules/reference_simplex_keep.face similarity index 100% rename from proteus/tests/post_processing/import_modules/reference_simplex_keep.face rename to test/post_processing/import_modules/reference_simplex_keep.face diff --git a/proteus/tests/post_processing/import_modules/reference_simplex_keep.node b/test/post_processing/import_modules/reference_simplex_keep.node similarity index 100% rename from proteus/tests/post_processing/import_modules/reference_simplex_keep.node rename to test/post_processing/import_modules/reference_simplex_keep.node diff --git a/proteus/tests/post_processing/import_modules/reference_simplex_keep.poly b/test/post_processing/import_modules/reference_simplex_keep.poly similarity index 100% rename from proteus/tests/post_processing/import_modules/reference_simplex_keep.poly rename to test/post_processing/import_modules/reference_simplex_keep.poly diff --git a/proteus/tests/post_processing/import_modules/sShaped_block_2d_n.py b/test/post_processing/import_modules/sShaped_block_2d_n.py similarity index 97% rename from proteus/tests/post_processing/import_modules/sShaped_block_2d_n.py rename to test/post_processing/import_modules/sShaped_block_2d_n.py index 990a175884..f832067c3e 100644 --- a/proteus/tests/post_processing/import_modules/sShaped_block_2d_n.py +++ b/test/post_processing/import_modules/sShaped_block_2d_n.py @@ -1,5 +1,3 @@ -from __future__ import print_function -from __future__ import absolute_import from proteus import * from proteus.default_n import * from .sShaped_block_2d_p import * @@ -100,4 +98,3 @@ #levelLinearSolver = PETSc linTolFac = 1.0e-10 - diff --git a/proteus/tests/post_processing/import_modules/sShaped_block_2d_p.py b/test/post_processing/import_modules/sShaped_block_2d_p.py similarity index 97% rename from proteus/tests/post_processing/import_modules/sShaped_block_2d_p.py rename to test/post_processing/import_modules/sShaped_block_2d_p.py index fbd90006c2..a5114f469f 100644 --- a/proteus/tests/post_processing/import_modules/sShaped_block_2d_p.py +++ b/test/post_processing/import_modules/sShaped_block_2d_p.py @@ -1,8 +1,3 @@ -from __future__ import absolute_import -from __future__ import division -from builtins import range -from past.utils import old_div -from builtins import object from proteus import * from proteus.default_p import * from . import blockDomain @@ -165,7 +160,7 @@ def initializeElementBoundaryQuadrature(self,t,cebq,cebq_global): x = cebq_global['x'][ebN,k]; numer = 2.0*self.a_types[material_left](x,t)[i,j]*self.a_types[material_right](x,t)[i,j] denom = self.a_types[material_left](x,t)[i,j] + self.a_types[material_right](x,t)[i,j] + 1.0e-20 - cebq_global[('a',ci,ci)][eN,k,i*nd+j] = old_div(numer,denom) + cebq_global[('a',ci,ci)][eN,k,i*nd+j] = numer/denom for eN in range(cebq['x'].shape[0]): for ebN_local in range(cebq['x'].shape[1]): ebN = self.elementBoundariesArray[eN,ebN_local] @@ -181,7 +176,7 @@ def initializeElementBoundaryQuadrature(self,t,cebq,cebq_global): for j in range(nd): numer = 2.0*self.a_types[material_left](x,t)[i,j]*self.a_types[material_right](x,t)[i,j] denom = self.a_types[material_left](x,t)[i,j] + self.a_types[material_right](x,t)[i,j] + 1.0e-20 - cebq[('a',ci,ci)][eN,ebN_local,k,i*nd+j] = old_div(numer,denom) + cebq[('a',ci,ci)][eN,ebN_local,k,i*nd+j] = numer/denom # # # diff --git a/proteus/tests/post_processing/save_velocity_batch.py b/test/post_processing/save_velocity_batch.py similarity index 94% rename from proteus/tests/post_processing/save_velocity_batch.py rename to test/post_processing/save_velocity_batch.py index 4cf21c6e78..a7d9638fd9 100644 --- a/proteus/tests/post_processing/save_velocity_batch.py +++ b/test/post_processing/save_velocity_batch.py @@ -1,3 +1,3 @@ simFlagsList[0]['storeQuantities'] = ['u',"q:('velocity',0)"] start -end +end \ No newline at end of file diff --git a/proteus/tests/post_processing/test_bdm2_mesh8.py b/test/post_processing/test_bdm2_mesh8.py similarity index 97% rename from proteus/tests/post_processing/test_bdm2_mesh8.py rename to test/post_processing/test_bdm2_mesh8.py index 7e97000afd..3846356ba2 100644 --- a/proteus/tests/post_processing/test_bdm2_mesh8.py +++ b/test/post_processing/test_bdm2_mesh8.py @@ -4,8 +4,6 @@ Test module for BDM2 Elements """ -from __future__ import print_function -from builtins import object import proteus.test_utils.TestTools import os import sys diff --git a/proteus/tests/post_processing/test_bdm_3Dprojection.py b/test/post_processing/test_bdm_3Dprojection.py similarity index 98% rename from proteus/tests/post_processing/test_bdm_3Dprojection.py rename to test/post_processing/test_bdm_3Dprojection.py index f714a67a34..9eb2777a4a 100644 --- a/proteus/tests/post_processing/test_bdm_3Dprojection.py +++ b/test/post_processing/test_bdm_3Dprojection.py @@ -4,8 +4,6 @@ Test module for BDM2 Elements """ -from __future__ import print_function -from builtins import object import proteus.test_utils.TestTools import os import sys diff --git a/proteus/tests/post_processing/test_bdm_projection.py b/test/post_processing/test_bdm_projection.py similarity index 98% rename from proteus/tests/post_processing/test_bdm_projection.py rename to test/post_processing/test_bdm_projection.py index 7f8f494f91..b4a3905f79 100644 --- a/proteus/tests/post_processing/test_bdm_projection.py +++ b/test/post_processing/test_bdm_projection.py @@ -4,8 +4,6 @@ Test module for BDM2 Elements """ -from __future__ import print_function -from builtins import object import proteus.test_utils.TestTools import os import sys diff --git a/proteus/tests/post_processing/test_elementwise_flux.py b/test/post_processing/test_elementwise_flux.py similarity index 97% rename from proteus/tests/post_processing/test_elementwise_flux.py rename to test/post_processing/test_elementwise_flux.py index 8782de1455..c9afb9603c 100644 --- a/proteus/tests/post_processing/test_elementwise_flux.py +++ b/test/post_processing/test_elementwise_flux.py @@ -4,8 +4,6 @@ Test module for BDM2 Elements """ -from __future__ import print_function -from builtins import object import proteus.test_utils.TestTools import os import sys diff --git a/proteus/tests/richards/re_vgm_sand_10m_1d_c0p1_n.py b/test/richards/re_vgm_sand_10m_1d_c0p1_n.py similarity index 99% rename from proteus/tests/richards/re_vgm_sand_10m_1d_c0p1_n.py rename to test/richards/re_vgm_sand_10m_1d_c0p1_n.py index c95f0cd22d..1e54ace6a0 100644 --- a/proteus/tests/richards/re_vgm_sand_10m_1d_c0p1_n.py +++ b/test/richards/re_vgm_sand_10m_1d_c0p1_n.py @@ -143,4 +143,4 @@ linTolFac = 0.01 -#conservativeFlux = {0:'pwl'} +#conservativeFlux = {0:'pwl'} \ No newline at end of file diff --git a/proteus/tests/richards/re_vgm_sand_10m_1d_p.py b/test/richards/re_vgm_sand_10m_1d_p.py similarity index 99% rename from proteus/tests/richards/re_vgm_sand_10m_1d_p.py rename to test/richards/re_vgm_sand_10m_1d_p.py index 966eaa593a..04058aadc9 100644 --- a/proteus/tests/richards/re_vgm_sand_10m_1d_p.py +++ b/test/richards/re_vgm_sand_10m_1d_p.py @@ -158,4 +158,4 @@ def flux(x,flag): diffusiveFluxBoundaryConditions = {0:{}} T = 0.5/timeScale -#T = 0.35/timeScale +#T = 0.35/timeScale \ No newline at end of file diff --git a/proteus/tests/richards/re_vgm_sand_10x10m_2d_c0p1_n.py b/test/richards/re_vgm_sand_10x10m_2d_c0p1_n.py similarity index 99% rename from proteus/tests/richards/re_vgm_sand_10x10m_2d_c0p1_n.py rename to test/richards/re_vgm_sand_10x10m_2d_c0p1_n.py index 0986e38f70..3ea067ad35 100644 --- a/proteus/tests/richards/re_vgm_sand_10x10m_2d_c0p1_n.py +++ b/test/richards/re_vgm_sand_10x10m_2d_c0p1_n.py @@ -113,4 +113,4 @@ #default number of layers to use > 1 with element partition means #C0P1 methods don't need to do communication in global element assembly #nodal partitioning does not need communication for C0P1 (has overlap 1) regardless -nLayersOfOverlapForParallel = 0 +nLayersOfOverlapForParallel = 0 \ No newline at end of file diff --git a/proteus/tests/richards/re_vgm_sand_10x10m_2d_p.py b/test/richards/re_vgm_sand_10x10m_2d_p.py similarity index 99% rename from proteus/tests/richards/re_vgm_sand_10x10m_2d_p.py rename to test/richards/re_vgm_sand_10x10m_2d_p.py index b98abcb81a..d01545d155 100644 --- a/proteus/tests/richards/re_vgm_sand_10x10m_2d_p.py +++ b/test/richards/re_vgm_sand_10x10m_2d_p.py @@ -123,4 +123,4 @@ def getFBC_2D_Richards_Shock(x,flag): diffusiveFluxBoundaryConditions = {0:{0:getFBC_2D_Richards_Shock}} -T = 0.35/timeScale +T = 0.35/timeScale \ No newline at end of file diff --git a/proteus/tests/richards/re_vgm_sand_10x10x10_3d_c0p1_n.py b/test/richards/re_vgm_sand_10x10x10_3d_c0p1_n.py similarity index 99% rename from proteus/tests/richards/re_vgm_sand_10x10x10_3d_c0p1_n.py rename to test/richards/re_vgm_sand_10x10x10_3d_c0p1_n.py index 2bdde5a90a..427b721836 100644 --- a/proteus/tests/richards/re_vgm_sand_10x10x10_3d_c0p1_n.py +++ b/test/richards/re_vgm_sand_10x10x10_3d_c0p1_n.py @@ -113,4 +113,4 @@ #default number of layers to use > 1 with element partition means #C0P1 methods don't need to do communication in global element assembly #nodal partitioning does not need communication for C0P1 (has overlap 1) regardless -nLayersOfOverlapForParallel = 1 +nLayersOfOverlapForParallel = 1 \ No newline at end of file diff --git a/proteus/tests/richards/re_vgm_sand_10x10x10_3d_p.py b/test/richards/re_vgm_sand_10x10x10_3d_p.py similarity index 99% rename from proteus/tests/richards/re_vgm_sand_10x10x10_3d_p.py rename to test/richards/re_vgm_sand_10x10x10_3d_p.py index 7cf7e595fa..92b8355eb8 100644 --- a/proteus/tests/richards/re_vgm_sand_10x10x10_3d_p.py +++ b/test/richards/re_vgm_sand_10x10x10_3d_p.py @@ -129,4 +129,4 @@ def getFBC_3D_Richards_Shock(x,flag): diffusiveFluxBoundaryConditions = {0:{0:getFBC_3D_Richards_Shock}} T = 0.25/timeScale -T = 0.3*0.25/timeScale +T = 0.3*0.25/timeScale \ No newline at end of file diff --git a/proteus/tests/sandbox/comm_test.py b/test/sandbox/comm_test.py similarity index 84% rename from proteus/tests/sandbox/comm_test.py rename to test/sandbox/comm_test.py index 944e137e20..f4296e9f35 100644 --- a/proteus/tests/sandbox/comm_test.py +++ b/test/sandbox/comm_test.py @@ -1,8 +1,5 @@ -from __future__ import print_function #import sys #from proteus import Comm -from future import standard_library -standard_library.install_aliases() import os import sys import socket diff --git a/proteus/tests/sandbox/test.py b/test/sandbox/test.py similarity index 96% rename from proteus/tests/sandbox/test.py rename to test/sandbox/test.py index ceb9635d11..a38c7c39e8 100644 --- a/proteus/tests/sandbox/test.py +++ b/test/sandbox/test.py @@ -1,5 +1,3 @@ -from __future__ import print_function -from builtins import range import numpy #alt #nodes of reference hex laid out clockwise bottom to top diff --git a/proteus/tests/sandbox/testDomain.cpp b/test/sandbox/testDomain.cpp similarity index 100% rename from proteus/tests/sandbox/testDomain.cpp rename to test/sandbox/testDomain.cpp diff --git a/proteus/tests/sandbox/testFemTools.py b/test/sandbox/testFemTools.py similarity index 98% rename from proteus/tests/sandbox/testFemTools.py rename to test/sandbox/testFemTools.py index fab9e7046f..cc5e223a0f 100644 --- a/proteus/tests/sandbox/testFemTools.py +++ b/test/sandbox/testFemTools.py @@ -1,9 +1,4 @@ #!/usr/bin/env python - -from __future__ import print_function -from __future__ import division -from builtins import range -from past.utils import old_div from MeshTools import * from FemTools import * import numpy @@ -20,7 +15,7 @@ def getEdgeNodesInPhysicalSpace(p0,p1,order): if order == 2: edgeRefNodes = (0.0,1.0,0.5) elif order == 3: - edgeRefNodes = (0.0,1.0,old_div(1.0,3.0),old_div(2.0,3.0)) + edgeRefNodes = (0.0,1.0,1.0/3.0,2.0/3.0) elif order == 4: edgeRefNodes = (0.0,1.0,0.25,0.5,0.75) else: #default is k=1 diff --git a/proteus/tests/sandbox/testMesh.cpp b/test/sandbox/testMesh.cpp similarity index 100% rename from proteus/tests/sandbox/testMesh.cpp rename to test/sandbox/testMesh.cpp diff --git a/proteus/tests/sandbox/testMesh.py b/test/sandbox/testMesh.py similarity index 99% rename from proteus/tests/sandbox/testMesh.py rename to test/sandbox/testMesh.py index ef6fd233e5..67c60bb089 100644 --- a/proteus/tests/sandbox/testMesh.py +++ b/test/sandbox/testMesh.py @@ -1,7 +1,4 @@ #!/usr/bin/env python - -from __future__ import print_function -from builtins import range from MeshTools import * import numpy diff --git a/proteus/tests/sandbox/testMesh2.py b/test/sandbox/testMesh2.py similarity index 99% rename from proteus/tests/sandbox/testMesh2.py rename to test/sandbox/testMesh2.py index 58eacaa9f6..a94ba1a12e 100755 --- a/proteus/tests/sandbox/testMesh2.py +++ b/test/sandbox/testMesh2.py @@ -2,8 +2,6 @@ """ A test script for MeshTools and cmeshTools """ -from __future__ import print_function -from builtins import range import Comm import MeshTools import cmeshTools diff --git a/proteus/tests/sandbox/testRKDG.py b/test/sandbox/testRKDG.py similarity index 99% rename from proteus/tests/sandbox/testRKDG.py rename to test/sandbox/testRKDG.py index 1cb9da2f0b..3940f2ca0d 100644 --- a/proteus/tests/sandbox/testRKDG.py +++ b/test/sandbox/testRKDG.py @@ -1,5 +1,4 @@ #!/usr/bin/env python - from ScalarTransport import * from ScalarTransportTests import * from LevelSetTests import * diff --git a/proteus/tests/sandbox/testReadMeshFromVTK.py b/test/sandbox/testReadMeshFromVTK.py similarity index 99% rename from proteus/tests/sandbox/testReadMeshFromVTK.py rename to test/sandbox/testReadMeshFromVTK.py index e12970793c..c244ce4d13 100644 --- a/proteus/tests/sandbox/testReadMeshFromVTK.py +++ b/test/sandbox/testReadMeshFromVTK.py @@ -1,5 +1,4 @@ #!/usr/bin/env python - from pyadh import * comm = Comm.init() cmeshTools.commInit() diff --git a/proteus/tests/sandbox/testTimeIntegration.py b/test/sandbox/testTimeIntegration.py similarity index 98% rename from proteus/tests/sandbox/testTimeIntegration.py rename to test/sandbox/testTimeIntegration.py index 432607b71c..2be2e079ee 100644 --- a/proteus/tests/sandbox/testTimeIntegration.py +++ b/test/sandbox/testTimeIntegration.py @@ -1,8 +1,3 @@ -from __future__ import print_function -from __future__ import division -from builtins import range -from past.utils import old_div -from builtins import object from LinearAlgebra import * from TimeIntegrationTools import * from NonlinearSolvers import * @@ -310,7 +305,7 @@ def getJacobian(self,jacobian): ode.timeIntegrator.runCFL = targetCFL t = t0 nsteps = 0 - dtFix = old_div(T,ntMax) + dtFix = T/ntMax L2err = 0.0 LIerr = 0.0 errT = 0.0 diff --git a/proteus/tests/shallow_water/dambreak_1d/sw_dam_break_1d_dgpk_n.py b/test/shallow_water/dambreak_1d/sw_dam_break_1d_dgpk_n.py similarity index 98% rename from proteus/tests/shallow_water/dambreak_1d/sw_dam_break_1d_dgpk_n.py rename to test/shallow_water/dambreak_1d/sw_dam_break_1d_dgpk_n.py index 910c7b88ca..5849032c00 100644 --- a/proteus/tests/shallow_water/dambreak_1d/sw_dam_break_1d_dgpk_n.py +++ b/test/shallow_water/dambreak_1d/sw_dam_break_1d_dgpk_n.py @@ -71,4 +71,4 @@ nl_atol_res = 1.0e-8 #only save the solution at the 'user time steps' in tnList, which is set using nDTout above -archiveFlag = ArchiveFlags.EVERY_USER_STEP +archiveFlag = ArchiveFlags.EVERY_USER_STEP \ No newline at end of file diff --git a/proteus/tests/shallow_water/dambreak_1d/sw_dam_break_1d_p.py b/test/shallow_water/dambreak_1d/sw_dam_break_1d_p.py similarity index 95% rename from proteus/tests/shallow_water/dambreak_1d/sw_dam_break_1d_p.py rename to test/shallow_water/dambreak_1d/sw_dam_break_1d_p.py index 7d1f8b6b44..e3c96d0dd7 100644 --- a/proteus/tests/shallow_water/dambreak_1d/sw_dam_break_1d_p.py +++ b/test/shallow_water/dambreak_1d/sw_dam_break_1d_p.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import object -from past.utils import old_div from proteus import * from proteus.default_p import * @@ -74,7 +71,7 @@ #for depth class DamBreakIC(object): def __init__(self,Lx,HL,HR): - self.xc = old_div(Lx,2.0) + self.xc = Lx/2.0 self.HL=HL self.HR=HR def uOfXT(self,x,t): diff --git a/proteus/tests/single_phase_gw/README.rst b/test/single_phase_gw/README.rst similarity index 100% rename from proteus/tests/single_phase_gw/README.rst rename to test/single_phase_gw/README.rst diff --git a/proteus/tests/cylinder2D/ibm_rans2p/__init__.py b/test/single_phase_gw/__init__.py similarity index 100% rename from proteus/tests/cylinder2D/ibm_rans2p/__init__.py rename to test/single_phase_gw/__init__.py diff --git a/proteus/tests/single_phase_gw/petsc.options b/test/single_phase_gw/petsc.options similarity index 100% rename from proteus/tests/single_phase_gw/petsc.options rename to test/single_phase_gw/petsc.options diff --git a/proteus/tests/single_phase_gw/single_phase_gw.py b/test/single_phase_gw/single_phase_gw.py similarity index 93% rename from proteus/tests/single_phase_gw/single_phase_gw.py rename to test/single_phase_gw/single_phase_gw.py index 2dbbdcca3d..658bd9da81 100644 --- a/proteus/tests/single_phase_gw/single_phase_gw.py +++ b/test/single_phase_gw/single_phase_gw.py @@ -19,9 +19,6 @@ since this is the form that proteus uses by default """ -from __future__ import division -from builtins import object -from past.utils import old_div from proteus import * from proteus import SubsurfaceTransportCoefficients as STC @@ -47,7 +44,7 @@ domain = Domain.RectangularDomain(L[:nd], units="m") refinement_level = 16 #define characteristic length -he = old_div(L[0],float(refinement_level)) +he = L[0]/float(refinement_level) ### Material Properties ### #homogeneous for now @@ -108,7 +105,7 @@ def uOfXT(self,x,t): # numerics parallel = False -domain.MeshOptions.nnx = domain.MeshOptions.nny = int(old_div(L[0],he)) +domain.MeshOptions.nnx = domain.MeshOptions.nny = int(L[0]/he) nLevels = 1 if parallel: nLevels = 1 diff --git a/proteus/tests/single_phase_gw/sp_gw_c0p1_n.py b/test/single_phase_gw/sp_gw_c0p1_n.py similarity index 90% rename from proteus/tests/single_phase_gw/sp_gw_c0p1_n.py rename to test/single_phase_gw/sp_gw_c0p1_n.py index f43dca462f..e27241207b 100644 --- a/proteus/tests/single_phase_gw/sp_gw_c0p1_n.py +++ b/test/single_phase_gw/sp_gw_c0p1_n.py @@ -1,6 +1,3 @@ -from __future__ import absolute_import -from __future__ import division -from past.utils import old_div from proteus import * from proteus.default_n import * from .sp_gw_p import * @@ -8,7 +5,7 @@ #fixed time step timeIntegration = BackwardEuler -DT = float(old_div(T,nDTout)) +DT = float(T/nDTout) stepController = FixedStep #Piecewise-Linears on triangles diff --git a/proteus/tests/single_phase_gw/sp_gw_ncp1_n.py b/test/single_phase_gw/sp_gw_ncp1_n.py similarity index 90% rename from proteus/tests/single_phase_gw/sp_gw_ncp1_n.py rename to test/single_phase_gw/sp_gw_ncp1_n.py index aaf66d79d7..3c9b786174 100644 --- a/proteus/tests/single_phase_gw/sp_gw_ncp1_n.py +++ b/test/single_phase_gw/sp_gw_ncp1_n.py @@ -1,6 +1,3 @@ -from __future__ import absolute_import -from __future__ import division -from past.utils import old_div from proteus import * from proteus.default_n import * from .sp_gw_p import * @@ -8,7 +5,7 @@ #fixed time step timeIntegration = BackwardEuler -DT = float(old_div(T,nDTout)) +DT = float(T/nDTout) stepController = FixedStep #Raviart-Thomas 0 space on simpleces diff --git a/proteus/tests/single_phase_gw/sp_gw_p.py b/test/single_phase_gw/sp_gw_p.py similarity index 95% rename from proteus/tests/single_phase_gw/sp_gw_p.py rename to test/single_phase_gw/sp_gw_p.py index d3c754ef74..1c16151e9a 100644 --- a/proteus/tests/single_phase_gw/sp_gw_p.py +++ b/test/single_phase_gw/sp_gw_p.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import import proteus from proteus import * from proteus.default_p import * diff --git a/proteus/tests/single_phase_gw/test_single_phase_gw.py b/test/single_phase_gw/test_single_phase_gw.py similarity index 97% rename from proteus/tests/single_phase_gw/test_single_phase_gw.py rename to test/single_phase_gw/test_single_phase_gw.py index b51c91b453..7f4785dae0 100644 --- a/proteus/tests/single_phase_gw/test_single_phase_gw.py +++ b/test/single_phase_gw/test_single_phase_gw.py @@ -9,10 +9,6 @@ \nabla \cdot \left( a(x) \nabla u \right) = f(x) """ -from __future__ import print_function -from __future__ import absolute_import -from builtins import range -from builtins import object import os import numpy as np import numpy.testing as npt diff --git a/proteus/tests/solver_tests/cavity2D.1.neigh b/test/solver_tests/cavity2D.1.neigh similarity index 100% rename from proteus/tests/solver_tests/cavity2D.1.neigh rename to test/solver_tests/cavity2D.1.neigh diff --git a/proteus/tests/solver_tests/cavity2D.1.poly b/test/solver_tests/cavity2D.1.poly similarity index 100% rename from proteus/tests/solver_tests/cavity2D.1.poly rename to test/solver_tests/cavity2D.1.poly diff --git a/proteus/tests/solver_tests/cavity2D.edge b/test/solver_tests/cavity2D.edge similarity index 100% rename from proteus/tests/solver_tests/cavity2D.edge rename to test/solver_tests/cavity2D.edge diff --git a/proteus/tests/solver_tests/cavity2D.ele b/test/solver_tests/cavity2D.ele similarity index 100% rename from proteus/tests/solver_tests/cavity2D.ele rename to test/solver_tests/cavity2D.ele diff --git a/proteus/tests/solver_tests/cavity2D.node b/test/solver_tests/cavity2D.node similarity index 100% rename from proteus/tests/solver_tests/cavity2D.node rename to test/solver_tests/cavity2D.node diff --git a/proteus/tests/solver_tests/comparison_files/Qp_expected.log b/test/solver_tests/comparison_files/Qp_expected.log similarity index 100% rename from proteus/tests/solver_tests/comparison_files/Qp_expected.log rename to test/solver_tests/comparison_files/Qp_expected.log diff --git a/proteus/tests/solver_tests/comparison_files/comparison_drivenCavityStokes_velocity_t1.csv b/test/solver_tests/comparison_files/comparison_drivenCavityStokes_velocity_t1.csv similarity index 100% rename from proteus/tests/solver_tests/comparison_files/comparison_drivenCavityStokes_velocity_t1.csv rename to test/solver_tests/comparison_files/comparison_drivenCavityStokes_velocity_t1.csv diff --git a/proteus/tests/solver_tests/comparison_files/comparison_twp_navier_stokes_cavity_2d_p_t1.csv b/test/solver_tests/comparison_files/comparison_twp_navier_stokes_cavity_2d_p_t1.csv similarity index 100% rename from proteus/tests/solver_tests/comparison_files/comparison_twp_navier_stokes_cavity_2d_p_t1.csv rename to test/solver_tests/comparison_files/comparison_twp_navier_stokes_cavity_2d_p_t1.csv diff --git a/proteus/tests/solver_tests/comparison_files/drivenCavityNSE_LSC_expected.csv b/test/solver_tests/comparison_files/drivenCavityNSE_LSC_expected.csv similarity index 100% rename from proteus/tests/solver_tests/comparison_files/drivenCavityNSE_LSC_expected.csv rename to test/solver_tests/comparison_files/drivenCavityNSE_LSC_expected.csv diff --git a/proteus/tests/solver_tests/comparison_files/drivenCavityNSE_LSC_expected.xmf b/test/solver_tests/comparison_files/drivenCavityNSE_LSC_expected.xmf similarity index 100% rename from proteus/tests/solver_tests/comparison_files/drivenCavityNSE_LSC_expected.xmf rename to test/solver_tests/comparison_files/drivenCavityNSE_LSC_expected.xmf diff --git a/proteus/tests/solver_tests/comparison_files/tp_pcd_y_output.csv b/test/solver_tests/comparison_files/tp_pcd_y_output.csv similarity index 100% rename from proteus/tests/solver_tests/comparison_files/tp_pcd_y_output.csv rename to test/solver_tests/comparison_files/tp_pcd_y_output.csv diff --git a/proteus/tests/solver_tests/comparison_files/tp_pcd_y_output_cheb.csv b/test/solver_tests/comparison_files/tp_pcd_y_output_cheb.csv similarity index 100% rename from proteus/tests/solver_tests/comparison_files/tp_pcd_y_output_cheb.csv rename to test/solver_tests/comparison_files/tp_pcd_y_output_cheb.csv diff --git a/proteus/tests/solver_tests/comparison_files/tppcd_y_dirichlet_dof.csv b/test/solver_tests/comparison_files/tppcd_y_dirichlet_dof.csv similarity index 100% rename from proteus/tests/solver_tests/comparison_files/tppcd_y_dirichlet_dof.csv rename to test/solver_tests/comparison_files/tppcd_y_dirichlet_dof.csv diff --git a/proteus/tests/solver_tests/comparison_files/twp_navier_stokes_cavity_2d.xmf b/test/solver_tests/comparison_files/twp_navier_stokes_cavity_2d.xmf similarity index 100% rename from proteus/tests/solver_tests/comparison_files/twp_navier_stokes_cavity_2d.xmf rename to test/solver_tests/comparison_files/twp_navier_stokes_cavity_2d.xmf diff --git a/proteus/tests/solver_tests/import_modules/Ap_rho.bin b/test/solver_tests/import_modules/Ap_rho.bin similarity index 100% rename from proteus/tests/solver_tests/import_modules/Ap_rho.bin rename to test/solver_tests/import_modules/Ap_rho.bin diff --git a/proteus/tests/solver_tests/import_modules/NavierStokes_ST_LS_SO_VV.py b/test/solver_tests/import_modules/NavierStokes_ST_LS_SO_VV.py similarity index 99% rename from proteus/tests/solver_tests/import_modules/NavierStokes_ST_LS_SO_VV.py rename to test/solver_tests/import_modules/NavierStokes_ST_LS_SO_VV.py index 5ebbe58fd6..51ca17b255 100644 --- a/proteus/tests/solver_tests/import_modules/NavierStokes_ST_LS_SO_VV.py +++ b/test/solver_tests/import_modules/NavierStokes_ST_LS_SO_VV.py @@ -250,4 +250,4 @@ def evaluate(self,t,c): c[('f',3)].flat[:] = 0.0 c[('df',3,1)].flat[:] = 0.0 c[('df',3,2)].flat[:] = 0.0 - c[('df',3,3)].flat[:] = 0.0 + c[('df',3,3)].flat[:] = 0.0 \ No newline at end of file diff --git a/proteus/tests/solver_tests/import_modules/Np_rho.bin b/test/solver_tests/import_modules/Np_rho.bin similarity index 100% rename from proteus/tests/solver_tests/import_modules/Np_rho.bin rename to test/solver_tests/import_modules/Np_rho.bin diff --git a/proteus/tests/solver_tests/import_modules/Qp_dens.bin b/test/solver_tests/import_modules/Qp_dens.bin similarity index 100% rename from proteus/tests/solver_tests/import_modules/Qp_dens.bin rename to test/solver_tests/import_modules/Qp_dens.bin diff --git a/proteus/tests/solver_tests/import_modules/Qp_visc.bin b/test/solver_tests/import_modules/Qp_visc.bin similarity index 100% rename from proteus/tests/solver_tests/import_modules/Qp_visc.bin rename to test/solver_tests/import_modules/Qp_visc.bin diff --git a/proteus/tests/solver_tests/import_modules/TwophaseNavierStokes_ST_LS_SO_VV.py b/test/solver_tests/import_modules/TwophaseNavierStokes_ST_LS_SO_VV.py similarity index 99% rename from proteus/tests/solver_tests/import_modules/TwophaseNavierStokes_ST_LS_SO_VV.py rename to test/solver_tests/import_modules/TwophaseNavierStokes_ST_LS_SO_VV.py index d05892c3c0..66dbdeadb4 100644 --- a/proteus/tests/solver_tests/import_modules/TwophaseNavierStokes_ST_LS_SO_VV.py +++ b/test/solver_tests/import_modules/TwophaseNavierStokes_ST_LS_SO_VV.py @@ -1,5 +1,3 @@ -from __future__ import division -from past.utils import old_div from proteus.TransportCoefficients import TwophaseNavierStokes_ST_LS_SO as TPNSE_ST_LS_SO import numpy @@ -62,12 +60,12 @@ def initializeElementQuadrature(self,t,cq): def evaluate(self,t,c): self.rho_0 = 1.0 self.rho_1 = 1.0 - self.nu_0 = old_div(1.,50.) + self.nu_0 = 1./50. # self.nu_1 = 1./5. if t==1.0: - self.nu_1 = old_div(1.,50.) + self.nu_1 = 1./50. elif t==2.0: - self.nu_1 = old_div(1.,5.) + self.nu_1 = 1./5. elif t==3.0: self.nu_1 = 2.0 elif t==4.0: diff --git a/proteus/tests/solver_tests/import_modules/cavity2d.py b/test/solver_tests/import_modules/cavity2d.py similarity index 97% rename from proteus/tests/solver_tests/import_modules/cavity2d.py rename to test/solver_tests/import_modules/cavity2d.py index a5dfa63791..7ab15ea128 100644 --- a/proteus/tests/solver_tests/import_modules/cavity2d.py +++ b/test/solver_tests/import_modules/cavity2d.py @@ -1,6 +1,3 @@ -from __future__ import print_function -from __future__ import division -from past.utils import old_div from math import * import proteus.MeshTools from proteus import Domain @@ -114,7 +111,7 @@ #domain.writePoly("mesh") #domain.writePLY("mesh") #domain.writeAsymptote("mesh") - domain.MeshOptions.triangleOptions = "VApq30Dena%8.8f" % (old_div((he ** 2), 2.0),) + domain.MeshOptions.triangleOptions = "VApq30Dena%8.8f" % ((he**2)/2.0,) #logEvent("""Mesh generated using: tetgen -%s %s""" % (triangleOptions, domain.polyfile + ".poly")) @@ -145,9 +142,9 @@ # Reynolds number = ? rho_0 = 1.205 -nu_0 = old_div(1.500e-5,1.500e-5) +nu_0 = 1.500e-5/1.500e-5 rho_1 = 998.2 -nu_1 = old_div(1.004e-6,1.500e-5) +nu_1 = 1.004e-6/1.500e-5 # Gravity g = [0.0,0.0] diff --git a/proteus/tests/solver_tests/import_modules/input_vec_tppcd.bin b/test/solver_tests/import_modules/input_vec_tppcd.bin similarity index 100% rename from proteus/tests/solver_tests/import_modules/input_vec_tppcd.bin rename to test/solver_tests/import_modules/input_vec_tppcd.bin diff --git a/proteus/tests/solver_tests/import_modules/nseDrivenCavity_2d.py b/test/solver_tests/import_modules/nseDrivenCavity_2d.py similarity index 97% rename from proteus/tests/solver_tests/import_modules/nseDrivenCavity_2d.py rename to test/solver_tests/import_modules/nseDrivenCavity_2d.py index b8aebdda70..cb88e991d4 100644 --- a/proteus/tests/solver_tests/import_modules/nseDrivenCavity_2d.py +++ b/test/solver_tests/import_modules/nseDrivenCavity_2d.py @@ -34,4 +34,4 @@ solveIteratively = opts.solveIteratively solveInParallel = opts.solveInParallel schur_solver = opts.schur_solver -RE_through_bdy = opts.RE_through_bdy +RE_through_bdy = opts.RE_through_bdy \ No newline at end of file diff --git a/proteus/tests/solver_tests/import_modules/nseDrivenCavity_2d_n.py b/test/solver_tests/import_modules/nseDrivenCavity_2d_n.py similarity index 98% rename from proteus/tests/solver_tests/import_modules/nseDrivenCavity_2d_n.py rename to test/solver_tests/import_modules/nseDrivenCavity_2d_n.py index 4b0d60f1dd..c7e247718c 100644 --- a/proteus/tests/solver_tests/import_modules/nseDrivenCavity_2d_n.py +++ b/test/solver_tests/import_modules/nseDrivenCavity_2d_n.py @@ -1,5 +1,3 @@ -from __future__ import print_function -from __future__ import absolute_import from proteus import * from proteus.default_n import * from proteus import defaults diff --git a/proteus/tests/solver_tests/import_modules/nseDrivenCavity_2d_p.py b/test/solver_tests/import_modules/nseDrivenCavity_2d_p.py similarity index 97% rename from proteus/tests/solver_tests/import_modules/nseDrivenCavity_2d_p.py rename to test/solver_tests/import_modules/nseDrivenCavity_2d_p.py index cfe0b7d35c..261764fb45 100644 --- a/proteus/tests/solver_tests/import_modules/nseDrivenCavity_2d_p.py +++ b/test/solver_tests/import_modules/nseDrivenCavity_2d_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * from proteus import defaults diff --git a/proteus/tests/solver_tests/import_modules/petsc.options.schur b/test/solver_tests/import_modules/petsc.options.schur similarity index 100% rename from proteus/tests/solver_tests/import_modules/petsc.options.schur rename to test/solver_tests/import_modules/petsc.options.schur diff --git a/proteus/tests/solver_tests/import_modules/petsc.options.schur_lsc b/test/solver_tests/import_modules/petsc.options.schur_lsc similarity index 100% rename from proteus/tests/solver_tests/import_modules/petsc.options.schur_lsc rename to test/solver_tests/import_modules/petsc.options.schur_lsc diff --git a/proteus/tests/solver_tests/import_modules/quad_mass_matrix.npy b/test/solver_tests/import_modules/quad_mass_matrix.npy similarity index 100% rename from proteus/tests/solver_tests/import_modules/quad_mass_matrix.npy rename to test/solver_tests/import_modules/quad_mass_matrix.npy diff --git a/proteus/tests/solver_tests/import_modules/sol_10.npy b/test/solver_tests/import_modules/sol_10.npy similarity index 100% rename from proteus/tests/solver_tests/import_modules/sol_10.npy rename to test/solver_tests/import_modules/sol_10.npy diff --git a/proteus/tests/solver_tests/import_modules/sol_20_lst.npy b/test/solver_tests/import_modules/sol_20_lst.npy similarity index 100% rename from proteus/tests/solver_tests/import_modules/sol_20_lst.npy rename to test/solver_tests/import_modules/sol_20_lst.npy diff --git a/proteus/tests/solver_tests/import_modules/step2d.py b/test/solver_tests/import_modules/step2d.py similarity index 98% rename from proteus/tests/solver_tests/import_modules/step2d.py rename to test/solver_tests/import_modules/step2d.py index 26857a45d2..aa1e98ab91 100644 --- a/proteus/tests/solver_tests/import_modules/step2d.py +++ b/test/solver_tests/import_modules/step2d.py @@ -1,5 +1,3 @@ -from __future__ import print_function -from __future__ import division from math import * import proteus.MeshTools from proteus import Domain diff --git a/proteus/tests/solver_tests/import_modules/step2d_so.py b/test/solver_tests/import_modules/step2d_so.py similarity index 92% rename from proteus/tests/solver_tests/import_modules/step2d_so.py rename to test/solver_tests/import_modules/step2d_so.py index fce5461bd0..8c543e0cdd 100644 --- a/proteus/tests/solver_tests/import_modules/step2d_so.py +++ b/test/solver_tests/import_modules/step2d_so.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus.default_so import * from proteus import defaults defaults.reset_default_so() diff --git a/proteus/tests/solver_tests/import_modules/stokesDrivenCavity_2d.py b/test/solver_tests/import_modules/stokesDrivenCavity_2d.py similarity index 97% rename from proteus/tests/solver_tests/import_modules/stokesDrivenCavity_2d.py rename to test/solver_tests/import_modules/stokesDrivenCavity_2d.py index b1de8f778d..b2396f5d1d 100644 --- a/proteus/tests/solver_tests/import_modules/stokesDrivenCavity_2d.py +++ b/test/solver_tests/import_modules/stokesDrivenCavity_2d.py @@ -31,4 +31,4 @@ numeric_scheme = opts.numeric_scheme useWeakBoundaryConditions = opts.useWeakBoundaryConditions solveIteratively = opts.solveIteratively -solveInParallel = opts.solveInParallel +solveInParallel = opts.solveInParallel \ No newline at end of file diff --git a/proteus/tests/solver_tests/import_modules/stokesDrivenCavity_2d_n.py b/test/solver_tests/import_modules/stokesDrivenCavity_2d_n.py similarity index 98% rename from proteus/tests/solver_tests/import_modules/stokesDrivenCavity_2d_n.py rename to test/solver_tests/import_modules/stokesDrivenCavity_2d_n.py index 5de3b07c6a..ff2dd4b56f 100644 --- a/proteus/tests/solver_tests/import_modules/stokesDrivenCavity_2d_n.py +++ b/test/solver_tests/import_modules/stokesDrivenCavity_2d_n.py @@ -1,5 +1,3 @@ -from __future__ import print_function -from __future__ import absolute_import from proteus import * from proteus.default_n import * from proteus import defaults diff --git a/proteus/tests/solver_tests/import_modules/stokesDrivenCavity_2d_p.py b/test/solver_tests/import_modules/stokesDrivenCavity_2d_p.py similarity index 97% rename from proteus/tests/solver_tests/import_modules/stokesDrivenCavity_2d_p.py rename to test/solver_tests/import_modules/stokesDrivenCavity_2d_p.py index 7fd7266e63..23f057293e 100644 --- a/proteus/tests/solver_tests/import_modules/stokesDrivenCavity_2d_p.py +++ b/test/solver_tests/import_modules/stokesDrivenCavity_2d_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * from proteus import defaults diff --git a/proteus/tests/solver_tests/import_modules/twp_navier_stokes_cavity_2d_n.py b/test/solver_tests/import_modules/twp_navier_stokes_cavity_2d_n.py similarity index 98% rename from proteus/tests/solver_tests/import_modules/twp_navier_stokes_cavity_2d_n.py rename to test/solver_tests/import_modules/twp_navier_stokes_cavity_2d_n.py index 3d4e81c914..f022a576b2 100644 --- a/proteus/tests/solver_tests/import_modules/twp_navier_stokes_cavity_2d_n.py +++ b/test/solver_tests/import_modules/twp_navier_stokes_cavity_2d_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * try: from . import cavity2d @@ -119,4 +118,3 @@ def updateTimeHistory(self,resetFromDOF=False): maxNonlinearIts = 100 maxLineSearches =0 - diff --git a/proteus/tests/solver_tests/import_modules/twp_navier_stokes_cavity_2d_p.py b/test/solver_tests/import_modules/twp_navier_stokes_cavity_2d_p.py similarity index 97% rename from proteus/tests/solver_tests/import_modules/twp_navier_stokes_cavity_2d_p.py rename to test/solver_tests/import_modules/twp_navier_stokes_cavity_2d_p.py index 95f32bc712..ffbd6f15f8 100644 --- a/proteus/tests/solver_tests/import_modules/twp_navier_stokes_cavity_2d_p.py +++ b/test/solver_tests/import_modules/twp_navier_stokes_cavity_2d_p.py @@ -1,8 +1,6 @@ """ Incompressible Navier-Stokes flow around a cylinder in 2D. """ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * from proteus import defaults diff --git a/proteus/tests/solver_tests/import_modules/twp_navier_stokes_cavity_2d_so.py b/test/solver_tests/import_modules/twp_navier_stokes_cavity_2d_so.py similarity index 92% rename from proteus/tests/solver_tests/import_modules/twp_navier_stokes_cavity_2d_so.py rename to test/solver_tests/import_modules/twp_navier_stokes_cavity_2d_so.py index 2e067a3f27..500e3dd440 100644 --- a/proteus/tests/solver_tests/import_modules/twp_navier_stokes_cavity_2d_so.py +++ b/test/solver_tests/import_modules/twp_navier_stokes_cavity_2d_so.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus.default_so import * from proteus import defaults defaults.reset_default_so() diff --git a/proteus/tests/solver_tests/import_modules/twp_navier_stokes_p.py b/test/solver_tests/import_modules/twp_navier_stokes_p.py similarity index 99% rename from proteus/tests/solver_tests/import_modules/twp_navier_stokes_p.py rename to test/solver_tests/import_modules/twp_navier_stokes_p.py index 5fc34beb37..b08f7f5f55 100644 --- a/proteus/tests/solver_tests/import_modules/twp_navier_stokes_p.py +++ b/test/solver_tests/import_modules/twp_navier_stokes_p.py @@ -188,4 +188,4 @@ def uOfXT(self,x,t): initialConditions = {0:PerturbedSurface_p(ct.waterLine_z), 1:AtRest(), - 2:AtRest()} + 2:AtRest()} \ No newline at end of file diff --git a/proteus/tests/solver_tests/import_modules/twp_navier_stokes_step2d_n.py b/test/solver_tests/import_modules/twp_navier_stokes_step2d_n.py similarity index 99% rename from proteus/tests/solver_tests/import_modules/twp_navier_stokes_step2d_n.py rename to test/solver_tests/import_modules/twp_navier_stokes_step2d_n.py index a4782cea4b..017f1ecb94 100644 --- a/proteus/tests/solver_tests/import_modules/twp_navier_stokes_step2d_n.py +++ b/test/solver_tests/import_modules/twp_navier_stokes_step2d_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from importlib import reload from proteus import * from proteus.default_n import * diff --git a/proteus/tests/solver_tests/import_modules/twp_navier_stokes_step2d_p.py b/test/solver_tests/import_modules/twp_navier_stokes_step2d_p.py similarity index 99% rename from proteus/tests/solver_tests/import_modules/twp_navier_stokes_step2d_p.py rename to test/solver_tests/import_modules/twp_navier_stokes_step2d_p.py index 563bb38bff..ec21594674 100644 --- a/proteus/tests/solver_tests/import_modules/twp_navier_stokes_step2d_p.py +++ b/test/solver_tests/import_modules/twp_navier_stokes_step2d_p.py @@ -1,8 +1,6 @@ """ Incompressible Navier-Stokes flow around a cylinder in 2D. """ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * from proteus import defaults diff --git a/proteus/tests/solver_tests/rdomain.1.neigh b/test/solver_tests/rdomain.1.neigh similarity index 100% rename from proteus/tests/solver_tests/rdomain.1.neigh rename to test/solver_tests/rdomain.1.neigh diff --git a/proteus/tests/solver_tests/rdomain.1.poly b/test/solver_tests/rdomain.1.poly similarity index 100% rename from proteus/tests/solver_tests/rdomain.1.poly rename to test/solver_tests/rdomain.1.poly diff --git a/proteus/tests/solver_tests/rdomain.edge b/test/solver_tests/rdomain.edge similarity index 100% rename from proteus/tests/solver_tests/rdomain.edge rename to test/solver_tests/rdomain.edge diff --git a/proteus/tests/solver_tests/rdomain.ele b/test/solver_tests/rdomain.ele similarity index 100% rename from proteus/tests/solver_tests/rdomain.ele rename to test/solver_tests/rdomain.ele diff --git a/proteus/tests/solver_tests/rdomain.node b/test/solver_tests/rdomain.node similarity index 100% rename from proteus/tests/solver_tests/rdomain.node rename to test/solver_tests/rdomain.node diff --git a/proteus/tests/solver_tests/rdomain.poly b/test/solver_tests/rdomain.poly similarity index 100% rename from proteus/tests/solver_tests/rdomain.poly rename to test/solver_tests/rdomain.poly diff --git a/proteus/tests/solver_tests/test_bochev_pressure_stabilization.py b/test/solver_tests/test_bochev_pressure_stabilization.py similarity index 95% rename from proteus/tests/solver_tests/test_bochev_pressure_stabilization.py rename to test/solver_tests/test_bochev_pressure_stabilization.py index b498d2ebe2..32c929bad2 100644 --- a/proteus/tests/solver_tests/test_bochev_pressure_stabilization.py +++ b/test/solver_tests/test_bochev_pressure_stabilization.py @@ -12,7 +12,7 @@ import sys import inspect import numpy as np -import tables +import h5py import pickle import pytest @@ -92,11 +92,11 @@ def test_bochev_pressure_cavity(load_cavity_problem, # actual = tables.open_file('twp_navier_stokes_cavity_2d.h5','r') ## assert numpy.allclose(expected.root.p_t1,actual.root.p_t1) # expected.close() - actual = tables.open_file('twp_navier_stokes_cavity_2d.h5','r') + actual = h5py.File('twp_navier_stokes_cavity_2d.h5','r') expected_path = 'comparison_files/' + 'comparison_' + 'twp_navier_stokes_cavity_2d' + '_p_t1.csv' #write comparison file #np.array(actual.root.p_t1).tofile(os.path.join(script_dir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(script_dir, expected_path),sep=","),np.array(actual.root.p_t1).flatten(),decimal=8) + np.testing.assert_almost_equal(np.fromfile(os.path.join(script_dir, expected_path),sep=","),np.array(actual['p_t1']).flatten(),decimal=8) actual.close() - clean_up_directory() + clean_up_directory() \ No newline at end of file diff --git a/proteus/tests/solver_tests/test_dof_order_routines.py b/test/solver_tests/test_dof_order_routines.py similarity index 98% rename from proteus/tests/solver_tests/test_dof_order_routines.py rename to test/solver_tests/test_dof_order_routines.py index 99122de50b..4b668b089d 100644 --- a/proteus/tests/solver_tests/test_dof_order_routines.py +++ b/test/solver_tests/test_dof_order_routines.py @@ -94,4 +94,4 @@ def test_blocked_dof_order(ownership_range, velocity_idx = np.arange(pressure_idx[-1] + 1, array_end + 1) assert np.array_equal(pressure_idx, pressure) - assert np.array_equal(velocity_idx, velocity) + assert np.array_equal(velocity_idx, velocity) \ No newline at end of file diff --git a/proteus/tests/solver_tests/test_iterative_methods.py b/test/solver_tests/test_iterative_methods.py similarity index 95% rename from proteus/tests/solver_tests/test_iterative_methods.py rename to test/solver_tests/test_iterative_methods.py index cf53780a17..b7746921ba 100644 --- a/proteus/tests/solver_tests/test_iterative_methods.py +++ b/test/solver_tests/test_iterative_methods.py @@ -4,9 +4,6 @@ Test module for solver shell operator. """ -from __future__ import division -from builtins import range -from past.utils import old_div import proteus.test_utils.TestTools from proteus.iproteus import * from proteus import Comm @@ -168,8 +165,8 @@ def test_chebyshev_iteration_1(self): ''' Tests the pcd_shell operators produce correct output. ''' A = self.quad_mass_matrix n = self.quad_mass_matrix.shape[0] - alpha = old_div(1.,4) - beta = old_div(9.,4) + alpha = 1./4 + beta = 9./4 x0 = np.zeros(n) b1 = np.ones(n) for i in range(0,n,2): @@ -189,10 +186,10 @@ def test_chebyshev_iteration_1(self): @pytest.mark.LinearSolvers def test_chebyshev_iteration_2(self): ''' Tests the pcd_shell operators produce correct output. ''' - A = np.diag(old_div(1.,np.diag(self.quad_mass_matrix))).dot(self.quad_mass_matrix) + A = np.diag(1./np.diag(self.quad_mass_matrix)).dot(self.quad_mass_matrix) n = self.quad_mass_matrix.shape[0] - alpha = old_div(1.,4) - beta = old_div(9.,4) + alpha = 1./4 + beta = 9./4 x0 = np.zeros(n) b1 = np.zeros(n) for i in range(0,n): diff --git a/proteus/tests/solver_tests/test_nseDC_THQuad_2D.py b/test/solver_tests/test_nseDC_THQuad_2D.py similarity index 96% rename from proteus/tests/solver_tests/test_nseDC_THQuad_2D.py rename to test/solver_tests/test_nseDC_THQuad_2D.py index 10fd1f4722..20575b230a 100644 --- a/proteus/tests/solver_tests/test_nseDC_THQuad_2D.py +++ b/test/solver_tests/test_nseDC_THQuad_2D.py @@ -11,7 +11,7 @@ import sys import inspect import numpy as np -import tables +import h5py import pickle import petsc4py import pytest @@ -53,12 +53,12 @@ def _runTest(self): # output. It needs to be confirmed that the new ouput is # in fact correct and drivenCavityNSE_LSC_expected.h5 should # be updated accordingly. - actual = tables.open_file('drivenCavityNSETrial.h5','r') + actual = h5py.File('drivenCavityNSETrial.h5','r') relpath = 'comparison_files/drivenCavityNSE_LSC_expected.csv' #np.savetxt(os.path.join(self._scriptdir,relpath),actual.root.velocity_t7.read(),delimiter=',') expected = np.loadtxt(os.path.join(self._scriptdir,relpath),delimiter=',') assert np.allclose(expected, - actual.root.velocity_t7.read(), + actual['velocity_t7'][:], rtol=1e-8, atol=1e-8) actual.close() @@ -94,4 +94,4 @@ def test_01_FullRun(self): self._runTest() if __name__ == '__main__': - pass + pass \ No newline at end of file diff --git a/proteus/tests/solver_tests/test_nse_RANS2P_step.py b/test/solver_tests/test_nse_RANS2P_step.py similarity index 99% rename from proteus/tests/solver_tests/test_nse_RANS2P_step.py rename to test/solver_tests/test_nse_RANS2P_step.py index c9bc93f266..267b8e9d89 100644 --- a/proteus/tests/solver_tests/test_nse_RANS2P_step.py +++ b/test/solver_tests/test_nse_RANS2P_step.py @@ -1,7 +1,5 @@ #!/usr/bin/env python """ Test modules for Driven Cavity Stokes preconditioners. """ -from __future__ import absolute_import - import proteus.test_utils.TestTools as TestTools import proteus from proteus import LinearAlgebraTools as LAT @@ -15,7 +13,7 @@ import sys import inspect import numpy as np -import tables +import h5py import pickle import petsc4py from petsc4py import PETSc @@ -173,7 +171,7 @@ def test_step_slip_FullRun(): print(L1,L2,L3) assert L1[0][1]==2 assert L2[0][1]==11 - assert L3[0][1]==11 + assert L3[0][1]<=10 @pytest.mark.LinearSolvers def test_step_noslip_FullRun(): diff --git a/proteus/tests/solver_tests/test_operator_shells.py b/test/solver_tests/test_operator_shells.py similarity index 99% rename from proteus/tests/solver_tests/test_operator_shells.py rename to test/solver_tests/test_operator_shells.py index a91e364f77..3c6bea65c2 100644 --- a/proteus/tests/solver_tests/test_operator_shells.py +++ b/test/solver_tests/test_operator_shells.py @@ -4,7 +4,6 @@ Test module for solver shell operator. """ -from builtins import object import proteus.test_utils.TestTools from proteus.iproteus import * from proteus import Comm diff --git a/proteus/tests/solver_tests/test_stokesDC_TH_2D.py b/test/solver_tests/test_stokesDC_TH_2D.py similarity index 98% rename from proteus/tests/solver_tests/test_stokesDC_TH_2D.py rename to test/solver_tests/test_stokesDC_TH_2D.py index e5af29cd68..c709cd617e 100644 --- a/proteus/tests/solver_tests/test_stokesDC_TH_2D.py +++ b/test/solver_tests/test_stokesDC_TH_2D.py @@ -1,6 +1,5 @@ #!/usr/bin/env python """ Test modules for Driven Cavity Stokes preconditioners. """ - import proteus.test_utils.TestTools as TestTools import proteus.LinearAlgebraTools as LAT import proteus.LinearSolvers as LS @@ -11,7 +10,7 @@ import sys import inspect import numpy as np -import tables +import h5py import pickle import petsc4py from petsc4py import PETSc @@ -96,11 +95,11 @@ def _runTest(self): self.so.sList, opts) self.ns.calculateSolution('stokes') - actual = tables.open_file('drivenCavityStokesTrial.h5','r') + actual = h5py.File('drivenCavityStokesTrial.h5','r') expected_path = 'comparison_files/' + 'comparison_' + 'drivenCavityStokes' + '_velocity_t1.csv' #write comparison file #np.array(actual.root.velocity_t1).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.velocity_t1).flatten(),decimal=2) + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['velocity_t1']).flatten(),decimal=2) actual.close() @pytest.mark.slowTest diff --git a/proteus/tests/sparse_mat_ex.mtx b/test/sparse_mat_ex.mtx similarity index 100% rename from proteus/tests/sparse_mat_ex.mtx rename to test/sparse_mat_ex.mtx diff --git a/proteus/tests/cylinder2D/ibm_rans2p_3D/__init__.py b/test/surface_tension/rising_bubble_rans3p/__init__.py similarity index 100% rename from proteus/tests/cylinder2D/ibm_rans2p_3D/__init__.py rename to test/surface_tension/rising_bubble_rans3p/__init__.py diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/clean.sh b/test/surface_tension/rising_bubble_rans3p/clean.sh similarity index 100% rename from proteus/tests/surface_tension/rising_bubble_rans3p/clean.sh rename to test/surface_tension/rising_bubble_rans3p/clean.sh diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_2D_ev_p_t2.csv b/test/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_2D_ev_p_t2.csv similarity index 100% rename from proteus/tests/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_2D_ev_p_t2.csv rename to test/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_2D_ev_p_t2.csv diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_2D_ev_phi_t2.csv b/test/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_2D_ev_phi_t2.csv similarity index 100% rename from proteus/tests/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_2D_ev_phi_t2.csv rename to test/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_2D_ev_phi_t2.csv diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_2D_ev_velocity_t2.csv b/test/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_2D_ev_velocity_t2.csv similarity index 100% rename from proteus/tests/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_2D_ev_velocity_t2.csv rename to test/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_2D_ev_velocity_t2.csv diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_2D_supg_p_t2.csv b/test/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_2D_supg_p_t2.csv similarity index 100% rename from proteus/tests/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_2D_supg_p_t2.csv rename to test/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_2D_supg_p_t2.csv diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_2D_supg_phi_t2.csv b/test/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_2D_supg_phi_t2.csv similarity index 100% rename from proteus/tests/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_2D_supg_phi_t2.csv rename to test/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_2D_supg_phi_t2.csv diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_2D_supg_velocity_t2.csv b/test/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_2D_supg_velocity_t2.csv similarity index 100% rename from proteus/tests/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_2D_supg_velocity_t2.csv rename to test/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_2D_supg_velocity_t2.csv diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_3D_ev_p_t2.csv b/test/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_3D_ev_p_t2.csv similarity index 100% rename from proteus/tests/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_3D_ev_p_t2.csv rename to test/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_3D_ev_p_t2.csv diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_3D_ev_phi_t2.csv b/test/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_3D_ev_phi_t2.csv similarity index 100% rename from proteus/tests/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_3D_ev_phi_t2.csv rename to test/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_3D_ev_phi_t2.csv diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_3D_ev_velocity_t2.csv b/test/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_3D_ev_velocity_t2.csv similarity index 100% rename from proteus/tests/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_3D_ev_velocity_t2.csv rename to test/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_3D_ev_velocity_t2.csv diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_3D_supg_p_t2.csv b/test/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_3D_supg_p_t2.csv similarity index 100% rename from proteus/tests/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_3D_supg_p_t2.csv rename to test/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_3D_supg_p_t2.csv diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_3D_supg_phi_t2.csv b/test/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_3D_supg_phi_t2.csv similarity index 100% rename from proteus/tests/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_3D_supg_phi_t2.csv rename to test/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_3D_supg_phi_t2.csv diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_3D_supg_velocity_t2.csv b/test/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_3D_supg_velocity_t2.csv similarity index 100% rename from proteus/tests/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_3D_supg_velocity_t2.csv rename to test/surface_tension/rising_bubble_rans3p/comparison_files/comparison_risingBubble_3D_supg_velocity_t2.csv diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/ls_consrv_n.py b/test/surface_tension/rising_bubble_rans3p/ls_consrv_n.py similarity index 96% rename from proteus/tests/surface_tension/rising_bubble_rans3p/ls_consrv_n.py rename to test/surface_tension/rising_bubble_rans3p/ls_consrv_n.py index 6a65b94870..09d5b7f794 100644 --- a/proteus/tests/surface_tension/rising_bubble_rans3p/ls_consrv_n.py +++ b/test/surface_tension/rising_bubble_rans3p/ls_consrv_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * try: from .risingBubble import * diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/ls_consrv_p.py b/test/surface_tension/rising_bubble_rans3p/ls_consrv_p.py similarity index 94% rename from proteus/tests/surface_tension/rising_bubble_rans3p/ls_consrv_p.py rename to test/surface_tension/rising_bubble_rans3p/ls_consrv_p.py index 2ccbbe8c4a..a4cdcaad31 100644 --- a/proteus/tests/surface_tension/rising_bubble_rans3p/ls_consrv_p.py +++ b/test/surface_tension/rising_bubble_rans3p/ls_consrv_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * try: diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/ls_n.py b/test/surface_tension/rising_bubble_rans3p/ls_n.py similarity index 97% rename from proteus/tests/surface_tension/rising_bubble_rans3p/ls_n.py rename to test/surface_tension/rising_bubble_rans3p/ls_n.py index 5dd1ba4a75..51cbdbecc8 100644 --- a/proteus/tests/surface_tension/rising_bubble_rans3p/ls_n.py +++ b/test/surface_tension/rising_bubble_rans3p/ls_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * try: from .ls_p import * diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/ls_p.py b/test/surface_tension/rising_bubble_rans3p/ls_p.py similarity index 94% rename from proteus/tests/surface_tension/rising_bubble_rans3p/ls_p.py rename to test/surface_tension/rising_bubble_rans3p/ls_p.py index c96d07d496..3d171ac20b 100644 --- a/proteus/tests/surface_tension/rising_bubble_rans3p/ls_p.py +++ b/test/surface_tension/rising_bubble_rans3p/ls_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * try: diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/mesh3D.ele b/test/surface_tension/rising_bubble_rans3p/mesh3D.ele similarity index 100% rename from proteus/tests/surface_tension/rising_bubble_rans3p/mesh3D.ele rename to test/surface_tension/rising_bubble_rans3p/mesh3D.ele diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/mesh3D.face b/test/surface_tension/rising_bubble_rans3p/mesh3D.face similarity index 100% rename from proteus/tests/surface_tension/rising_bubble_rans3p/mesh3D.face rename to test/surface_tension/rising_bubble_rans3p/mesh3D.face diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/mesh3D.node b/test/surface_tension/rising_bubble_rans3p/mesh3D.node similarity index 100% rename from proteus/tests/surface_tension/rising_bubble_rans3p/mesh3D.node rename to test/surface_tension/rising_bubble_rans3p/mesh3D.node diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/parameters.py b/test/surface_tension/rising_bubble_rans3p/parameters.py similarity index 93% rename from proteus/tests/surface_tension/rising_bubble_rans3p/parameters.py rename to test/surface_tension/rising_bubble_rans3p/parameters.py index 3fea7ae97b..ff5d3df269 100644 --- a/proteus/tests/surface_tension/rising_bubble_rans3p/parameters.py +++ b/test/surface_tension/rising_bubble_rans3p/parameters.py @@ -4,4 +4,4 @@ ("USE_SUPG_NS",0,"Use SUPG stabilization"), ("ARTIFICIAL_VISCOSITY_NS",2,"0: no art visc., 1: shock capturing, 2: entropy-viscosity"), ("nd",2,"Physical dimensioln") -],mutable=True) +],mutable=True) \ No newline at end of file diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/pressureInitial_n.py b/test/surface_tension/rising_bubble_rans3p/pressureInitial_n.py similarity index 96% rename from proteus/tests/surface_tension/rising_bubble_rans3p/pressureInitial_n.py rename to test/surface_tension/rising_bubble_rans3p/pressureInitial_n.py index ee1905b761..b0eca90540 100644 --- a/proteus/tests/surface_tension/rising_bubble_rans3p/pressureInitial_n.py +++ b/test/surface_tension/rising_bubble_rans3p/pressureInitial_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/pressureInitial_p.py b/test/surface_tension/rising_bubble_rans3p/pressureInitial_p.py similarity index 94% rename from proteus/tests/surface_tension/rising_bubble_rans3p/pressureInitial_p.py rename to test/surface_tension/rising_bubble_rans3p/pressureInitial_p.py index e394e8d8d8..529d791514 100644 --- a/proteus/tests/surface_tension/rising_bubble_rans3p/pressureInitial_p.py +++ b/test/surface_tension/rising_bubble_rans3p/pressureInitial_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from math import * from proteus import * from proteus.default_p import * diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/pressure_n.py b/test/surface_tension/rising_bubble_rans3p/pressure_n.py similarity index 96% rename from proteus/tests/surface_tension/rising_bubble_rans3p/pressure_n.py rename to test/surface_tension/rising_bubble_rans3p/pressure_n.py index e93e8c3b06..bbbd763071 100644 --- a/proteus/tests/surface_tension/rising_bubble_rans3p/pressure_n.py +++ b/test/surface_tension/rising_bubble_rans3p/pressure_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/pressure_p.py b/test/surface_tension/rising_bubble_rans3p/pressure_p.py similarity index 93% rename from proteus/tests/surface_tension/rising_bubble_rans3p/pressure_p.py rename to test/surface_tension/rising_bubble_rans3p/pressure_p.py index 0e22e0881a..d4bea1b986 100644 --- a/proteus/tests/surface_tension/rising_bubble_rans3p/pressure_p.py +++ b/test/surface_tension/rising_bubble_rans3p/pressure_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from math import * from proteus import * from proteus.default_p import * diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/pressureincrement_n.py b/test/surface_tension/rising_bubble_rans3p/pressureincrement_n.py similarity index 96% rename from proteus/tests/surface_tension/rising_bubble_rans3p/pressureincrement_n.py rename to test/surface_tension/rising_bubble_rans3p/pressureincrement_n.py index 9905874f80..33dd60e648 100644 --- a/proteus/tests/surface_tension/rising_bubble_rans3p/pressureincrement_n.py +++ b/test/surface_tension/rising_bubble_rans3p/pressureincrement_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * from proteus.default_n import * try: diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/pressureincrement_p.py b/test/surface_tension/rising_bubble_rans3p/pressureincrement_p.py similarity index 95% rename from proteus/tests/surface_tension/rising_bubble_rans3p/pressureincrement_p.py rename to test/surface_tension/rising_bubble_rans3p/pressureincrement_p.py index f26403226c..a582d745e4 100644 --- a/proteus/tests/surface_tension/rising_bubble_rans3p/pressureincrement_p.py +++ b/test/surface_tension/rising_bubble_rans3p/pressureincrement_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from math import * from proteus import * from proteus.default_p import * diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/redist_n.py b/test/surface_tension/rising_bubble_rans3p/redist_n.py similarity index 97% rename from proteus/tests/surface_tension/rising_bubble_rans3p/redist_n.py rename to test/surface_tension/rising_bubble_rans3p/redist_n.py index ad78f941c2..a98caa584a 100644 --- a/proteus/tests/surface_tension/rising_bubble_rans3p/redist_n.py +++ b/test/surface_tension/rising_bubble_rans3p/redist_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * try: from .redist_p import * diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/redist_p.py b/test/surface_tension/rising_bubble_rans3p/redist_p.py similarity index 94% rename from proteus/tests/surface_tension/rising_bubble_rans3p/redist_p.py rename to test/surface_tension/rising_bubble_rans3p/redist_p.py index cf4c9cd5a4..75b9c611f0 100644 --- a/proteus/tests/surface_tension/rising_bubble_rans3p/redist_p.py +++ b/test/surface_tension/rising_bubble_rans3p/redist_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * from math import * diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/risingBubble.py b/test/surface_tension/rising_bubble_rans3p/risingBubble.py similarity index 95% rename from proteus/tests/surface_tension/rising_bubble_rans3p/risingBubble.py rename to test/surface_tension/rising_bubble_rans3p/risingBubble.py index d6669b3c36..e6ed201138 100644 --- a/proteus/tests/surface_tension/rising_bubble_rans3p/risingBubble.py +++ b/test/surface_tension/rising_bubble_rans3p/risingBubble.py @@ -1,7 +1,3 @@ -from __future__ import print_function -from __future__ import absolute_import -from __future__ import division -from past.utils import old_div from math import * import proteus.MeshTools from proteus import Domain @@ -50,10 +46,10 @@ T=3.0 # Water rho_0 = 1000.0 - nu_0 = old_div(10.0,rho_0) + nu_0 = 10.0/rho_0 # Air rho_1 = 100.0 - nu_1 = old_div(1.0,rho_1) + nu_1 = 1.0/rho_1 # Surface tension sigma_01 = 24.5 # Gravity @@ -62,10 +58,10 @@ T=3.0 # Water rho_0 = 1000.0 - nu_0 = old_div(10.0,rho_0) + nu_0 = 10.0/rho_0 # Air rho_1 = 1.0 - nu_1 = old_div(0.1,rho_1) + nu_1 = 0.1/rho_1 # Surface tension sigma_01 = 1.96 # Gravity @@ -152,12 +148,12 @@ # Domain and mesh if nd==2: L = (1.0 , 2.0) - he = old_div(L[0],float(4*Refinement-1)) + he = L[0]/float(4*Refinement-1) he*=0.5 he*=0.5 else: L = (1.0 , 1.0, 2.0) - he = old_div(L[0],float(4*Refinement-1)) + he = L[0]/float(4*Refinement-1) if AUTOMATED_TEST==False: he*=0.65 @@ -191,7 +187,7 @@ triangleFlag=1 domain = Domain.RectangularDomain(L) domain.polyfile = os.path.dirname(os.path.abspath(__file__))+"/"+"mesh3D" - he = old_div(L[0],(nnx - 1)) + he = L[0]/(nnx-1) else: if nd==2: vertices = [[0.0, 0.0], #0 @@ -261,9 +257,9 @@ domain.writePLY("mesh") domain.writeAsymptote("mesh") if nd==2: - triangleOptions = "VApq30Dena%8.8f" % (old_div((he ** 2), 2.0),) + triangleOptions = "VApq30Dena%8.8f" % ((he**2)/2.0,) else: - triangleOptions="VApq1.4q12feena%21.16e" % (old_div((he**3),6.0),) + triangleOptions="VApq1.4q12feena%21.16e" % ((he**3)/6.0,) logEvent("""Mesh generated using: tetgen -%s %s""" % (triangleOptions, domain.polyfile + ".poly")) @@ -362,7 +358,7 @@ #dt_init = dt_fixed dt_init = min(0.1*dt_fixed,0.001) runCFL=0.33 -nDTout = int(round(old_div(T,dt_fixed))) +nDTout = int(round(T/dt_fixed)) ########################################## # Signed Distance # diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/risingBubble_so.py b/test/surface_tension/rising_bubble_rans3p/risingBubble_so.py similarity index 96% rename from proteus/tests/surface_tension/rising_bubble_rans3p/risingBubble_so.py rename to test/surface_tension/rising_bubble_rans3p/risingBubble_so.py index ef283a0112..01c2df003b 100644 --- a/proteus/tests/surface_tension/rising_bubble_rans3p/risingBubble_so.py +++ b/test/surface_tension/rising_bubble_rans3p/risingBubble_so.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import range from proteus.default_so import * try: from . import risingBubble diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/test_surf_tension.py b/test/surface_tension/rising_bubble_rans3p/test_surf_tension.py similarity index 77% rename from proteus/tests/surface_tension/rising_bubble_rans3p/test_surf_tension.py rename to test/surface_tension/rising_bubble_rans3p/test_surf_tension.py index c4fbf7c6a9..59532b0ae6 100644 --- a/proteus/tests/surface_tension/rising_bubble_rans3p/test_surf_tension.py +++ b/test/surface_tension/rising_bubble_rans3p/test_surf_tension.py @@ -2,8 +2,6 @@ """ Test module for surface tension """ -from builtins import range -from builtins import object from proteus.iproteus import * from proteus import Comm comm = Comm.get() @@ -11,7 +9,7 @@ Profiling.verbose=True import os import numpy as np -import tables +import h5py import pytest from proteus import default_so from . import (parameters, @@ -72,19 +70,19 @@ def teardown_method(self,method): pass def compare_files(self,path,name): - actual = tables.open_file(name+'.h5','r') + actual = h5py.File(name+'.h5','r') expected_path = 'comparison_files/' + 'comparison_' + name + '_phi_t2.csv' #write comparison file #np.array(actual.root.phi_t2).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.phi_t2).flatten(),decimal=10) + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['phi_t2']).flatten(),decimal=10) expected_path = 'comparison_files/' + 'comparison_' + name + '_p_t2.csv' #np.array(actual.root.p_t2).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.p_t2).flatten(),decimal=10) + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['p_t2']).flatten(),decimal=10) expected_path = 'comparison_files/' + 'comparison_' + name + '_velocity_t2.csv' #np.array(actual.root.velocity_t2).tofile(os.path.join(self._scriptdir, expected_path),sep=",") - np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual.root.velocity_t2).flatten(),decimal=10) + np.testing.assert_almost_equal(np.fromfile(os.path.join(self._scriptdir, expected_path),sep=","),np.array(actual['velocity_t2']).flatten(),decimal=10) actual.close() @@ -124,14 +122,6 @@ def test_2D_with_supg(self): opts) ns.calculateSolution('2D_supg') # COMPARE VS SAVED FILES # - #expected_path = 'comparison_files/risingBubble_2D_supg.h5' - #expected = tables.open_file(os.path.join(self._scriptdir,expected_path)) - #actual = tables.open_file('risingBubble_2D_supg.h5','r') - #assert np.allclose(expected.root.phi_t2,actual.root.phi_t2,atol=1e-5) - #assert np.allclose(expected.root.p_t2,actual.root.p_t2,atol=1e-5) - #assert np.allclose(expected.root.velocity_t2,actual.root.velocity_t2,atol=1e-5) - #expected.close() - #actual.close() self.compare_files('comparison_files',self.so.name) def test_2D_with_EV(self): @@ -169,14 +159,6 @@ def test_2D_with_EV(self): opts) ns.calculateSolution('2D_ev') # COMPARE VS SAVED FILES # - #expected_path = 'comparison_files/risingBubble_2D_ev.h5' - #expected = tables.open_file(os.path.join(self._scriptdir,expected_path)) - #actual = tables.open_file('risingBubble_2D_ev.h5','r') - #assert np.allclose(expected.root.phi_t2,actual.root.phi_t2,atol=1e-5) - #assert np.allclose(expected.root.p_t2,actual.root.p_t2,atol=1e-5) - #assert np.allclose(expected.root.velocity_t2,actual.root.velocity_t2,atol=1e-5) - #expected.close() - #actual.close() self.compare_files('comparison_files',self.so.name) def test_3D_with_SUPG(self): @@ -214,14 +196,6 @@ def test_3D_with_SUPG(self): opts) ns.calculateSolution('3D_supg') # COMPARE VS SAVED FILES # - #expected_path = 'comparison_files/risingBubble_3D_supg.h5' - #expected = tables.open_file(os.path.join(self._scriptdir,expected_path)) - #actual = tables.open_file('risingBubble_3D_supg.h5','r') - #assert np.allclose(expected.root.phi_t2,actual.root.phi_t2,atol=1e-5) - #assert np.allclose(expected.root.p_t2,actual.root.p_t2,atol=1e-5) - #assert np.allclose(expected.root.velocity_t2,actual.root.velocity_t2,atol=1e-5) - #expected.close() - #actual.close() self.compare_files('comparison_files',self.so.name) def test_3D_with_EV(self): @@ -260,13 +234,4 @@ def test_3D_with_EV(self): failed = ns.calculateSolution('3D_ev') assert(not failed) # COMPARE VS SAVED FILES # - #expected_path = 'comparison_files/risingBubble_3D_ev.h5' - #expected = tables.open_file(os.path.join(self._scriptdir,expected_path)) - #actual = tables.open_file('risingBubble_3D_ev.h5','r') - #assert np.allclose(expected.root.phi_t2,actual.root.phi_t2,atol=1e-5) - #assert np.allclose(expected.root.p_t2,actual.root.p_t2,atol=1e-5) - #assert np.allclose(expected.root.velocity_t2,actual.root.velocity_t2,atol=1e-5) - #expected.close() - #actual.close() self.compare_files('comparison_files',self.so.name) - diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/twp_navier_stokes_n.py b/test/surface_tension/rising_bubble_rans3p/twp_navier_stokes_n.py similarity index 98% rename from proteus/tests/surface_tension/rising_bubble_rans3p/twp_navier_stokes_n.py rename to test/surface_tension/rising_bubble_rans3p/twp_navier_stokes_n.py index 5766e3b3c1..e7dbf4dc5f 100644 --- a/proteus/tests/surface_tension/rising_bubble_rans3p/twp_navier_stokes_n.py +++ b/test/surface_tension/rising_bubble_rans3p/twp_navier_stokes_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * try: from .twp_navier_stokes_p import * diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/twp_navier_stokes_p.py b/test/surface_tension/rising_bubble_rans3p/twp_navier_stokes_p.py similarity index 98% rename from proteus/tests/surface_tension/rising_bubble_rans3p/twp_navier_stokes_p.py rename to test/surface_tension/rising_bubble_rans3p/twp_navier_stokes_p.py index d11726ca96..263be7ef44 100644 --- a/proteus/tests/surface_tension/rising_bubble_rans3p/twp_navier_stokes_p.py +++ b/test/surface_tension/rising_bubble_rans3p/twp_navier_stokes_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * try: diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/vof_n.py b/test/surface_tension/rising_bubble_rans3p/vof_n.py similarity index 97% rename from proteus/tests/surface_tension/rising_bubble_rans3p/vof_n.py rename to test/surface_tension/rising_bubble_rans3p/vof_n.py index 4070512146..f405065e0d 100644 --- a/proteus/tests/surface_tension/rising_bubble_rans3p/vof_n.py +++ b/test/surface_tension/rising_bubble_rans3p/vof_n.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import from proteus import * try: from .risingBubble import * diff --git a/proteus/tests/surface_tension/rising_bubble_rans3p/vof_p.py b/test/surface_tension/rising_bubble_rans3p/vof_p.py similarity index 95% rename from proteus/tests/surface_tension/rising_bubble_rans3p/vof_p.py rename to test/surface_tension/rising_bubble_rans3p/vof_p.py index 8d418908b2..3e91ea3a48 100644 --- a/proteus/tests/surface_tension/rising_bubble_rans3p/vof_p.py +++ b/test/surface_tension/rising_bubble_rans3p/vof_p.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import -from builtins import object from proteus import * from proteus.default_p import * from proteus.ctransportCoefficients import smoothedHeaviside diff --git a/proteus/tests/testFMMandFSW.cpp b/test/testFMMandFSW.cpp similarity index 100% rename from proteus/tests/testFMMandFSW.cpp rename to test/testFMMandFSW.cpp diff --git a/proteus/tests/test_CompQuad.py b/test/test_CompQuad.py similarity index 84% rename from proteus/tests/test_CompQuad.py rename to test/test_CompQuad.py index 7855b50fd9..4d5b587ef0 100644 --- a/proteus/tests/test_CompQuad.py +++ b/test/test_CompQuad.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import range -from past.utils import old_div from proteus import (Comm, Profiling, Quadrature) from proteus.Profiling import logEvent @@ -38,7 +35,7 @@ def ex2(N, hk, x0, y0): quad = Quadrature.GaussTriangle(N) comp_quad = Quadrature.CompositeTriangle(quad, hk) - N = int(np.ceil(old_div(1, hk))) + N = int(np.ceil(1/hk)) ii = np.sum(comp_quad.weights[np.less_equal( comp_quad.points[:, 0] * y0 + comp_quad.points[:, 1] * x0, x0 * y0)]) @@ -46,8 +43,8 @@ def ex2(N, hk, x0, y0): ee = np.abs(ii - x0 * y0 * 0.5) logEvent("hk=%f\t true-int=%f\t comp-int=%f error=%f" % - (old_div(1.0, N), x0 * y0 * 0.5, ii, ee)) - return old_div(1.0, N), ee + (1.0/N, x0 * y0 * 0.5, ii, ee)) + return 1.0/N, ee def ex3(N, hk, r0): @@ -67,14 +64,14 @@ def ex3(N, hk, r0): quad = Quadrature.GaussTriangle(N) comp_quad = Quadrature.CompositeTriangle(quad, hk) - N = int(np.ceil(old_div(1, hk))) + N = int(np.ceil(1/hk)) ii = np.sum(comp_quad.weights[np.less_equal( comp_quad.points[:, 0] ** 2 + comp_quad.points[:, 1] ** 2, r0 * r0)]) ee = np.abs(ii - r0**2 * 0.25 * np.pi) logEvent("hk=%f\t true-int=%f\t comp-int=%f error=%f" % - (old_div(1.0, N), r0**2 * 0.25 * np.pi, ii, ee)) - return old_div(1.0, N), ee + (1.0/N, r0**2 * 0.25 * np.pi, ii, ee)) + return 1.0/N, ee def ex4(N, hk): @@ -92,7 +89,7 @@ def ex4(N, hk): quad = Quadrature.GaussTriangle(N) comp_quad = Quadrature.CompositeTriangle(quad, hk) - N = int(np.ceil(old_div(1, hk))) + N = int(np.ceil(1/hk)) quad_points = np.asarray(quad.points, 'd') quad_weights = np.asarray(quad.weights, 'd') @@ -102,8 +99,8 @@ def ex4(N, hk): ee = np.abs(ii_quad - ii_comp_quad) logEvent("hk=%f\t quad-int=%f\t comp-quad-int=%f error=%f" % - (old_div(1.0, N), ii_quad, ii_comp_quad, ee)) - return old_div(1.0, N), ee + (1.0/N, ii_quad, ii_comp_quad, ee)) + return 1.0/N, ee def ex5(N, hk): @@ -121,7 +118,7 @@ def ex5(N, hk): quad = Quadrature.GaussTriangle(N) comp_quad = Quadrature.CompositeTriangle(quad, hk) - N = int(np.ceil(old_div(1, hk))) + N = int(np.ceil(1/hk)) quad_points = np.asarray(quad.points, 'd') quad_weights = np.asarray(quad.weights, 'd') @@ -132,8 +129,8 @@ def ex5(N, hk): ee = np.abs(ii_quad - ii_comp_quad) logEvent("hk=%f\t quad-int=%f\t comp-quad-int=%f error=%f" % - (old_div(1.0, N), ii_quad, ii_comp_quad, ee)) - return old_div(1.0, N), ee + (1.0/N, ii_quad, ii_comp_quad, ee)) + return 1.0/N, ee def ex6(N, hk): @@ -151,7 +148,7 @@ def ex6(N, hk): quad = Quadrature.GaussTriangle(N) comp_quad = Quadrature.CompositeTriangle(quad, hk) - N = int(np.ceil(old_div(1, hk))) + N = int(np.ceil(1/hk)) quad_points = np.asarray(quad.points, 'd') quad_weights = np.asarray(quad.weights, 'd') @@ -163,8 +160,8 @@ def ex6(N, hk): ee = np.abs(ii_quad - ii_comp_quad) logEvent("hk=%f\t quad-int=%f\t comp-quad-int=%f error=%f" % - (old_div(1.0, N), ii_quad, ii_comp_quad, ee)) - return old_div(1.0, N), ee + (1.0/N, ii_quad, ii_comp_quad, ee)) + return 1.0/N, ee def get_convergence_rate(hh, ee, cc): @@ -181,7 +178,7 @@ def get_convergence_rate(hh, ee, cc): convergence rate: :math:`cc[i]=log(ee[i]/ee[i-1])/log(hh[i]/hh[i-1]), i>0` """ for i in range(1, hh.shape[0]): - cc[i] = old_div(np.log(old_div(ee[i], (ee[i - 1] + 1e-15))), np.log(old_div(hh[i], hh[i - 1]))) + cc[i] = np.log(ee[i]/(ee[i - 1] + 1e-15))/np.log(hh[i]/hh[i - 1]) class TestCompQuad(unittest.TestCase): @@ -192,7 +189,7 @@ def test_constant_exact(self): #====================================================================== M = 10 for i in range(M): - hk, error = ex2(1, old_div(1.0, 2**i), 1.0, 1.0) + hk, error = ex2(1, 1.0/2**i, 1.0, 1.0) assert np.allclose(error, 0.0, atol=1e-10) def test_1st_poly_exact(self): @@ -201,7 +198,7 @@ def test_1st_poly_exact(self): #====================================================================== M = 10 for i in range(M): - hk, error = ex4(1, old_div(1.0, 2**i)) + hk, error = ex4(1, 1.0/2**i) assert np.allclose(error, 0.0, atol=1e-10) def test_2nd_poly_exact(self): @@ -210,7 +207,7 @@ def test_2nd_poly_exact(self): #====================================================================== M = 10 for i in range(M): - hk, error = ex5(2, old_div(1.0, 2**i)) + hk, error = ex5(2, 1.0/2**i) assert np.allclose(error, 0.0, atol=1e-10) def test_3rd_poly_exact(self): @@ -219,7 +216,7 @@ def test_3rd_poly_exact(self): #====================================================================== M = 10 for i in range(M): - hk, error = ex6(3, old_div(1.0, 2**i)) + hk, error = ex6(3, 1.0/2**i) assert np.allclose(error, 0.0, atol=1e-10) def test_line(self): @@ -232,7 +229,7 @@ def test_line(self): convergence_rate = np.zeros((M,), 'd') for i in range(M): - cell_size[i], error[i] = ex2(1, old_div(1.0, 2**i), 0.6, 1.0) + cell_size[i], error[i] = ex2(1, 1.0/2**i, 0.6, 1.0) get_convergence_rate(cell_size, error, convergence_rate) logEvent("average convergence rate is %f" % @@ -241,7 +238,7 @@ def test_line(self): convergence_rate[1:]), 1.0, "convergence should be > 1") for i in range(M): - cell_size[i], error[i] = ex2(2, old_div(1.0, 2**i), 0.6, 1.0) + cell_size[i], error[i] = ex2(2, 1.0/2**i, 0.6, 1.0) get_convergence_rate(cell_size, error, convergence_rate) logEvent("average convergence rate is %f" % @@ -250,7 +247,7 @@ def test_line(self): convergence_rate[1:]), 1.0, "convergence should be > 1") for i in range(M): - cell_size[i], error[i] = ex2(3, old_div(1.0, 2**i), 0.6, 1.0) + cell_size[i], error[i] = ex2(3, 1.0/2**i, 0.6, 1.0) get_convergence_rate(cell_size, error, convergence_rate) logEvent("average convergence rate is %f" % @@ -259,7 +256,7 @@ def test_line(self): convergence_rate[1:]), 1.0, "convergence should be > 1") for i in range(M): - cell_size[i], error[i] = ex2(4, old_div(1.0, 2**i), 0.6, 1.0) + cell_size[i], error[i] = ex2(4, 1.0/2**i, 0.6, 1.0) get_convergence_rate(cell_size, error, convergence_rate) logEvent("average convergence rate is %f" % @@ -277,7 +274,7 @@ def test_circle(self): convergence_rate = np.zeros((M,), 'd') for i in range(M): - cell_size[i], error[i] = ex3(1, old_div(1.0, 2**i), 0.5) + cell_size[i], error[i] = ex3(1, 1.0/2**i, 0.5) get_convergence_rate(cell_size, error, convergence_rate) logEvent("average convergence rate is %f" % @@ -286,7 +283,7 @@ def test_circle(self): convergence_rate[1:]), 1.0, "convergence should be > 1") for i in range(M): - cell_size[i], error[i] = ex3(2, old_div(1.0, 2**i), 0.5) + cell_size[i], error[i] = ex3(2, 1.0/2**i, 0.5) get_convergence_rate(cell_size, error, convergence_rate) logEvent("average convergence rate is %f" % @@ -295,7 +292,7 @@ def test_circle(self): convergence_rate[1:]), 1.0, "convergence should be > 1") for i in range(M): - cell_size[i], error[i] = ex3(3, old_div(1.0, 2**i), 0.5) + cell_size[i], error[i] = ex3(3, 1.0/2**i, 0.5) get_convergence_rate(cell_size, error, convergence_rate) logEvent("average convergence rate is %f" % @@ -304,7 +301,7 @@ def test_circle(self): convergence_rate[1:]), 1.0, "convergence should be > 1") for i in range(M): - cell_size[i], error[i] = ex3(4, old_div(1.0, 2**i), 0.5) + cell_size[i], error[i] = ex3(4, 1.0/2**i, 0.5) get_convergence_rate(cell_size, error, convergence_rate) logEvent("average convergence rate is %f" % diff --git a/proteus/tests/test_CompQuad_3D.py b/test/test_CompQuad_3D.py similarity index 89% rename from proteus/tests/test_CompQuad_3D.py rename to test/test_CompQuad_3D.py index 18f7530258..1d898c3284 100644 --- a/proteus/tests/test_CompQuad_3D.py +++ b/test/test_CompQuad_3D.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import range -from past.utils import old_div from proteus import (Comm, Profiling, Quadrature) from proteus.Profiling import logEvent @@ -40,7 +37,7 @@ def ex2(N, hk, x0=1, y0=1, z0=1): comp_quad = Quadrature.CompositeTetrahedron(quad, hk) ii = np.sum(comp_quad.weights[np.less_equal( - old_div(comp_quad.points[:, 0], x0) + old_div(comp_quad.points[:, 1], y0) + old_div(+ comp_quad.points[:, 2], z0), 1.0)]) + comp_quad.points[:,0]/x0 + comp_quad.points[:,1]/y0 + +comp_quad.points[:,2]/z0, 1.0)]) ee = np.abs(ii - x0 * y0 * z0 / 6.0) @@ -172,7 +169,7 @@ def get_convergence_rate(hh, ee, cc): convergence rate: :math:`cc[i]=log(ee[i]/ee[i-1])/log(hh[i]/hh[i-1]), i>0` """ for i in range(1, hh.shape[0]): - cc[i] = old_div(np.log(old_div(ee[i], (ee[i - 1] + 1e-15))), np.log(old_div(hh[i], hh[i - 1]))) + cc[i] = np.log(ee[i]/(ee[i - 1] + 1e-15))/np.log(hh[i]/hh[i - 1]) class TestCompQuad(unittest.TestCase): @@ -183,7 +180,7 @@ def test_constant_exact(self): #====================================================================== M = 5 for i in range(M): - hk, error = ex2(1, old_div(1.0, 2**i), 1.0, 1.0, 1.0) + hk, error = ex2(1, 1.0/2**i, 1.0, 1.0, 1.0) assert np.allclose(error, 0.0, atol=1e-10) def test_1st_poly_exact(self): @@ -192,7 +189,7 @@ def test_1st_poly_exact(self): #====================================================================== M = 5 for i in range(M): - hk, error = ex4(1, old_div(1.0, 2**i)) + hk, error = ex4(1, 1.0/2**i) assert np.allclose(error, 0.0, atol=1e-10) def test_2nd_poly_exact(self): @@ -201,7 +198,7 @@ def test_2nd_poly_exact(self): #====================================================================== M = 5 for i in range(M): - hk, error = ex5(2, old_div(1.0, 2**i)) + hk, error = ex5(2, 1.0/2**i) assert np.allclose(error, 0.0, atol=1e-10) def test_3rd_poly_exact(self): @@ -210,7 +207,7 @@ def test_3rd_poly_exact(self): #====================================================================== M = 5 for i in range(M): - hk, error = ex6(3, old_div(1.0, 2**i)) + hk, error = ex6(3, 1.0/2**i) assert np.allclose(error, 0.0, atol=1e-10) def test_plane(self): @@ -223,7 +220,7 @@ def test_plane(self): convergence_rate = np.zeros((M,), 'd') for i in range(M): - cell_size[i], error[i] = ex2(1, old_div(1.0, 2**i), 0.5, 0.6, 0.7) + cell_size[i], error[i] = ex2(1, 1.0/2**i, 0.5, 0.6, 0.7) get_convergence_rate(cell_size, error, convergence_rate) logEvent("average convergence rate is %f" % @@ -232,7 +229,7 @@ def test_plane(self): convergence_rate[1:]), 1.0, "convergence should be > 1") for i in range(M): - cell_size[i], error[i] = ex2(2, old_div(1.0, 2**i), 0.5, 0.6, 0.7) + cell_size[i], error[i] = ex2(2, 1.0/2**i, 0.5, 0.6, 0.7) get_convergence_rate(cell_size, error, convergence_rate) logEvent("average convergence rate is %f" % @@ -241,7 +238,7 @@ def test_plane(self): convergence_rate[1:]), 1.0, "convergence should be > 1") for i in range(M): - cell_size[i], error[i] = ex2(3, old_div(1.0, 2**i), 0.5, 0.6, 0.7) + cell_size[i], error[i] = ex2(3, 1.0/2**i, 0.5, 0.6, 0.7) get_convergence_rate(cell_size, error, convergence_rate) logEvent("average convergence rate is %f" % @@ -250,7 +247,7 @@ def test_plane(self): convergence_rate[1:]), 1.0, "convergence should be > 1") for i in range(M): - cell_size[i], error[i] = ex2(4, old_div(1.0, 2**i), 0.5, 0.6, 0.7) + cell_size[i], error[i] = ex2(4, 1.0/2**i, 0.5, 0.6, 0.7) get_convergence_rate(cell_size, error, convergence_rate) logEvent("average convergence rate is %f" % @@ -268,7 +265,7 @@ def test_sphere(self): convergence_rate = np.zeros((M,), 'd') for i in range(M): - cell_size[i], error[i] = ex3(1, old_div(1.0, 2**i), 0.5) + cell_size[i], error[i] = ex3(1, 1.0/2**i, 0.5) get_convergence_rate(cell_size, error, convergence_rate) logEvent("average convergence rate is %f" % @@ -277,7 +274,7 @@ def test_sphere(self): convergence_rate[1:]), 1.0, "convergence should be > 1") for i in range(M): - cell_size[i], error[i] = ex3(2, old_div(1.0, 2**i), 0.5) + cell_size[i], error[i] = ex3(2, 1.0/2**i, 0.5) get_convergence_rate(cell_size, error, convergence_rate) logEvent("average convergence rate is %f" % @@ -286,7 +283,7 @@ def test_sphere(self): convergence_rate[1:]), 1.0, "convergence should be > 1") for i in range(M): - cell_size[i], error[i] = ex3(3, old_div(1.0, 2**i), 0.5) + cell_size[i], error[i] = ex3(3, 1.0/2**i, 0.5) get_convergence_rate(cell_size, error, convergence_rate) logEvent("average convergence rate is %f" % @@ -295,7 +292,7 @@ def test_sphere(self): convergence_rate[1:]), 1.0, "convergence should be > 1") for i in range(M): - cell_size[i], error[i] = ex3(4, old_div(1.0, 2**i), 0.5) + cell_size[i], error[i] = ex3(4, 1.0/2**i, 0.5) get_convergence_rate(cell_size, error, convergence_rate) logEvent("average convergence rate is %f" % diff --git a/proteus/tests/test_analyticalSolutions.py b/test/test_analyticalSolutions.py similarity index 99% rename from proteus/tests/test_analyticalSolutions.py rename to test/test_analyticalSolutions.py index 8c3e32543e..fa05849006 100644 --- a/proteus/tests/test_analyticalSolutions.py +++ b/test/test_analyticalSolutions.py @@ -700,4 +700,4 @@ def test_PoiseuillePipeFlow_P(): x[:, :, slice, 1], ux[:, :, slice]) plt.title('Poiseuille Pipe Flow: Pressure') - plt.savefig("PoiseuillePipeFlow_P.png") + plt.savefig("PoiseuillePipeFlow_P.png") \ No newline at end of file diff --git a/proteus/tests/test_bodydynamics.py b/test/test_bodydynamics.py similarity index 91% rename from proteus/tests/test_bodydynamics.py rename to test/test_bodydynamics.py index 1e0acaed84..9d44c663c4 100644 --- a/proteus/tests/test_bodydynamics.py +++ b/test/test_bodydynamics.py @@ -1,7 +1,3 @@ -from __future__ import print_function -from __future__ import division -from builtins import range -from past.utils import old_div from proteus import Comm, Profiling import numpy as np import numpy.testing as npt @@ -56,30 +52,30 @@ def testRungeKutta(self): K = 100000.0 C = 1000.0 m = 50.0 - a0 = old_div((F - C*v0 - K*u0), m) + a0 = (F-C*v0-K*u0)/m velCheck = True # Loop through substeps for i in range(substeps): # 1st step u1 = u0 v1 = v0 - a1 = old_div((F - C*v1 - K*u1), m) + a1 = (F-C*v1-K*u1)/m # 2nd step u2 = u0 + v1*dt/2. v2 = v0 + a1*dt/2. - a2 = old_div((F - C*v2 - K*u2), m) + a2 = (F-C*v2-K*u2)/m # 3rd step u3 = u0 + v2*dt/2. v3 = v0 + a2*dt/2. - a3 = old_div((F - C*v3 - K*u3), m) + a3 = (F-C*v3-K*u3)/m # 4th step u4 = u0 + v3*dt v4 = v0 + a3*dt - a4 = old_div((F - C*v4 - K*u4), m) + a4 = (F-C*v4-K*u4)/m # Final step u = u0 + dt/6.*(v1+2*v2+2*v3+v4) v = v0 + dt/6.*(a1+2*a2+2*a3+a4) - a = old_div((F - C*v - K*u), m) + a = (F-C*v-K*u)/m # Check for friction module, when velocity is reversed if velCheck: if v0*v < 0.0: @@ -213,8 +209,8 @@ def testGetInertia(self): mst.assembleDomain(domain2D) c2d = caisson2D c2d.nd = 2 - Ix = (old_div((dim[0]**2),12.)) - Iy = (old_div((dim[1]**2),12.)) + Ix = ((dim[0]**2)/12.) + Iy = ((dim[1]**2)/12.) It = Ix + Iy mass = 50.0 I1 = It*mass @@ -229,9 +225,9 @@ def testGetInertia(self): pos = np.array([0.0, 0.0, 0.0]) dim = (0.3, 0.385, 0.4) angle = radians(10.) - Ix = (old_div((dim[0]**2),12.)) - Iy = (old_div((dim[1]**2),12.)) - Iz = (old_div((dim[2]**2),12.)) + Ix = ((dim[0]**2)/12.) + Iy = ((dim[1]**2)/12.) + Iz = ((dim[2]**2)/12.) It = np.array([ [Iz + Iy, 0.0, 0.0], [0.0, Ix + Iz, 0.0], [0.0, 0.0, Ix + Iy] ]) @@ -239,7 +235,7 @@ def testGetInertia(self): # rotational axis and versors ax, ay, az = axis = np.array([1., 1., 1.]) mod = np.sqrt((ax**2)+(ay**2)+(az**2)) - axis_ver = (old_div(axis,mod)) + axis_ver = (axis/mod) # shape caisson = mst.Cuboid(domain=domain3D, dim=dim, coords=[pos[0], pos[1], pos[2]]) caisson.rotate(rot=angle, axis=axis) @@ -278,7 +274,7 @@ def testGetAcceleration(self): F = np.array([100.0, -200.0, 10.0]) mass = 150.0 - acceleration = old_div(F,mass) + acceleration = F/mass c2d.F = F c2d.mass = mass @@ -300,7 +296,7 @@ def testGetAngularAcceleration(self): F = np.array([100.0, -200.0, 10.0]) mass = 150.0 - acceleration = old_div(F,mass) + acceleration = F/mass c2d.F = F c2d.mass = mass @@ -322,8 +318,8 @@ def testGetDisplacement(self): mst.assembleDomain(domain2D) c2d = caisson2D c2d.nd = 2 - Ix = (old_div((dim[0]**2),12.)) - Iy = (old_div((dim[1]**2),12.)) + Ix = ((dim[0]**2)/12.) + Iy = ((dim[1]**2)/12.) It = Ix + Iy mass = 50.0 c2d.mass, c2d.It = mass, It @@ -334,14 +330,14 @@ def testGetDisplacement(self): c2d.init_barycenter, c2d.last_position, c2d.last_velocity = init_barycenter, last_position, last_velocity Fx, Fy, Fz = F = np.array([200., 300., 0.0]) dt, substeps = 0.001, 50 - dt_sub = c2d.dt_sub = float(old_div(dt,substeps)) + dt_sub = c2d.dt_sub = float(dt/substeps) c2d.F, c2d.substeps, c2d.dt, c2d.acceleration = F, substeps, dt, c2d.getAcceleration() # runge-kutta calculation c2d.scheme = 'Runge_Kutta' u0 = ux0, uy0, uz0 = last_position - init_barycenter v0 = vx0, vy0, vz0 = last_velocity - a0 = ax0, ay0, az0 = old_div((F - C*v0 - K*u0), mass) + a0 = ax0, ay0, az0 = (F-C*v0-K*u0)/mass for ii in range(substeps): ux, vx, ax = bd.runge_kutta(ux0, vx0, ax0, dt_sub, substeps, Fx, Kx, Cx, mass, False) uy, vy, ay = bd.runge_kutta(uy0, vy0, ay0, dt_sub, substeps, Fy, Ky, Cy, mass, False) @@ -366,8 +362,8 @@ def testStep(self): mst.assembleDomain(domain2D) c2d = caisson2D nd = c2d.nd = 2 - Ix = (old_div((dim[0]**2),12.)) - Iy = (old_div((dim[1]**2),12.)) + Ix = ((dim[0]**2)/12.) + Iy = ((dim[1]**2)/12.) It = Ix + Iy mass = 50.0 I = mass*It @@ -377,12 +373,12 @@ def testStep(self): F = Fx, Fy, Fz = np.array([200., 300., 0.0]) M = Mx, My, Mz = np.array([0., 0., 50.0]) dt, substeps = 0.001, 20 - dt_sub = c2d.dt_sub = float(old_div(dt,substeps)) + dt_sub = c2d.dt_sub = float(dt/substeps) c2d.F, c2d.substeps, c2d.dt, c2d.acceleration = F, substeps, dt, c2d.getAcceleration() c2d.InputMotion = False c2d.scheme = 'Forward_Euler' - h, tra_velocity = bd.forward_euler(last_position, last_velocity, old_div(F,mass), dt) - rot, rot_velocity = bd.forward_euler(last_rotation, last_ang_vel, old_div(M,I), dt) + h, tra_velocity = bd.forward_euler(last_position, last_velocity, F/mass, dt) + rot, rot_velocity = bd.forward_euler(last_rotation, last_ang_vel, M/I, dt) if rot[2] < 0.0: rot[2]=-rot[2] # 2d calculation caisson.translate(h[:nd]), caisson.rotate(rot[2]) @@ -424,8 +420,8 @@ def testGetInertia(self): pivot = np.array([(caisson.vertices[0][0]+caisson.vertices[1][0])*0.5, caisson.vertices[0][1], 0.0]) d = dx, dy, dz = pivot - caisson.barycenter # inertia transformation with different pivot - Ix = (old_div((dim[0]**2),12.)) + dy**2 - Iy = (old_div((dim[1]**2),12.)) + dx**2 + Ix = ((dim[0]**2)/12.) + dy**2 + Iy = ((dim[1]**2)/12.) + dx**2 It = Ix + Iy I = It*mass I1 = c2d.getInertia(vec=(0.,0.,1.), pivot=pivot) @@ -453,9 +449,9 @@ def testFrictionModule(self): mst.assembleDomain(domain2D) c2d = caisson2D c2d.nd = 2 - dt_sub = c2d.dt_sub = float(old_div(dt,substeps)) - Ix = (old_div((dim[0]**2),12.)) - Iy = (old_div((dim[1]**2),12.)) + dt_sub = c2d.dt_sub = float(dt/substeps) + Ix = ((dim[0]**2)/12.) + Iy = ((dim[1]**2)/12.) It = Ix + Iy mass = 50.0 c2d.mass, c2d.It = mass, It @@ -472,11 +468,11 @@ def testFrictionModule(self): c2d.last_uxEl = pos[0]+disp[0]-init_barycenter[0] c2d.F, c2d.init_barycenter, c2d.last_position, c2d.last_velocity = F, init_barycenter, last_position, last_velocity eps = 10.**-30 - sign_static, sign_dynamic = old_div(Fx,abs(Fx+eps)), old_div(last_velocity[0],abs(last_velocity[0]+eps)) + sign_static, sign_dynamic = Fx/abs(Fx+eps), last_velocity[0]/abs(last_velocity[0]+eps) c2d.sliding, sign, m = True, sign_dynamic, m_dynamic # vertical calculation and frictional force uy0, vy0 = (last_position[1] - init_barycenter[1]), last_velocity[1] - ay0 = old_div((Fy - Cy*vy0 - Ky*uy0), mass) + ay0 = (Fy-Cy*vy0-Ky*uy0)/mass uy, vy, ay = bd.runge_kutta(uy0, vy0, ay0, dt_sub, substeps, Fy, Ky, Cy, mass, False) Rx = -Kx*(last_position[0]-init_barycenter[0]) Ry = -Ky*uy @@ -489,7 +485,7 @@ def testFrictionModule(self): vx0, vz0 = last_velocity[0], last_velocity[2] Fh = Fx+Ftan Kx, Cx = 0.0, 0.0 - ax0, az0 = old_div((Fh - Cx*vx0 - Kx*ux0), mass) , old_div((Fz - Cz*vz0 - Kz*uz0), mass) + ax0, az0 = (Fh-Cx*vx0-Kx*ux0)/mass , (Fz-Cz*vz0-Kz*uz0)/mass ux, vx, ax = bd.runge_kutta(ux0, vx0, ax0, dt_sub, substeps, Fh, Kx, Cx, mass, True) uz, vz, az = bd.runge_kutta(uz0, vz0, az0, dt_sub, substeps, Fz, Kz, Cz, mass, False) # bodydynamics calculation @@ -516,9 +512,9 @@ def testFrictionModule(self): mst.assembleDomain(domain2D) c2d = caisson2D c2d.nd = 2 - dt_sub = c2d.dt_sub = float(old_div(dt,substeps)) - Ix = (old_div((dim[0]**2),12.)) - Iy = (old_div((dim[1]**2),12.)) + dt_sub = c2d.dt_sub = float(dt/substeps) + Ix = ((dim[0]**2)/12.) + Iy = ((dim[1]**2)/12.) It = Ix + Iy mass = 50.0 c2d.mass, c2d.It = mass, It @@ -535,11 +531,11 @@ def testFrictionModule(self): c2d.last_uxEl = pos[0]+disp[0]-init_barycenter[0] c2d.F, c2d.init_barycenter, c2d.last_position, c2d.last_velocity = F, init_barycenter, last_position, last_velocity eps = 10.**-30 - sign_static, sign_dynamic = old_div(Fx,abs(Fx+eps)), old_div(last_velocity[0],abs(last_velocity[0]+eps)) + sign_static, sign_dynamic = Fx/abs(Fx+eps), last_velocity[0]/abs(last_velocity[0]+eps) c2d.sliding, sign, m = False, sign_static, m_static # vertical calculation and frictional force uy0, vy0 = (last_position[1] - init_barycenter[1]), last_velocity[1] - ay0 = old_div((Fy - Cy*vy0 - Ky*uy0), mass) + ay0 = (Fy-Cy*vy0-Ky*uy0)/mass uy, vy, ay = bd.runge_kutta(uy0, vy0, ay0, dt_sub, substeps, Fy, Ky, Cy, mass, False) Rx = -Kx*(last_position[0]-init_barycenter[0]) Ry = -Ky*uy @@ -552,7 +548,7 @@ def testFrictionModule(self): vx0, vz0 = last_velocity[0], last_velocity[2] Fh = Fx+Ftan Kx, Cx = 0.0, 0.0 - ax0, az0 = old_div((Fh - Cx*vx0 - Kx*ux0), mass) , old_div((Fz - Cz*vz0 - Kz*uz0), mass) + ax0, az0 = (Fh-Cx*vx0-Kx*ux0)/mass , (Fz-Cz*vz0-Kz*uz0)/mass ux, vx, ax = bd.runge_kutta(ux0, vx0, ax0, dt_sub, substeps, Fh, Kx, Cx, mass, True) uz, vz, az = bd.runge_kutta(uz0, vz0, az0, dt_sub, substeps, Fz, Kz, Cz, mass, False) # bodydynamics calculation @@ -579,9 +575,9 @@ def testFrictionModule(self): mst.assembleDomain(domain2D) c2d = caisson2D c2d.nd = 2 - dt_sub = c2d.dt_sub = float(old_div(dt,substeps)) - Ix = (old_div((dim[0]**2),12.)) - Iy = (old_div((dim[1]**2),12.)) + dt_sub = c2d.dt_sub = float(dt/substeps) + Ix = ((dim[0]**2)/12.) + Iy = ((dim[1]**2)/12.) It = Ix + Iy mass = 50.0 c2d.mass, c2d.It = mass, It @@ -598,11 +594,11 @@ def testFrictionModule(self): c2d.last_uxEl = pos[0]+disp[0]-init_barycenter[0] c2d.F, c2d.init_barycenter, c2d.last_position, c2d.last_velocity = F, init_barycenter, last_position, last_velocity eps = 10.**-30 - sign_static, sign_dynamic = old_div(Fx,abs(Fx+eps)), old_div(last_velocity[0],abs(last_velocity[0]+eps)) + sign_static, sign_dynamic = Fx/abs(Fx+eps), last_velocity[0]/abs(last_velocity[0]+eps) c2d.sliding, sign, m = False, sign_static, m_static # vertical calculation and frictional force uy0, vy0 = (last_position[1] - init_barycenter[1]), last_velocity[1] - ay0 = old_div((Fy - Cy*vy0 - Ky*uy0), mass) + ay0 = (Fy-Cy*vy0-Ky*uy0)/mass uy, vy, ay = bd.runge_kutta(uy0, vy0, ay0, dt_sub, substeps, Fy, Ky, Cy, mass, False) Rx = -Kx*(last_position[0]-init_barycenter[0]) Ry = -Ky*uy @@ -614,7 +610,7 @@ def testFrictionModule(self): ux0, uz0 = last_position[0] - init_barycenter[0], last_position[2] - init_barycenter[2] vx0, vz0 = last_velocity[0], last_velocity[2] Fh = Fx - ax0, az0 = old_div((Fh - Cx*vx0 - Kx*ux0), mass) , old_div((Fz - Cz*vz0 - Kz*uz0), mass) + ax0, az0 = (Fh-Cx*vx0-Kx*ux0)/mass , (Fz-Cz*vz0-Kz*uz0)/mass ux, vx, ax = bd.runge_kutta(ux0, vx0, ax0, dt_sub, substeps, Fh, Kx, Cx, mass, True) uz, vz, az = bd.runge_kutta(uz0, vz0, az0, dt_sub, substeps, Fz, Kz, Cz, mass, False) # bodydynamics calculation @@ -641,7 +637,7 @@ def testOverturningModule(self): mst.assembleDomain(domain2D) c2d = caisson2D c2d.nd = 2 - dt_sub = c2d.dt_sub = float(old_div(dt,substeps)) + dt_sub = c2d.dt_sub = float(dt/substeps) Krot = 200000. Crot = 2000. c2d.Krot, c2d.Crot = Krot, Crot @@ -661,15 +657,15 @@ def testOverturningModule(self): distance = dx, dy, dz = pivot - barycenter Mpivot = np.array([0., 0., dx*Fy-dy*Fx]) # Moment calculated in pivot Mp = M - Mpivot # Moment transformation through the new pivot - Ix = (old_div((dim[0]**2),12.)) + dy**2 - Iy = (old_div((dim[1]**2),12.)) + dx**2 + Ix = ((dim[0]**2)/12.) + dy**2 + Iy = ((dim[1]**2)/12.) + dx**2 It = Ix + Iy I = It*mass c2d.springs = True # runge-kutta calculation c2d.scheme = 'Runge_Kutta' rz0, vrz0 = atan2(last_rotation[0,1], last_rotation[0,0]), last_ang_vel[2] - arz0 = old_div((Mp[2] - Crot*vrz0 - Krot*rz0), I) + arz0 = (Mp[2]-Crot*vrz0-Krot*rz0)/I rz, vrz, arz = bd.runge_kutta(rz0, vrz0, arz0, dt_sub, substeps, Mp[2], Krot, Crot, I, False) # calculation with bodydynamics mopdule c2d.cV_init = c2d.cV = c2d.cV_last = caisson.vertices diff --git a/proteus/tests/test_boundaryconditions.py b/test/test_boundaryconditions.py similarity index 99% rename from proteus/tests/test_boundaryconditions.py rename to test/test_boundaryconditions.py index 4672bb9a11..d65c9682e5 100644 --- a/proteus/tests/test_boundaryconditions.py +++ b/test/test_boundaryconditions.py @@ -1,5 +1,3 @@ - - """ Testing module for proteus.BoundaryConditions Work in progress @@ -10,11 +8,6 @@ setHydrostaticPressureOutletWithDepth() wallFunctions() """ -from __future__ import division - - -from past.utils import old_div -from builtins import object import os, sys import random import unittest @@ -680,7 +673,7 @@ def test_unsteady_two_phase_velocity_inlet(self): U = H*wind_speed + (1-H)*wave_u u_calc += [U] p_calc += [np.sum(U*b_or[b_i])] - if wavePhi >= old_div(smoothing,2.): + if wavePhi >= smoothing/2.: Hvof = 1. elif smoothing > 0 and -smoothing/2. < wavePhi < smoothing/2.: Hvof = smoothedHeaviside(smoothing, wavePhi) @@ -739,8 +732,8 @@ def test_two_phase_velocity_inlet(self): water = 0. kInflow = 0.00005 dissipationInflow = 0.00001 - kInflowAir = old_div(kInflow, 10.) - dissipationInflowAir = old_div(dissipationInflow, 10.) + kInflowAir = kInflow/10. + dissipationInflowAir = dissipationInflow/10. BC = create_BC(folder='mprans', b_or=b_or, b_i=b_i) # setting variables uDir, vDir, wDir, vofDir, pAdv, kDir, dissipationDir = [],[],[],[],[],[],[] diff --git a/proteus/tests/test_context.py b/test/test_context.py similarity index 97% rename from proteus/tests/test_context.py rename to test/test_context.py index 97a352e32e..161a1ae201 100644 --- a/proteus/tests/test_context.py +++ b/test/test_context.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import import os, sys def ContextObject(): diff --git a/proteus/tests/test_equivalent_polynomials.py b/test/test_equivalent_polynomials.py similarity index 99% rename from proteus/tests/test_equivalent_polynomials.py rename to test/test_equivalent_polynomials.py index 196f858dd0..a014801487 100644 --- a/proteus/tests/test_equivalent_polynomials.py +++ b/test/test_equivalent_polynomials.py @@ -411,4 +411,4 @@ def test_3D(): print(int_D, int_D_exact) assert(int_H == approx(int_H_exact,1e-12,1e-12)) assert(int_ImH == approx(int_ImH_exact,1e-12,1e-12)) - assert(int_D == approx(int_D_exact,1e-11,1e-11)) + assert(int_D == approx(int_D_exact,1e-11,1e-11)) \ No newline at end of file diff --git a/proteus/tests/test_gauges.py b/test/test_gauges.py similarity index 98% rename from proteus/tests/test_gauges.py rename to test/test_gauges.py index 7f6d39af95..fe4fe9594f 100644 --- a/proteus/tests/test_gauges.py +++ b/test/test_gauges.py @@ -1,9 +1,4 @@ -from __future__ import print_function -from __future__ import division -from past.utils import old_div -from builtins import object from math import ceil, sqrt, pow - import os import numpy as np import numpy.testing as npt @@ -83,7 +78,7 @@ def uOfXT(self,x,t): nnx = nny = int(ceil(sqrt(total_nodes)))+1 mlMesh = build2DMesh(p, nnx, nny) elif p.nd == 3: - nnx = nny = nnz = int(ceil(pow(total_nodes, old_div(1.0,3.0))))+1 + nnx = nny = nnz = int(ceil(pow(total_nodes, 1.0/3.0)))+1 mlMesh = build3DMesh(p, nnx, nny, nnz) model = Transport.MultilevelTransport(p, n, mlMesh) diff --git a/proteus/tests/test_gmsh_generation.py b/test/test_gmsh_generation.py similarity index 80% rename from proteus/tests/test_gmsh_generation.py rename to test/test_gmsh_generation.py index 8bcb92aa26..454ba4577e 100644 --- a/proteus/tests/test_gmsh_generation.py +++ b/test/test_gmsh_generation.py @@ -1,5 +1,3 @@ -from __future__ import division -from past.utils import old_div import unittest import numpy.testing as npt import numpy as np @@ -36,8 +34,11 @@ def test_gmsh_generation_2D(self): [5., 0., 0.], [5., 5., 0.], [0., 5., 0.]] + domain.vertexFlags = [1,2,3,4] domain.segments = [[0, 1], [1, 2], [2, 3], [3, 0]] + domain.segmentFlags =[1,2,3,4] domain.facets = [[[0, 1, 2, 3]]] + domain.facetFlags = [1] domain.writeGeo('gmsh_mesh_test_2D', he_max=0.1) gmsh_cmd = "gmsh {0:s} -v 10 -2 -o {1:s} -format msh2".format(domain.geofile+".geo", domain.geofile+".msh") check_call(gmsh_cmd, shell=True) @@ -50,13 +51,13 @@ def test_gmsh_generation_2D(self): # npt.assert_equal(elefile.readline(), '6664 3 1\n') with open('gmsh_mesh_test_2D.node', 'r') as nodefile: numNodes = int(nodefile.readline().split(' ', 1)[0]) - assert abs(1.0-old_div(numNodes,numNodes_reference_2D)) < THRESHOLD + assert abs(1.0-numNodes/numNodes_reference_2D) < THRESHOLD with open('gmsh_mesh_test_2D.edge', 'r') as edgefile: numEdges = int(edgefile.readline().split(' ', 1)[0]) - assert abs(1.0-old_div(numEdges,numEdges_reference_2D)) < THRESHOLD + assert abs(1.0-numEdges/numEdges_reference_2D) < THRESHOLD with open('gmsh_mesh_test_2D.ele', 'r') as elefile: numElements = int(elefile.readline().split(' ', 1)[0]) - assert abs(1.0-old_div(numElements,numElements_reference_2D)) < THRESHOLD + assert abs(1.0-numElements/numElements_reference_2D) < THRESHOLD def test_gmsh_generation_3D(self): @@ -77,13 +78,13 @@ def test_gmsh_generation_3D(self): # with open('gmsh_mesh_test_3D.ele', 'r') as elefile: # npt.assert_equal(elefile.readline(), '37473 4 1\n') with open('gmsh_mesh_test_3D.node', 'r') as nodefile: - assert(old_div(abs(int(nodefile.readline().split()[0]) - numNodes_reference_3D ),numNodes_reference_3D ) < THRESHOLD) + assert(abs(int(nodefile.readline().split()[0]) - numNodes_reference_3D )/numNodes_reference_3D < THRESHOLD) with open('gmsh_mesh_test_3D.edge', 'r') as edgefile: - assert(old_div(abs(int(edgefile.readline().split()[0]) - numEdges_reference_3D ),numEdges_reference_3D ) < THRESHOLD) + assert(abs(int(edgefile.readline().split()[0]) - numEdges_reference_3D )/numEdges_reference_3D < THRESHOLD) with open('gmsh_mesh_test_3D.face', 'r') as facefile: - assert(old_div(abs(int(facefile.readline().split()[0]) - numFaces_reference_3D ),numFaces_reference_3D ) < THRESHOLD) + assert(abs(int(facefile.readline().split()[0]) - numFaces_reference_3D )/numFaces_reference_3D < THRESHOLD) with open('gmsh_mesh_test_3D.ele', 'r') as elefile: - assert(old_div(abs(int(elefile.readline().split()[0]) - numElements_reference_3D ),numElements_reference_3D ) < THRESHOLD) + assert(abs(int(elefile.readline().split()[0]) - numElements_reference_3D )/numElements_reference_3D < THRESHOLD) if __name__ == '__main__': unittest.main(verbosity=2) diff --git a/proteus/tests/test_lapack.py b/test/test_lapack.py similarity index 98% rename from proteus/tests/test_lapack.py rename to test/test_lapack.py index 221ceb091b..ebe88bf13a 100644 --- a/proteus/tests/test_lapack.py +++ b/test/test_lapack.py @@ -93,4 +93,4 @@ def test_denseCalculateEigenvalues(simple_dense_matrix): assert np.allclose(eigvals_r, real_eig_vals) assert np.array_equal(eigvals_i, imag_eig_vals) assert np.allclose(leftEigenvectors, left_eig_vectors) - assert np.allclose(rightEigenvectors, right_eig_vectors) + assert np.allclose(rightEigenvectors, right_eig_vectors) \ No newline at end of file diff --git a/proteus/tests/test_mbd_chrono.py b/test/test_mbd_chrono.py similarity index 61% rename from proteus/tests/test_mbd_chrono.py rename to test/test_mbd_chrono.py index c6d08a5c01..3e2ce9c21a 100644 --- a/proteus/tests/test_mbd_chrono.py +++ b/test/test_mbd_chrono.py @@ -6,22 +6,23 @@ import pychrono as chrono class TestCable(unittest.TestCase): + @pytest.mark.skip() def testHangingCableANCF(self): g = np.array([0.,0.,-9.81]) system = fsi.ProtChSystem() - system.ChSystem.Set_G_acc(chrono.ChVectorD(g[0], g[1], g[2])) + system.ChSystem.SetGravitationalAcceleration(chrono.ChVector3d(g[0], g[1], g[2])) system.setTimeStep(1e-1) - - # timestepper = chrono.ChTimestepperEulerImplicitLinearized() - # system.ChSystem.SetTimestepper(timestepper) + timestepper = chrono.ChTimestepperEulerImplicitLinearized() + system.ChSystem.SetTimestepper(timestepper) solver = chrono.ChSolverMINRES() system.ChSystem.SetSolver(solver) solver.SetMaxIterations(100) solver.EnableWarmStart(True) solver.EnableDiagonalPreconditioner(True) solver.SetVerbose(True) - system.ChSystem.SetSolverForceTolerance(1e-10) - system.ChSystem.SetSolverMaxIterations(100) + system.ChSystem.GetSolver().AsIterative().SetTolerance(1e-10) + #system.ChSystem.GetSolver().AsIterative().SetTolerancePrimal(1e-10) + system.ChSystem.GetSolver().AsIterative().SetMaxIterations(100) mesh = fsi.ProtChMesh(system) L = np.array([5.]) nb_elems = np.array([3]) @@ -30,7 +31,7 @@ def testHangingCableANCF(self): E = np.array([1e10]) cable_type = b"CableANCF" fairlead_body = fsi.ProtChBody(system) - fairlead_body.ChBody.SetBodyFixed(True) + fairlead_body.ChBody.SetFixed(True) mooring = fsi.ProtChMoorings(system=system, mesh=mesh, length=L, nb_elems=nb_elems, d=d, rho=rho, E=E, beam_type=cable_type) # vertical cable mooring.setNodesPositionFunction(lambda s: np.array([0., 0., s]), lambda s: np.array([0., 0., 1.])) @@ -80,30 +81,32 @@ def testSetterGetter(self): mass0 = body.getMass() npt.assert_almost_equal(mass0, mass) - # CURRENTLY NOT FULLY WORKING - # def testHangingCableEuler(self): - # g = np.array([0.,0.,-9.81]) - # system = fsi.ProtChSystem(gravity=g) - # system.setTimeStep(1e-1) - # mesh = fsi.Mesh(system) - # L = np.array([5.]) - # nb_elems = np.array([3]) - # d = np.array([1e-3]) - # rho = np.array([1000.]) - # E = np.array([1e10]) - # cable_type = "BeamEuler" - # mooring = fsi.ProtChMoorings(system=system, mesh=mesh, length=L, nb_elems=nb_elems, d=d, rho=rho, E=E, beam_type=cable_type) - # mooring.external_forces_manual = True # tri: should work without this line - # # vertical cable - # fairlead_body = fsi.ProtChBody(system) - # fairlead_body.ChBody.SetBodyFixed(True) - # mooring.setNodesPositionFunction(lambda s: np.array([0., 0., s]), lambda s: np.array([0., 0., 1.])) - # mooring.setNodesPosition() - # mooring.buildNodes() - # mooring.attachBackNodeToBody(fairlead_body) - # system.calculate_init() - # system.calculate(0.5) - # T = mooring.getTensionBack() - # T_sol = -np.ones(3)*g*rho*(np.pi*d**2/4.*L) - # npt.assert_almost_equal(T, T_sol) - + #CURRENTLY NOT FULLY WORKING + @pytest.mark.skip() + def testHangingCableEuler(self): + g = np.array([0.,0.,-9.81]) + system = fsi.ProtChSystem() + system.setGravitationalAcceleration(g) + system.setTimeStep(1e-1) + mesh = fsi.ProtChMesh(system) + mesh.getChronoObject() + L = np.array([5.]) + nb_elems = np.array([3]) + d = np.array([1e-3]) + rho = np.array([1000.]) + E = np.array([1e10]) + cable_type = b"BeamEuler" + mooring = fsi.ProtChMoorings(system=system, mesh=mesh, length=L, nb_elems=nb_elems, d=d, rho=rho, E=E, beam_type=cable_type) + mooring.external_forces_manual = True # tri: should work without this line + # vertical cable + fairlead_body = fsi.ProtChBody(system) + fairlead_body.ChBody.SetFixed(True) + mooring.setNodesPositionFunction(lambda s: np.array([0., 0., s]), lambda s: np.array([0., 0., 1.])) + mooring.setNodesPosition() + mooring.buildNodes() + mooring.attachBackNodeToBody(fairlead_body) + system.calculate_init() + system.calculate(0.5) + T = mooring.getTensionBack() + T_sol = -np.ones(3)*g*rho*(np.pi*d**2/4.*L) + npt.assert_almost_equal(T, T_sol) diff --git a/proteus/tests/test_mpi4py_garnet.pbs b/test/test_mpi4py_garnet.pbs similarity index 100% rename from proteus/tests/test_mpi4py_garnet.pbs rename to test/test_mpi4py_garnet.pbs diff --git a/proteus/tests/test_mpi4py_petsc4py_diamond.pbs b/test/test_mpi4py_petsc4py_diamond.pbs similarity index 100% rename from proteus/tests/test_mpi4py_petsc4py_diamond.pbs rename to test/test_mpi4py_petsc4py_diamond.pbs diff --git a/proteus/tests/test_mpi4py_petsc4py_lonestar.sge b/test/test_mpi4py_petsc4py_lonestar.sge similarity index 100% rename from proteus/tests/test_mpi4py_petsc4py_lonestar.sge rename to test/test_mpi4py_petsc4py_lonestar.sge diff --git a/proteus/tests/test_mpi4py_petsc4py_ranger.sge b/test/test_mpi4py_petsc4py_ranger.sge similarity index 100% rename from proteus/tests/test_mpi4py_petsc4py_ranger.sge rename to test/test_mpi4py_petsc4py_ranger.sge diff --git a/proteus/tests/test_petsc4py_garnet.pbs b/test/test_petsc4py_garnet.pbs similarity index 100% rename from proteus/tests/test_petsc4py_garnet.pbs rename to test/test_petsc4py_garnet.pbs diff --git a/proteus/tests/test_proteus_garnet.pbs b/test/test_proteus_garnet.pbs similarity index 100% rename from proteus/tests/test_proteus_garnet.pbs rename to test/test_proteus_garnet.pbs diff --git a/proteus/tests/test_proteus_lightning.pbs b/test/test_proteus_lightning.pbs similarity index 100% rename from proteus/tests/test_proteus_lightning.pbs rename to test/test_proteus_lightning.pbs diff --git a/proteus/tests/test_proteus_lonestar.sge b/test/test_proteus_lonestar.sge similarity index 100% rename from proteus/tests/test_proteus_lonestar.sge rename to test/test_proteus_lonestar.sge diff --git a/proteus/tests/test_proteus_ranger.sge b/test/test_proteus_ranger.sge similarity index 100% rename from proteus/tests/test_proteus_ranger.sge rename to test/test_proteus_ranger.sge diff --git a/proteus/tests/test_quadrature.py b/test/test_quadrature.py similarity index 99% rename from proteus/tests/test_quadrature.py rename to test/test_quadrature.py index 5d507ebf53..28874f567e 100644 --- a/proteus/tests/test_quadrature.py +++ b/test/test_quadrature.py @@ -1,4 +1,3 @@ -from __future__ import print_function from numpy import dot, sum import numpy.testing as npt from proteus.EGeometry import (X,Y,Z) diff --git a/proteus/tests/test_read_mesh_xml.py b/test/test_read_mesh_xml.py similarity index 96% rename from proteus/tests/test_read_mesh_xml.py rename to test/test_read_mesh_xml.py index b447711308..0ab605c953 100644 --- a/proteus/tests/test_read_mesh_xml.py +++ b/test/test_read_mesh_xml.py @@ -36,4 +36,4 @@ def test_write_3x3_cube(verbose=0): h5_base = xmf_base mesh_info = readMeshXdmf(xmf_base,h5_base,verbose=0) - writeHexMesh(mesh_info,'hexMesh_3x3',index_base=0) + writeHexMesh(mesh_info,'hexMesh_3x3',index_base=0) \ No newline at end of file diff --git a/proteus/tests/test_sedclosure.py b/test/test_sedclosure.py similarity index 91% rename from proteus/tests/test_sedclosure.py rename to test/test_sedclosure.py index f0b77c7657..49b35131e9 100644 --- a/proteus/tests/test_sedclosure.py +++ b/test/test_sedclosure.py @@ -1,6 +1,3 @@ -from __future__ import division -from builtins import object -from past.utils import old_div from proteus import Comm, Profiling import numpy as np import numpy.testing as npt @@ -28,7 +25,7 @@ def __init__(self): self.fContact = 0.02 self.mContact = 2. self.nContact = 5. - self.angFriction = old_div(np.pi,6.) + self.angFriction = np.pi/6. self.vos_limiter = 0.6 self.mu_fr_limiter = 0.1 self.sedSt = HsuSedStress( self.aDarcy, self.bForch, self.grain, self.packFraction, self.packMargin,self.maxFraction, self.frFraction, self.sigmaC, self.C3e, self.C4e, self.eR ,self.fContact, self.mContact, self.nContact, self.angFriction, self.vos_limiter, self.mu_fr_limiter) @@ -110,8 +107,8 @@ def testGranularDrag4(self): nu = 1e-4 Rep = (1.- sedF) * umag * gl.grain / nu draga = gl.aDarcy * nu* sedF /((1.-sedF)*gl.grain**2) + gl.bForch * umag / gl.grain - dragb = old_div(( 0.44 * 0.75 * umag * (1. -sedF)**(-1.65) ), gl.grain) # Chen and Hsu 2014 - w = 0.5 + old_div((sedF - gl.packFraction), (2. * gl.packMargin)) + dragb = (0.44*0.75*umag*(1.-sedF)**(-1.65))/gl.grain # Chen and Hsu 2014 + w = 0.5 + (sedF-gl.packFraction)/(2.*gl.packMargin) drag =rhoFluid* (w*draga + (1.-w) * dragb) drag2 = gl.sedSt.betaCoeff(sedF, rhoFluid,uf, us, nu) if(drag2 != 0): @@ -187,10 +184,10 @@ def test_dTkeSed_dk(self): beta = gl.sedSt.betaCoeff(sedF,rhoFluid, uf, us, nu) - t_p =old_div(rhoS, beta) + t_p =rhoS/beta l_c = np.sqrt(np.pi)*gl.grain / (24.*sedF * gl.sedSt.gs0(sedF)) - t_cl = min(old_div(l_c,np.sqrt(theta_n)),0.165*kappa_n/epsilon_n) - aa = old_div(1,( 1. + old_div(t_p,t_cl))) + t_cl = min(l_c/np.sqrt(theta_n),0.165*kappa_n/epsilon_n) + aa = 1/( 1. + t_p/t_cl) es1 = 2.*beta * rhoS*(1-aa)*sedF/((1-sedF)*rhoFluid) @@ -219,10 +216,10 @@ def test_dEpsSed_dE(self): beta = gl.sedSt.betaCoeff(sedF, rhoFluid,uf, us, nu) - t_p =old_div(rhoS, beta) + t_p =rhoS/beta l_c = np.sqrt(np.pi)*gl.grain / (24.*sedF * gl.sedSt.gs0(sedF)) - t_cl = min(old_div(l_c,np.sqrt(theta_n)),0.165*kappa_n/epsilon_n) - aa = old_div(1,( 1. + old_div(t_p,t_cl))) + t_cl = min(l_c/np.sqrt(theta_n),0.165*kappa_n/epsilon_n) + aa = 1/( 1. + t_p/t_cl) es1 = 2.*beta *(1-aa)*sedF*kappa_n/((1-sedF)*rhoFluid) @@ -287,7 +284,7 @@ def testMu_sc(self): rhoS = 2000 test = gl.sedSt.mu_sc(sedF,rhoS,theta) g0 = gl.sedSt.gs0(sedF) - valid = rhoS * gl.grain * sqrt(theta) * ( 0.8 *sedF**2 * g0 * (1. + gl.eR) / sqrt(np.pi) + (old_div(1.,15)) *sedF**2 * g0 * (1. + gl.eR) * sqrt(np.pi) + (old_div(1.,6.)) *sedF * sqrt(np.pi) + (old_div(5.,48.)) * sqrt(np.pi)/((1+gl.eR)*g0)) + valid = rhoS * gl.grain * sqrt(theta) * ( 0.8 *sedF**2 * g0 * (1. + gl.eR) / sqrt(np.pi) + (1./15) *sedF**2 * g0 * (1. + gl.eR) * sqrt(np.pi) + (1./6.) *sedF * sqrt(np.pi) + (5./48.) * sqrt(np.pi)/((1+gl.eR)*g0)) self.assertTrue(round(test,f) == round(valid,f)) def testL_sc(self): @@ -301,7 +298,7 @@ def testL_sc(self): rhoS = 2000 test = gl.sedSt.l_sc(sedF,rhoS,theta) g0 = gl.sedSt.gs0(sedF) - valid = (old_div(4.,3.))*sedF**2 * rhoS * gl.grain *g0*(1+gl.eR)* (old_div(sqrt(theta), sqrt(np.pi)) ) + valid = (4./3.)*sedF**2 * rhoS * gl.grain *g0*(1+gl.eR)* (sqrt(theta)/sqrt(np.pi) ) self.assertTrue(round(test,f) == round(valid,f)) @@ -330,14 +327,14 @@ def test_tsc_term(self): s_tensor = np.array([ [ 2.*dudx , dudy+dvdx, dudz+dwdx], [ dudy+dvdx, 2.*dvdy, dvdz+dwdy], [ dudz+dwdx, dvdz+dwdy, 2.* dwdz]]) - t_tensor = mu * s_tensor + (l - (old_div(2.,3.)) * mu) * divU * np.array([ [ 1 , 0 , 0], + t_tensor = mu * s_tensor + (l - (2./3.) * mu) * divU * np.array([ [ 1 , 0 , 0], [ 0, 1, 0], [ 0, 0, 1] ]) product = s_tensor * t_tensor valid = 0. for i in product: for j in i: - valid+=old_div(j, (3.*rhoS*sedF)) + valid+=j/(3.*rhoS*sedF) self.assertTrue(round(test,f) == round(valid,f)) @@ -358,7 +355,7 @@ def testgamma_s(self): dwdz = random.random() + 1e-30 test = gl.sedSt.gamma_s(sedF,rhoS,theta , theta_np1, dudx, dvdy, dwdz) divU = dudx + dvdy + dwdz - valid = - 3. * (1. - gl.eR**2) * sedF**2 * rhoS * g0 * theta_np1 * ( (old_div(sqrt(theta),sqrt(np.pi))) * (old_div(4.,gl.grain)) - divU) * (old_div(2.,(3. * rhoS * sedF))) + valid = - 3. * (1. - gl.eR**2) * sedF**2 * rhoS * g0 * theta_np1 * ( (sqrt(theta)/sqrt(np.pi)) * (4./gl.grain) - divU) * (2./(3.*rhoS*sedF)) self.assertTrue(round(test,f) == round(valid,f)) def testdgamma_s_dtheta(self): @@ -378,7 +375,7 @@ def testdgamma_s_dtheta(self): test = gl.sedSt.dgamma_s_dtheta(sedF,rhoS,theta , dudx, dvdy, dwdz) divU = dudx + dvdy + dwdz - valid = - 3. * (1. - gl.eR**2) * sedF**2 * rhoS * g0 * ( (old_div(sqrt(theta),sqrt(np.pi))) * (old_div(4.,gl.grain)) - divU) * (old_div(2.,(3. * rhoS * sedF))) + valid = - 3. * (1. - gl.eR**2) * sedF**2 * rhoS * g0 * ( (sqrt(theta)/sqrt(np.pi)) * (4./gl.grain) - divU) * (2./(3.*rhoS*sedF)) self.assertTrue(round(test,f) == round(valid,f)) def testJint1(self): @@ -400,10 +397,10 @@ def testJint1(self): beta = gl.sedSt.betaCoeff(sedF, rhoFluid, uf, us, nu) - t_p =old_div(rhoS, beta) + t_p =rhoS/beta l_c = np.sqrt(np.pi)*gl.grain / (24.*sedF * gl.sedSt.gs0(sedF)) - t_cl = min(old_div(l_c,np.sqrt(theta_n)),0.165*kappa_n/epsilon_n) - aa = old_div(1,( 1. + old_div(t_p,t_cl))) + t_cl = min(l_c/np.sqrt(theta_n),0.165*kappa_n/epsilon_n) + aa = 1/( 1. + t_p/t_cl) es1 = 2.*beta * rhoS*(1-aa)*sedF*kappa_n/((1-sedF)*rhoFluid) @@ -414,7 +411,7 @@ def testJint1(self): test = gl.sedSt.jint1(sedF,rhoFluid, rhoS, uf,us, kappa_n,epsilon_n, theta_n, nu) - self.assertTrue(round(test,f) ==round(2*aa*beta*sedF*kappa_n*(old_div(2.,(3.*sedF*rhoS))),f )) + self.assertTrue(round(test,f) ==round(2*aa*beta*sedF*kappa_n*(2./(3.*sedF*rhoS)),f )) def testJint2(self): @@ -437,7 +434,7 @@ def testJint2(self): test = gl.sedSt.jint2(sedF,rhoFluid, rhoS,uf,us, theta_n, nu) - self.assertTrue(round(test,f) ==round(-3*beta*sedF*theta_n*(old_div(2.,(3.*sedF*rhoS))),f )) + self.assertTrue(round(test,f) ==round(-3*beta*sedF*theta_n*(2./(3.*sedF*rhoS)),f )) def testJint2dTheta(self): gl=GlobalVariables() @@ -459,7 +456,7 @@ def testJint2dTheta(self): test = gl.sedSt.djint2_dtheta(sedF,rhoFluid, rhoS,uf,us, nu) - self.assertTrue(round(test,f) ==round(-3*beta*sedF*(old_div(2.,(3.*sedF*rhoS))),f )) + self.assertTrue(round(test,f) ==round(-3*beta*sedF*(2./(3.*sedF*rhoS)),f )) def testK_diff(self): @@ -473,7 +470,7 @@ def testK_diff(self): rhoS = 2000 test = gl.sedSt.k_diff(sedF,rhoS,theta) g0 = gl.sedSt.gs0(sedF) - valid = rhoS * gl.grain * sqrt(theta) * ( 2. *sedF**2 * g0 * (1. + gl.eR) / sqrt(np.pi) + (old_div(9.,16)) *sedF**2 * g0 * (1. + gl.eR) * sqrt(np.pi) + (old_div(15.,16.)) *sedF * sqrt(np.pi) + (old_div(25.,64.)) * sqrt(np.pi)/((1+gl.eR)*g0)) + valid = rhoS * gl.grain * sqrt(theta) * ( 2. *sedF**2 * g0 * (1. + gl.eR) / sqrt(np.pi) + (9./16) *sedF**2 * g0 * (1. + gl.eR) * sqrt(np.pi) + (15./16.) *sedF * sqrt(np.pi) + (25./64.) * sqrt(np.pi)/((1+gl.eR)*g0)) self.assertTrue(round(test,f) == round(valid,f)) @@ -522,7 +519,7 @@ def test_gradp_fr_limiter(self): # No limiter sedF = 0.58 p_friction = gl.fContact*(sedF-gl.frFraction)**gl.mContact/(gl.maxFraction-sedF)**gl.nContact - gradp = p_friction*(old_div(gl.mContact,(sedF-gl.frFraction))+old_div(gl.nContact,(gl.maxFraction-sedF))) + gradp = p_friction*(gl.mContact/(sedF-gl.frFraction)+gl.nContact/(gl.maxFraction-sedF)) gradp_test = gl.sedSt.gradp_friction(sedF) self.assertAlmostEqual(gradp,gradp_test) @@ -531,14 +528,14 @@ def test_gradp_fr_limiter(self): # Exactly at the limiter sedF = 0.6 p_friction = gl.fContact*(sedF-gl.frFraction)**gl.mContact/(gl.maxFraction-sedF)**gl.nContact - gradp = p_friction*(old_div(gl.mContact,(sedF-gl.frFraction))+old_div(gl.nContact,(gl.maxFraction-sedF))) + gradp = p_friction*(gl.mContact/(sedF-gl.frFraction)+gl.nContact/(gl.maxFraction-sedF)) gradp_test = gl.sedSt.gradp_friction(sedF) self.assertAlmostEqual(gradp,gradp_test) # Over the limiter sedF = 0.62 sedFm = min(gl.vos_limiter,sedF) p_friction = gl.fContact*(sedFm-gl.frFraction)**gl.mContact/(gl.maxFraction-sedFm)**gl.nContact - gradp = p_friction*(old_div(gl.mContact,(sedFm-gl.frFraction))+old_div(gl.nContact,(gl.maxFraction-sedFm))) + gradp = p_friction*(gl.mContact/(sedFm-gl.frFraction)+gl.nContact/(gl.maxFraction-sedFm)) gradp_test = gl.sedSt.gradp_friction(sedF) self.assertAlmostEqual(gradp,gradp_test) diff --git a/proteus/tests/test_spatialtools.py b/test/test_spatialtools.py similarity index 99% rename from proteus/tests/test_spatialtools.py rename to test/test_spatialtools.py index 04b8fc9ad9..145142a4d2 100644 --- a/proteus/tests/test_spatialtools.py +++ b/test/test_spatialtools.py @@ -5,9 +5,6 @@ test inertia test rigid body calculations """ -from __future__ import division -from builtins import range -from past.utils import old_div import unittest import numpy.testing as npt import numpy as np @@ -334,7 +331,7 @@ def test_absorption_zones(self): epsFact_porous = 0.5 center = [0.5, 0., 0.] orientation = [1., 0., 0.] - dragAlpha = old_div(0.5,1.005e-6) + dragAlpha = 0.5/1.005e-6 dragBeta = 0. porosity = 1. domain = create_domain2D() @@ -447,7 +444,7 @@ def test_generation_zones(self): epsFact_porous = 0.5 center = [0.5, 0., 0.] orientation = [1., 0., 0.] - dragAlpha = old_div(0.5,1.005e-6) + dragAlpha = 0.5/1.005e-6 dragBeta = 0. porosity = 1. from proteus import WaveTools as wt @@ -589,7 +586,7 @@ def test_generation_zones(self): def test_porous_zones(self): flag = 1 - dragAlpha = old_div(0.5,1.005e-6) + dragAlpha = 0.5/1.005e-6 dragBeta = 0. porosity = 1. domain = create_domain2D() diff --git a/proteus/tests/test_superlu.py b/test/test_superlu.py similarity index 98% rename from proteus/tests/test_superlu.py rename to test/test_superlu.py index a09b280aaa..3f39f0e8e9 100644 --- a/proteus/tests/test_superlu.py +++ b/test/test_superlu.py @@ -132,4 +132,4 @@ def test_sparseFactorPrepare_1(simple_nonsingular_sparse_mat): superluWrappers.sparseFactorPrepare(A, sparseFactor) x = np.ones(A.nr) superluWrappers.sparseFactorSolve(sparseFactor, x) - assert np.array_equal(x, np.array([-.5, .5, -.5])) + assert np.array_equal(x, np.array([-.5, .5, -.5])) \ No newline at end of file diff --git a/proteus/tests/wave_tests/data_timeSeries.dat b/test/wave_tests/data_timeSeries.dat similarity index 100% rename from proteus/tests/wave_tests/data_timeSeries.dat rename to test/wave_tests/data_timeSeries.dat diff --git a/proteus/tests/wave_tests/data_timeSeries.txt b/test/wave_tests/data_timeSeries.txt similarity index 100% rename from proteus/tests/wave_tests/data_timeSeries.txt rename to test/wave_tests/data_timeSeries.txt diff --git a/proteus/tests/wave_tests/data_timeSeries_err1.csv b/test/wave_tests/data_timeSeries_err1.csv similarity index 100% rename from proteus/tests/wave_tests/data_timeSeries_err1.csv rename to test/wave_tests/data_timeSeries_err1.csv diff --git a/proteus/tests/wave_tests/data_timeSeries_err2.txt b/test/wave_tests/data_timeSeries_err2.txt similarity index 100% rename from proteus/tests/wave_tests/data_timeSeries_err2.txt rename to test/wave_tests/data_timeSeries_err2.txt diff --git a/proteus/tests/wave_tests/test_wavetools.py b/test/wave_tests/test_wavetools.py similarity index 93% rename from proteus/tests/wave_tests/test_wavetools.py rename to test/wave_tests/test_wavetools.py index 3935de1e22..dc5f578167 100644 --- a/proteus/tests/wave_tests/test_wavetools.py +++ b/test/wave_tests/test_wavetools.py @@ -1,8 +1,3 @@ -from __future__ import print_function -from __future__ import division - -from builtins import range -from past.utils import old_div from proteus import Comm, Profiling import numpy as np import numpy.testing as npt @@ -57,7 +52,7 @@ def testFastCosh(self): mwl = 0. for ii in range(0,1001): Z = -float(ii)/1000.*d - err = old_div((cosh(k*Z) - fastcosh_test(k,Z)),cosh(k*Z)) + err = (cosh(k*Z)-fastcosh_test(k,Z))/cosh(k*Z) RMS += err**2 maxErr = max(maxErr, abs(err)) RMS /=1000. @@ -75,7 +70,7 @@ def testFastSinh(self): mwl = 0. for ii in range(0,1001): Z = -float(ii)/1000.*d - err = old_div((sinh(k*Z) - fastsinh_test(k,Z)),(cosh(k*Z))) + err = (sinh(k*Z)-fastsinh_test(k,Z))/(cosh(k*Z)) RMS += err**2 maxErr = max(maxErr, abs(err)) RMS /=1000. @@ -93,7 +88,7 @@ def testFastProfileCosh(self): mwl = 0. for ii in range(0,1001): Z = -float(ii)/1000.*d - err = (old_div(cosh(k*(Z+d)),sinh(k*d))) + err = (cosh(k*(Z+d))/sinh(k*d)) fcos = coshkzd_test(k,Z,d) err = (err - fcos)#/sinh(k*d) RMS += err**2 @@ -114,7 +109,7 @@ def testFastProfileSinh(self): mwl = 0. for ii in range(0,1001): Z = -float(ii)/1000.*d - err = (old_div(sinh(k*(Z+d)),sinh(k*d))) + err = (sinh(k*(Z+d))/sinh(k*d)) err = err- sinhkzd_test(k,Z,d) RMS += err**2 maxErr = max(maxErr, abs(err)) @@ -130,7 +125,7 @@ def testVDir(self): def testDirVector(self): from proteus.WaveTools import setDirVector - self.assertTrue(all(setDirVector(np.array([2.,2.,1.]))== old_div(np.array([2.,2.,1]),3.))) + self.assertTrue(all(setDirVector(np.array([2.,2.,1.]))== np.array([2.,2.,1])/3.)) def testDirCheck(self): from proteus.WaveTools import dirCheck @@ -200,7 +195,7 @@ def testEtaMode(self): t =50. kDir = [0.05,0.02,0.0] omega = 0.5 - phi = old_div(3.14,5.) + phi = 3.14/5. amplitude =0.2 eta = amplitude*cos(kDir[0]*x+kDir[1]*y+kDir[2]*z - omega*t +phi) self.assertTrue((eta - eta_mode([x,y,z],t,kDir,omega,phi,amplitude)==0.))# check eta @@ -230,7 +225,7 @@ def testVelMode(self): # Checking particle velocities vDir = np.array([0,0,1]) t= 0. kAbs = 2*pi - Ud = Udrift(amplitude,abs(g[-1]),old_div(omega,kAbs),depth) + Ud = Udrift(amplitude,abs(g[-1]),omega/kAbs,depth) for i in range(4): U_x, U_y, U_z = vel_mode([x,y,z],t,kDir,kAbs,omega,phi,amplitude,mwl,depth,vDir,gAbs) x+= 0.25 @@ -295,7 +290,7 @@ def test_dispersion(self): from proteus.WaveTools import dispersion length = 2*pi/dispersion(2*pi/5.,4.) lTheor = 27.958 - self.assertTrue(old_div(abs(length - lTheor),lTheor)<0.001) + self.assertTrue(abs(length-lTheor)/lTheor<0.001) length = 2*pi/dispersion([2*pi/1.94,2*pi/1.94,],1.) length-=5. length/=5 @@ -325,12 +320,12 @@ def test_Jonswap(self): #JONSWAP tests sig = sigma(f,f0) gamma = 6.*random.random() + 1. Hs = random.random() - bj = 0.0624*(1.094 - 0.01915*log(gamma))/(0.23+0.0336*gamma-old_div(0.185,(1.9+gamma))) - r_exp = np.exp(old_div(-(old_div(f,f0) -1 )**2,(2.*sig**2))) - JON = (bj*(Hs**2)*(f0**4)/f**5)*np.exp(-1.25*(old_div(f0,f))**4)*(gamma**r_exp) + bj = 0.0624*(1.094 - 0.01915*log(gamma))/(0.23+0.0336*gamma-0.185/(1.9+gamma)) + r_exp = np.exp(-(f/f0 -1 )**2/(2.*sig**2)) + JON = (bj*(Hs**2)*(f0**4)/f**5)*np.exp(-1.25*(f0/f)**4)*(gamma**r_exp) JON2 = JONSWAP(f,f0,Hs,gamma,TMA=False, depth = None) - JCOMP = old_div(JON2,JON) + JCOMP = JON2/JON self.assertTrue((np.around(JCOMP,10)==1).all()) h = random.random() # Checking failure mode @@ -341,7 +336,7 @@ def test_Jonswap(self): #JONSWAP tests k = dispersion(2*pi*f,h) TMA = np.tanh(k*h)*np.tanh(k*h)/(1.+2.*k*h/np.sinh(2*k*h)) JON2 = JONSWAP(f,f0,Hs,gamma,TMA=True, depth=h) - JCOMP = old_div(JON2,(TMA*JON)) + JCOMP = JON2/(TMA*JON) self.assertTrue((np.around(JCOMP,10)==1).all()) def test_PM(self): #PM tests @@ -350,9 +345,9 @@ def test_PM(self): #PM tests f = np.linspace(f0/2.,2.*f0,10) Hs = random.random() g = 9.81 - S_PM = (old_div(5.,16.)) * Hs**2 * f0**4 / f**5 * np.exp(-5./4. * (old_div(f0,f))**4) + S_PM = (5./16.) * Hs**2 * f0**4 / f**5 * np.exp(-5./4. * (f0/f)**4) S_PM2 = PM_mod(f,f0,Hs) - SCOMP = old_div(S_PM2,S_PM) + SCOMP = S_PM2/S_PM self.assertTrue((np.around(SCOMP,10)==1).all()) def testCos2s(self): @@ -434,7 +429,7 @@ def testSolitary(self): t = 5. cc = np.sqrt(9.81*(dd+HH)) - eta_Ref = old_div(HH, np.cosh( np.sqrt(3.*HH/4./dd**3)*(x - cc*t))**2) + eta_Ref = HH/np.cosh(np.sqrt(3.*HH/4./dd**3)*(x-cc*t))**2 xx = x*waveDir/5. self.assertAlmostEqual(eta_Ref, aa.eta(xx,t)) @@ -463,7 +458,7 @@ def pow(a,b): 2.0 * d3 + d2 * HH + 12.0 * dd * HH * Z + 6.0 * HH * Z**2.0 + (2.0 * d3 - d2 * HH - 6.0 * dd * HH * Z - 3.0 * HH * Z**2 ) * a1)/(a2)**4 - Uvert = 1.0 / ( 4.0 * np.sqrt(G_* dd) ) * np.sqrt(3.0) * G_ * (old_div(HH, dd**3.0))** 1.5 * (dd + Z)*( + Uvert = 1.0 / ( 4.0 * np.sqrt(G_* dd) ) * np.sqrt(3.0) * G_ * (HH/dd**3.0)** 1.5 * (dd + Z)*( 2.0 * dd**3 - 7.0 * dd**2.0 * HH + 10.0 * dd * HH * Z + 5.0 * HH * Z**2.0 + (2.0 * dd**3.0 + dd**2.0 * HH - 2.0 * dd * HH * Z - HH * Z**2.0)* cosh(np.sqrt( 3.0 * HH / dd**3.0) * phase ))/( @@ -547,15 +542,15 @@ def testLinear(self): etaRef = amp*cos(kw*(normDir[0]*x+normDir[1]*y+normDir[2]*z) - omega * t +phi0) z0 = z - mwl - uxRef = normDir[0]*(amp*omega*fcosh(kw,z0,depth,fast=False)*cos(kw*(normDir[0]*x+normDir[1]*y+normDir[2]*z) - omega * t +phi0)-Ud(amp,gAbs,old_div(omega,kw),depth)) - uyRef = normDir[1]*(amp*omega*fcosh(kw,z0,depth,fast=False)*cos(kw*(normDir[0]*x+normDir[1]*y+normDir[2]*z) - omega * t +phi0)-Ud(amp,gAbs,old_div(omega,kw),depth)) + uxRef = normDir[0]*(amp*omega*fcosh(kw,z0,depth,fast=False)*cos(kw*(normDir[0]*x+normDir[1]*y+normDir[2]*z) - omega * t +phi0)-Ud(amp,gAbs,omega/kw,depth)) + uyRef = normDir[1]*(amp*omega*fcosh(kw,z0,depth,fast=False)*cos(kw*(normDir[0]*x+normDir[1]*y+normDir[2]*z) - omega * t +phi0)-Ud(amp,gAbs,omega/kw,depth)) uzRef = amp*omega*fsinh(kw,z0,depth,fast=False)*sin(kw*(normDir[0]*x+normDir[1]*y+normDir[2]*z) - omega * t +phi0) # print ux,uxRef - err = abs(old_div(eta,etaRef) - 1.) - err_x = abs(old_div(ux,uxRef) - 1.) - err_y = abs(old_div(uy,uyRef) - 1.) - err_z = abs(old_div(uz,uzRef) - 1.) + err = abs(eta/etaRef - 1.) + err_x = abs(ux/uxRef - 1.) + err_y = abs(uy/uyRef - 1.) + err_z = abs(uz/uzRef - 1.) self.assertTrue((err <= 1e-8)) self.assertTrue((err_x <= 1e-8)) self.assertTrue((err_y <= 1e-8)) @@ -612,16 +607,16 @@ def testFenton(self): for ii in range(len(YC)): jj+=1 etaRef+=YC[ii]*fcos(jj*kw*(normDir[0]*x+normDir[1]*y+normDir[2]*z)-jj*omega*t + jj*phi0)/kw - amp = tanh(kw*jj*depth)*np.sqrt(old_div(gAbs,kw))*BC[ii]/omega - c = old_div(omega,kw) - uxRef += normDir[0]*( np.sqrt(old_div(gAbs,kw))*jj*BC[ii]*fcosh(jj*kw,z0,depth) *fcos(jj*kw*(normDir[0]*x+normDir[1]*y+normDir[2]*z)-jj*omega*t +jj*phi0)*tanh(jj*kw*depth)-Ud(amp,gAbs,c,depth)) - uyRef += normDir[1]* (np.sqrt(old_div(gAbs,kw))*jj*BC[ii]*fcosh(jj*kw,z0,depth) *fcos(jj*kw*(normDir[0]*x+normDir[1]*y+normDir[2]*z)-jj*omega*t +jj*phi0)*tanh(jj*kw*depth)-Ud(amp,gAbs,c,depth)) - uzRef += np.sqrt(old_div(gAbs,kw))*jj*BC[ii]*fsinh(jj*kw,z0,depth) *fcos(0.5*pi -( jj*kw*(normDir[0]*x+normDir[1]*y+normDir[2]*z)-jj*omega*t +jj*phi0))*tanh(jj*kw*depth) - - err = abs(old_div(eta,etaRef) - 1.) - err_x = abs(old_div(ux,uxRef) - 1.) - err_y = abs(old_div(uy,uyRef) - 1.) - err_z = abs(old_div(uz,uzRef) - 1.) + amp = tanh(kw*jj*depth)*np.sqrt(gAbs/kw)*BC[ii]/omega + c = omega/kw + uxRef += normDir[0]*( np.sqrt(gAbs/kw)*jj*BC[ii]*fcosh(jj*kw,z0,depth) *fcos(jj*kw*(normDir[0]*x+normDir[1]*y+normDir[2]*z)-jj*omega*t +jj*phi0)*tanh(jj*kw*depth)-Ud(amp,gAbs,c,depth)) + uyRef += normDir[1]* (np.sqrt(gAbs/kw)*jj*BC[ii]*fcosh(jj*kw,z0,depth) *fcos(jj*kw*(normDir[0]*x+normDir[1]*y+normDir[2]*z)-jj*omega*t +jj*phi0)*tanh(jj*kw*depth)-Ud(amp,gAbs,c,depth)) + uzRef += np.sqrt(gAbs/kw)*jj*BC[ii]*fsinh(jj*kw,z0,depth) *fcos(0.5*pi -( jj*kw*(normDir[0]*x+normDir[1]*y+normDir[2]*z)-jj*omega*t +jj*phi0))*tanh(jj*kw*depth) + + err = abs(eta/etaRef - 1.) + err_x = abs(ux/uxRef - 1.) + err_y = abs(uy/uyRef - 1.) + err_z = abs(uz/uzRef - 1.) Uo = waveHeight * omega * tanh(kw*depth) Uoz = waveHeight * omega @@ -668,7 +663,7 @@ def testAutoFenton(self): Fenton.copyFiles() Bc_test, Yc_test = Fenton.getBYCoeffs() wl_test = Fenton.getWavelength()*depth - err = old_div((wl_test-wavelength),wavelength) + err = (wl_test-wavelength)/wavelength self.assertTrue((err <= 1e-3)) self.assertEqual(np.round(Bc_test,7).all(), np.round(Bc,7).all()) self.assertEqual(np.round(Yc_test,7).all(), np.round(Yc,7).all()) @@ -833,16 +828,16 @@ def testRandom(self): # setDirVector are tested above from proteus.WaveTools import setDirVector, dispersion, reduceToIntervals, returnRectangles, JONSWAP,Udrift - fmin = old_div(1.,(Tp * bandFactor)) - fmax = old_div(bandFactor,(Tp)) + fmin = 1./(Tp*bandFactor) + fmax = bandFactor/(Tp) fi = np.linspace(fmin,fmax,N) - df = old_div((fmax-fmin),(N -1 )) + df = (fmax-fmin)/(N-1) ki = dispersion(2*pi*fi,depth) kp = dispersion(2*pi / Tp,depth) z0 = z - mwl normDir = setDirVector(waveDir) fim = reduceToIntervals(fi,df) - Si_Jm = JONSWAP(fim,old_div(1.,Tp),Hs,gamma,TMA, depth) + Si_Jm = JONSWAP(fim,1./Tp,Hs,gamma,TMA, depth) ai = np.sqrt(2.*returnRectangles(Si_Jm,fim)) omega = 2*pi*fi etaRef = 0. @@ -852,14 +847,14 @@ def testRandom(self): for ii in range(N): etaRef+=ai[ii]*fcos(ki[ii]*(normDir[0]*x+normDir[1]*y+normDir[2]*z)-omega[ii]*t +phi[ii]) - uxRef += normDir[0]*ai[ii]*omega[ii] *fcosh(ki[ii],z0,depth) *fcos(ki[ii]*(normDir[0]*x+normDir[1]*y+normDir[2]*z)-omega[ii]*t +phi[ii])-normDir[0]*Udrift(ai[ii],gAbs,old_div(omega[ii],ki[ii]),depth) - uyRef += normDir[1]*ai[ii]*omega[ii] *fcosh(ki[ii],z0,depth) * fcos(ki[ii]*(normDir[0]*x+normDir[1]*y+normDir[2]*z)-omega[ii]*t +phi[ii])-normDir[1]*Udrift(ai[ii],gAbs,old_div(omega[ii],ki[ii]),depth) + uxRef += normDir[0]*ai[ii]*omega[ii] *fcosh(ki[ii],z0,depth) *fcos(ki[ii]*(normDir[0]*x+normDir[1]*y+normDir[2]*z)-omega[ii]*t +phi[ii])-normDir[0]*Udrift(ai[ii],gAbs,omega[ii]/ki[ii],depth) + uyRef += normDir[1]*ai[ii]*omega[ii] *fcosh(ki[ii],z0,depth) * fcos(ki[ii]*(normDir[0]*x+normDir[1]*y+normDir[2]*z)-omega[ii]*t +phi[ii])-normDir[1]*Udrift(ai[ii],gAbs,omega[ii]/ki[ii],depth) uzRef += ai[ii]*omega[ii] *fsinh(ki[ii],z0,depth) * fcos(ki[ii]*(normDir[0]*x+normDir[1]*y+normDir[2]*z)-omega[ii]*t +phi[ii],True) - err = abs(old_div(eta,etaRef) - 1.) - err_x =abs(old_div(ux,uxRef) - 1.) - err_y =abs(old_div(uy,uyRef) - 1.) - err_z =abs(old_div(uz,uzRef) - 1.) + err = abs(eta/etaRef - 1.) + err_x =abs(ux/uxRef - 1.) + err_y =abs(uy/uyRef - 1.) + err_z =abs(uz/uzRef - 1.) self.assertTrue(err <= 1e-8) @@ -875,9 +870,9 @@ def testRandom(self): Lgen = np.array([5,0,0]) Tstart = 0 Tend = 2. - Tlag = old_div(sum(Lgen[:]*normDir[:]),min(old_div(omega[:],ki[:]))) + Tlag = sum(Lgen[:]*normDir[:])/min(omega[:]/ki[:]) Tstart2 = Tstart - Tlag - dt = old_div(Tp,50.) + dt = Tp/50. Nf = int((Tend-Tstart2)/dt) tlist = np.linspace(Tstart2,Tend,Nf) etaWrite = np.zeros(len(tlist),) @@ -1164,7 +1159,7 @@ def testDirectional(self): spectral_params = {"gamma": gamma, "TMA": TMA,"depth": depth} bandFactor = 2.0 spreadName = "mitsuyasu" - spread_params = {"f0": old_div(1.,Tp), "smax": 15.} + spread_params = {"f0": 1./Tp, "smax": 15.} phiSymm = False aa= DirectionalWaves( @@ -1196,12 +1191,12 @@ def testDirectional(self): # setDirVector are tested above from proteus.WaveTools import setDirVector, dispersion, reduceToIntervals, returnRectangles3D, JONSWAP,mitsuyasu, normIntegral - fmin = old_div(1.,(Tp * bandFactor)) - fmax = old_div(bandFactor,(Tp)) + fmin = 1./(Tp*bandFactor) + fmax = bandFactor/(Tp) fi = np.linspace(fmin,fmax,N) thetas = np.linspace(theta0 - pi/2,theta0+pi/2,2*M+1) - dth = old_div(pi,(2*M)) - df = old_div((fmax-fmin),(N - 1 )) + dth = pi/(2*M) + df = (fmax-fmin)/(N-1) ki = dispersion(2*pi*fi,depth) kp = dispersion(2*pi/Tp,depth) waveDirs = np.zeros((2*M+1,3),) @@ -1211,8 +1206,8 @@ def testDirectional(self): fim = reduceToIntervals(fi,df) thetas-=theta0 thetas_m = reduceToIntervals(thetas,dth) - Si_Jm = JONSWAP(fim,old_div(1.,Tp),Hs,gamma,TMA, depth) - Si_dir = mitsuyasu(thetas_m,fim,old_div(1.,Tp), 15.) + Si_Jm = JONSWAP(fim,1./Tp,Hs,gamma,TMA, depth) + Si_dir = mitsuyasu(thetas_m,fim,1./Tp, 15.) for ii in range(0,N): Si_dir[:,ii] = normIntegral(Si_dir[:,ii],thetas_m) Si_dir[:,ii]*= Si_Jm[ii] @@ -1228,14 +1223,14 @@ def testDirectional(self): for jj in range(2*M+1): normDir = waveDirs[jj,:] etaRef+=ai[jj,ii]*fcos(ki[ii]*(normDir[0]*x+normDir[1]*y+normDir[2]*z)-omega[ii]*t +phi[jj,ii]) - uxRef += normDir[0]*ai[jj,ii]*omega[ii] *fcosh(ki[ii],z0,depth) *fcos(ki[ii]*(normDir[0]*x+normDir[1]*y+normDir[2]*z)-omega[ii]*t +phi[jj,ii])-normDir[0]*Udrift(ai[jj,ii],gAbs,old_div(omega[ii],ki[ii]),depth) - uyRef += normDir[1]*ai[jj,ii]*omega[ii] *fcosh(ki[ii],z0,depth) * fcos(ki[ii]*(normDir[0]*x+normDir[1]*y+normDir[2]*z)-omega[ii]*t +phi[jj,ii])-normDir[1]*Udrift(ai[jj,ii],gAbs,old_div(omega[ii],ki[ii]),depth) + uxRef += normDir[0]*ai[jj,ii]*omega[ii] *fcosh(ki[ii],z0,depth) *fcos(ki[ii]*(normDir[0]*x+normDir[1]*y+normDir[2]*z)-omega[ii]*t +phi[jj,ii])-normDir[0]*Udrift(ai[jj,ii],gAbs,omega[ii]/ki[ii],depth) + uyRef += normDir[1]*ai[jj,ii]*omega[ii] *fcosh(ki[ii],z0,depth) * fcos(ki[ii]*(normDir[0]*x+normDir[1]*y+normDir[2]*z)-omega[ii]*t +phi[jj,ii])-normDir[1]*Udrift(ai[jj,ii],gAbs,omega[ii]/ki[ii],depth) uzRef += ai[jj,ii]*omega[ii] *fsinh(ki[ii],z0,depth) * fcos(ki[ii]*(normDir[0]*x+normDir[1]*y+normDir[2]*z)-omega[ii]*t +phi[jj,ii],True) - err = abs(old_div(eta,etaRef) - 1.) - err_x =abs(old_div(ux,uxRef) - 1.) - err_y =abs(old_div(uy,uyRef) - 1.) - err_z =abs(old_div(uz,uzRef) - 1.) + err = abs(eta/etaRef - 1.) + err_x =abs(ux/uxRef - 1.) + err_y =abs(uy/uyRef - 1.) + err_z =abs(uz/uzRef - 1.) self.assertTrue(err <= 1e-8) @@ -1760,7 +1755,7 @@ def testRandomFast(self): g, cutoff, rec_d, - {"Nwaves":Nwaves, "Tm":old_div(Tp,1.1), "Window":"costap","Overlap":0.7, "Cutoff":0.1}, + {"Nwaves":Nwaves, "Tm":Tp/1.1, "Window":"costap","Overlap":0.7, "Cutoff":0.1}, True, series ) @@ -1808,10 +1803,10 @@ def testRandomFast(self): 'randomFastSeries.txt',] remove_files(filenames) - self.assertTrue(round(abs(old_div(aRF.eta(x,t),aT.eta(x,t))),8) == 1.) - self.assertTrue(round(abs(old_div(aRF.u(x,t)[0],aT.u(x,t)[0])),8) == 1.) - self.assertTrue(round(abs(old_div(aRF.u(x,t)[1],aT.u(x,t)[1])),8) == 1.) - self.assertTrue(round(abs(old_div(aRF.u(x,t)[2],aT.u(x,t)[2])),8) == 1.) + self.assertTrue(round(abs(aRF.eta(x,t)/aT.eta(x,t)),8) == 1.) + self.assertTrue(round(abs(aRF.u(x,t)[0]/aT.u(x,t)[0]),8) == 1.) + self.assertTrue(round(abs(aRF.u(x,t)[1]/aT.u(x,t)[1]),8) == 1.) + self.assertTrue(round(abs(aRF.u(x,t)[2]/aT.u(x,t)[2]),8) == 1.) """ from matplotlib import pyplot as plt @@ -1929,11 +1924,11 @@ def testFunctions(self): etaT = 0. for ii in range(N): kh = aR.ki[ii]*aR.depth - ai = 0.25 * aR.ai[ii]**2 * aR.ki[ii] / tanh(kh) * (2. + old_div(3.,(sinh(kh)**2))) + ai = 0.25 * aR.ai[ii]**2 * aR.ki[ii] / tanh(kh) * (2. + 3./(sinh(kh)**2)) etaT += eta_mode(xi,t,2.*aR.kDir[ii],2.*aR.omega[ii],2.*aR.phi[ii],ai) # 2nd order testing # print etaT,aNL.eta_2ndOrder(xi,t) - self.assertTrue(round(old_div(etaT,aNL.eta_2ndOrder(xi,t)),2)==1) + self.assertTrue(round(etaT/aNL.eta_2ndOrder(xi,t),2)==1) ww = aR.omega ki = aR.ki @@ -1952,8 +1947,8 @@ def testFunctions(self): k2h = ki[jj] * aR.depth Dp = (w1p2)**2 - aR.gAbs*k1p2*tanh(kh12) Bp = w1p2_sq - Bp = Bp - w1b2*( 1. - old_div(1.,(tanh(k1h)*tanh(k2h)))) * (w1p2**2 + aR.gAbs * k1p2 *tanh(kh12)) / Dp - Bp += w1p2*( old_div(ww[ii]**3,sinh(k1h)**2) + old_div(ww[jj]**3,sinh(k2h)**2))/Dp + Bp = Bp - w1b2*( 1. - 1./(tanh(k1h)*tanh(k2h))) * (w1p2**2 + aR.gAbs * k1p2 *tanh(kh12)) / Dp + Bp += w1p2*( ww[ii]**3/sinh(k1h)**2 + ww[jj]**3/sinh(k2h)**2)/Dp Bp =0.5* Bp / aR.gAbs @@ -1961,7 +1956,7 @@ def testFunctions(self): ai = aR.ai[ii]*aR.ai[jj]*Bp etaT += eta_mode(xi,t,aR.kDir[ii] + aR.kDir[jj],w1p2,aR.phi[ii] + aR.phi[jj],ai) # print etaT,aNL.eta_short(xi,t) - self.assertTrue(round(old_div(etaT,aNL.eta_short(xi,t)),2)==1 ) + self.assertTrue(round(etaT/aNL.eta_short(xi,t),2)==1 ) # Testing lower harmonics etaT = 0. N = aR.N @@ -1976,8 +1971,8 @@ def testFunctions(self): k2h = ki[jj] * aR.depth Dp = (w1p2)**2 - aR.gAbs*k1p2*tanh(kh12) Bp = w1p2_sq - Bp = Bp + w1b2*( 1. + old_div(1.,(tanh(k1h)*tanh(k2h)))) * (w1p2**2 + aR.gAbs * k1p2 *tanh(kh12)) / Dp - Bp += w1p2*( old_div(ww[ii]**3,sinh(k1h)**2) - old_div(ww[jj]**3,sinh(k2h)**2))/Dp + Bp = Bp + w1b2*( 1. + 1./(tanh(k1h)*tanh(k2h))) * (w1p2**2 + aR.gAbs * k1p2 *tanh(kh12)) / Dp + Bp += w1p2*( ww[ii]**3/sinh(k1h)**2 - ww[jj]**3/sinh(k2h)**2)/Dp Bp =0.5* Bp / aR.gAbs @@ -1985,7 +1980,7 @@ def testFunctions(self): ai = aR.ai[ii]*aR.ai[jj]*Bp etaT += eta_mode(xi,t,aR.kDir[ii] - aR.kDir[jj],w1p2,aR.phi[ii] - aR.phi[jj],ai) # print etaT,aNL.eta_long(xi,t) - self.assertTrue(round(old_div(etaT,aNL.eta_long(xi,t)),2)==1 ) + self.assertTrue(round(etaT/aNL.eta_long(xi,t),2)==1 ) # Testing setup etaT = 0. @@ -2138,13 +2133,13 @@ def testRandomNLFast(self): Lgen, NLongW=NLongW) - Tm = old_div(Tp,1.1) - Ts = old_div(Tm,2.) + Tm = Tp/1.1 + Ts = Tm/2. Tmax = NLongW*Tm - dt_s = old_div(Ts,50.) - dt = old_div(Tm,50.) - dt_l = old_div(Tmax, 50.) + dt_s = Ts/50. + dt = Tm/50. + dt_l = Tmax/50. series = aR.writeEtaSeries(Tstart,Tend,dt,x0,fname,"linear",False,Lgen) series_l = aR.writeEtaSeries(Tstart,Tend,dt_l,x0,fname,"long",False,Lgen) @@ -2162,9 +2157,9 @@ def testRandomNLFast(self): - Nw = int(old_div((Tend-Tstart),Ts)) + Nw = int((Tend-Tstart)/Ts) Nw1 = min(15,Nw) - Nw = int(old_div(Nw,Nw1)) + Nw = int(Nw/Nw1) if Nw < 3: rec_d = True @@ -2190,9 +2185,9 @@ def testRandomNLFast(self): Tend = series[-1,0] cutoff = 0.2*Ts/(Tend-Tstart) - Nw = int(old_div((Tend-Tstart),Tm)) + Nw = int((Tend-Tstart)/Tm) Nw1 = min(15,Nw) - Nw = int(old_div(Nw,Nw1)) + Nw = int(Nw/Nw1) if Nw < 3: rec_d = True @@ -2218,9 +2213,9 @@ def testRandomNLFast(self): Tend = series_l[-1,0] cutoff = 0.2*Tmax/(Tend-Tstart) - Nw = int(old_div((Tend-Tstart),Tmax)) + Nw = int((Tend-Tstart)/Tmax) Nw1 = min(15,Nw) - Nw = int(old_div(Nw,Nw1)) + Nw = int(Nw/Nw1) if Nw < 3: rec_d = True else: @@ -2253,8 +2248,8 @@ def testRandomNLFast(self): sumerr += (aR.eta_linear(x0,series[aa,0]) - aT.eta(x0,series[aa,0]))**2 sumabs += abs(aR.eta_linear(x0,series[aa,0])) - err = old_div(np.sqrt(sumerr),len(series)) - err = old_div(err, (old_div(sumabs,len(series)))) + err = np.sqrt(sumerr)/len(series) + err = err/(sumabs/len(series)) self.assertTrue(err < 0.005) # print err @@ -2265,8 +2260,8 @@ def testRandomNLFast(self): if (series_s[aa,0] > Tcut) and (series_s[aa,0] < series_s[-1,0] - Tcut): sumerr += (aR.eta_short(x0,series_s[aa,0])+aR.eta_2ndOrder(x0,series_s[aa,0]) - aT_s.eta(x0,series_s[aa,0]))**2 sumabs += abs( aR.eta_short(x0,series_s[aa,0])+ aR.eta_2ndOrder(x0,series_s[aa,0]) ) - err = old_div(np.sqrt(sumerr),len(series_s)) - err = old_div(err, (old_div(sumabs,len(series_s)))) + err = np.sqrt(sumerr)/len(series_s) + err = err/(sumabs/len(series_s)) self.assertTrue(err < 0.005) # print err for aa in range(len(series_l)): @@ -2274,8 +2269,8 @@ def testRandomNLFast(self): if (series_l[aa,0] > Tcut) and (series_l[aa,0] < series_l[-1,0] - Tcut): sumerr += (aR.eta_long(x0,series_l[aa,0]) - aT_l.eta(x0,series_l[aa,0]))**2 sumabs += abs(aR.eta_linear(x0,series_l[aa,0])) - err = old_div(np.sqrt(sumerr),len(series_l)) - err = old_div(err, (old_div(sumabs,len(series_l)))) + err = np.sqrt(sumerr)/len(series_l) + err = err/(sumabs/len(series_l)) self.assertTrue(err < 0.005) # print err @@ -2283,7 +2278,7 @@ def testRandomNLFast(self): #Cjecking consistency of the timeSeriesClass x = x0 + Lgen * 0.3 - t = old_div(Tend,2.) + t = Tend/2. self.assertTrue( round(aRF.eta(x,t) == aT_s.eta(x,t)+aT.eta(x,t)+aT_l.eta(x,t),8) )